implement various LegoWorldPresenter functions (#621)

* implement LegoWorldPresenterFunctions

* fix typo

* Fixes/match

* Fix

* Match

* Fixes

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2024-03-03 20:34:55 -05:00 committed by GitHub
parent 7f5ad98749
commit c2a46b058b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 152 additions and 50 deletions

View file

@ -7,7 +7,10 @@
// SIZE 0x50 // SIZE 0x50
class LegoActorPresenter : public LegoEntityPresenter { class LegoActorPresenter : public LegoEntityPresenter {
public: public:
~LegoActorPresenter() override{}; // LegoActorPresenter() {}
// FUNCTION: LEGO1 0x100679c0
~LegoActorPresenter() override {}
// FUNCTION: LEGO1 0x1000cb10 // FUNCTION: LEGO1 0x1000cb10
inline const char* ClassName() const override // vtable+0x0c inline const char* ClassName() const override // vtable+0x0c

View file

@ -57,7 +57,7 @@ class LegoEntity : public MxEntity {
void FUN_10010c30(); void FUN_10010c30();
void FUN_100114e0(MxU8 p_unk0x59); 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 LegoROI* GetROI() { return m_roi; }
inline MxU8 GetFlags() { return m_flags; } inline MxU8 GetFlags() { return m_flags; }

View file

@ -33,9 +33,10 @@ class LegoEntityPresenter : public MxCompositePresenter {
virtual void Init(); // vtable+0x68 virtual void Init(); // vtable+0x68
virtual undefined4 SetEntity(LegoEntity* p_entity); // vtable+0x6c 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 // SYNTHETIC: LEGO1 0x100535a0
// LegoEntityPresenter::`scalar deleting destructor' // LegoEntityPresenter::`scalar deleting destructor'

View file

@ -4,12 +4,17 @@
#include "mxvideopresenter.h" #include "mxvideopresenter.h"
class LegoROI; class LegoROI;
class LegoWorld;
class LegoEntity;
class MxDSChunk;
// VTABLE: LEGO1 0x100d4e50 // VTABLE: LEGO1 0x100d4e50
// SIZE 0x6c (discovered through inline constructor at 0x10009ae6) // SIZE 0x6c (discovered through inline constructor at 0x10009ae6)
class LegoModelPresenter : public MxVideoPresenter { class LegoModelPresenter : public MxVideoPresenter {
public: public:
// inline in scalar dtor LegoModelPresenter() { Reset(); }
// FUNCTION: LEGO1 0x10067a10
~LegoModelPresenter() override { Destroy(TRUE); } ~LegoModelPresenter() override { Destroy(TRUE); }
static void configureLegoModelPresenter(MxS32 p_modelPresenterConfig); static void configureLegoModelPresenter(MxS32 p_modelPresenterConfig);
@ -31,6 +36,14 @@ class LegoModelPresenter : public MxVideoPresenter {
void ParseExtra() override; // vtable+0x30 void ParseExtra() override; // vtable+0x30
void Destroy() override; // vtable+0x38 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 // SYNTHETIC: LEGO1 0x1000cdd0
// LegoModelPresenter::`scalar deleting destructor' // LegoModelPresenter::`scalar deleting destructor'

View file

@ -36,7 +36,7 @@ class LegoPartPresenter : public MxMediaPresenter {
inline void Reset() { m_partData = NULL; } inline void Reset() { m_partData = NULL; }
MxResult ParsePart(MxDSChunk& p_chunk); MxResult Read(MxDSChunk& p_chunk);
void FUN_1007df20(); void FUN_1007df20();
private: private:

View file

@ -30,7 +30,7 @@ class LegoTexturePresenter : public MxMediaPresenter {
// SYNTHETIC: LEGO1 0x1000cf40 // SYNTHETIC: LEGO1 0x1000cf40
// LegoTexturePresenter::`scalar deleting destructor' // LegoTexturePresenter::`scalar deleting destructor'
MxResult ParseTexture(MxDSChunk& p_chunk); MxResult Read(MxDSChunk& p_chunk);
void FUN_1004f290(); void FUN_1004f290();
private: private:

View file

@ -83,7 +83,7 @@ void LegoEntity::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2)
} }
// STUB: LEGO1 0x100109b0 // 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 // TODO
} }

View file

@ -82,11 +82,7 @@ void LegoEntityPresenter::RepeatingTickle()
} }
// FUNCTION: LEGO1 0x10053730 // FUNCTION: LEGO1 0x10053730
void LegoEntityPresenter::SetEntityLocation( void LegoEntityPresenter::SetEntityLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up)
Mx3DPointFloat& p_location,
Mx3DPointFloat& p_direction,
Mx3DPointFloat& p_up
)
{ {
if (m_entity) { if (m_entity) {
m_entity->SetLocation(p_location, p_direction, p_up, TRUE); m_entity->SetLocation(p_location, p_direction, p_up, TRUE);

View file

@ -1,9 +1,11 @@
#include "legoworldpresenter.h" #include "legoworldpresenter.h"
#include "define.h" #include "define.h"
#include "legoactorpresenter.h"
#include "legoanimationmanager.h" #include "legoanimationmanager.h"
#include "legobuildingmanager.h" #include "legobuildingmanager.h"
#include "legoentity.h" #include "legoentity.h"
#include "legomodelpresenter.h"
#include "legoomni.h" #include "legoomni.h"
#include "legopartpresenter.h" #include "legopartpresenter.h"
#include "legoplantmanager.h" #include "legoplantmanager.h"
@ -29,7 +31,7 @@
MxS32 g_legoWorldPresenterQuality = 1; MxS32 g_legoWorldPresenterQuality = 1;
// GLOBAL: LEGO1 0x100f75d8 // GLOBAL: LEGO1 0x100f75d8
long g_wdbOffset = 0; MxLong g_wdbOffset = 0;
// FUNCTION: LEGO1 0x100665b0 // FUNCTION: LEGO1 0x100665b0
void LegoWorldPresenter::configureLegoWorldPresenter(MxS32 p_legoWorldPresenterQuality) void LegoWorldPresenter::configureLegoWorldPresenter(MxS32 p_legoWorldPresenterQuality)
@ -224,7 +226,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
chunk.SetData(buff); chunk.SetData(buff);
LegoTexturePresenter texturePresenter; LegoTexturePresenter texturePresenter;
if (texturePresenter.ParseTexture(chunk) == SUCCESS) { if (texturePresenter.Read(chunk) == SUCCESS) {
texturePresenter.FUN_1004f290(); texturePresenter.FUN_1004f290();
} }
@ -243,7 +245,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
chunk.SetData(buff); chunk.SetData(buff);
LegoPartPresenter partPresenter; LegoPartPresenter partPresenter;
if (partPresenter.ParsePart(chunk) == SUCCESS) { if (partPresenter.Read(chunk) == SUCCESS) {
partPresenter.FUN_1007df20(); partPresenter.FUN_1007df20();
} }
@ -314,17 +316,89 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
return SUCCESS; return SUCCESS;
} }
// STUB: LEGO1 0x10067360 // FUNCTION: LEGO1 0x10067360
MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile) MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile)
{ {
// TODO MxResult result;
return SUCCESS; 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;
} }
// STUB: LEGO1 0x100674b0 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;
}
// FUNCTION: LEGO1 0x100674b0
MxResult LegoWorldPresenter::FUN_100674b0(ModelDbModel& p_model, FILE* p_wdbFile, LegoWorld* p_world) 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; return SUCCESS;
} }

View file

@ -202,6 +202,16 @@ MxResult LegoModelPresenter::CreateROI(MxStreamChunk* p_chunk)
return result; return result;
} }
// STUB: LEGO1 0x1007ff70
void LegoModelPresenter::FUN_1007ff70(
MxDSChunk& p_chunk,
LegoEntity* p_entity,
undefined p_modelUnknown0x34,
LegoWorld* p_world
)
{
}
// FUNCTION: LEGO1 0x10080050 // FUNCTION: LEGO1 0x10080050
void LegoModelPresenter::ReadyTickle() void LegoModelPresenter::ReadyTickle()
{ {
@ -214,13 +224,13 @@ void LegoModelPresenter::ReadyTickle()
if (m_roi != NULL) { if (m_roi != NULL) {
if (m_compositePresenter && m_compositePresenter->IsA("LegoEntityPresenter")) { 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) ((LegoEntityPresenter*) m_compositePresenter)
->GetEntity() ->GetInternalEntity()
->SetFlags( ->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(); ParseExtra();
@ -240,11 +250,12 @@ void LegoModelPresenter::ReadyTickle()
VideoManager()->Get3DManager()->GetLego3DView()->Moved(*m_roi); VideoManager()->Get3DManager()->GetLego3DView()->Moved(*m_roi);
if (m_compositePresenter != NULL && m_compositePresenter->IsA("LegoEntityPresenter")) { 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) ((LegoEntityPresenter*) m_compositePresenter)
->GetEntity() ->GetInternalEntity()
->SetFlags( ->SetFlags(
((LegoEntityPresenter*) m_compositePresenter)->GetEntity()->GetFlags() & ~LegoEntity::c_bit2 ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() &
~LegoEntity::c_bit2
); );
} }

View file

@ -36,7 +36,7 @@ void LegoPartPresenter::Destroy(MxBool p_fromDestructor)
} }
// STUB: LEGO1 0x1007ca30 // STUB: LEGO1 0x1007ca30
MxResult LegoPartPresenter::ParsePart(MxDSChunk& p_chunk) MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk)
{ {
// TODO // TODO
return SUCCESS; return SUCCESS;

View file

@ -20,7 +20,7 @@ MxResult LegoTexturePresenter::AddToManager()
} }
// STUB: LEGO1 0x1004ebd0 // STUB: LEGO1 0x1004ebd0
MxResult LegoTexturePresenter::ParseTexture(MxDSChunk& p_chunk) MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk)
{ {
// TODO // TODO
return SUCCESS; return SUCCESS;

View file

@ -35,13 +35,13 @@ MxResult ModelDbModel::Read(FILE* p_file)
return FAILURE; 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; 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; 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; return FAILURE;
} }
@ -65,11 +65,11 @@ MxResult ModelDbPart::Read(FILE* p_file)
m_roiName = buff; 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 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 // FUNCTION: LEGO1 0x10027910

View file

@ -13,8 +13,8 @@ struct ModelDbPart {
MxResult Read(FILE* p_file); MxResult Read(FILE* p_file);
MxString m_roiName; // 0x00 MxString m_roiName; // 0x00
undefined4 m_unk0x10; // 0x10 undefined4 m_partDataLength; // 0x10
undefined4 m_unk0x14; // 0x14 undefined4 m_partDataOffset; // 0x14
}; };
// VTABLE: LEGO1 0x100d6888 // VTABLE: LEGO1 0x100d6888
@ -35,8 +35,8 @@ class ModelDbPartList : public MxList<ModelDbPart*> {
MxS32 compare = strcmpi(p_a->m_roiName.GetData(), p_b->m_roiName.GetData()); MxS32 compare = strcmpi(p_a->m_roiName.GetData(), p_b->m_roiName.GetData());
if (compare == 0) { if (compare == 0) {
p_b->m_unk0x10 = p_a->m_unk0x10; p_b->m_partDataLength = p_a->m_partDataLength;
p_b->m_unk0x14 = p_a->m_unk0x14; p_b->m_partDataOffset = p_a->m_partDataOffset;
} }
return compare; return compare;
@ -97,9 +97,9 @@ struct ModelDbModel {
undefined4 m_unk0x04; // 0x04 undefined4 m_unk0x04; // 0x04
undefined4 m_unk0x08; // 0x08 undefined4 m_unk0x08; // 0x08
char* m_presenterName; // 0x0c char* m_presenterName; // 0x0c
undefined4 m_unk0x10[3]; // 0x10 float m_location[3]; // 0x10
undefined4 m_unk0x1c[3]; // 0x1c float m_direction[3]; // 0x1c
undefined4 m_unk0x28[3]; // 0x28 float m_up[3]; // 0x28
undefined m_unk0x34; // 0x34 undefined m_unk0x34; // 0x34
}; };

View file

@ -73,6 +73,9 @@ class MxDSAction : public MxDSObject {
inline Mx3DPointFloat& GetLocation() { return m_location; } inline Mx3DPointFloat& GetLocation() { return m_location; }
inline Mx3DPointFloat& GetDirection() { return m_direction; } inline Mx3DPointFloat& GetDirection() { return m_direction; }
inline Mx3DPointFloat& GetUp() { return m_up; } 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 MxCore* GetUnknown84() { return m_unk0x84; }
inline void SetUnknown84(MxCore* p_unk0x84) { m_unk0x84 = p_unk0x84; } inline void SetUnknown84(MxCore* p_unk0x84) { m_unk0x84 = p_unk0x84; }
inline MxCore* GetOrigin() { return m_origin; } inline MxCore* GetOrigin() { return m_origin; }

View file

@ -15,7 +15,7 @@ class MxEntity : public MxCore {
MxEntity() { this->m_mxEntityId = -1; } MxEntity() { this->m_mxEntityId = -1; }
// FUNCTION: LEGO1 0x1000c110 // FUNCTION: LEGO1 0x1000c110
~MxEntity() override{}; ~MxEntity() override {}
// FUNCTION: LEGO1 0x1000c180 // FUNCTION: LEGO1 0x1000c180
inline const char* ClassName() const override // vtable+0x0c inline const char* ClassName() const override // vtable+0x0c

View file

@ -29,7 +29,7 @@ class MxPresenter : public MxCore {
MxPresenter() { Init(); } MxPresenter() { Init(); }
// FUNCTION: LEGO1 0x1000bf00 // FUNCTION: LEGO1 0x1000bf00
~MxPresenter() override{}; // vtable+0x00 ~MxPresenter() override {} // vtable+0x00
MxResult Tickle() override; // vtable+0x08 MxResult Tickle() override; // vtable+0x08
@ -117,6 +117,7 @@ class MxPresenter : public MxCore {
inline MxS32 GetY() const { return this->m_location.GetY(); } inline MxS32 GetY() const { return this->m_location.GetY(); }
inline MxS32 GetDisplayZ() const { return this->m_displayZ; } inline MxS32 GetDisplayZ() const { return this->m_displayZ; }
inline MxDSAction* GetAction() const { return this->m_action; } inline MxDSAction* GetAction() const { return this->m_action; }
inline void SetAction(MxDSAction* p_action) { m_action = p_action; }
inline void SetCompositePresenter(MxCompositePresenter* p_compositePresenter) inline void SetCompositePresenter(MxCompositePresenter* p_compositePresenter)
{ {