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
17 changed files with 152 additions and 50 deletions

View File

@@ -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

View File

@@ -57,7 +57,7 @@ public:
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; }

View File

@@ -33,9 +33,10 @@ public:
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'

View File

@@ -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 @@ public:
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'

View File

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

View File

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

View File

@@ -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
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -202,6 +202,16 @@ done:
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
);
}

View File

@@ -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;

View File

@@ -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;