diff --git a/LEGO1/lego/legoomni/include/legoactorpresenter.h b/LEGO1/lego/legoomni/include/legoactorpresenter.h index 9c3b35bf..aea15b64 100644 --- a/LEGO1/lego/legoomni/include/legoactorpresenter.h +++ b/LEGO1/lego/legoomni/include/legoactorpresenter.h @@ -7,7 +7,10 @@ // SIZE 0x50 class LegoActorPresenter : public LegoEntityPresenter { public: - ~LegoActorPresenter() override{}; + // LegoActorPresenter() {} + + // FUNCTION: LEGO1 0x100679c0 + ~LegoActorPresenter() override {} // FUNCTION: LEGO1 0x1000cb10 inline const char* ClassName() const override // vtable+0x0c diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 68a246b5..b18799e1 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -57,7 +57,7 @@ class LegoEntity : public MxEntity { void FUN_10010c30(); void FUN_100114e0(MxU8 p_unk0x59); - void SetLocation(Mx3DPointFloat& p_location, Mx3DPointFloat& p_direction, Mx3DPointFloat& p_up, MxBool); + void SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool); inline LegoROI* GetROI() { return m_roi; } inline MxU8 GetFlags() { return m_flags; } diff --git a/LEGO1/lego/legoomni/include/legoentitypresenter.h b/LEGO1/lego/legoomni/include/legoentitypresenter.h index dec78dae..4e98eb5b 100644 --- a/LEGO1/lego/legoomni/include/legoentitypresenter.h +++ b/LEGO1/lego/legoomni/include/legoentitypresenter.h @@ -33,9 +33,10 @@ class LegoEntityPresenter : public MxCompositePresenter { virtual void Init(); // vtable+0x68 virtual undefined4 SetEntity(LegoEntity* p_entity); // vtable+0x6c - void SetEntityLocation(Mx3DPointFloat& p_location, Mx3DPointFloat& p_direction, Mx3DPointFloat& p_up); + void SetEntityLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up); - inline LegoEntity* GetEntity() { return m_entity; } + inline LegoEntity* GetInternalEntity() { return m_entity; } + inline void SetInternalEntity(LegoEntity* p_entity) { m_entity = p_entity; } // SYNTHETIC: LEGO1 0x100535a0 // LegoEntityPresenter::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legomodelpresenter.h b/LEGO1/lego/legoomni/include/legomodelpresenter.h index b85c2c26..bde10f31 100644 --- a/LEGO1/lego/legoomni/include/legomodelpresenter.h +++ b/LEGO1/lego/legoomni/include/legomodelpresenter.h @@ -4,12 +4,17 @@ #include "mxvideopresenter.h" class LegoROI; +class LegoWorld; +class LegoEntity; +class MxDSChunk; // VTABLE: LEGO1 0x100d4e50 // SIZE 0x6c (discovered through inline constructor at 0x10009ae6) class LegoModelPresenter : public MxVideoPresenter { public: - // inline in scalar dtor + LegoModelPresenter() { Reset(); } + + // FUNCTION: LEGO1 0x10067a10 ~LegoModelPresenter() override { Destroy(TRUE); } static void configureLegoModelPresenter(MxS32 p_modelPresenterConfig); @@ -31,6 +36,14 @@ class LegoModelPresenter : public MxVideoPresenter { void ParseExtra() override; // vtable+0x30 void Destroy() override; // vtable+0x38 + void FUN_1007ff70(MxDSChunk& p_chunk, LegoEntity* p_entity, undefined p_modelUnknown0x34, LegoWorld* p_world); + + inline void Reset() + { + m_roi = NULL; + m_addedToView = FALSE; + } + // SYNTHETIC: LEGO1 0x1000cdd0 // LegoModelPresenter::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legopartpresenter.h b/LEGO1/lego/legoomni/include/legopartpresenter.h index 90cc2ddc..8f3cda07 100644 --- a/LEGO1/lego/legoomni/include/legopartpresenter.h +++ b/LEGO1/lego/legoomni/include/legopartpresenter.h @@ -36,7 +36,7 @@ class LegoPartPresenter : public MxMediaPresenter { inline void Reset() { m_partData = NULL; } - MxResult ParsePart(MxDSChunk& p_chunk); + MxResult Read(MxDSChunk& p_chunk); void FUN_1007df20(); private: diff --git a/LEGO1/lego/legoomni/include/legotexturepresenter.h b/LEGO1/lego/legoomni/include/legotexturepresenter.h index 657d3a52..98471be4 100644 --- a/LEGO1/lego/legoomni/include/legotexturepresenter.h +++ b/LEGO1/lego/legoomni/include/legotexturepresenter.h @@ -30,7 +30,7 @@ class LegoTexturePresenter : public MxMediaPresenter { // SYNTHETIC: LEGO1 0x1000cf40 // LegoTexturePresenter::`scalar deleting destructor' - MxResult ParseTexture(MxDSChunk& p_chunk); + MxResult Read(MxDSChunk& p_chunk); void FUN_1004f290(); private: diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 9ac45046..c7060136 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -83,7 +83,7 @@ void LegoEntity::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) } // STUB: LEGO1 0x100109b0 -void LegoEntity::SetLocation(Mx3DPointFloat& p_location, Mx3DPointFloat& p_direction, Mx3DPointFloat& p_up, MxBool) +void LegoEntity::SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool) { // TODO } diff --git a/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp index ca65b767..0c9ff60f 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp @@ -82,11 +82,7 @@ void LegoEntityPresenter::RepeatingTickle() } // FUNCTION: LEGO1 0x10053730 -void LegoEntityPresenter::SetEntityLocation( - Mx3DPointFloat& p_location, - Mx3DPointFloat& p_direction, - Mx3DPointFloat& p_up -) +void LegoEntityPresenter::SetEntityLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up) { if (m_entity) { m_entity->SetLocation(p_location, p_direction, p_up, TRUE); diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 0b96ed04..4faf16e3 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -1,9 +1,11 @@ #include "legoworldpresenter.h" #include "define.h" +#include "legoactorpresenter.h" #include "legoanimationmanager.h" #include "legobuildingmanager.h" #include "legoentity.h" +#include "legomodelpresenter.h" #include "legoomni.h" #include "legopartpresenter.h" #include "legoplantmanager.h" @@ -29,7 +31,7 @@ MxS32 g_legoWorldPresenterQuality = 1; // GLOBAL: LEGO1 0x100f75d8 -long g_wdbOffset = 0; +MxLong g_wdbOffset = 0; // FUNCTION: LEGO1 0x100665b0 void LegoWorldPresenter::configureLegoWorldPresenter(MxS32 p_legoWorldPresenterQuality) @@ -224,7 +226,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) chunk.SetData(buff); LegoTexturePresenter texturePresenter; - if (texturePresenter.ParseTexture(chunk) == SUCCESS) { + if (texturePresenter.Read(chunk) == SUCCESS) { texturePresenter.FUN_1004f290(); } @@ -243,7 +245,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) chunk.SetData(buff); LegoPartPresenter partPresenter; - if (partPresenter.ParsePart(chunk) == SUCCESS) { + if (partPresenter.Read(chunk) == SUCCESS) { partPresenter.FUN_1007df20(); } @@ -314,17 +316,89 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) return SUCCESS; } -// STUB: LEGO1 0x10067360 +// FUNCTION: LEGO1 0x10067360 MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile) { - // TODO - return SUCCESS; + MxResult result; + MxU8* buff = new MxU8[p_part.m_partDataLength]; + + fseek(p_wdbFile, p_part.m_partDataOffset, 0); + if (fread(buff, p_part.m_partDataLength, 1, p_wdbFile) != 1) { + return FAILURE; + } + + MxDSChunk chunk; + chunk.SetLength(p_part.m_partDataLength); + chunk.SetData(buff); + + LegoPartPresenter part; + result = part.Read(chunk); + + if (result == SUCCESS) { + part.FUN_1007df20(); + } + + delete[] buff; + return result; } -// STUB: LEGO1 0x100674b0 +// FUNCTION: LEGO1 0x100674b0 MxResult LegoWorldPresenter::FUN_100674b0(ModelDbModel& p_model, FILE* p_wdbFile, LegoWorld* p_world) { - // TODO + MxU8* buff = new MxU8[p_model.m_unk0x04]; + + fseek(p_wdbFile, p_model.m_unk0x08, 0); + if (fread(buff, p_model.m_unk0x04, 1, p_wdbFile) != 1) { + return FAILURE; + } + + MxDSChunk chunk; + chunk.SetLength(p_model.m_unk0x04); + chunk.SetData(buff); + + MxDSAction action; + MxAtomId atom; + action.SetLocation(p_model.m_location); + action.SetDirection(p_model.m_direction); + action.SetUp(p_model.m_up); + + MxU32 objectId = m_unk0x50; + m_unk0x50++; + action.SetObjectId(objectId); + + action.SetAtomId(atom); + + LegoEntity* createdEntity = NULL; + + if (!strcmp(p_model.m_presenterName, "LegoActorPresenter")) { + LegoActorPresenter presenter; + presenter.SetAction(&action); + LegoEntity* entity = (LegoEntity*) presenter.CreateEntity("LegoActor"); + presenter.SetInternalEntity(entity); + presenter.SetEntityLocation(p_model.m_location, p_model.m_direction, p_model.m_up); + entity->Create(action); + } + else if (!strcmp(p_model.m_presenterName, "LegoEntityPresenter")) { + LegoEntityPresenter presenter; + presenter.SetAction(&action); + createdEntity = (LegoEntity*) presenter.CreateEntity("LegoEntity"); + presenter.SetInternalEntity(createdEntity); + presenter.SetEntityLocation(p_model.m_location, p_model.m_direction, p_model.m_up); + createdEntity->Create(action); + } + + LegoModelPresenter modelPresenter; + + if (createdEntity != NULL) { + action.SetLocation(Mx3DPointFloat(0.0, 0.0, 0.0)); + action.SetUp(Mx3DPointFloat(0.0, 0.0, 1.0)); + action.SetDirection(Mx3DPointFloat(0.0, 1.0, 0.0)); + } + + modelPresenter.SetAction(&action); + modelPresenter.FUN_1007ff70(chunk, createdEntity, p_model.m_unk0x34, p_world); + delete[] buff; + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp index aa43528a..36433c4a 100644 --- a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp @@ -202,6 +202,16 @@ MxResult LegoModelPresenter::CreateROI(MxStreamChunk* p_chunk) return result; } +// STUB: LEGO1 0x1007ff70 +void LegoModelPresenter::FUN_1007ff70( + MxDSChunk& p_chunk, + LegoEntity* p_entity, + undefined p_modelUnknown0x34, + LegoWorld* p_world +) +{ +} + // FUNCTION: LEGO1 0x10080050 void LegoModelPresenter::ReadyTickle() { @@ -214,13 +224,13 @@ void LegoModelPresenter::ReadyTickle() if (m_roi != NULL) { if (m_compositePresenter && m_compositePresenter->IsA("LegoEntityPresenter")) { - ((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->SetROI(m_roi, m_addedToView, TRUE); + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->SetROI(m_roi, m_addedToView, TRUE); ((LegoEntityPresenter*) m_compositePresenter) - ->GetEntity() + ->GetInternalEntity() ->SetFlags( - ((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->GetFlags() & ~LegoEntity::c_bit2 + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & ~LegoEntity::c_bit2 ); - ((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->FUN_100114e0(0); + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->FUN_100114e0(0); } ParseExtra(); @@ -240,11 +250,12 @@ void LegoModelPresenter::ReadyTickle() VideoManager()->Get3DManager()->GetLego3DView()->Moved(*m_roi); if (m_compositePresenter != NULL && m_compositePresenter->IsA("LegoEntityPresenter")) { - ((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->SetROI(m_roi, TRUE, TRUE); + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->SetROI(m_roi, TRUE, TRUE); ((LegoEntityPresenter*) m_compositePresenter) - ->GetEntity() + ->GetInternalEntity() ->SetFlags( - ((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->GetFlags() & ~LegoEntity::c_bit2 + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & + ~LegoEntity::c_bit2 ); } diff --git a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp index b792f202..e121e475 100644 --- a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp @@ -36,7 +36,7 @@ void LegoPartPresenter::Destroy(MxBool p_fromDestructor) } // STUB: LEGO1 0x1007ca30 -MxResult LegoPartPresenter::ParsePart(MxDSChunk& p_chunk) +MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk) { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp index b101b2c9..619ca81d 100644 --- a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp @@ -20,7 +20,7 @@ MxResult LegoTexturePresenter::AddToManager() } // STUB: LEGO1 0x1004ebd0 -MxResult LegoTexturePresenter::ParseTexture(MxDSChunk& p_chunk) +MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk) { // TODO return SUCCESS; diff --git a/LEGO1/modeldb/modeldb.cpp b/LEGO1/modeldb/modeldb.cpp index 57980ec8..d7a8336f 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -35,13 +35,13 @@ MxResult ModelDbModel::Read(FILE* p_file) return FAILURE; } - if (fread(&m_unk0x10, sizeof(*m_unk0x10), 3, p_file) != 3) { + if (fread(&m_location, sizeof(*m_location), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_unk0x1c, sizeof(*m_unk0x1c), 3, p_file) != 3) { + if (fread(&m_direction, sizeof(*m_direction), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_unk0x28, sizeof(*m_unk0x28), 3, p_file) != 3) { + if (fread(&m_up, sizeof(*m_up), 3, p_file) != 3) { return FAILURE; } @@ -65,11 +65,11 @@ MxResult ModelDbPart::Read(FILE* p_file) m_roiName = buff; - if (fread(&m_unk0x10, sizeof(m_unk0x10), 1, p_file) != 1) { + if (fread(&m_partDataLength, sizeof(m_partDataLength), 1, p_file) != 1) { return FAILURE; } - return fread(&m_unk0x14, sizeof(m_unk0x14), 1, p_file) == 1 ? SUCCESS : FAILURE; + return fread(&m_partDataOffset, sizeof(m_partDataOffset), 1, p_file) == 1 ? SUCCESS : FAILURE; } // FUNCTION: LEGO1 0x10027910 diff --git a/LEGO1/modeldb/modeldb.h b/LEGO1/modeldb/modeldb.h index ebebae17..943927ef 100644 --- a/LEGO1/modeldb/modeldb.h +++ b/LEGO1/modeldb/modeldb.h @@ -12,9 +12,9 @@ struct ModelDbPart { MxResult Read(FILE* p_file); - MxString m_roiName; // 0x00 - undefined4 m_unk0x10; // 0x10 - undefined4 m_unk0x14; // 0x14 + MxString m_roiName; // 0x00 + undefined4 m_partDataLength; // 0x10 + undefined4 m_partDataOffset; // 0x14 }; // VTABLE: LEGO1 0x100d6888 @@ -35,8 +35,8 @@ class ModelDbPartList : public MxList { MxS32 compare = strcmpi(p_a->m_roiName.GetData(), p_b->m_roiName.GetData()); if (compare == 0) { - p_b->m_unk0x10 = p_a->m_unk0x10; - p_b->m_unk0x14 = p_a->m_unk0x14; + p_b->m_partDataLength = p_a->m_partDataLength; + p_b->m_partDataOffset = p_a->m_partDataOffset; } return compare; @@ -93,14 +93,14 @@ class ModelDbPartListCursor : public MxListCursor { struct ModelDbModel { MxResult Read(FILE* p_file); - char* m_modelName; // 0x00 - undefined4 m_unk0x04; // 0x04 - undefined4 m_unk0x08; // 0x08 - char* m_presenterName; // 0x0c - undefined4 m_unk0x10[3]; // 0x10 - undefined4 m_unk0x1c[3]; // 0x1c - undefined4 m_unk0x28[3]; // 0x28 - undefined m_unk0x34; // 0x34 + char* m_modelName; // 0x00 + undefined4 m_unk0x04; // 0x04 + undefined4 m_unk0x08; // 0x08 + char* m_presenterName; // 0x0c + float m_location[3]; // 0x10 + float m_direction[3]; // 0x1c + float m_up[3]; // 0x28 + undefined m_unk0x34; // 0x34 }; // SIZE 0x18 diff --git a/LEGO1/omni/include/mxdsaction.h b/LEGO1/omni/include/mxdsaction.h index f1294371..1ba24f40 100644 --- a/LEGO1/omni/include/mxdsaction.h +++ b/LEGO1/omni/include/mxdsaction.h @@ -73,6 +73,9 @@ class MxDSAction : public MxDSObject { inline Mx3DPointFloat& GetLocation() { return m_location; } inline Mx3DPointFloat& GetDirection() { return m_direction; } inline Mx3DPointFloat& GetUp() { return m_up; } + inline void SetLocation(const Vector3& p_location) { m_location = p_location; } + inline void SetDirection(const Vector3& p_direction) { m_direction = p_direction; } + inline void SetUp(const Vector3& p_up) { m_up = p_up; } inline MxCore* GetUnknown84() { return m_unk0x84; } inline void SetUnknown84(MxCore* p_unk0x84) { m_unk0x84 = p_unk0x84; } inline MxCore* GetOrigin() { return m_origin; } diff --git a/LEGO1/omni/include/mxentity.h b/LEGO1/omni/include/mxentity.h index ed75d148..217fa397 100644 --- a/LEGO1/omni/include/mxentity.h +++ b/LEGO1/omni/include/mxentity.h @@ -15,7 +15,7 @@ class MxEntity : public MxCore { MxEntity() { this->m_mxEntityId = -1; } // FUNCTION: LEGO1 0x1000c110 - ~MxEntity() override{}; + ~MxEntity() override {} // FUNCTION: LEGO1 0x1000c180 inline const char* ClassName() const override // vtable+0x0c diff --git a/LEGO1/omni/include/mxpresenter.h b/LEGO1/omni/include/mxpresenter.h index 606e9c5a..f0c3e1b8 100644 --- a/LEGO1/omni/include/mxpresenter.h +++ b/LEGO1/omni/include/mxpresenter.h @@ -29,7 +29,7 @@ class MxPresenter : public MxCore { MxPresenter() { Init(); } // FUNCTION: LEGO1 0x1000bf00 - ~MxPresenter() override{}; // vtable+0x00 + ~MxPresenter() override {} // vtable+0x00 MxResult Tickle() override; // vtable+0x08 @@ -117,6 +117,7 @@ class MxPresenter : public MxCore { inline MxS32 GetY() const { return this->m_location.GetY(); } inline MxS32 GetDisplayZ() const { return this->m_displayZ; } inline MxDSAction* GetAction() const { return this->m_action; } + inline void SetAction(MxDSAction* p_action) { m_action = p_action; } inline void SetCompositePresenter(MxCompositePresenter* p_compositePresenter) {