diff --git a/CMakeLists.txt b/CMakeLists.txt index 47b7cc23..483ba9db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp LEGO1/lego/legoomni/src/common/legogamestate.cpp - LEGO1/lego/legoomni/src/common/legonavcontroller.cpp LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp LEGO1/lego/legoomni/src/common/legoplantmanager.cpp LEGO1/lego/legoomni/src/common/legostate.cpp @@ -49,6 +48,7 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/entity/legoentity.cpp LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp LEGO1/lego/legoomni/src/entity/legojetski.cpp + LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp LEGO1/lego/legoomni/src/entity/legopathactor.cpp LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp LEGO1/lego/legoomni/src/entity/legorace.cpp diff --git a/LEGO1/lego/legoomni/include/legocameracontroller.h b/LEGO1/lego/legoomni/include/legocameracontroller.h index 1d8aaa9c..660ee5ae 100644 --- a/LEGO1/lego/legoomni/include/legocameracontroller.h +++ b/LEGO1/lego/legoomni/include/legocameracontroller.h @@ -14,7 +14,7 @@ class LegoCameraController : public LegoPointOfViewController { LegoCameraController(); virtual ~LegoCameraController() override; // vtable+0x0 - virtual MxLong Notify(MxParam& p_param); // vtable+04 + virtual MxLong Notify(MxParam& p_param) override; // vtable+04 // FUNCTION: LEGO1 0x10011ec0 inline virtual const char* ClassName() const override // vtable+0x0c @@ -29,14 +29,14 @@ class LegoCameraController : public LegoPointOfViewController { return !strcmp(p_name, ClassName()) || MxCore::IsA(p_name); } - virtual void OnLButtonDown(MxPoint32 p_point); // vtable+0x30 - virtual void OnLButtonUp(MxPoint32 p_point); // vtable+0x34 - virtual void OnRButtonDown(MxPoint32 p_point); // vtable+0x38 - virtual void OnRButtonUp(MxPoint32 p_point); // vtable+0x3c - virtual void OnMouseMove(MxU8 p_modifier, MxPoint32 p_point); // vtable+0x40 - virtual MxResult Initialize(); // vtable+0x44 + virtual void OnLButtonDown(MxPoint32 p_point) override; // vtable+0x30 + virtual void OnLButtonUp(MxPoint32 p_point) override; // vtable+0x34 + virtual void OnRButtonDown(MxPoint32 p_point) override; // vtable+0x38 + virtual void OnRButtonUp(MxPoint32 p_point) override; // vtable+0x3c + virtual void OnMouseMove(MxU8 p_modifier, MxPoint32 p_point) override; // vtable+0x40 + virtual MxResult Create(); // vtable+0x44 - void LookAt(Vector3Impl& p_at, Vector3Impl& p_dir, Vector3Impl& p_up); + void SetWorldTransform(Vector3Impl& p_at, Vector3Impl& p_dir, Vector3Impl& p_up); void FUN_100123e0(Matrix4Data& p_transform, MxU32); Vector3Data& FUN_10012740(); Vector3Data& FUN_100127f0(); @@ -47,12 +47,4 @@ class LegoCameraController : public LegoPointOfViewController { Matrix4Data m_matrix2; // 0x80 }; -// todo: move to legonotify.h -enum LegoEventNotificationParamType { - c_lButtonState = 1, - c_rButtonState = 2, - c_modKey1 = 4, - c_modKey2 = 8, -}; - #endif // LEGOCAMERACONTROLLER_H diff --git a/LEGO1/lego/legoomni/include/legonotify.h b/LEGO1/lego/legoomni/include/legonotify.h new file mode 100644 index 00000000..ed4218b2 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legonotify.h @@ -0,0 +1,11 @@ +#ifndef LEGONOTIFY_H +#define LEGONOTIFY_H + +enum LegoEventNotificationParamType { + c_lButtonState = 1, + c_rButtonState = 2, + c_modKey1 = 4, + c_modKey2 = 8, +}; + +#endif // LEGONOTIFY_H diff --git a/LEGO1/lego/legoomni/include/legopointofviewcontroller.h b/LEGO1/lego/legoomni/include/legopointofviewcontroller.h index 7bb00e92..f0f8c3b1 100644 --- a/LEGO1/lego/legoomni/include/legopointofviewcontroller.h +++ b/LEGO1/lego/legoomni/include/legopointofviewcontroller.h @@ -1,8 +1,11 @@ #ifndef LEGOPOINTOFVIEWCONTROLLER_H #define LEGOPOINTOFVIEWCONTROLLER_H + #include "decomp.h" #include "mxcore.h" +#include + class Lego3DView; class LegoEntity; class LegoNavController; @@ -12,10 +15,11 @@ class LegoNavController; // LegoMouseController // VTABLE: LEGO1 0x100d8dd8 +// SIZE 0x20 class LegoMouseController : public MxCore { public: LegoMouseController(); - ~LegoMouseController(); + virtual ~LegoMouseController() override; virtual void LeftDown(int, int); // vtable+0x14 virtual void LeftDrag(int, int); // vtable+0x18 @@ -25,25 +29,22 @@ class LegoMouseController : public MxCore { virtual void RightUp(int, int); // vtable+0x28 private: - // note: in the leaked source code, this is a bool (which is typedefed to int) - MxU32 m_isButtonDown; // 0x08 - undefined4 m_unk0xc; // 0x0c - MxDouble m_buttonX; // 0x10 - MxDouble m_buttonY; // 0x18 + BOOL m_isButtonDown; // 0x08 + undefined4 m_unk0xc; // 0x0c + MxDouble m_buttonX; // 0x10 + MxDouble m_buttonY; // 0x18 }; // VTABLE: LEGO1 0x100d8e08 +// SIZE 0x38 class LegoPointOfViewController : public LegoMouseController { public: LegoPointOfViewController(); - ~LegoPointOfViewController(); + virtual ~LegoPointOfViewController() override; - virtual MxResult Tickle(); // vtable+0x08 - - MxResult Create(Lego3DView* p_lego3DView); - - void LeftDown(int p_x, int p_y); - void LeftDrag(int p_x, int p_y); + virtual MxResult Tickle() override; // vtable+0x08 + virtual void LeftDown(int p_x, int p_y) override; // vtable+0x0c + virtual void LeftDrag(int p_x, int p_y) override; // vtable+0x10 // FUNCTION: LEGO1 0x10011e40 virtual void LeftUp(int p_x, int p_y) override @@ -76,13 +77,18 @@ class LegoPointOfViewController : public LegoMouseController { AffectPointOfView(); } // vtable+0x28 virtual void SetEntity(LegoEntity* p_entity); // vtable+0x2c - LegoEntity* GetEntity() { return m_entity; } + + MxResult Create(Lego3DView* p_lego3DView); + + inline LegoEntity* GetEntity() { return m_entity; } protected: void AffectPointOfView(); - Lego3DView* m_lego3DView; // 0x20 - LegoEntity* m_entity; // 0x24 - double m_entityOffsetUp; // 0x28 - LegoNavController* m_nav; // 0x30 + + Lego3DView* m_lego3DView; // 0x20 + LegoEntity* m_entity; // 0x24 + MxDouble m_entityOffsetUp; // 0x28 + LegoNavController* m_nav; // 0x30 }; + #endif /* LEGOPOINTOFVIEWCONTROLLER_H */ diff --git a/LEGO1/lego/legoomni/src/build/helicopter.cpp b/LEGO1/lego/legoomni/src/build/helicopter.cpp index 87ee1dcb..f4220183 100644 --- a/LEGO1/lego/legoomni/src/build/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/build/helicopter.cpp @@ -238,7 +238,7 @@ MxU32 Helicopter::VTable0xd8(MxType18NotificationParam& p_param) mat.GetMatrix()[i][2] = mat2[i][2] * c + mat2[i][1] * s; } Vector3Impl at(mat.GetMatrix()[3]), dir(mat.GetMatrix()[2]), up(mat.GetMatrix()[1]); - m_world->GetCamera()->LookAt(at, dir, up); + m_world->GetCamera()->SetWorldTransform(at, dir, up); FUN_10010c30(); break; } @@ -247,7 +247,7 @@ MxU32 Helicopter::VTable0xd8(MxType18NotificationParam& p_param) mat.SetIdentity(); Vector3Impl at(mat.GetMatrix()[3]), dir(mat.GetMatrix()[2]), up(mat.GetMatrix()[1]); at[1] = 1.25; - m_world->GetCamera()->LookAt(at, dir, up); + m_world->GetCamera()->SetWorldTransform(at, dir, up); if (GameState()->GetUnknown10() == 0) { ((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(0); VTable0xe8(0x29, TRUE, 7); diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index e59645f6..34afaac0 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -1,6 +1,7 @@ #include "legocameracontroller.h" #include "legoinputmanager.h" +#include "legonotify.h" #include "legoomni.h" #include "legovideomanager.h" @@ -9,7 +10,7 @@ DECOMP_SIZE_ASSERT(LegoCameraController, 0xc8); // FUNCTION: LEGO1 0x10011d50 LegoCameraController::LegoCameraController() { - LookAt(Vector3Data(0, 0, 0), Vector3Data(0, 0, 1), Vector3Data(0, 1, 0)); + SetWorldTransform(Vector3Data(0, 0, 0), Vector3Data(0, 0, 1), Vector3Data(0, 1, 0)); } // FUNCTION: LEGO1 0x10011f70 @@ -23,7 +24,7 @@ LegoCameraController::~LegoCameraController() } // FUNCTION: LEGO1 0x10011ff0 -MxResult LegoCameraController::Initialize() +MxResult LegoCameraController::Create() { InputManager()->SetCamera(this); return LegoPointOfViewController::Create(VideoManager()->Get3DManager()->GetLego3DView()); @@ -70,7 +71,7 @@ void LegoCameraController::OnMouseMove(MxU8 p_modifier, MxPoint32 p_point) } // FUNCTION: LEGO1 0x10012260 -void LegoCameraController::LookAt(Vector3Impl& p_at, Vector3Impl& p_dir, Vector3Impl& p_up) +void LegoCameraController::SetWorldTransform(Vector3Impl& p_at, Vector3Impl& p_dir, Vector3Impl& p_up) { CalcLocalTransform(p_at, p_dir, p_up, m_matrix1); m_matrix2 = m_matrix1; diff --git a/LEGO1/lego/legoomni/src/common/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp similarity index 100% rename from LEGO1/lego/legoomni/src/common/legonavcontroller.cpp rename to LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp diff --git a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp index 4859fc1b..4ea4d428 100644 --- a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp @@ -3,12 +3,15 @@ #include "legopointofviewcontroller.h" #include "mxticklemanager.h" +DECOMP_SIZE_ASSERT(LegoMouseController, 0x20); +DECOMP_SIZE_ASSERT(LegoPointOfViewController, 0x38); + ////////////////////////////////////////////////////////////////////// // FUNCTION: LEGO1 0x10065550 LegoMouseController::LegoMouseController() { - m_isButtonDown = 0; + m_isButtonDown = FALSE; } // FUNCTION: LEGO1 0x100655d0 @@ -19,7 +22,7 @@ LegoMouseController::~LegoMouseController() // FUNCTION: LEGO1 0x10065620 void LegoMouseController::LeftDown(int p_x, int p_y) { - m_isButtonDown = 1; + m_isButtonDown = TRUE; m_buttonX = p_x; m_buttonY = p_y; } @@ -27,7 +30,7 @@ void LegoMouseController::LeftDown(int p_x, int p_y) // FUNCTION: LEGO1 0x10065640 void LegoMouseController::LeftUp(int p_x, int p_y) { - m_isButtonDown = 0; + m_isButtonDown = FALSE; m_buttonX = p_x; m_buttonY = p_y; } @@ -42,7 +45,7 @@ void LegoMouseController::LeftDrag(int p_x, int p_y) // FUNCTION: LEGO1 0x10065680 void LegoMouseController::RightDown(int p_x, int p_y) { - m_isButtonDown = 1; + m_isButtonDown = TRUE; m_buttonX = p_x; m_buttonY = p_y; } @@ -50,7 +53,7 @@ void LegoMouseController::RightDown(int p_x, int p_y) // FUNCTION: LEGO1 0x100656a0 void LegoMouseController::RightUp(int p_x, int p_y) { - m_isButtonDown = 0; + m_isButtonDown = FALSE; m_buttonX = p_x; m_buttonY = p_y; }