diff --git a/LEGO1/lego/legoomni/include/legotextureinfo.h b/LEGO1/lego/legoomni/include/legotextureinfo.h index 3256ebbf..e7cd894b 100644 --- a/LEGO1/lego/legoomni/include/legotextureinfo.h +++ b/LEGO1/lego/legoomni/include/legotextureinfo.h @@ -17,6 +17,7 @@ class LegoTextureInfo { static LegoTextureInfo* Create(const char* p_name, LegoTexture* p_texture); static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo); + static BOOL GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_textureInfo); LegoResult FUN_10066010(LegoU8* p_bits); @@ -27,4 +28,7 @@ class LegoTextureInfo { LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c }; +// GLOBAL: LEGO1 0x100db6f0 +// IID_IDirect3DRMTexture2 + #endif // LEGOTEXTUREINFO_H diff --git a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index 75034536..2a750a48 100644 --- a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -160,6 +160,30 @@ BOOL LegoTextureInfo::SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textu return TRUE; } +// FUNCTION: LEGO1 0x10065f90 +BOOL LegoTextureInfo::GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_textureInfo) +{ + TglImpl::MeshImpl::MeshData* data = ((TglImpl::MeshImpl*) pMesh)->ImplementationData(); + + IDirect3DRMMesh* mesh = data->groupMesh; + D3DRMGROUPINDEX id = data->groupIndex; + LPDIRECT3DRMTEXTURE returnPtr = NULL; + LPDIRECT3DRMTEXTURE2 texture = NULL; + + if (mesh->GetGroupTexture(id, &returnPtr) == D3DRM_OK) { + if (returnPtr->QueryInterface(IID_IDirect3DRMTexture2, (LPVOID*) &texture) == D3DRM_OK) { + p_textureInfo = (LegoTextureInfo*) texture->GetAppData(); + + texture->Release(); + returnPtr->Release(); + } + + return TRUE; + } + + return FALSE; +} + // STUB: LEGO1 0x10066010 LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits) { diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index 0aae147d..e9997907 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -362,6 +362,20 @@ LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo) return SUCCESS; } +// FUNCTION: LEGO1 0x100aadc0 +LegoResult LegoLOD::GetTexture(LegoTextureInfo*& p_textureInfo) +{ + for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + if (m_melems[i].m_unk0x04) { + if (LegoTextureInfo::GetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo) == TRUE) { + return SUCCESS; + } + } + } + + return FAILURE; +} + // 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 395f416c..a47a3d24 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -32,6 +32,7 @@ class LegoLOD : public ViewLOD { 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); + LegoResult GetTexture(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 7885482f..c18b5de6 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -498,10 +498,29 @@ LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo) return result; } -// STUB: LEGO1 0x100a92a0 -LegoResult LegoROI::GetTexture(LegoTextureInfo*&) +// FUNCTION: LEGO1 0x100a92a0 +// FUNCTION: BETA10 0x1018b12d +LegoResult LegoROI::GetTexture(LegoTextureInfo*& p_textureInfo) { - // TODO + CompoundObject::iterator it; + + int lodCount = GetLODCount(); + for (LegoU32 i = 0; i < lodCount; i++) { + LegoLOD* lod = (LegoLOD*) GetLOD(i); + + if (lod->GetTexture(p_textureInfo) == SUCCESS) { + return SUCCESS; + } + } + + if (comp != NULL) { + for (it = comp->begin(); it != comp->end(); it++) { + if (((LegoROI*) *it)->GetTexture(p_textureInfo) == SUCCESS) { + return SUCCESS; + } + } + } + return FAILURE; } diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index d71d8b47..34b5f809 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -36,7 +36,7 @@ class LegoROI : public ViewROI { LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time); LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo); - LegoResult GetTexture(LegoTextureInfo*&); + LegoResult GetTexture(LegoTextureInfo*& p_textureInfo); LegoU32 FUN_100a9410(Vector3&, Vector3&, float, float, Vector3&, LegoBool); void SetName(const LegoChar* p_name);