From 689178f68906785692da1ea577f07118c82c078d Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 30 May 2024 08:48:14 -0400 Subject: [PATCH] Implement/match LegoCameraController::FUN_10012290 and FUN_10012320 (#969) --- .../lego/legoomni/include/legocameracontroller.h | 4 ++-- .../legoomni/src/entity/legocameracontroller.cpp | 15 ++++++++++----- LEGO1/realtime/matrix.h | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocameracontroller.h b/LEGO1/lego/legoomni/include/legocameracontroller.h index f7325286..8e6e4989 100644 --- a/LEGO1/lego/legoomni/include/legocameracontroller.h +++ b/LEGO1/lego/legoomni/include/legocameracontroller.h @@ -36,8 +36,8 @@ public: virtual MxResult Create(); // vtable+0x44 void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up); - void FUN_10012290(float); - void FUN_10012320(MxFloat); + void FUN_10012290(float p_angle); + void FUN_10012320(float p_angle); void FUN_100123e0(const Matrix4& p_transform, MxU32 p_und); Mx3DPointFloat GetWorldUp(); Mx3DPointFloat GetWorldLocation(); diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index 6025f614..da455eab 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -124,15 +124,20 @@ void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3& m_matrix2 = m_matrix1; } -// STUB: LEGO1 0x10012290 -void LegoCameraController::FUN_10012290(float) +// FUNCTION: LEGO1 0x10012290 +// FUNCTION: BETA10 0x10068c34 +void LegoCameraController::FUN_10012290(float p_angle) { + m_matrix1 = m_matrix2; + m_matrix1.RotateZ(p_angle); } -// STUB: LEGO1 0x10012320 -void LegoCameraController::FUN_10012320(MxFloat) +// FUNCTION: LEGO1 0x10012320 +// FUNCTION: BETA10 0x10068c73 +void LegoCameraController::FUN_10012320(float p_angle) { - // TODO + m_matrix1 = m_matrix2; + m_matrix1.RotateY(p_angle); } // FUNCTION: LEGO1 0x100123e0 diff --git a/LEGO1/realtime/matrix.h b/LEGO1/realtime/matrix.h index df2260ea..f90cc3e8 100644 --- a/LEGO1/realtime/matrix.h +++ b/LEGO1/realtime/matrix.h @@ -133,6 +133,20 @@ public: } } + // FUNCTION: BETA10 0x1001fd60 + inline void RotateY(const float& p_angle) + { + float s = sin(p_angle); + float c = cos(p_angle); + float matrix[4][4]; + memcpy(matrix, m_data, sizeof(float) * 16); + for (int i = 0; i < 4; i++) { + m_data[i][0] = matrix[i][0] * c + matrix[i][2] * s; + m_data[i][2] = matrix[i][2] * c - matrix[i][0] * s; + } + } + + // FUNCTION: BETA10 0x1006ab10 inline void RotateZ(const float& p_angle) { float s = sin(p_angle);