From 32ae9f3803ee12462be58575404339d66609be5f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 8 Mar 2024 15:29:16 -0500 Subject: [PATCH] Implement/match LegoROI::FUN_100a9170 (#639) * Implement.match LegoROI::FUN_100a9170 * Add two LOD functions --- LEGO1/lego/sources/roi/legolod.cpp | 23 +++++++++++++++++++++-- LEGO1/lego/sources/roi/legolod.h | 1 + LEGO1/lego/sources/roi/legoroi.cpp | 27 +++++++++++++++++++++++---- LEGO1/lego/sources/roi/legoroi.h | 2 +- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index bf81b29a..4db477b8 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -311,10 +311,29 @@ done: return FAILURE; } -// STUB: LEGO1 0x100aad00 +// FUNCTION: LEGO1 0x100aacb0 +LegoResult LegoLOD::FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) +{ + for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + if (!m_meshes[i].m_unk0x04) { + m_meshes[i].m_tglMesh->SetColor(p_red, p_green, p_blue, p_alpha); + } + } + + return SUCCESS; +} + +// FUNCTION: LEGO1 0x100aad00 LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo) { - // TODO + for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + if (m_meshes[i].m_unk0x04) { + SetGroupTexture(m_meshes[i].m_tglMesh, p_textureInfo); + m_meshes[i].m_tglMesh->SetColor(1.0F, 1.0F, 1.0F, 0.0F); + m_meshes[i].m_unk0x04 = TRUE; + } + } + return SUCCESS; } diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index 00993cb3..18df610f 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -28,6 +28,7 @@ public: float VTable0x10() override { return 0.0; } // vtable+0x10 LegoResult Read(Tgl::Renderer*, LegoTextureContainer* p_textureContainer, LegoStorage* p_storage); + LegoResult FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100aad00(LegoTextureInfo* p_textureInfo); static LegoBool FUN_100aae20(const LegoChar* p_name); diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index 8b701fca..b985420b 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -418,11 +418,30 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time) return FUN_100a8da0(root, mat, p_time, this); } -// STUB: LEGO1 0x100a9170 -LegoResult LegoROI::FUN_100a9170(LegoFloat, LegoFloat, LegoFloat, LegoFloat) +// FUNCTION: LEGO1 0x100a9170 +LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) { - // TODO - return SUCCESS; + LegoResult result = SUCCESS; + CompoundObject::iterator it; + + int lodCount = GetLODCount(); + for (LegoU32 i = 0; i < lodCount; i++) { + LegoLOD* lod = (LegoLOD*) GetLOD(i); + + if (lod->FUN_100aacb0(p_red, p_green, p_blue, p_alpha) != SUCCESS) { + result = FAILURE; + } + } + + if (comp != NULL) { + for (it = comp->begin(); it != comp->end(); it++) { + if (((LegoROI*) *it)->FUN_100a9170(p_red, p_green, p_blue, p_alpha) != SUCCESS) { + result = FAILURE; + } + } + } + + return result; } // FUNCTION: LEGO1 0x100a9210 diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index f7fc194c..44aeee2a 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -32,7 +32,7 @@ public: LegoROI* FUN_100a8ce0(const LegoChar* p_name, LegoROI* p_roi); LegoResult FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi); LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time); - LegoResult FUN_100a9170(LegoFloat, LegoFloat, LegoFloat, LegoFloat); + LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo); float IntrinsicImportance() const override; // vtable+0x04