diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index ca445081..6177a144 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -61,7 +61,7 @@ class LegoCharacterManager { MxU32 GetRefCount(LegoROI* p_roi); void FUN_10083db0(LegoROI* p_roi); void FUN_10083f10(LegoROI* p_roi); - MxU32 FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo); + MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo); LegoExtraActor* GetActor(const char* p_key); LegoCharacterData* GetData(const char* p_key); LegoCharacterData* GetData(LegoROI* p_roi); @@ -75,7 +75,7 @@ class LegoCharacterManager { private: LegoROI* CreateROI(const char* p_key); void RemoveROI(LegoROI* p_roi); - LegoROI* FUN_10084cf0(LegoROI* p_roi, const char* p_name); + LegoROI* FindChildROI(LegoROI* p_roi, const char* p_name); MxResult FUN_10085870(LegoROI* p_roi); static char* g_customizeAnimFile; diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 53b43697..577cb4cd 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -25,6 +25,9 @@ MxU32 g_unk0x100fc4d8 = 50; // GLOBAL: LEGO1 0x100fc4dc MxU32 g_unk0x100fc4dc = 66; +// GLOBAL: LEGO1 0x100fc4e8 +MxU32 g_unk0x100fc4e8 = 0; + // GLOBAL: LEGO1 0x100fc4ec MxU32 g_unk0x100fc4ec = 2; @@ -469,11 +472,52 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) return roi; } -// STUB: LEGO1 0x100849a0 -MxU32 LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo) +// FUNCTION: LEGO1 0x100849a0 +// FUNCTION: BETA10 0x10075b51 +MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo) { - // TODO - return 0; + LegoResult result = SUCCESS; + LegoROI* head = FindChildROI(p_roi, g_characterLODs[4].m_name); + + if (head != NULL) { + char lodName[256]; + + ViewLODList* lodList = GetViewLODListManager()->Lookup(g_characterLODs[4].m_parentName); + MxS32 lodSize = lodList->Size(); + sprintf(lodName, "%s%s%d", p_roi->GetName(), "head", g_unk0x100fc4e8++); + ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize); + + Tgl::Renderer* renderer = VideoManager()->GetRenderer(); + + if (p_textureInfo == NULL) { + LegoCharacterData* info = GetData(p_roi->GetName()); + LegoCharacterData::Part& part = info->m_parts[3]; + p_textureInfo = TextureContainer()->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]); + } + + for (MxS32 i = 0; i < lodSize; i++) { + LegoLOD* lod = (LegoLOD*) (*lodList)[i]; + LegoLOD* clone = lod->Clone(renderer); + + if (p_textureInfo != NULL) { + clone->FUN_100aad70(p_textureInfo); + } + + dupLodList->PushBack(clone); + } + + lodList->Release(); + lodList = dupLodList; + + if (head->GetUnknown0xe0() >= 0) { + VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->FUN_100a66a0(head); + } + + head->SetLODList(lodList); + lodList->Release(); + } + + return head != NULL; } // FUNCTION: LEGO1 0x10084c00 @@ -537,7 +581,8 @@ LegoCharacterData* LegoCharacterManager::GetData(LegoROI* p_roi) } // FUNCTION: LEGO1 0x10084cf0 -LegoROI* LegoCharacterManager::FUN_10084cf0(LegoROI* p_roi, const char* p_name) +// FUNCTION: BETA10 0x10075fe2 +LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name) { const CompoundObject* comp = p_roi->GetComp(); @@ -575,7 +620,7 @@ MxBool LegoCharacterManager::FUN_10084ec0(LegoROI* p_roi) unk0x00 = part.m_unk0x00[part.m_unk0x08]; } - LegoROI* childROI = FUN_10084cf0(p_roi, g_characterLODs[1].m_name); + LegoROI* childROI = FindChildROI(p_roi, g_characterLODs[1].m_name); if (childROI != NULL) { char lodName[256]; diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index 9a36ec9f..0aae147d 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -350,6 +350,18 @@ LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo) return SUCCESS; } +// FUNCTION: LEGO1 0x100aad70 +LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo) +{ + for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + if (m_melems[i].m_unk0x04) { + LegoTextureInfo::SetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo); + } + } + + return SUCCESS; +} + // FUNCTION: LEGO1 0x100aae20 LegoBool LegoLOD::FUN_100aae20(const LegoChar* p_name) { diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index f454f200..395f416c 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -31,6 +31,7 @@ class LegoLOD : public ViewLOD { LegoLOD* Clone(Tgl::Renderer* p_renderer); LegoResult FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100aad00(LegoTextureInfo* p_textureInfo); + LegoResult FUN_100aad70(LegoTextureInfo* p_textureInfo); static LegoBool FUN_100aae20(const LegoChar* p_name);