From 2c613fc84e97adde0ae9fb67ffb57f3b1d3c33cc Mon Sep 17 00:00:00 2001 From: EM Date: Wed, 4 Feb 2026 18:48:14 +0300 Subject: [PATCH] Push Free Camera Co-Authored-By: Hyper <34012267+hyperbx@users.noreply.github.com> --- Hedgehog/Base/hhObject.h | 3 ++ Hedgehog/Base/hhObject.inl | 34 +++++++++++++++++++ Hedgehog/Math/Vector.h | 10 ++++++ Hedgehog/Universe/Engine/hhMessage.h | 19 +++++++++++ SWA.h | 10 ++++++ SWA/Camera/CameraController.h | 17 ++++++++-- SWA/Camera/Controller/FreeCamera.h | 16 +++++++++ SWA/Globals.h | 26 ++++++++------ SWA/Message/MsgCameraPauseMove.h | 17 ++++++++++ SWA/Message/MsgPopCameraController.h | 34 +++++++++++++++++++ SWA/Message/MsgSetPosition.h | 19 +++++++++++ SWA/Message/MsgSetVelocity.h | 19 +++++++++++ SWA/Player/Character/Base/PlayerContext.h | 29 ++++++++++++++++ .../Character/EvilSonic/EvilSonicContext.h | 16 ++++++--- .../Character/Speed/PlayerSpeedContext.h | 15 ++++++++ .../Character/Speed/PlayerSpeedContext.inl | 7 ++++ SWA/Replay/Camera/ReplayFreeCamera.h | 16 +++++++++ SWA/Tool/FreeCameraTool/FreeCameraTool.h | 17 ++++++++++ 18 files changed, 307 insertions(+), 17 deletions(-) create mode 100644 Hedgehog/Base/hhObject.inl create mode 100644 Hedgehog/Universe/Engine/hhMessage.h create mode 100644 SWA/Camera/Controller/FreeCamera.h create mode 100644 SWA/Message/MsgCameraPauseMove.h create mode 100644 SWA/Message/MsgPopCameraController.h create mode 100644 SWA/Message/MsgSetPosition.h create mode 100644 SWA/Message/MsgSetVelocity.h create mode 100644 SWA/Player/Character/Base/PlayerContext.h create mode 100644 SWA/Player/Character/Speed/PlayerSpeedContext.h create mode 100644 SWA/Player/Character/Speed/PlayerSpeedContext.inl create mode 100644 SWA/Replay/Camera/ReplayFreeCamera.h create mode 100644 SWA/Tool/FreeCameraTool/FreeCameraTool.h diff --git a/Hedgehog/Base/hhObject.h b/Hedgehog/Base/hhObject.h index 80723ee..9d83108 100644 --- a/Hedgehog/Base/hhObject.h +++ b/Hedgehog/Base/hhObject.h @@ -1,6 +1,7 @@ #pragma once #include "SWA.inl" +#include "Hedgehog/Base/System/hhAllocator.h" namespace Hedgehog::Base { @@ -21,3 +22,5 @@ namespace Hedgehog::Base void operator delete(void* in_pMem, void* in_pObj); }; } + +#include "hhObject.inl" diff --git a/Hedgehog/Base/hhObject.inl b/Hedgehog/Base/hhObject.inl new file mode 100644 index 0000000..89f467a --- /dev/null +++ b/Hedgehog/Base/hhObject.inl @@ -0,0 +1,34 @@ +namespace Hedgehog::Base +{ + inline CObject::CObject() + { + } + + inline CObject::CObject(const swa_null_ctor&) + { + } + + inline void* CObject::operator new(const size_t in_Size) + { + return __HH_ALLOC(in_Size); + } + + inline void CObject::operator delete(void* in_pMem) + { + return __HH_FREE(in_pMem); + } + + inline void* CObject::operator new(const size_t in_Size, void* in_pObj) + { + return in_pObj; + } + + inline void* CObject::operator new(const size_t in_Size, const size_t in_Align, void* in_pObj) + { + return in_pObj; + } + + inline void CObject::operator delete(void* in_pMem, void* in_pObj) + { + } +} diff --git a/Hedgehog/Math/Vector.h b/Hedgehog/Math/Vector.h index 7ea0e38..fb81a1c 100644 --- a/Hedgehog/Math/Vector.h +++ b/Hedgehog/Math/Vector.h @@ -18,6 +18,16 @@ namespace Hedgehog::Math be Y; be Z; be W; + + CVector operator*(const float& scalar) const + { + return { X * scalar, Y * scalar, Z * scalar }; + } + + CVector operator+(const CVector& v) const + { + return { X + v.X, Y + v.Y, Z + v.Z }; + } }; class CVector4 diff --git a/Hedgehog/Universe/Engine/hhMessage.h b/Hedgehog/Universe/Engine/hhMessage.h new file mode 100644 index 0000000..e08e7a8 --- /dev/null +++ b/Hedgehog/Universe/Engine/hhMessage.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include + +namespace Hedgehog::Universe +{ + class Message : public Base::CObject + { + public: + be m_pVftable; + be m_SenderActorID; + boost::shared_ptr m_spSelf; + }; + + class MessageTypeGet : public Message {}; + class MessageTypeSet : public Message {}; +} diff --git a/SWA.h b/SWA.h index 4190922..4d4a0cb 100644 --- a/SWA.h +++ b/SWA.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +91,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -96,6 +102,8 @@ #include #include #include +#include +#include #include #include #include @@ -126,4 +134,6 @@ #include #include #include +#include +#include diff --git a/SWA/Camera/CameraController.h b/SWA/Camera/CameraController.h index 9262ed0..7e1d4b3 100644 --- a/SWA/Camera/CameraController.h +++ b/SWA/Camera/CameraController.h @@ -1,17 +1,28 @@ #pragma once #include +#include +#include namespace SWA { - class CCameraController : public Hedgehog::Universe::CStateMachineBase::CStateBase + class CCamera; + + class CCameraController { public: - SWA_INSERT_PADDING(0x04); + SWA_INSERT_PADDING(0x08); + xpointer m_pCamera; + SWA_INSERT_PADDING(0x58); be m_FieldOfView; - SWA_INSERT_PADDING(0x68); + SWA_INSERT_PADDING(0x08); + Hedgehog::Math::CVector m_Position; + Hedgehog::Math::CVector m_UpVector; + Hedgehog::Math::CQuaternion m_Rotation; + SWA_INSERT_PADDING(0x30); }; + SWA_ASSERT_OFFSETOF(CCameraController, m_pCamera, 0x08); SWA_ASSERT_OFFSETOF(CCameraController, m_FieldOfView, 0x64); SWA_ASSERT_SIZEOF(CCameraController, 0xD0); } diff --git a/SWA/Camera/Controller/FreeCamera.h b/SWA/Camera/Controller/FreeCamera.h new file mode 100644 index 0000000..20e174d --- /dev/null +++ b/SWA/Camera/Controller/FreeCamera.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include "SWA/Camera/CameraController.h" + +namespace SWA +{ + class CFreeCamera : public CCameraController + { + public: + SWA_INSERT_PADDING(0x10); + be m_Speed; + }; + + SWA_ASSERT_OFFSETOF(CFreeCamera, m_Speed, 0xE0); +} diff --git a/SWA/Globals.h b/SWA/Globals.h index ddd6acc..edff36d 100644 --- a/SWA/Globals.h +++ b/SWA/Globals.h @@ -6,13 +6,15 @@ namespace SWA { struct SGlobals { - // ms_DrawLightFieldSamplingPoint: サンプリング点をデバッグ表示 + // ms_DrawLightFieldSamplingPoint: サンプリング点をデバッグ表示 static inline bool* ms_DrawLightFieldSamplingPoint; + static inline be* ms_FreeCameraSpeed; + // N/A static inline bool* ms_IsAutoSaveWarningShown; - // ms_IgnoreLightFieldData: データを無視する + // ms_IgnoreLightFieldData: データを無視する static inline bool* ms_IgnoreLightFieldData; // IsCollisionRender @@ -24,22 +26,24 @@ namespace SWA // IsObjectCollisionRender static inline bool* ms_IsObjectCollisionRender; - // ms_IsRenderDebugDraw: デバッグ描画 + // ms_IsRenderDebugDraw: デバッグ描画 static inline bool* ms_IsRenderDebugDraw; - // ms_IsRenderDebugDrawText: デバッグ文字描画 + // ms_IsRenderDebugDrawText: デバッグ文字描画 static inline bool* ms_IsRenderDebugDrawText; - // ms_IsRenderDebugPositionDraw: デバッグ位置描画 + // ms_IsRenderDebugPositionDraw: デバッグ位置描画 static inline bool* ms_IsRenderDebugPositionDraw; - // ms_IsRenderGameMainHud: ゲームメインHUD 描画 + static inline bool* ms_IsRenderDepthOfField; + + // ms_IsRenderGameMainHud: ゲームメインHUD 描画 static inline bool* ms_IsRenderGameMainHud; - // ms_IsRenderHud: 全 HUD 描画 + // ms_IsRenderHud: å…¨ HUD 描画 static inline bool* ms_IsRenderHud; - // ms_IsRenderHudPause: ポーズメニュー 描画 + // ms_IsRenderHudPause: ポーズメニュー 描画 static inline bool* ms_IsRenderHudPause; // N/A @@ -48,15 +52,16 @@ namespace SWA // IsTriggerRender static inline bool* ms_IsTriggerRender; - // ms_LightFieldDebug: 値をデバッグ表示 + // ms_LightFieldDebug: 値をデバッグ表示 static inline bool* ms_LightFieldDebug; - // VisualizeLoadedLevel: ミップレベルを視覚化 赤=0, 緑=1, 青=2, 黄=未ロード + // VisualizeLoadedLevel: ミップレベルを視覚化 赤=0, ç·‘=1, 青=2, 黄=未ロード static inline bool* ms_VisualizeLoadedLevel; static void Init() { ms_DrawLightFieldSamplingPoint = (bool*)MmGetHostAddress(0x83367BCE); + ms_FreeCameraSpeed = (be*)MmGetHostAddress(0x83366DF8); ms_IgnoreLightFieldData = (bool*)MmGetHostAddress(0x83367BCF); ms_IsAutoSaveWarningShown = (bool*)MmGetHostAddress(0x83367BC1); ms_IsCollisionRender = (bool*)MmGetHostAddress(0x833678A6); @@ -65,6 +70,7 @@ namespace SWA ms_IsRenderDebugDraw = (bool*)MmGetHostAddress(0x8328BB23); ms_IsRenderDebugDrawText = (bool*)MmGetHostAddress(0x8328BB25); ms_IsRenderDebugPositionDraw = (bool*)MmGetHostAddress(0x8328BB24); + ms_IsRenderDepthOfField = (bool*)MmGetHostAddress(0x83302720); ms_IsRenderGameMainHud = (bool*)MmGetHostAddress(0x8328BB27); ms_IsRenderHud = (bool*)MmGetHostAddress(0x8328BB26); ms_IsRenderHudPause = (bool*)MmGetHostAddress(0x8328BB28); diff --git a/SWA/Message/MsgCameraPauseMove.h b/SWA/Message/MsgCameraPauseMove.h new file mode 100644 index 0000000..f128f3e --- /dev/null +++ b/SWA/Message/MsgCameraPauseMove.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace SWA::Message +{ + class MsgCameraPauseMove : public Hedgehog::Universe::MessageTypeSet + { + public: + SWA_INSERT_PADDING(0x08); + bool m_isPaused; + + MsgCameraPauseMove(bool in_isPaused) : m_isPaused(in_isPaused) {} + }; + + SWA_ASSERT_OFFSETOF(MsgCameraPauseMove, m_isPaused, 0x18); +} diff --git a/SWA/Message/MsgPopCameraController.h b/SWA/Message/MsgPopCameraController.h new file mode 100644 index 0000000..d03ee09 --- /dev/null +++ b/SWA/Message/MsgPopCameraController.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include "SWA/Camera/CameraController.h" +#include "Hedgehog/Base/Type/hhSharedString.h" + +namespace SWA::Message +{ + class MsgPopCameraController : public Hedgehog::Universe::MessageTypeSet + { + public: + SWA_INSERT_PADDING(0x08); + xpointer m_pCameraController; + SWA_INSERT_PADDING(0x08); + xpointer m_pCameraName; + be m_InterpolateTime; + bool m_Field2C; + bool m_Field2D; + bool m_Field2E; + + MsgPopCameraController(CCameraController* in_pCameraController, float in_interpolateTime) + : m_pCameraController(in_pCameraController), m_InterpolateTime(in_interpolateTime) {} + + MsgPopCameraController(Hedgehog::Base::CSharedString* in_pCameraName, float in_interpolateTime) + : m_pCameraName(in_pCameraName), m_InterpolateTime(in_interpolateTime) {} + }; + + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_pCameraController, 0x18); + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_pCameraName, 0x24); + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_InterpolateTime, 0x28); + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_Field2C, 0x2C); + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_Field2D, 0x2D); + SWA_ASSERT_OFFSETOF(MsgPopCameraController, m_Field2E, 0x2E); +} diff --git a/SWA/Message/MsgSetPosition.h b/SWA/Message/MsgSetPosition.h new file mode 100644 index 0000000..9cb8775 --- /dev/null +++ b/SWA/Message/MsgSetPosition.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "Hedgehog/Math/Vector.h" + +namespace SWA::Message +{ + class MsgSetPosition : public Hedgehog::Universe::MessageTypeSet + { + public: + SWA_INSERT_PADDING(0x10); + Hedgehog::Math::CVector m_Position; + + MsgSetPosition(const Hedgehog::Math::CVector& in_rPosition) : m_Position(in_rPosition) {} + }; + + SWA_ASSERT_OFFSETOF(MsgSetPosition, m_Position, 0x20); + SWA_ASSERT_SIZEOF(MsgSetPosition, 0x30); +} diff --git a/SWA/Message/MsgSetVelocity.h b/SWA/Message/MsgSetVelocity.h new file mode 100644 index 0000000..81da238 --- /dev/null +++ b/SWA/Message/MsgSetVelocity.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "Hedgehog/Math/Vector.h" + +namespace SWA::Message +{ + class MsgSetVelocity : public Hedgehog::Universe::MessageTypeSet + { + public: + SWA_INSERT_PADDING(0x10); + Hedgehog::Math::CVector m_Velocity; + + MsgSetVelocity(const Hedgehog::Math::CVector& in_rVelocity) : m_Velocity(in_rVelocity) {} + }; + + SWA_ASSERT_OFFSETOF(MsgSetVelocity, m_Velocity, 0x20); + SWA_ASSERT_SIZEOF(MsgSetVelocity, 0x30); +} diff --git a/SWA/Player/Character/Base/PlayerContext.h b/SWA/Player/Character/Base/PlayerContext.h new file mode 100644 index 0000000..e26b495 --- /dev/null +++ b/SWA/Player/Character/Base/PlayerContext.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "boost/smart_ptr/shared_ptr.h" + +namespace SWA::Player +{ + class CPlayer; + + class CPlayerContext + { + public: + SWA_INSERT_PADDING(0x10); + boost::shared_ptr m_spMatrixNode; + SWA_INSERT_PADDING(0x18); + boost::anonymous_shared_ptr m_spRayCastCollision; + SWA_INSERT_PADDING(0xC8); + xpointer m_pPlayer; + SWA_INSERT_PADDING(0xF8); + boost::shared_ptr m_spParameter; + SWA_INSERT_PADDING(0x0C); + }; + + SWA_ASSERT_OFFSETOF(CPlayerContext, m_spMatrixNode, 0x10); + SWA_ASSERT_OFFSETOF(CPlayerContext, m_spRayCastCollision, 0x30); + SWA_ASSERT_OFFSETOF(CPlayerContext, m_pPlayer, 0x100); + SWA_ASSERT_OFFSETOF(CPlayerContext, m_spParameter, 0x1FC); + SWA_ASSERT_SIZEOF(CPlayerContext, 0x210); +} diff --git a/SWA/Player/Character/EvilSonic/EvilSonicContext.h b/SWA/Player/Character/EvilSonic/EvilSonicContext.h index d8f38ae..ebc5ecf 100644 --- a/SWA/Player/Character/EvilSonic/EvilSonicContext.h +++ b/SWA/Player/Character/EvilSonic/EvilSonicContext.h @@ -2,22 +2,30 @@ #include "SWA.inl" #include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h" +#include "SWA/Player/Character/Base/PlayerContext.h" namespace SWA::Player { - class CEvilSonicContext // : public CPlayerContext + class CEvilSonicContext : public CPlayerContext { public: - SWA_INSERT_PADDING(0x688); + SWA_INSERT_PADDING(0x478); be m_DarkGaiaEnergy; SWA_INSERT_PADDING(0x138); be m_AnimationID; SWA_INSERT_PADDING(0x38); - be m_UnkHudGuideF32; - be m_UnkHudGuideU32; + be m_Field800; + be m_Field804; SWA_INSERT_PADDING(0x18); be m_GuideType; SWA_INSERT_PADDING(0xA8); be m_OutOfControlCount; }; + + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_DarkGaiaEnergy, 0x688); + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_AnimationID, 0x7C4); + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_Field800, 0x800); + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_Field804, 0x804); + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_GuideType, 0x820); + SWA_ASSERT_OFFSETOF(CEvilSonicContext, m_OutOfControlCount, 0x8CC); } diff --git a/SWA/Player/Character/Speed/PlayerSpeedContext.h b/SWA/Player/Character/Speed/PlayerSpeedContext.h new file mode 100644 index 0000000..4cc449c --- /dev/null +++ b/SWA/Player/Character/Speed/PlayerSpeedContext.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "SWA/Player/Character/Base/PlayerContext.h" + +namespace SWA::Player +{ + class CPlayerSpeedContext : public CPlayerContext + { + public: + static CPlayerSpeedContext* GetInstance(); + }; +} + +#include "PlayerSpeedContext.inl" diff --git a/SWA/Player/Character/Speed/PlayerSpeedContext.inl b/SWA/Player/Character/Speed/PlayerSpeedContext.inl new file mode 100644 index 0000000..dd452f8 --- /dev/null +++ b/SWA/Player/Character/Speed/PlayerSpeedContext.inl @@ -0,0 +1,7 @@ +namespace SWA::Player +{ + inline CPlayerSpeedContext* CPlayerSpeedContext::GetInstance() + { + return *(xpointer*)MmGetHostAddress(0x83362F98); + } +} diff --git a/SWA/Replay/Camera/ReplayFreeCamera.h b/SWA/Replay/Camera/ReplayFreeCamera.h new file mode 100644 index 0000000..a9ffd7a --- /dev/null +++ b/SWA/Replay/Camera/ReplayFreeCamera.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include "SWA/Camera/CameraController.h" + +namespace SWA +{ + class CReplayFreeCamera : public CCameraController + { + public: + SWA_INSERT_PADDING(0x90); + be m_Speed; + }; + + SWA_ASSERT_OFFSETOF(CReplayFreeCamera, m_Speed, 0x160); +} diff --git a/SWA/Tool/FreeCameraTool/FreeCameraTool.h b/SWA/Tool/FreeCameraTool/FreeCameraTool.h new file mode 100644 index 0000000..ccc1f78 --- /dev/null +++ b/SWA/Tool/FreeCameraTool/FreeCameraTool.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include "SWA/System/GameObject.h" +#include "SWA/Camera/Controller/FreeCamera.h" + +namespace SWA +{ + class CFreeCameraTool : public CGameObject + { + public: + SWA_INSERT_PADDING(0x04); + xpointer m_pFreeCamera; + }; + + SWA_ASSERT_OFFSETOF(CFreeCameraTool, m_pFreeCamera, 0xC0); +}