From 338f06a80980c26e1898a9c2da84d525f732e0e3 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 15:56:15 -0400 Subject: [PATCH 01/14] Link RPGrpModel --- config/RSPE01_01/symbols.txt | 26 ++++++++++++------------- configure.py | 2 +- include/Pack/RPGraphics/RPGrpModel.h | 2 +- include/egg/gfxe/eggModelBoundingInfo.h | 2 +- src/Pack/RPGraphics/RPGrpModel.cpp | 5 +++-- src/Pack/RPSystem/RPSysDvdStatus.cpp | 14 +------------ 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 7649b616..753a8b72 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -2966,9 +2966,9 @@ getNumViewMtx__Q23EGG7ModelExCFv = .text:0x80095114; // type:function size:0x64 getShapeMinMax__Q23EGG7ModelExFUsPQ34nw4r4math4VEC3PQ34nw4r4math4VEC3b = .text:0x80095178; // type:function size:0x460 scope:global setVisible__Q23EGG7ModelExFb = .text:0x800955D8; // type:function size:0x2C scope:global calcWorld__Q23EGG7ModelExCFPQ34nw4r4math5MTX34 = .text:0x80095604; // type:function size:0x1C4 scope:global -calcView__Q23EGG7ModelExCFPCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x800957C8; // type:function size:0x194 scope:global +calcView__Q23EGG7ModelExCFRCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x800957C8; // type:function size:0x194 scope:global drawShapeDirectly__Q23EGG7ModelExFUlbbPQ34nw4r4math5MTX34 = .text:0x8009595C; // type:function size:0x49C scope:global -replaceTexture__Q23EGG7ModelExFPCcRC9_GXTexObjbPQ23EGG20TextureReplaceResultUsbUl = .text:0x80095DF8; // type:function size:0x27C scope:global +replaceTexture__Q23EGG7ModelExFPCcRC9_GXTexObjbPQ23EGG20TextureReplaceResultUsb = .text:0x80095DF8; // type:function size:0x27C scope:global attachBoundingInfo__Q23EGG7ModelExFPQ23EGG17ModelBoundingInfo = .text:0x80096074; // type:function size:0x5C scope:global getResShp__Q23EGG7ModelExCFUs = .text:0x800960D0; // type:function size:0x17C scope:global getResMat__Q23EGG7ModelExCFUs = .text:0x8009624C; // type:function size:0x1A8 scope:global @@ -7794,16 +7794,16 @@ Construct__10RPGrpModelFUsPCcUcUlUl = .text:0x801A9E58; // type:function size:0x Construct__10RPGrpModelFUsiUcUlUl = .text:0x801A9EEC; // type:function size:0x94 Construct__10RPGrpModelFUsUcUlUl = .text:0x801A9F80; // type:function size:0xB4 SetJointVisible__10RPGrpModelFUlb = .text:0x801AA034; // type:function size:0x28 -IsJointVisible__10RPGrpModelCFv = .text:0x801AA05C; // type:function size:0xC +IsJointVisible__10RPGrpModelCFUl = .text:0x801AA05C; // type:function size:0xC SetShapeVisible__10RPGrpModelFUlb = .text:0x801AA068; // type:function size:0x28 -IsShapeVisible__10RPGrpModelCFv = .text:0x801AA090; // type:function size:0xC +IsShapeVisible__10RPGrpModelCFUl = .text:0x801AA090; // type:function size:0xC GetJointNum__10RPGrpModelCFv = .text:0x801AA09C; // type:function size:0x8 GetShapeNum__10RPGrpModelCFv = .text:0x801AA0A4; // type:function size:0x8 GetViewMtxNum__10RPGrpModelCFv = .text:0x801AA0AC; // type:function size:0x8 -DrawDirect__10RPGrpModelFUlPQ23EGG9Matrix34f = .text:0x801AA0B4; // type:function size:0x14 +DrawDirect__10RPGrpModelFUlPQ34nw4r4math5MTX34 = .text:0x801AA0B4; // type:function size:0x14 CalcBeforeDraw__10RPGrpModelFv = .text:0x801AA0C8; // type:function size:0x14 -CalcView__10RPGrpModelFRCQ23EGG9Matrix34fPQ23EGG9Matrix34f = .text:0x801AA0DC; // type:function size:0x40 -GetShapeMinMax__10RPGrpModelCFUsPQ23EGG8Vector3fPQ23EGG8Vector3f = .text:0x801AA11C; // type:function size:0xC +CalcView__10RPGrpModelFRCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x801AA0DC; // type:function size:0x40 +GetShapeMinMax__10RPGrpModelCFUsPQ34nw4r4math4VEC3PQ34nw4r4math4VEC3 = .text:0x801AA11C; // type:function size:0xC fn_801AA128 = .text:0x801AA128; // type:function size:0x1C fn_801AA144 = .text:0x801AA144; // type:function size:0x7C fn_801AA1C0 = .text:0x801AA1C0; // type:function size:0x110 @@ -8029,7 +8029,7 @@ fn_801B2580 = .text:0x801B2580; // type:function size:0x40 fn_801B25C0 = .text:0x801B25C0; // type:function size:0x14 fn_801B25D4 = .text:0x801B25D4; // type:function size:0x14 fn_801B25E8 = .text:0x801B25E8; // type:function size:0x10 -fn_801B25F8 = .text:0x801B25F8; // type:function size:0x40 +__ct__22RPGrpModelBoundingInfoFUlP10RPGrpModel = .text:0x801B25F8; // type:function size:0x40 fn_801B2638 = .text:0x801B2638; // type:function size:0x58 fn_801B2690 = .text:0x801B2690; // type:function size:0x8 fn_801B2698 = .text:0x801B2698; // type:function size:0x8 @@ -8046,8 +8046,8 @@ fn_801B28C8 = .text:0x801B28C8; // type:function size:0xE0 fn_801B29A8 = .text:0x801B29A8; // type:function size:0x1A4 fn_801B2B4C = .text:0x801B2B4C; // type:function size:0x1A4 fn_801B2CF0 = .text:0x801B2CF0; // type:function size:0x1C4 -fn_801B2EB4 = .text:0x801B2EB4; // type:function size:0x6F4 -fn_801B35A8 = .text:0x801B35A8; // type:function size:0x808 +Calc__18RPGrpModelMaterialFv = .text:0x801B2EB4; // type:function size:0x6F4 +__ct__18RPGrpModelMaterialFP10RPGrpModelUs = .text:0x801B35A8; // type:function size:0x808 fn_801B3DB0 = .text:0x801B3DB0; // type:function size:0x40 fn_801B3DF0 = .text:0x801B3DF0; // type:function size:0x78 fn_801B3E68 = .text:0x801B3E68; // type:function size:0x730 @@ -8055,8 +8055,8 @@ fn_801B4598 = .text:0x801B4598; // type:function size:0x70 fn_801B4608 = .text:0x801B4608; // type:function size:0x40 fn_801B4648 = .text:0x801B4648; // type:function size:0x4 fn_801B464C = .text:0x801B464C; // type:function size:0x1F4 -fn_801B4840 = .text:0x801B4840; // type:function size:0xCC -fn_801B490C = .text:0x801B490C; // type:function size:0x15C +Clear__16RPGrpModelRecordFv = .text:0x801B4840; // type:function size:0xCC +__ct__16RPGrpModelRecordFUsP10RPGrpModel = .text:0x801B490C; // type:function size:0x15C fn_801B4A68 = .text:0x801B4A68; // type:function size:0x78 fn_801B4AE0 = .text:0x801B4AE0; // type:function size:0x4 fn_801B4AE4 = .text:0x801B4AE4; // type:function size:0x40 @@ -15152,7 +15152,7 @@ lbl_803833B6 = .rodata:0x803833B6; // type:object size:0x18A lbl_80383540 = .rodata:0x80383540; // type:object size:0x130 TYPE_NAME__Q34nw4r3g3d6ScnRfl = .rodata:0x80383670; // type:object size:0xC scope:global lbl_80383680 = .rodata:0x80383680; // type:object size:0x18 data:4byte -lbl_80383698 = .rodata:0x80383698; // type:object size:0x18 +GEOMETRY_MAGNIFY__10RPGrpModel = .rodata:0x80383698; // type:object size:0x18 lbl_803836B0 = .rodata:0x803836B0; // type:object size:0x18 lbl_803836C8 = .rodata:0x803836C8; // type:object size:0x18 lbl_803836E0 = .rodata:0x803836E0; // type:object size:0x10 diff --git a/configure.py b/configure.py index bd0396d6..6614caf6 100755 --- a/configure.py +++ b/configure.py @@ -1235,7 +1235,7 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPGraphics/RPGrpCamera.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathManager.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpLightManager.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpModel.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpModel.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnm.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnmImplement.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelImplement.cpp"), diff --git a/include/Pack/RPGraphics/RPGrpModel.h b/include/Pack/RPGraphics/RPGrpModel.h index ec6bed6c..5420c166 100644 --- a/include/Pack/RPGraphics/RPGrpModel.h +++ b/include/Pack/RPGraphics/RPGrpModel.h @@ -261,7 +261,7 @@ class RPGrpModel { }; protected: - static const nw4r::math::_VEC3 GEOMETRY_MAGNIFY[1 /* ??? */]; + static const nw4r::math::_VEC3 GEOMETRY_MAGNIFY[/* ??? */]; //! Allocator used for model-related allocations static EGG::Allocator* spAllocator; diff --git a/include/egg/gfxe/eggModelBoundingInfo.h b/include/egg/gfxe/eggModelBoundingInfo.h index e9d12c9b..459a511e 100644 --- a/include/egg/gfxe/eggModelBoundingInfo.h +++ b/include/egg/gfxe/eggModelBoundingInfo.h @@ -50,7 +50,7 @@ class ModelBoundingInfo { ModelBoundingInfo(u32, ModelEx*); virtual ~ModelBoundingInfo(); - void Calc(); + void calc(); SphereData* getSphere() const { #line 99 diff --git a/src/Pack/RPGraphics/RPGrpModel.cpp b/src/Pack/RPGraphics/RPGrpModel.cpp index ccd56f08..7071d19f 100644 --- a/src/Pack/RPGraphics/RPGrpModel.cpp +++ b/src/Pack/RPGraphics/RPGrpModel.cpp @@ -14,8 +14,9 @@ RPGrpModel* RPGrpModel::spCalcModel = NULL; nw4r::math::MTX34* RPGrpModel::spCalcWorldMtxArray = NULL; nw4r::math::MTX34* RPGrpModel::spCalcViewMtxArray = NULL; -const nw4r::math::_VEC3 RPGrpModel::GEOMETRY_MAGNIFY[1 /* ??? */] = { +const nw4r::math::_VEC3 RPGrpModel::GEOMETRY_MAGNIFY[/* ??? */] = { {-1.0f, 1.0f, 1.0f}, + {0.0f, 0.0f, 0.0f}, }; RPGrpModel* RPGrpModel::Construct(RPGrpHandle handle, u8 viewNo, u32 typeOption, @@ -162,7 +163,7 @@ void RPGrpModel::Calc() { InternalCalc(); if (mpBoundingInfo != NULL) { - mpBoundingInfo->Calc(); + mpBoundingInfo->calc(); } spCalcModel = NULL; diff --git a/src/Pack/RPSystem/RPSysDvdStatus.cpp b/src/Pack/RPSystem/RPSysDvdStatus.cpp index 79518673..c698ec69 100644 --- a/src/Pack/RPSystem/RPSysDvdStatus.cpp +++ b/src/Pack/RPSystem/RPSysDvdStatus.cpp @@ -244,27 +244,15 @@ void RPSysDvdStatus::draw() { } } -#if defined(BUG_FIX) - std::strncpy(mpErrorMessage, pLanguage[0], MESSAGE_BUFFER_SIZE); - - if (mErrorStatus == EErrorStatus_NoOrWrongDisk || - mErrorStatus == EErrorStatus_DiskError) { - - std::strcat(mpErrorMessage, GAME_DISK_NAME); - std::strcat(mpErrorMessage, pLanguage[1]); - } -#else - // @bug Unsafe string operations std::strcpy(mpErrorMessage, pLanguage[0]); - // @bug Same comparison twice (one should be EErrorStatus_DiskError) + // @bug Same comparison twice if (mErrorStatus == EErrorStatus_NoOrWrongDisk || mErrorStatus == EErrorStatus_NoOrWrongDisk) { std::strcat(mpErrorMessage, GAME_DISK_NAME); std::strcat(mpErrorMessage, pLanguage[1]); } -#endif RP_GET_INSTANCE(RPSysTextWriter) ->Print(mpErrorMessage, std::strlen(mpErrorMessage)); From f626838b293d9ee74ad4420e1955eae22a422d00 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:22:29 -0400 Subject: [PATCH 02/14] RPGrpLightManager OK --- config/RSPE01_01/symbols.txt | 4 +- configure.py | 2 +- include/Pack/RPGraphics.h | 1 + include/Pack/RPGraphics/RPGrpLightManager.h | 46 +++++++++++++++++++++ include/egg/gfxe/eggLightManager.h | 5 ++- src/Pack/RPGraphics/RPGrpLightManager.cpp | 19 +++++++++ 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpLightManager.h create mode 100644 src/Pack/RPGraphics/RPGrpLightManager.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 753a8b72..b3d09c71 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -2898,7 +2898,7 @@ fn_8009047C = .text:0x8009047C; // type:function size:0x78 LoadObjIndxGX__Q23EGG12LightManagerCFv = .text:0x800904F4; // type:function size:0x74 scope:global LoadLightSetGD__Q23EGG12LightManagerCFiPUlPUlPUlPUlP8_GXColor = .text:0x80090568; // type:function size:0x6C scope:global DoneDraw__Q23EGG12LightManagerFv = .text:0x800905D4; // type:function size:0x2C scope:global -LoadScnLightInner__Q23EGG12LightManagerFQ34nw4r3g3d9ResAnmScnfsUl = .text:0x80090600; // type:function size:0x270 scope:global +LoadScnLightInner__Q23EGG12LightManagerFQ34nw4r3g3d9ResAnmScnfUl = .text:0x80090600; // type:function size:0x270 scope:global CopyToG3D_World__Q23EGG12LightManagerCFPQ34nw4r3g3d7ScnRoot = .text:0x80090870; // type:function size:0x168 scope:global CopyToG3D_View__Q23EGG12LightManagerCFPQ34nw4r3g3d7ScnRootRCQ34nw4r4math5MTX34 = .text:0x800909D8; // type:function size:0x94 scope:global GetBinaryType__Q23EGG12LightManagerCFv = .text:0x80090A6C; // type:function size:0x10 scope:global @@ -7775,7 +7775,7 @@ fn_801A9738 = .text:0x801A9738; // type:function size:0x40 fn_801A9778 = .text:0x801A9778; // type:function size:0x40 fn_801A97B8 = .text:0x801A97B8; // type:function size:0x14 fn_801A97CC = .text:0x801A97CC; // type:function size:0x14 -fn_801A97E0 = .text:0x801A97E0; // type:function size:0x80 +LoadScnLight__17RPGrpLightManagerFUsPCcfUl = .text:0x801A97E0; // type:function size:0x80 RemoveGenList__10RPGrpModelFv = .text:0x801A9860; // type:function size:0x44 ReplaceTexture__10RPGrpModelFPCcRC12RPGrpTextureb = .text:0x801A98A4; // type:function size:0x94 SetReverseCulling__10RPGrpModelFb = .text:0x801A9938; // type:function size:0xC4 diff --git a/configure.py b/configure.py index 6614caf6..63887ea4 100755 --- a/configure.py +++ b/configure.py @@ -1234,7 +1234,7 @@ def MatchingFor(*versions): "objects": [ Object(NonMatching, "Pack/RPGraphics/RPGrpCamera.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathManager.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpLightManager.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpLightManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpModel.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnm.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnmImplement.cpp"), diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index 37c44590..750b2e62 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpLightManager.h b/include/Pack/RPGraphics/RPGrpLightManager.h new file mode 100644 index 00000000..38e2e46c --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpLightManager.h @@ -0,0 +1,46 @@ +#ifndef RP_GRAPHICS_LIGHT_MANAGER_H +#define RP_GRAPHICS_LIGHT_MANAGER_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +/** + * @brief Light manager + */ +class RPGrpLightManager : public EGG::LightManager { +public: + /** + * @brief Constructor + * + * @param viewNum Maximum number of renderer views + */ + RPGrpLightManager(u8 viewNum) + : EGG::LightManager(LIGHT_NUM, AMBIENT_NUM, viewNum) {} + + /** + * @brief Applies light settings from the specified scene resource + * + * @param handle File resource handle + * @param pName Scene file name + * @param frame Animation frame (defaults to the first frame) + * @param lightSetRef Light set reference number (defaults to index 0) + */ + void LoadScnLight(RPGrpHandle handle, const char* pName, f32 frame = 0.0f, + u32 lightSetRef = -1); + +private: + //! Maximum number of light objects + static const int LIGHT_NUM = 16; + + //! Maximum number of ambient light objects + static const int AMBIENT_NUM = 8; +}; + +//! @} + +#endif diff --git a/include/egg/gfxe/eggLightManager.h b/include/egg/gfxe/eggLightManager.h index 0766d679..21aef07c 100644 --- a/include/egg/gfxe/eggLightManager.h +++ b/include/egg/gfxe/eggLightManager.h @@ -3,7 +3,6 @@ #include #include - #include #include @@ -15,7 +14,7 @@ class LightManager : IBinary { struct Bin : IBinary::Bin {}; public: - LightManager(u32, u32, u8); + LightManager(u32 lightNum, u32 ambientNum, u8 viewNum); virtual void SetBinaryInner(const IBinary::Bin&); // at 0x8 virtual void GetBinaryInner(IBinary::Bin*) const; // at 0xC virtual const char* GetBinaryType() const; // at 0x10 @@ -29,6 +28,8 @@ class LightManager : IBinary { void DoneDraw(); + void LoadScnLightInner(nw4r::g3d::ResAnmScn, f32, u32); + LightObj* GetLightObj(u16 index) const { #line 157 EGG_ASSERT(index < GetNum()); diff --git a/src/Pack/RPGraphics/RPGrpLightManager.cpp b/src/Pack/RPGraphics/RPGrpLightManager.cpp new file mode 100644 index 00000000..1a4da12a --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpLightManager.cpp @@ -0,0 +1,19 @@ +#include + +/** + * @brief Applies light settings from the specified scene resource + * + * @param handle File resource handle + * @param pName Scene file name + * @param frame Animation frame (defaults to the first frame) + * @param lightSetRef Light set reference number (defaults to index 0) + */ +void RPGrpLightManager::LoadScnLight(RPGrpHandle handle, const char* pName, + f32 frame, u32 lightSetRef) { + + const nw4r::g3d::ResAnmScn scn = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + LoadScnLightInner(scn, frame, lightSetRef); +} From f2419d66efd5874cffd0cc5209f92449314a5b3e Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:30:15 -0400 Subject: [PATCH 03/14] Move eggBitFlag to prim --- include/egg/core.h | 2 -- include/egg/core/eggColorFader.h | 2 +- include/egg/core/eggDisplay.h | 2 +- include/egg/core/eggHeap.h | 2 +- include/egg/core/eggProcessMeter.h | 2 -- include/egg/core/eggStream.h | 2 +- include/egg/core/eggVideo.h | 2 +- include/egg/prim.h | 1 + include/egg/{core => prim}/eggBitFlag.h | 4 ++-- 9 files changed, 8 insertions(+), 11 deletions(-) rename include/egg/{core => prim}/eggBitFlag.h (97%) diff --git a/include/egg/core.h b/include/egg/core.h index 23bb288e..22d4b787 100644 --- a/include/egg/core.h +++ b/include/egg/core.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -35,5 +34,4 @@ #include #include - #endif diff --git a/include/egg/core/eggColorFader.h b/include/egg/core/eggColorFader.h index 8d031ef6..2cb917d5 100644 --- a/include/egg/core/eggColorFader.h +++ b/include/egg/core/eggColorFader.h @@ -2,8 +2,8 @@ #define EGG_CORE_COLOR_FADER_H #include -#include #include +#include #include diff --git a/include/egg/core/eggDisplay.h b/include/egg/core/eggDisplay.h index 75e761e4..b5c6e325 100644 --- a/include/egg/core/eggDisplay.h +++ b/include/egg/core/eggDisplay.h @@ -2,9 +2,9 @@ #define EGG_CORE_DISPLAY_H #include -#include #include #include +#include #include diff --git a/include/egg/core/eggHeap.h b/include/egg/core/eggHeap.h index f436f234..5a85df27 100644 --- a/include/egg/core/eggHeap.h +++ b/include/egg/core/eggHeap.h @@ -2,8 +2,8 @@ #define EGG_CORE_HEAP_H #include -#include #include +#include #include diff --git a/include/egg/core/eggProcessMeter.h b/include/egg/core/eggProcessMeter.h index 7847893e..8a4ffc04 100644 --- a/include/egg/core/eggProcessMeter.h +++ b/include/egg/core/eggProcessMeter.h @@ -2,12 +2,10 @@ #define EGG_CORE_PROCESS_METER_H #include -#include #include #include #include #include - #include #include diff --git a/include/egg/core/eggStream.h b/include/egg/core/eggStream.h index 51250e77..eb324b44 100644 --- a/include/egg/core/eggStream.h +++ b/include/egg/core/eggStream.h @@ -2,7 +2,7 @@ #define EGG_CORE_STREAM_H #include -#include +#include namespace EGG { diff --git a/include/egg/core/eggVideo.h b/include/egg/core/eggVideo.h index afe9fb7d..1f7ace50 100644 --- a/include/egg/core/eggVideo.h +++ b/include/egg/core/eggVideo.h @@ -2,7 +2,7 @@ #define EGG_CORE_VIDEO_H #include -#include +#include #include #include diff --git a/include/egg/prim.h b/include/egg/prim.h index 8c749dc3..5e46997c 100644 --- a/include/egg/prim.h +++ b/include/egg/prim.h @@ -2,6 +2,7 @@ #define EGG_PUBLIC_PRIM_H #include +#include #include #include diff --git a/include/egg/core/eggBitFlag.h b/include/egg/prim/eggBitFlag.h similarity index 97% rename from include/egg/core/eggBitFlag.h rename to include/egg/prim/eggBitFlag.h index b3c9d6b9..5cc0d952 100644 --- a/include/egg/core/eggBitFlag.h +++ b/include/egg/prim/eggBitFlag.h @@ -1,5 +1,5 @@ -#ifndef EGG_CORE_BIT_FLAG_H -#define EGG_CORE_BIT_FLAG_H +#ifndef EGG_PRIM_BIT_FLAG_H +#define EGG_PRIM_BIT_FLAG_H #include namespace EGG { From e324d9154b9c1971328d882faa34599389419fed Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 17:56:38 -0400 Subject: [PATCH 04/14] RPGrpModelMisc matching --- config/RSPE01_01/symbols.txt | 16 +-- include/Pack/RPGraphics.h | 1 + include/Pack/RPGraphics/RPGrpLightManager.h | 2 +- include/Pack/RPGraphics/RPGrpModelMisc.h | 69 ++++++++++++ include/egg/core/eggIBinary.h | 117 +++++++++++--------- include/egg/gfxe/eggDrawPathBloom.h | 6 +- include/egg/gfxe/eggLightManager.h | 2 +- include/egg/gfxe/eggLightObject.h | 4 +- include/egg/gfxe/eggLightTexture.h | 10 +- include/egg/gfxe/eggLightTextureManager.h | 2 +- src/Pack/RPGraphics/RPGrpModelMisc.cpp | 15 +++ src/egg/gfxe/eggLightTextureManager.cpp | 2 +- 12 files changed, 170 insertions(+), 76 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpModelMisc.h create mode 100644 src/Pack/RPGraphics/RPGrpModelMisc.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index b3d09c71..b555c3fb 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -7905,7 +7905,7 @@ __dt__13RPGrpModelG3DFv = .text:0x801ADDC8; // type:function size:0x58 @76@ExecCallbackB__13RPGrpModelG3DFPQ34nw4r3g3d13WorldMtxManipQ34nw4r3g3d6ResMdlPQ34nw4r3g3d16FuncObjCalcWorld = .text:0x801ADE58; // type:function size:0x8 @76@ExecCallbackA__13RPGrpModelG3DFPQ34nw4r3g3d12ChrAnmResultQ34nw4r3g3d6ResMdlPQ34nw4r3g3d16FuncObjCalcWorld = .text:0x801ADE60; // type:function size:0x8 @76@__dt__13RPGrpModelG3DFv = .text:0x801ADE68; // type:function size:0x8 -fn_801ADE70 = .text:0x801ADE70; // type:function size:0x10 +GetBinaryType__14RPGrpModelMiscCFv = .text:0x801ADE70; // type:function size:0x10 fn_801ADE80 = .text:0x801ADE80; // type:function size:0x10 fn_801ADE90 = .text:0x801ADE90; // type:function size:0x10 fn_801ADEA0 = .text:0x801ADEA0; // type:function size:0x10 @@ -7919,11 +7919,11 @@ fn_801AE160 = .text:0x801AE160; // type:function size:0x54 fn_801AE1B4 = .text:0x801AE1B4; // type:function size:0x68 fn_801AE21C = .text:0x801AE21C; // type:function size:0x34 fn_801AE250 = .text:0x801AE250; // type:function size:0xAC -fn_801AE2FC = .text:0x801AE2FC; // type:function size:0x8 -fn_801AE304 = .text:0x801AE304; // type:function size:0x40 -fn_801AE344 = .text:0x801AE344; // type:function size:0x4 -fn_801AE348 = .text:0x801AE348; // type:function size:0x4 -fn_801AE34C = .text:0x801AE34C; // type:function size:0x8 +GetVersion__14RPGrpModelMiscCFv = .text:0x801AE2FC; // type:function size:0x8 +__dt__14RPGrpModelMisc = .text:0x801AE304; // type:function size:0x40 +SetBinaryInner__14RPGrpModelMiscFRCQ33EGG25IBinary<14RPGrpModelMisc>3Bin = .text:0x801AE344; // type:function size:0x4 +GetBinaryInner__14RPGrpModelMiscCFPQ33EGG25IBinary<14RPGrpModelMisc>3Bin = .text:0x801AE348; // type:function size:0x4 +GetBinarySize__Q23EGG25IBinary<14RPGrpModelMisc>CFv = .text:0x801AE34C; // type:function size:0x8 fn_801AE354 = .text:0x801AE354; // type:function size:0x40 InternalGetResultTransform__20RPGrpModelResManagerFQ34nw4r3g3d9ResAnmChrUsfPQ23EGG9Matrix34fPQ23EGG8Vector3fPQ23EGG8Vector3fPQ23EGG8Vector3f = .text:0x801AE394; // type:function size:0xA8 GetResultTransform__20RPGrpModelResManagerFUsUsfPQ23EGG9Matrix34fPQ23EGG8Vector3fPQ23EGG8Vector3fPQ23EGG8Vector3f = .text:0x801AE43C; // type:function size:0xD0 @@ -11996,7 +11996,7 @@ fn_80285634 = .text:0x80285634; // type:function size:0x44 fn_80285678 = .text:0x80285678; // type:function size:0x34 fn_802856AC = .text:0x802856AC; // type:function size:0x30 fn_802856DC = .text:0x802856DC; // type:function size:0x30 -fn_8028570C = .text:0x8028570C; // type:function size:0x12C +SetBinary__Q23EGG25IBinary<14RPGrpModelMisc>FPCv = .text:0x8028570C; // type:function size:0x12C fn_80285838 = .text:0x80285838; // type:function size:0x8 fn_80285840 = .text:0x80285840; // type:function size:0x8 fn_80285848 = .text:0x80285848; // type:function size:0x8 @@ -18656,7 +18656,7 @@ jumptable_803BA2B0 = .data:0x803BA2B0; // type:object size:0x20 scope:local jumptable_803BA2D0 = .data:0x803BA2D0; // type:object size:0x20 scope:local lbl_803BA2F0 = .data:0x803BA2F0; // type:object size:0xF8 lbl_803BA3E8 = .data:0x803BA3E8; // type:object size:0x10 -lbl_803BA3F8 = .data:0x803BA3F8; // type:object size:0x20 +__vt__14RPGrpModelMisc = .data:0x803BA3F8; // type:object size:0x20 scope:weak jumptable_803BA418 = .data:0x803BA418; // type:object size:0x28 scope:local jumptable_803BA440 = .data:0x803BA440; // type:object size:0x30 scope:local jumptable_803BA470 = .data:0x803BA470; // type:object size:0x28 scope:local diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index 750b2e62..ecb1ae56 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpLightManager.h b/include/Pack/RPGraphics/RPGrpLightManager.h index 38e2e46c..bedf6d4e 100644 --- a/include/Pack/RPGraphics/RPGrpLightManager.h +++ b/include/Pack/RPGraphics/RPGrpLightManager.h @@ -19,7 +19,7 @@ class RPGrpLightManager : public EGG::LightManager { * * @param viewNum Maximum number of renderer views */ - RPGrpLightManager(u8 viewNum) + explicit RPGrpLightManager(u8 viewNum) : EGG::LightManager(LIGHT_NUM, AMBIENT_NUM, viewNum) {} /** diff --git a/include/Pack/RPGraphics/RPGrpModelMisc.h b/include/Pack/RPGraphics/RPGrpModelMisc.h new file mode 100644 index 00000000..646ea1f4 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpModelMisc.h @@ -0,0 +1,69 @@ +#ifndef RP_GRAPHICS_MODEL_MISC_H +#define RP_GRAPHICS_MODEL_MISC_H +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +/** + * @brief Model material miscellaneous settings + */ +class RPGrpModelMisc : public EGG::IBinary { +public: + /** + * @brief Material target + */ + struct MatTarget { + char name[32]; // at 0x0 + bool unk20; // at 0x20 + f32 unk24; // at 0x24 + }; + + /** + * @brief Main binary file structure + */ + struct BinData { + u16 targetNum; // at 0x10 + MatTarget targets[]; // at 0x14 + }; + + /** + * @brief Deserializes this object from a binary file + * + * @param rBinary Binary file contents + */ + virtual void SetBinaryInner(const Bin& /* rBinary */) override { // at 0x8 + // Stubbed out in revision 1 + } + + /** + * @brief Serializes this object to a binary file + * + * @param[out] pBinary Binary file contents + */ + virtual void GetBinaryInner(Bin* /* pBinary */) const override { // at 0xC + // Stubbed out in revision 1 + } + + /** + * @brief Gets the binary signature of this object + */ + virtual const char* GetBinaryType() const override; + + /** + * @brief Gets the binary version of this object + */ + virtual u8 GetVersion() const override { + return VERSION; + } + +private: + //! Version of this file's specification + static const u8 VERSION = 0; +}; + +//! @} + +#endif diff --git a/include/egg/core/eggIBinary.h b/include/egg/core/eggIBinary.h index d06a9a0f..484ca5cc 100644 --- a/include/egg/core/eggIBinary.h +++ b/include/egg/core/eggIBinary.h @@ -1,65 +1,74 @@ #ifndef EGG_CORE_IBINARY_H #define EGG_CORE_IBINARY_H -#include "types_egg.h" -#include "eggAssert.h" - -namespace EGG -{ - template - class IBinary - { - public: - struct Bin - { - char magic[4]; // at 0x0 - u32 size; // at 0x4 - u8 UNK_0x5[0x8 - 0x5]; - u8 version; // at 0x8 - u8 UNK_0x09[0x10 - 0x9]; - }; - - virtual void SetBinaryInner(const Bin&) = 0; // at 0x8 - virtual void GetBinaryInner(Bin *) const = 0; // at 0xC - virtual const char * GetBinaryType() const = 0; // at 0x10 - virtual u32 GetBinarySize() const { return sizeof(T::Bin); }; // at 0x14 - virtual u8 GetVersion() const = 0; // at 0x18 - - void SetBinary(const void *bin) - { - #line 93 - EGG_ASSERT(bin); - Bin *binary = (Bin *)bin; - - EGG_ASSERT_MSG(GetBinaryType()[0] == binary->magic[0] - && GetBinaryType()[1] == binary->magic[1] - && GetBinaryType()[2] == binary->magic[2] - && GetBinaryType()[3] == binary->magic[3], +#include + +#include + +namespace EGG { + +template class IBinary { +public: +#pragma pack(push, 1) + struct BinHeader { + char magic[4]; // at 0x0 + u32 size; // at 0x4 + u8 version; // at 0x8 + u8 unk9[0x10 - 0x9]; + }; + + struct Bin { + BinHeader header; + typename T::BinData data; + }; +#pragma pack(pop) + + virtual void SetBinaryInner(const Bin& rBinary) = 0; // at 0x8 + virtual void GetBinaryInner(Bin* pBinary) const = 0; // at 0xC + + virtual const char* GetBinaryType() const = 0; // at 0x10 + virtual u32 GetBinarySize() const { + return sizeof(T::Bin); + }; // at 0x14 + + virtual u8 GetVersion() const = 0; // at 0x18 + + void SetBinary(const void* bin) { +#line 93 + EGG_ASSERT(bin); + Bin* pBinary = (Bin*)bin; + + EGG_ASSERT_MSG(GetBinaryType()[0] == pBinary->magic[0] + && GetBinaryType()[1] == pBinary->magic[1] + && GetBinaryType()[2] == pBinary->magic[2] + && GetBinaryType()[3] == pBinary->magic[3], "Not for this class."); - SetBinaryInner(*bin); - } + SetBinaryInner(*pBinary); + } - void GetBinary(void *bin) const - { - #line 105 - EGG_ASSERT(bin); - Bin *binary = (Bin *)bin; + void GetBinary(void* bin) const { +#line 105 + EGG_ASSERT(bin); + Bin* pBinary = (Bin*)bin; - binary->version = GetVersion(); - binary->size = GetBinarySize(); - for (int i = 0; i < sizeof(Bin::magic); i++) - { - binary->magic[i] = GetBinaryType()[i]; - } + pBinary->version = GetVersion(); + pBinary->size = GetBinarySize(); - GetBinaryInner(binary); + for (int i = 0; i < sizeof(Bin::magic); i++) { + pBinary->magic[i] = GetBinaryType()[i]; } - static void SetBinaryExtension(const char *ext) { sExtension = ext; } + GetBinaryInner(pBinary); + } - private: - static const char *sExtension; - }; -} + static void SetBinaryExtension(const char* pExtension) { + spExtension = pExtension; + } + +private: + static const char* spExtension; +}; + +} // namespace EGG -#endif \ No newline at end of file +#endif diff --git a/include/egg/gfxe/eggDrawPathBloom.h b/include/egg/gfxe/eggDrawPathBloom.h index d5d8c0c9..c8a008c1 100644 --- a/include/egg/gfxe/eggDrawPathBloom.h +++ b/include/egg/gfxe/eggDrawPathBloom.h @@ -2,13 +2,15 @@ #define EGG_GFXE_DRAW_PATH_BLOOM_H #include -#include - #include +#include namespace EGG { class DrawPathBloom : public DrawPathBase, public IBinary { +public: + struct BinData {}; + public: DrawPathBloom(); virtual ~DrawPathBloom(); // at 0x8 diff --git a/include/egg/gfxe/eggLightManager.h b/include/egg/gfxe/eggLightManager.h index 21aef07c..07d3c08a 100644 --- a/include/egg/gfxe/eggLightManager.h +++ b/include/egg/gfxe/eggLightManager.h @@ -11,7 +11,7 @@ namespace EGG { class LightManager : IBinary { public: - struct Bin : IBinary::Bin {}; + struct BinData {}; public: LightManager(u32 lightNum, u32 ambientNum, u8 viewNum); diff --git a/include/egg/gfxe/eggLightObject.h b/include/egg/gfxe/eggLightObject.h index 1bb424d1..fbdcec65 100644 --- a/include/egg/gfxe/eggLightObject.h +++ b/include/egg/gfxe/eggLightObject.h @@ -3,17 +3,15 @@ #include #include - #include #include - namespace EGG { class LightObj : IBinary { public: - struct Bin : IBinary::Bin { + struct BinData { u8 spotFn; // at 0x10 u8 distAttnFn; // at 0x11 u8 BYTE_0x12; diff --git a/include/egg/gfxe/eggLightTexture.h b/include/egg/gfxe/eggLightTexture.h index 5185ce2d..38bac039 100644 --- a/include/egg/gfxe/eggLightTexture.h +++ b/include/egg/gfxe/eggLightTexture.h @@ -8,7 +8,7 @@ namespace EGG { class LightTexture : public CapTexture, public IBinary { public: - struct Bin : IBinary::Bin {}; + struct BinData {}; public: static void initialize(u16, Heap*); @@ -16,10 +16,10 @@ class LightTexture : public CapTexture, public IBinary { static void getDrawSetting(u16*, u16*, u16*, u16*, u16); LightTexture(u16, const char*, LightTextureManager*); - virtual void SetBinaryInner(const IBinary::Bin&); // at 0x8 - virtual void GetBinaryInner(IBinary::Bin*) const; // at 0xC - virtual const char* GetBinaryType() const; // at 0x10 - virtual u8 GetVersion() const; // at 0x18 + virtual void SetBinaryInner(const Bin&); // at 0x8 + virtual void GetBinaryInner(Bin*) const; // at 0xC + virtual const char* GetBinaryType() const; // at 0x10 + virtual u8 GetVersion() const; // at 0x18 void draw(); void capture(const GXColor&, bool); diff --git a/include/egg/gfxe/eggLightTextureManager.h b/include/egg/gfxe/eggLightTextureManager.h index b975e9dc..eb24b1c7 100644 --- a/include/egg/gfxe/eggLightTextureManager.h +++ b/include/egg/gfxe/eggLightTextureManager.h @@ -13,7 +13,7 @@ class LightObj; class LightTextureManager : IBinary { public: - struct Bin : IBinary::Bin { + struct BinData { char unk10[0x20 - 0x10]; }; diff --git a/src/Pack/RPGraphics/RPGrpModelMisc.cpp b/src/Pack/RPGraphics/RPGrpModelMisc.cpp new file mode 100644 index 00000000..5eb82f71 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpModelMisc.cpp @@ -0,0 +1,15 @@ +#include + +#include + +/** + * @brief File extension for RPGrpModelMisc binaries + */ +template <> const char* EGG::IBinary::spExtension = "pmmisc"; + +/** + * @brief Gets the binary signature of this object + */ +const char* RPGrpModelMisc::GetBinaryType() const override { + return "MMSC"; +} diff --git a/src/egg/gfxe/eggLightTextureManager.cpp b/src/egg/gfxe/eggLightTextureManager.cpp index bcf72568..6c71346c 100644 --- a/src/egg/gfxe/eggLightTextureManager.cpp +++ b/src/egg/gfxe/eggLightTextureManager.cpp @@ -10,7 +10,7 @@ namespace EGG { -template <> const char* IBinary::sExtension = "blmap"; +template <> const char* IBinary::spExtension = "blmap"; using namespace nw4r; LightTextureManager::LightTextureManager(LightManager* pManager) From c07366675b328af735aecf8277bbfe764dde133c Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 18:03:03 -0400 Subject: [PATCH 05/14] RPGrpModelBoundingInfo OK --- config/RSPE01_01/symbols.txt | 4 ++-- configure.py | 2 +- include/Pack/RPGraphics/RPGrpModel.h | 4 ++++ include/Pack/RPGraphics/RPGrpModelBoundingInfo.h | 5 ----- src/Pack/RPGraphics/RPGrpModelBoundingInfo.cpp | 10 ++++++++++ 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/Pack/RPGraphics/RPGrpModelBoundingInfo.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index b555c3fb..cc113c71 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -8030,7 +8030,7 @@ fn_801B25C0 = .text:0x801B25C0; // type:function size:0x14 fn_801B25D4 = .text:0x801B25D4; // type:function size:0x14 fn_801B25E8 = .text:0x801B25E8; // type:function size:0x10 __ct__22RPGrpModelBoundingInfoFUlP10RPGrpModel = .text:0x801B25F8; // type:function size:0x40 -fn_801B2638 = .text:0x801B2638; // type:function size:0x58 +__dt__22RPGrpModelBoundingInfoFv = .text:0x801B2638; // type:function size:0x58 fn_801B2690 = .text:0x801B2690; // type:function size:0x8 fn_801B2698 = .text:0x801B2698; // type:function size:0x8 fn_801B26A0 = .text:0x801B26A0; // type:function size:0x24 @@ -18687,7 +18687,7 @@ lbl_803BA698 = .data:0x803BA698; // type:object size:0x28 lbl_803BA6C0 = .data:0x803BA6C0; // type:object size:0x18 lbl_803BA6D8 = .data:0x803BA6D8; // type:object size:0x10 data:string lbl_803BA6E8 = .data:0x803BA6E8; // type:object size:0x19 data:string -lbl_803BA708 = .data:0x803BA708; // type:object size:0x10 +__vt__22RPGrpModelBoundingInfo = .data:0x803BA708; // type:object size:0x10 lbl_803BA718 = .data:0x803BA718; // type:object size:0x18 lbl_803BA730 = .data:0x803BA730; // type:object size:0x10 lbl_803BA740 = .data:0x803BA740; // type:object size:0x10 diff --git a/configure.py b/configure.py index 63887ea4..43352ecc 100755 --- a/configure.py +++ b/configure.py @@ -1249,7 +1249,7 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPGraphics/RPGrpViewRender3D.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelScene.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathLightMap.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpModelBoundingInfo.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpModelBoundingInfo.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelMaterial.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelRecord.cpp"), diff --git a/include/Pack/RPGraphics/RPGrpModel.h b/include/Pack/RPGraphics/RPGrpModel.h index 5420c166..a7200df7 100644 --- a/include/Pack/RPGraphics/RPGrpModel.h +++ b/include/Pack/RPGraphics/RPGrpModel.h @@ -190,6 +190,10 @@ class RPGrpModel { void Calc(); void Entry(); + EGG::ModelEx* GetModelEx() const { + return mpModelEx; + } + nw4r::g3d::ScnObj* GetScnObj() const { return mpModelEx->getScnObj(); } diff --git a/include/Pack/RPGraphics/RPGrpModelBoundingInfo.h b/include/Pack/RPGraphics/RPGrpModelBoundingInfo.h index a64ff0fa..e414bc96 100644 --- a/include/Pack/RPGraphics/RPGrpModelBoundingInfo.h +++ b/include/Pack/RPGraphics/RPGrpModelBoundingInfo.h @@ -22,11 +22,6 @@ class RPGrpModelBoundingInfo : public EGG::ModelBoundingInfo { * @param pModel Owner model */ RPGrpModelBoundingInfo(u32 flags, RPGrpModel* pModel); - - /** - * @brief Destructor - */ - virtual ~RPGrpModelBoundingInfo() {} // at 0x8 }; //! @} diff --git a/src/Pack/RPGraphics/RPGrpModelBoundingInfo.cpp b/src/Pack/RPGraphics/RPGrpModelBoundingInfo.cpp new file mode 100644 index 00000000..03546511 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpModelBoundingInfo.cpp @@ -0,0 +1,10 @@ +#include + +/** + * @brief Constructor + * + * @param flags Bound type flags + * @param pModel Owner model + */ +RPGrpModelBoundingInfo::RPGrpModelBoundingInfo(u32 flags, RPGrpModel* pModel) + : EGG::ModelBoundingInfo(flags, pModel->GetModelEx()) {} From dcce348674754d4a557df19ee9e0e27d1cd0a40d Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 18:30:57 -0400 Subject: [PATCH 06/14] RPGrpTexture WIP --- config/RSPE01_01/symbols.txt | 4 +- include/Pack/RPGraphics.h | 1 + include/Pack/RPGraphics/RPGrpCaptureTexture.h | 56 +++++++++++++++++++ .../Pack/RPGraphics/RPGrpModelResManager.h | 10 ++-- include/Pack/RPGraphics/RPGrpTexture.h | 47 ++++++++++++---- src/Pack/RPGraphics/RPGrpLightManager.cpp | 2 + src/Pack/RPGraphics/RPGrpTexture.cpp | 43 ++++++++++++-- 7 files changed, 140 insertions(+), 23 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpCaptureTexture.h diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index cc113c71..fc8b828b 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -8062,9 +8062,9 @@ fn_801B4AE0 = .text:0x801B4AE0; // type:function size:0x4 fn_801B4AE4 = .text:0x801B4AE4; // type:function size:0x40 fn_801B4B24 = .text:0x801B4B24; // type:function size:0x40 __ct__12RPGrpTextureFUsPCc = .text:0x801B4B64; // type:function size:0x80 -fn_801B4BE4 = .text:0x801B4BE4; // type:function size:0x50 +__ct__12RPGrpTextureFPC19RPGrpCaptureTexture = .text:0x801B4BE4; // type:function size:0x50 __ct__12RPGrpTextureFPCQ23EGG7ResTIMG = .text:0x801B4C34; // type:function size:0x3C -fn_801B4C70 = .text:0x801B4C70; // type:function size:0x50 +__ct__12RPGrpTextureFPCQ23EGG10CpuTexture = .text:0x801B4C70; // type:function size:0x50 fn_801B4CC0 = .text:0x801B4CC0; // type:function size:0x10C fn_801B4DCC = .text:0x801B4DCC; // type:function size:0x11C fn_801B4EE8 = .text:0x801B4EE8; // type:function size:0x40 diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index ecb1ae56..bb74aa00 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -2,6 +2,7 @@ #define RP_PUBLIC_GRAPHICS_H #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpCaptureTexture.h b/include/Pack/RPGraphics/RPGrpCaptureTexture.h new file mode 100644 index 00000000..367d8ee3 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpCaptureTexture.h @@ -0,0 +1,56 @@ +#ifndef RP_GRAPHICS_CAPTURE_TEXTURE_H +#define RP_GRAPHICS_CAPTURE_TEXTURE_H +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +// Forward declarations +class RPGrpScreen; + +/** + * @brief Screen capture texture wrapper + */ +class RPGrpCaptureTexture { +public: + enum { + EFlag_MipMap = 1 << 0, + }; + +private: + //! State flags + u16 mFlags; // at 0x0 + //! Capture setting flags + u16 mCapFlags; // at 0x2 + + //! Capture texture implementation + EGG::CapTexture* mpCapTexture; // at 0x4 + +public: + /** + * @brief Constructor + * + * @param pScreen Capture source + * @param format Texture format + * @param flags Creation flags + */ + RPGrpCaptureTexture(RPGrpScreen* pScreen, int format, u32 flags); + + /** + * @brief Destructor + */ + virtual ~RPGrpCaptureTexture() {} + + /** + * @brief Accesses the underlying capture texture + */ + EGG::CapTexture* GetCapTexture() const { + return mpCapTexture; + } +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpModelResManager.h b/include/Pack/RPGraphics/RPGrpModelResManager.h index a5ad62eb..43d47f31 100644 --- a/include/Pack/RPGraphics/RPGrpModelResManager.h +++ b/include/Pack/RPGraphics/RPGrpModelResManager.h @@ -349,9 +349,11 @@ struct RPGrpModelResManager::ResType { TResData* pResData; // at 0x0 ResType() : pResData(NULL) {} - ResType(void* pResData_) : pResData(static_cast(pResData_)) {} - TRes Get() const { + explicit ResType(void* pResData_) + : pResData(static_cast(pResData_)) {} + + const TRes Get() const { return TRes(pResData); } }; @@ -430,7 +432,7 @@ SUBFILE_NAME_LIST; RPGrpModelResManager::GetData( \ RPGrpHandle handle, int index) const { \ \ - return mpResList[handle].pResFile->Get().Get##Y(index); \ + return GetData(handle).Get##Y(index); \ } SUBFILE_NAME_LIST; @@ -442,7 +444,7 @@ SUBFILE_NAME_LIST; RPGrpModelResManager::GetData( \ RPGrpHandle handle, const char* pName) const { \ \ - return mpResList[handle].pResFile->Get().Get##Y(pName); \ + return GetData(handle).Get##Y(pName); \ } SUBFILE_NAME_LIST; diff --git a/include/Pack/RPGraphics/RPGrpTexture.h b/include/Pack/RPGraphics/RPGrpTexture.h index f530c079..596ec842 100644 --- a/include/Pack/RPGraphics/RPGrpTexture.h +++ b/include/Pack/RPGraphics/RPGrpTexture.h @@ -1,42 +1,67 @@ -#ifndef RP_GRAPHICS_MODEL_TEXTURE_H -#define RP_GRAPHICS_MODEL_TEXTURE_H +#ifndef RP_GRAPHICS_TEXTURE_H +#define RP_GRAPHICS_TEXTURE_H #include #include +#include + #include //! @addtogroup rp_graphics //! @{ +// Forward declarations +class RPGrpCaptureTexture; + /** - * @brief Texture utility + * @brief GPU texture wrapper */ class RPGrpTexture { private: - GXTexObj mGXTexObj; // at 0x0 + //! GX texture object + GXTexObj mTexObj; // at 0x0 public: /** - * @brief Constructor that uses a texture image resource. + * @brief Constructor + * + * @param pCpuTexture CPU texture + */ + RPGrpTexture(const EGG::CpuTexture* pCpuTexture); + + /** + * @brief Constructor + * + * @param pResTIMG Texture image resource + */ + RPGrpTexture(const EGG::ResTIMG* pResTIMG); + + /** + * @brief Constructor * - * @param pRes Texture image resource + * @param pCapTexture Capture texture */ - RPGrpTexture(const EGG::ResTIMG* pRes); + RPGrpTexture(const RPGrpCaptureTexture* pCapTexture); /** - * @brief Constructor that uses a texture resource from a resource file - * handle. + * @brief Constructor * * @param handle Resource file handle - * @param pName File name. + * @param pName Texture name */ RPGrpTexture(RPGrpHandle handle, const char* pName); + /** + * @brief Destructor + */ virtual ~RPGrpTexture() {} + /** + * @brief Accesses the underlying GX texture object + */ const GXTexObj& GetTexObj() const { - return mGXTexObj; + return mTexObj; } }; diff --git a/src/Pack/RPGraphics/RPGrpLightManager.cpp b/src/Pack/RPGraphics/RPGrpLightManager.cpp index 1a4da12a..166d2e6a 100644 --- a/src/Pack/RPGraphics/RPGrpLightManager.cpp +++ b/src/Pack/RPGraphics/RPGrpLightManager.cpp @@ -1,5 +1,7 @@ #include +#include + /** * @brief Applies light settings from the specified scene resource * diff --git a/src/Pack/RPGraphics/RPGrpTexture.cpp b/src/Pack/RPGraphics/RPGrpTexture.cpp index 094872f8..f2305b7d 100644 --- a/src/Pack/RPGraphics/RPGrpTexture.cpp +++ b/src/Pack/RPGraphics/RPGrpTexture.cpp @@ -2,15 +2,46 @@ #include -RPGrpTexture::RPGrpTexture(const EGG::ResTIMG* pRes) { - EGG::GXUtility::getTexObj(&mGXTexObj, *pRes); +#include + +/** + * @brief Constructor + * + * @param pCpuTexture CPU texture + */ +RPGrpTexture::RPGrpTexture(const EGG::CpuTexture* pCpuTexture) { + pCpuTexture->getTexObj(&mTexObj); +} + +/** + * @brief Constructor + * + * @param pResTIMG Texture image resource + */ +RPGrpTexture::RPGrpTexture(const EGG::ResTIMG* pResTIMG) { + EGG::GXUtility::getTexObj(&mTexObj, *pResTIMG); +} + +/** + * @brief Constructor + * + * @param pCapTexture Capture texture + */ +RPGrpTexture::RPGrpTexture(const RPGrpCaptureTexture* pCapTexture) { + pCapTexture->GetCapTexture()->getTexObj(&mTexObj); } +/** + * @brief Constructor + * + * @param handle Resource file handle + * @param pName Texture name + */ RPGrpTexture::RPGrpTexture(RPGrpHandle handle, const char* pName) { - nw4r::g3d::ResFile file = + const nw4r::g3d::ResTex tex = RPGrpModelResManager::GetCurrent() - ->GetData(handle); + ->GetData(handle, pName); - EGG::GXUtility::getTexObj(&mGXTexObj, file.GetResTex(pName), GX_CLAMP, - GX_CLAMP, GX_LINEAR, GX_LINEAR); + EGG::GXUtility::getTexObj(&mTexObj, tex, GX_CLAMP, GX_CLAMP, GX_LINEAR, + GX_LINEAR); } From 6ed1504093447beec511315b70dbe82688364493 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 19:20:16 -0400 Subject: [PATCH 07/14] RPGrpCaptureTexture OK --- config/RSPE01_01/symbols.txt | 8 +-- configure.py | 2 +- include/Pack/RPGraphics/RPGrpCaptureTexture.h | 51 ++++++++++++++-- include/Pack/RPGraphics/RPGrpTexture.h | 6 +- src/Pack/RPGraphics/RPGrpCaptureTexture.cpp | 59 +++++++++++++++++++ 5 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 src/Pack/RPGraphics/RPGrpCaptureTexture.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index fc8b828b..76730a66 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -8065,9 +8065,9 @@ __ct__12RPGrpTextureFUsPCc = .text:0x801B4B64; // type:function size:0x80 __ct__12RPGrpTextureFPC19RPGrpCaptureTexture = .text:0x801B4BE4; // type:function size:0x50 __ct__12RPGrpTextureFPCQ23EGG7ResTIMG = .text:0x801B4C34; // type:function size:0x3C __ct__12RPGrpTextureFPCQ23EGG10CpuTexture = .text:0x801B4C70; // type:function size:0x50 -fn_801B4CC0 = .text:0x801B4CC0; // type:function size:0x10C -fn_801B4DCC = .text:0x801B4DCC; // type:function size:0x11C -fn_801B4EE8 = .text:0x801B4EE8; // type:function size:0x40 +Capture__19RPGrpCaptureTextureFi = .text:0x801B4CC0; // type:function size:0x10C +__ct__19RPGrpCaptureTextureFP11RPGrpScreen9_GXTexFmtUl = .text:0x801B4DCC; // type:function size:0x11C +__dt__19RPGrpCaptureTextureFv = .text:0x801B4EE8; // type:function size:0x40 fn_801B4F28 = .text:0x801B4F28; // type:function size:0x70 fn_801B4F98 = .text:0x801B4F98; // type:function size:0x9C fn_801B5034 = .text:0x801B5034; // type:function size:0x70 @@ -18694,7 +18694,7 @@ lbl_803BA740 = .data:0x803BA740; // type:object size:0x10 lbl_803BA750 = .data:0x803BA750; // type:object size:0x18 lbl_803BA768 = .data:0x803BA768; // type:object size:0x18 __vt__12RPGrpTexture = .data:0x803BA780; // type:object size:0x10 -lbl_803BA790 = .data:0x803BA790; // type:object size:0x10 +__vt__19RPGrpCaptureTexture = .data:0x803BA790; // type:object size:0x10 lbl_803BA7A0 = .data:0x803BA7A0; // type:object size:0x10 lbl_803BA7B0 = .data:0x803BA7B0; // type:object size:0xD0 lbl_803BA880 = .data:0x803BA880; // type:object size:0xC0 diff --git a/configure.py b/configure.py index 43352ecc..1a4a1dd1 100755 --- a/configure.py +++ b/configure.py @@ -1254,7 +1254,7 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPGraphics/RPGrpModelMaterial.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelRecord.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpTexture.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpCaptureTexture.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpCaptureTexture.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpFogManager.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpProjectionObject.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelRfl.cpp"), diff --git a/include/Pack/RPGraphics/RPGrpCaptureTexture.h b/include/Pack/RPGraphics/RPGrpCaptureTexture.h index 367d8ee3..c99bb224 100644 --- a/include/Pack/RPGraphics/RPGrpCaptureTexture.h +++ b/include/Pack/RPGraphics/RPGrpCaptureTexture.h @@ -15,18 +15,24 @@ class RPGrpScreen; */ class RPGrpCaptureTexture { public: + /** + * @brief Flags for use with the constructor + */ enum { + //! Whether to enable the mipmap filter EFlag_MipMap = 1 << 0, }; private: - //! State flags - u16 mFlags; // at 0x0 - //! Capture setting flags - u16 mCapFlags; // at 0x2 + //! EFB setting flags + u16 mEfbFlags; // at 0x0 + //! Texture setting flags + u16 mTexFlags; // at 0x2 //! Capture texture implementation EGG::CapTexture* mpCapTexture; // at 0x4 + //! Capture texture source + RPGrpScreen* mpScreen; // at 0x8 public: /** @@ -36,19 +42,54 @@ class RPGrpCaptureTexture { * @param format Texture format * @param flags Creation flags */ - RPGrpCaptureTexture(RPGrpScreen* pScreen, int format, u32 flags); + RPGrpCaptureTexture(RPGrpScreen* pScreen, GXTexFmt format, u32 flags = 0); /** * @brief Destructor */ virtual ~RPGrpCaptureTexture() {} + /** + * @brief Captures the EFB contents as a texture + * + * @param format Texture format override (optional) + */ + void Capture(int format = -1); + /** * @brief Accesses the underlying capture texture */ EGG::CapTexture* GetCapTexture() const { return mpCapTexture; } + + /** + * @brief Tests whether the mipmap filter is enabled + */ + bool IsMipMapEnable() const { + return (mTexFlags & ETexFlag_MipMap) != 0; + } + +private: + /** + * @brief EFB setting flag + */ + enum EEfbFlag { + //! Whether to clear the EFB color channel when copying the texture + EEfbFlag_ColorUpdate = 1 << 0, + //! Whether to clear the EFB alpha channel when copying the texture + EEfbFlag_AlphaUpdate = 1 << 1, + //! Whether to clear the Z-buffer when copying the texture + EEfbFlag_ZBufferUpdate = 1 << 2, + }; + + /** + * @brief Texture settting flag + */ + enum ETexFlag { + //! Whether to enable the mipmap filter + ETexFlag_MipMap = 1 << 0, + }; }; //! @} diff --git a/include/Pack/RPGraphics/RPGrpTexture.h b/include/Pack/RPGraphics/RPGrpTexture.h index 596ec842..6dbdb313 100644 --- a/include/Pack/RPGraphics/RPGrpTexture.h +++ b/include/Pack/RPGraphics/RPGrpTexture.h @@ -28,21 +28,21 @@ class RPGrpTexture { * * @param pCpuTexture CPU texture */ - RPGrpTexture(const EGG::CpuTexture* pCpuTexture); + explicit RPGrpTexture(const EGG::CpuTexture* pCpuTexture); /** * @brief Constructor * * @param pResTIMG Texture image resource */ - RPGrpTexture(const EGG::ResTIMG* pResTIMG); + explicit RPGrpTexture(const EGG::ResTIMG* pResTIMG); /** * @brief Constructor * * @param pCapTexture Capture texture */ - RPGrpTexture(const RPGrpCaptureTexture* pCapTexture); + explicit RPGrpTexture(const RPGrpCaptureTexture* pCapTexture); /** * @brief Constructor diff --git a/src/Pack/RPGraphics/RPGrpCaptureTexture.cpp b/src/Pack/RPGraphics/RPGrpCaptureTexture.cpp new file mode 100644 index 00000000..e557431a --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpCaptureTexture.cpp @@ -0,0 +1,59 @@ +#include + +#include + +/** + * @brief Constructor + * + * @param pScreen Capture source + * @param format Texture format + * @param flags Creation flags + */ +RPGrpCaptureTexture::RPGrpCaptureTexture(RPGrpScreen* pScreen, GXTexFmt format, + u32 flags) + : mEfbFlags(0), mTexFlags(0), mpScreen(pScreen) { + + if (flags & EFlag_MipMap) { + mTexFlags |= ETexFlag_MipMap; + } + + bool mipmap = IsMipMapEnable(); + const RPGrpScreen::DataEfb& rEfb = pScreen->GetDataEfb(); + + mpCapTexture = new EGG::CapTexture( + mipmap ? rEfb.vp.width / 2 : rEfb.vp.width, + mipmap ? rEfb.vp.height / 2 : rEfb.vp.height, format); + + mpCapTexture->configure(); + mpCapTexture->alloc(); +} + +/** + * @brief Captures the EFB contents as a texture + * + * @param format Texture format override (optional) + */ +void RPGrpCaptureTexture::Capture(int format) { + if (mEfbFlags & EEfbFlag_ColorUpdate) { + mpCapTexture->enableColorUpdate(); + } else { + mpCapTexture->disableColorUpdate(); + } + + if (mEfbFlags & EEfbFlag_AlphaUpdate) { + mpCapTexture->enableAlphaUpdate(); + } else { + mpCapTexture->disableAlphaUpdate(); + } + + if (mEfbFlags & EEfbFlag_ZBufferUpdate) { + mpCapTexture->enableZBufferUpdate(); + } else { + mpCapTexture->disableZBufferUpdate(); + } + + const RPGrpScreen::DataEfb& rEfb = mpScreen->GetDataEfb(); + mpCapTexture->capture(rEfb.vp.x, rEfb.vp.y, IsMipMapEnable(), format); + + GXInvalidateTexAll(); +} From 26887047ae83ee914c5e2dc094c10cc8fdc3dc34 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 19:25:57 -0400 Subject: [PATCH 08/14] RPGrpFogManager OK --- config/RSPE01_01/symbols.txt | 2 +- configure.py | 2 +- include/Pack/RPGraphics.h | 1 + include/Pack/RPGraphics/RPGrpFogManager.h | 29 +++++++++++++++++++++++ src/Pack/RPGraphics/RPGrpFogManager.cpp | 20 ++++++++++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpFogManager.h create mode 100644 src/Pack/RPGraphics/RPGrpFogManager.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 76730a66..41e514e1 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -8068,7 +8068,7 @@ __ct__12RPGrpTextureFPCQ23EGG10CpuTexture = .text:0x801B4C70; // type:function s Capture__19RPGrpCaptureTextureFi = .text:0x801B4CC0; // type:function size:0x10C __ct__19RPGrpCaptureTextureFP11RPGrpScreen9_GXTexFmtUl = .text:0x801B4DCC; // type:function size:0x11C __dt__19RPGrpCaptureTextureFv = .text:0x801B4EE8; // type:function size:0x40 -fn_801B4F28 = .text:0x801B4F28; // type:function size:0x70 +LoadScnFog__15RPGrpFogManagerFUsPCcf = .text:0x801B4F28; // type:function size:0x70 fn_801B4F98 = .text:0x801B4F98; // type:function size:0x9C fn_801B5034 = .text:0x801B5034; // type:function size:0x70 fn_801B50A4 = .text:0x801B50A4; // type:function size:0x7C diff --git a/configure.py b/configure.py index 1a4a1dd1..446a0578 100755 --- a/configure.py +++ b/configure.py @@ -1255,7 +1255,7 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPGraphics/RPGrpModelRecord.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpTexture.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpCaptureTexture.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpFogManager.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpFogManager.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpProjectionObject.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelRfl.cpp"), ], diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index bb74aa00..f64d3bd2 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpFogManager.h b/include/Pack/RPGraphics/RPGrpFogManager.h new file mode 100644 index 00000000..105bef10 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpFogManager.h @@ -0,0 +1,29 @@ +#ifndef RP_GRAPHICS_FOG_MANAGER_H +#define RP_GRAPHICS_FOG_MANAGER_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +/** + * @brief Fog manager + */ +class RPGrpFogManager : public EGG::FogManager { +public: + /** + * @brief Applies fog settings from the specified scene resource + * + * @param handle File resource handle + * @param pName Scene file name + * @param frame Animation frame (defaults to the first frame) + */ + void LoadScnFog(RPGrpHandle handle, const char* pName, f32 frame = 0.0f); +}; + +//! @} + +#endif diff --git a/src/Pack/RPGraphics/RPGrpFogManager.cpp b/src/Pack/RPGraphics/RPGrpFogManager.cpp new file mode 100644 index 00000000..b1e54fc2 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpFogManager.cpp @@ -0,0 +1,20 @@ +#include + +#include + +/** + * @brief Applies fog settings from the specified scene resource + * + * @param handle File resource handle + * @param pName Scene file name + * @param frame Animation frame (defaults to the first frame) + */ +void RPGrpFogManager::LoadScnFog(RPGrpHandle handle, const char* pName, + f32 frame) { + + const nw4r::g3d::ResAnmScn scn = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + EGG::FogManager::LoadScnFog(scn, frame); +} From a16df178d0de41b744c13afe8ce13e4e45252566 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:56:01 -0400 Subject: [PATCH 09/14] RPGrpCamera OK --- config/RSPE01_01/symbols.txt | 32 +- configure.py | 2 +- include/Pack/RPGraphics.h | 1 + include/Pack/RPGraphics/RPGrpCamera.h | 226 ++++++++++++ include/Pack/RPGraphics/RPGrpCaptureTexture.h | 2 +- include/Pack/RPGraphics/RPGrpTexture.h | 2 +- src/Pack/RPGraphics/RPGrpCamera.cpp | 332 ++++++++++++++++++ 7 files changed, 578 insertions(+), 19 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpCamera.h create mode 100644 src/Pack/RPGraphics/RPGrpCamera.cpp diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 41e514e1..fb5a8ee1 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -7743,19 +7743,19 @@ __dt__Q34nw4r3g3d6ScnRflFv = .text:0x801A8334; // type:function size:0x68 scope: GetTypeObj__Q34nw4r3g3d6ScnRflCFv = .text:0x801A839C; // type:function size:0xC scope:weak GetTypeName__Q34nw4r3g3d6ScnRflCFv = .text:0x801A83A8; // type:function size:0x30 scope:weak IsDerivedFrom__Q34nw4r3g3d6ScnRflCFQ44nw4r3g3d6G3dObj7TypeObj = .text:0x801A83D8; // type:function size:0x68 scope:weak -fn_801A8440 = .text:0x801A8440; // type:function size:0x18C -fn_801A85CC = .text:0x801A85CC; // type:function size:0x244 -fn_801A8810 = .text:0x801A8810; // type:function size:0x4C -fn_801A885C = .text:0x801A885C; // type:function size:0x4C -fn_801A88A8 = .text:0x801A88A8; // type:function size:0x50 -fn_801A88F8 = .text:0x801A88F8; // type:function size:0x8 -fn_801A8900 = .text:0x801A8900; // type:function size:0x26C -fn_801A8B6C = .text:0x801A8B6C; // type:function size:0x90 -fn_801A8BFC = .text:0x801A8BFC; // type:function size:0x12C -fn_801A8D28 = .text:0x801A8D28; // type:function size:0xB0 -fn_801A8DD8 = .text:0x801A8DD8; // type:function size:0x4 -fn_801A8DDC = .text:0x801A8DDC; // type:function size:0x40 -fn_801A8E1C = .text:0x801A8E1C; // type:function size:0x48 +LoadScnCameraMatrix__11RPGrpCameraFQ34nw4r3g3d9ResAnmScnUcf = .text:0x801A8440; // type:function size:0x18C +SyncFromMatrix__11RPGrpCameraFUs = .text:0x801A85CC; // type:function size:0x244 +GetScreenToWorld__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC2PC11RPGrpScreen = .text:0x801A8810; // type:function size:0x4C +GetScreenToWorld__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3PC11RPGrpScreen = .text:0x801A885C; // type:function size:0x4C +GetWorldToScreen__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3PC11RPGrpScreen = .text:0x801A88A8; // type:function size:0x50 +SaveViewMatrix__11RPGrpCameraFv = .text:0x801A88F8; // type:function size:0x8 +CalcMatrix__11RPGrpCameraFv = .text:0x801A8900; // type:function size:0x26C +Identity__11RPGrpCameraFv = .text:0x801A8B6C; // type:function size:0x90 +CopyFromAnother__11RPGrpCameraFRC11RPGrpCamera = .text:0x801A8BFC; // type:function size:0x12C +__ct__11RPGrpCameraFv = .text:0x801A8D28; // type:function size:0xB0 +Initialize__11RPGrpCameraFv = .text:0x801A8DD8; // type:function size:0x4 +__dt__11RPGrpCameraFv = .text:0x801A8DDC; // type:function size:0x40 +__sinit_\RPGrpCamera_cpp = .text:0x801A8E1C; // type:function size:0x48 fn_801A8E64 = .text:0x801A8E64; // type:function size:0x88 fn_801A8EEC = .text:0x801A8EEC; // type:function size:0x10 fn_801A8EFC = .text:0x801A8EFC; // type:function size:0x214 @@ -18637,7 +18637,7 @@ lbl_803B9EA0 = .data:0x803B9EA0; // type:object size:0x10 __vt__17RPSysNWC24Manager = .data:0x803B9F4C; // type:object size:0xC __vt__20RPSysParticleManager = .data:0x803B9F58; // type:object size:0x38 __vt__Q34nw4r3g3d6ScnRfl = .data:0x803B9F90; // type:object size:0x34 scope:global -lbl_803B9FC8 = .data:0x803B9FC8; // type:object size:0x10 +__vt__11RPGrpCamera = .data:0x803B9FC8; // type:object size:0x10 lbl_803B9FD8 = .data:0x803B9FD8; // type:object size:0x18 lbl_803B9FF0 = .data:0x803B9FF0; // type:object size:0x18 lbl_803BA008 = .data:0x803BA008; // type:object size:0x18 @@ -19865,7 +19865,7 @@ lbl_804A41E0 = .bss:0x804A41E0; // type:object size:0x30 lbl_804A4210 = .bss:0x804A4210; // type:object size:0x10 data:4byte lbl_804A4220 = .bss:0x804A4220; // type:object size:0x10 lbl_804A4230 = .bss:0x804A4230; // type:object size:0x10 -lbl_804A4240 = .bss:0x804A4240; // type:object size:0x178 +IDENT__11RPGrpCamera = .bss:0x804A4240; // type:object size:0x178 lbl_804A43B8 = .bss:0x804A43B8; // type:object size:0x110 lbl_804A44C8 = .bss:0x804A44C8; // type:object size:0x30 lbl_804A44F8 = .bss:0x804A44F8; // type:object size:0x10 @@ -21904,7 +21904,7 @@ lbl_804BF5BC = .sbss:0x804BF5BC; // type:object size:0x2 data:2byte lbl_804BF5BE = .sbss:0x804BF5BE; // type:object size:0x1 data:byte gap_11_804BF5BF_sbss = .sbss:0x804BF5BF; // type:object size:0x1 scope:global lbl_804BF5C0 = .sbss:0x804BF5C0; // type:object size:0x8 data:4byte -lbl_804BF5C8 = .sbss:0x804BF5C8; // type:object size:0x8 data:byte +@GUARD@cameraData$16612 = .sbss:0x804BF5C8; // type:object size:0x8 data:byte spAllocator__10RPGrpModel = .sbss:0x804BF5D0; // type:object size:0x4 data:4byte spEntryHead__10RPGrpModel = .sbss:0x804BF5D4; // type:object size:0x4 data:4byte spEntryTail__10RPGrpModel = .sbss:0x804BF5D8; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index 446a0578..a902aa03 100755 --- a/configure.py +++ b/configure.py @@ -1232,7 +1232,7 @@ def MatchingFor(*versions): "cflags": cflags_rp, "progress_category": "graphics", # str | List[str] "objects": [ - Object(NonMatching, "Pack/RPGraphics/RPGrpCamera.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpCamera.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpLightManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpModel.cpp"), diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index f64d3bd2..1e96513f 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -2,6 +2,7 @@ #define RP_PUBLIC_GRAPHICS_H #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpCamera.h b/include/Pack/RPGraphics/RPGrpCamera.h new file mode 100644 index 00000000..2c015ca5 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpCamera.h @@ -0,0 +1,226 @@ +#ifndef RP_GRAPHICS_CAMERA_H +#define RP_GRAPHICS_CAMERA_H +#include + +#include +#include + +//! @addtogroup rp_graphics +//! @{ + +// Forward declarations +class RPGrpScreen; + +/** + * @brief Camera controller + */ +class RPGrpCamera { +public: + /** + * @brief Camera behavior type + */ + enum ECameraType { + //! Use the G3D camera animation result + ECameraType_Anm, + //! World matrix is supplied directly + ECameraType_Direct, + //! Look at the target position + ECameraType_LookAt, + //! Rotate around the target point + ECameraType_Orbit, + //! Camera is placed in the scene + ECameraType_Free, + }; + +public: + //! Camera with identity transform + static RPGrpCamera IDENT; + +private: + //! Camera view matrix (world -> cam) + nw4r::math::MTX34 mViewMtx; // at 0x0 + //! Inverse of the view matrix (cam -> world) + nw4r::math::MTX34 mWorldMtx; // at 0x30 + //! View matrix controlled by a G3D camera animation + nw4r::math::MTX34 mAnmViewMtx; // at 0x60 + //! World matrix supplied for direct type cameras + nw4r::math::MTX34 mDirectWorldMtx; // at 0x90 + + //! World position of the camera + nw4r::math::VEC3 mPosition; // at 0xC0 + //! World position of the camera's target + nw4r::math::VEC3 mTarget; // at 0xCC + //! Rotation of the camera, in degrees + nw4r::math::VEC3 mRotation; // at 0xD8 + + //! Distance to the camera target + f32 mDistance; // at 0xE4 + + //! Right vector (+X) + nw4r::math::VEC3 mRight; // at 0xE8 + //! Up vector (+Y) + nw4r::math::VEC3 mUp; // at 0xF4 + //! Forward vector (+Z) + nw4r::math::VEC3 mForward; // at 0x100 + + //! Camera behavior type + ECameraType mCameraType; // at 0x10C + //! Camera state flags + u16 mFlags; // at 0x110 + + //! World matrix during the previous frame + nw4r::math::MTX34 mWorldMtxOld; // at 0x114 + + //! Saved state of the view matrix + nw4r::math::MTX34 mSavedViewMtx; // at 0x144 + +public: + /** + * @brief Initializes the camera system + */ + static void Initialize(); + + /** + * @brief Constructor + */ + RPGrpCamera(); + + /** + * @brief Destructor + */ + virtual ~RPGrpCamera() {} // at 0x8 + + /** + * @brief Copies the state from another camera + * + * @param rOther Camera from which to copy + */ + virtual void CopyFromAnother(const RPGrpCamera& rOther); // at 0xC + + /** + * @brief Resets the camera transformation + */ + void Identity(); + + /** + * @brief Updates the camera state based on the camera type + */ + void CalcMatrix(); + + /** + * @brief Saves the current state of the view matrix + */ + void SaveViewMatrix(); + + /** + * @brief Converts a position from world-space to screen-space + * + * @param[out] pScreenPos Position in screen-space + * @param rWorldPos Position in world-space + * @param pScreen Screen + */ + void GetWorldToScreen(nw4r::math::VEC3* pScreenPos, + const nw4r::math::VEC3& rWorldPos, + const RPGrpScreen* pScreen) const; + + /** + * @brief Converts a position from screen-space to world-space + * + * @param[out] pWorldPos Position in world-space + * @param rScreenPos Position in screen-space + * @param pScreen Screen + */ + void GetScreenToWorld(nw4r::math::VEC3* pWorldPos, + const nw4r::math::VEC3& rScreenPos, + const RPGrpScreen* pScreen) const; + + /** + * @brief Converts a position from screen-space to world-space + * + * @param[out] pWorldPos Position in world-space + * @param rScreenPos Position in screen-space + * @param pScreen Screen + */ + void GetScreenToWorld(nw4r::math::VEC3* pWorldPos, + const nw4r::math::VEC2& rScreenPos, + const RPGrpScreen* pScreen) const; + + /** + * @brief Applies camera settings from the specified scene resource + * + * @param scn Scene resource + * @param refNumber Camera reference number + * @param frame Animation frame (defaults to the first frame) + */ + void LoadScnCameraMatrix(const nw4r::g3d::ResAnmScn scn, u8 refNumber, + f32 frame = 0.0f); + +private: + /** + * @brief Bit flags to control SyncFromMatrix behavior + */ + enum ESyncFlag { + //! Derive position using the world matrix + ESyncFlag_Position = 1 << 0, + + //! Derive the up vector using the world matrix + ESyncFlag_Up = 1 << 1, + //! Derive the target position using the world matrix + ESyncFlag_Target = 1 << 2, + //! Derive rotation using the world matrix + ESyncFlag_Rotation = 1 << 3, + //! Calculate distance to the target position + ESyncFlag_Distance = 1 << 4, + + //! Derive the view matrix from the world matrix + ESyncFlag_ViewMtx = 1 << 5, + //! Derive the world matrix from the view matrix + ESyncFlag_WorldMtx = 1 << 6, + + //! Save the view matrix to the G3D animation matrix + ESyncFlag_AnmViewMtx = 1 << 7, + //! Save the world matrix to the direct world matrix + ESyncFlag_DirectWorldMtx = 1 << 8, + + // Sync flag presets + ESyncFlag_ForAnmCamera = ESyncFlag_Position | ESyncFlag_Up | + ESyncFlag_Target | ESyncFlag_Rotation | + ESyncFlag_WorldMtx | ESyncFlag_DirectWorldMtx, + + ESyncFlag_ForDirectCamera = ESyncFlag_Position | ESyncFlag_Up | + ESyncFlag_Target | ESyncFlag_Rotation | + ESyncFlag_ViewMtx | ESyncFlag_AnmViewMtx, + + ESyncFlag_ForLookAtCamera = ESyncFlag_Rotation | ESyncFlag_Distance | + ESyncFlag_WorldMtx | ESyncFlag_AnmViewMtx | + ESyncFlag_DirectWorldMtx, + + ESyncFlag_ForOrbitCamera = ESyncFlag_Position | ESyncFlag_Up | + ESyncFlag_WorldMtx | ESyncFlag_AnmViewMtx | + ESyncFlag_DirectWorldMtx, + + ESyncFlag_ForFreeCamera = ESyncFlag_Up | ESyncFlag_Target | + ESyncFlag_ViewMtx | ESyncFlag_AnmViewMtx | + ESyncFlag_DirectWorldMtx, + }; + + /** + * @brief Camera state flags + */ + enum { + EFlag_5 = 1 << 5, + EFlag_7 = 1 << 7, + }; + +private: + /** + * @brief Derives components of the camera state from the world matrix + * + * @param flags Flags controlling which components to update + */ + void SyncFromMatrix(u16 flags); +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpCaptureTexture.h b/include/Pack/RPGraphics/RPGrpCaptureTexture.h index c99bb224..10ed5d57 100644 --- a/include/Pack/RPGraphics/RPGrpCaptureTexture.h +++ b/include/Pack/RPGraphics/RPGrpCaptureTexture.h @@ -47,7 +47,7 @@ class RPGrpCaptureTexture { /** * @brief Destructor */ - virtual ~RPGrpCaptureTexture() {} + virtual ~RPGrpCaptureTexture() {} // at 0x8 /** * @brief Captures the EFB contents as a texture diff --git a/include/Pack/RPGraphics/RPGrpTexture.h b/include/Pack/RPGraphics/RPGrpTexture.h index 6dbdb313..3d1dc922 100644 --- a/include/Pack/RPGraphics/RPGrpTexture.h +++ b/include/Pack/RPGraphics/RPGrpTexture.h @@ -55,7 +55,7 @@ class RPGrpTexture { /** * @brief Destructor */ - virtual ~RPGrpTexture() {} + virtual ~RPGrpTexture() {} // at 0x8 /** * @brief Accesses the underlying GX texture object diff --git a/src/Pack/RPGraphics/RPGrpCamera.cpp b/src/Pack/RPGraphics/RPGrpCamera.cpp new file mode 100644 index 00000000..b3b4bae2 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpCamera.cpp @@ -0,0 +1,332 @@ +#include + +#include +#include + +#include + +/** + * @brief Camera with identity transform + */ +RPGrpCamera RPGrpCamera::IDENT; + +/** + * @brief Initializes the camera system + */ +void RPGrpCamera::Initialize() {} + +/** + * @brief Constructor + */ +RPGrpCamera::RPGrpCamera() : mCameraType(ECameraType_LookAt), mFlags(0) { + Identity(); +} + +/** + * @brief Copies the state from another camera + * + * @param rOther Camera from which to copy + */ +void RPGrpCamera::CopyFromAnother(const RPGrpCamera& rOther) { + if (this == &rOther) { + return; + } + + nw4r::math::MTX34Copy(&mViewMtx, &rOther.mViewMtx); + nw4r::math::MTX34Copy(&mWorldMtx, &rOther.mWorldMtx); + nw4r::math::MTX34Copy(&mAnmViewMtx, &rOther.mAnmViewMtx); + nw4r::math::MTX34Copy(&mDirectWorldMtx, &rOther.mDirectWorldMtx); + + mPosition = rOther.mPosition; + mTarget = rOther.mTarget; + mRotation = rOther.mRotation; + + mDistance = rOther.mDistance; + mRight = rOther.mRight; + mUp = rOther.mUp; + mForward = rOther.mForward; + + mCameraType = rOther.mCameraType; + mFlags = rOther.mFlags; + + nw4r::math::MTX34Copy(&mWorldMtxOld, &rOther.mWorldMtxOld); + nw4r::math::MTX34Copy(&mSavedViewMtx, &rOther.mSavedViewMtx); +} + +/** + * @brief Resets the camera transformation + */ +void RPGrpCamera::Identity() { + nw4r::math::MTX34Identity(&mViewMtx); + nw4r::math::MTX34Identity(&mWorldMtxOld); + nw4r::math::MTX34Identity(&mSavedViewMtx); + + mPosition.x = mPosition.y = mPosition.z = 0.0f; + + mTarget.x = mTarget.y = 0.0f; + mTarget.z = -1.0f; + + mRotation.x = mRotation.y = mRotation.z = 0.0f; + + mDistance = -1.0f; + + mUp.x = mUp.z = 0.0f; + mUp.y = 1.0f; + + CalcMatrix(); + mFlags &= ~EFlag_5; +} + +/** + * @brief Updates the camera state based on the camera type + */ +void RPGrpCamera::CalcMatrix() { + nw4r::math::MTX34Copy(&mWorldMtxOld, &mWorldMtx); + + switch (mCameraType) { + case ECameraType_Anm: { + nw4r::math::MTX34Copy(&mViewMtx, &mAnmViewMtx); + SyncFromMatrix(ESyncFlag_ForAnmCamera); + break; + } + + case ECameraType_Direct: { + nw4r::math::MTX34Copy(&mWorldMtx, &mDirectWorldMtx); + SyncFromMatrix(ESyncFlag_ForDirectCamera); + break; + } + + case ECameraType_LookAt: { + nw4r::math::MTX34LookAt(&mViewMtx, &mPosition, &mUp, &mTarget); + SyncFromMatrix(ESyncFlag_ForLookAtCamera); + break; + } + + case ECameraType_Orbit: { + nw4r::math::MTX34 rot; + PSMTXTrans(mViewMtx, -mTarget.x, -mTarget.y, -mTarget.z); + + PSMTXRotRad(rot, 'Y', NW4R_MATH_DEG_TO_RAD(-mRotation.y)); + nw4r::math::MTX34Mult(&mViewMtx, &rot, &mViewMtx); + + PSMTXRotRad(rot, 'X', NW4R_MATH_DEG_TO_RAD(-mRotation.x)); + nw4r::math::MTX34Mult(&mViewMtx, &rot, &mViewMtx); + + PSMTXRotRad(rot, 'Z', NW4R_MATH_DEG_TO_RAD(-mRotation.z)); + nw4r::math::MTX34Mult(&mViewMtx, &rot, &mViewMtx); + + PSMTXTransApply(mViewMtx, mViewMtx, 0.0f, 0.0f, mDistance); + + SyncFromMatrix(ESyncFlag_ForOrbitCamera); + break; + } + + case ECameraType_Free: { + nw4r::math::MTX34 rot; + nw4r::math::MTX34Identity(&mWorldMtx); + + PSMTXRotRad(rot, 'Z', NW4R_MATH_DEG_TO_RAD(mRotation.z)); + nw4r::math::MTX34Mult(&mWorldMtx, &rot, &mWorldMtx); + + PSMTXRotRad(rot, 'X', NW4R_MATH_DEG_TO_RAD(mRotation.x)); + nw4r::math::MTX34Mult(&mWorldMtx, &rot, &mWorldMtx); + + PSMTXRotRad(rot, 'Y', NW4R_MATH_DEG_TO_RAD(mRotation.y)); + nw4r::math::MTX34Mult(&mWorldMtx, &rot, &mWorldMtx); + + PSMTXTransApply(mWorldMtx, mWorldMtx, mPosition.x, mPosition.y, + mPosition.z); + + SyncFromMatrix(ESyncFlag_ForFreeCamera); + break; + } + } + + mRight.x = mWorldMtx._00; + mRight.y = mWorldMtx._10; + mRight.z = mWorldMtx._20; + + mForward.x = mWorldMtx._02; + mForward.y = mWorldMtx._12; + mForward.z = mWorldMtx._22; + + mFlags &= ~EFlag_7; +} + +/** + * @brief Saves the current state of the view matrix + */ +void RPGrpCamera::SaveViewMatrix() { + nw4r::math::MTX34Copy(&mSavedViewMtx, &mViewMtx); +} + +/** + * @brief Converts a position from world-space to screen-space + * + * @param[out] pScreenPos Position in screen-space + * @param rWorldPos Position in world-space + * @param pScreen Screen + */ +void RPGrpCamera::GetWorldToScreen(nw4r::math::VEC3* pScreenPos, + const nw4r::math::VEC3& rWorldPos, + const RPGrpScreen* pScreen) const { + + nw4r::math::VEC3TransformCoord(pScreenPos, &mViewMtx, &rWorldPos); + pScreen->GetViewToScreen(pScreenPos, *pScreenPos); +} + +/** + * @brief Converts a position from screen-space to world-space + * + * @param[out] pWorldPos Position in world-space + * @param rScreenPos Position in screen-space + * @param pScreen Screen + */ +void RPGrpCamera::GetScreenToWorld(nw4r::math::VEC3* pWorldPos, + const nw4r::math::VEC3& rScreenPos, + const RPGrpScreen* pScreen) const { + + pScreen->GetScreenToView(pWorldPos, rScreenPos); + nw4r::math::VEC3TransformCoord(pWorldPos, &mWorldMtx, pWorldPos); +} + +/** + * @brief Converts a position from screen-space to world-space + * + * @param[out] pWorldPos Position in world-space + * @param rScreenPos Position in screen-space + * @param pScreen Screen + */ +void RPGrpCamera::GetScreenToWorld(nw4r::math::VEC3* pWorldPos, + const nw4r::math::VEC2& rScreenPos, + const RPGrpScreen* pScreen) const { + + pScreen->GetScreenToView(pWorldPos, rScreenPos); + nw4r::math::VEC3TransformCoord(pWorldPos, &mWorldMtx, pWorldPos); +} + +/** + * @brief Derives components of the camera state from the world matrix + * + * @param flags Flags controlling which components to update + */ +void RPGrpCamera::SyncFromMatrix(u16 flags) { + if (flags & ESyncFlag_ViewMtx) { + nw4r::math::MTX34Inv(&mViewMtx, &mWorldMtx); + } else if (flags & ESyncFlag_WorldMtx) { + nw4r::math::MTX34Inv(&mWorldMtx, &mViewMtx); + } + + if (flags & ESyncFlag_AnmViewMtx) { + nw4r::math::MTX34Copy(&mAnmViewMtx, &mViewMtx); + } + + if (flags & ESyncFlag_DirectWorldMtx) { + nw4r::math::MTX34Copy(&mDirectWorldMtx, &mWorldMtx); + } + + if (flags & ESyncFlag_Position) { + mPosition.x = mWorldMtx._03; + mPosition.y = mWorldMtx._13; + mPosition.z = mWorldMtx._23; + } + + if (flags & ESyncFlag_Up) { + mUp.x = mWorldMtx._01; + mUp.y = mWorldMtx._11; + mUp.z = mWorldMtx._21; + } + + if (flags & ESyncFlag_Target) { + mTarget.x = mDistance * mWorldMtx._02 + mWorldMtx._03; + mTarget.y = mDistance * mWorldMtx._12 + mWorldMtx._13; + mTarget.z = mDistance * mWorldMtx._22 + mWorldMtx._23; + } + + if (flags & ESyncFlag_Rotation) { + f32 _12 = mWorldMtx._12; + + if (_12 - 1.0f >= -1e-22f) { + mRotation.x = -90.0f; + mRotation.y = -nw4r::math::Atan2Deg(mWorldMtx._20, mWorldMtx._00); + mRotation.z = 0.0f; + return; + + } else if (_12 + 1.0f <= 1e-22f) { + mRotation.x = +90.0f; + mRotation.y = -nw4r::math::Atan2Deg(mWorldMtx._20, mWorldMtx._00); + mRotation.z = 0.0f; + return; + + } else { + mRotation.x = -std::asinf(_12) * 180 / NW4R_MATH_PI; + mRotation.y = -nw4r::math::Atan2Deg(-mWorldMtx._02, mWorldMtx._22); + mRotation.z = -nw4r::math::Atan2Deg(-mWorldMtx._10, mWorldMtx._11); + } + } + + if (flags & ESyncFlag_Distance) { + f32 length = nw4r::math::VEC3DistSq(&mPosition, &mTarget); + mDistance = -nw4r::math::FSqrt(length); + } +} + +/** + * @brief Applies camera settings from the specified scene resource + * + * @param scn Scene resource + * @param refNumber Camera reference number + * @param frame Animation frame (defaults to the first frame) + */ +void RPGrpCamera::LoadScnCameraMatrix(const nw4r::g3d::ResAnmScn scn, + u8 refNumber, f32 frame) { + if (!scn.IsValid()) { + return; + } + + const nw4r::g3d::ResAnmCamera cam = + scn.GetResAnmCameraByRefNumber(refNumber); + + nw4r::g3d::CameraAnmResult result; + cam.GetAnmResult(&result, frame); + + static nw4r::g3d::CameraData cameraData; + nw4r::g3d::Camera workCamera(&cameraData); + workCamera.Init(); + + nw4r::g3d::Camera::PostureInfo posture; + + switch (result.flags & nw4r::g3d::CameraAnmResult::FLAG_CAMERA_TYPE_MASK) { + case nw4r::g3d::CameraAnmResult::CAMERATYPE_ROTATE: { + posture.tp = nw4r::g3d::Camera::POSTURE_ROTATE; + + posture.cameraRotate = result.rotate.rot; + break; + } + + case nw4r::g3d::CameraAnmResult::CAMERATYPE_AIM: { + posture.tp = nw4r::g3d::Camera::POSTURE_AIM; + + posture.cameraTarget = result.rotate.rot; + posture.cameraTwist = result.aim.twist; + + nw4r::math::VEC3 dir = posture.cameraTarget - result.pos; + mDistance = -nw4r::math::VEC3Len(&dir); + break; + } + } + + workCamera.SetPosition(result.pos); + workCamera.SetPosture(posture); + + // Briefly change camera types so we can apply the G3D result + ECameraType oldType = mCameraType; + mCameraType = ECameraType_Anm; + { + workCamera.GetCameraMtx(&mAnmViewMtx); + CalcMatrix(); + } + mCameraType = oldType; +} + +DECOMP_FORCELITERAL(RPGrpCamera_cpp, 0.0f); From 0bdd108253c27a784db5b6e8c1fdce5cfbddc965 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:56:24 -0400 Subject: [PATCH 10/14] Update symbols.txt --- config/RSPE01_01/symbols.txt | 70 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index fb5a8ee1..51bd1b10 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -7754,8 +7754,8 @@ Identity__11RPGrpCameraFv = .text:0x801A8B6C; // type:function size:0x90 CopyFromAnother__11RPGrpCameraFRC11RPGrpCamera = .text:0x801A8BFC; // type:function size:0x12C __ct__11RPGrpCameraFv = .text:0x801A8D28; // type:function size:0xB0 Initialize__11RPGrpCameraFv = .text:0x801A8DD8; // type:function size:0x4 -__dt__11RPGrpCameraFv = .text:0x801A8DDC; // type:function size:0x40 -__sinit_\RPGrpCamera_cpp = .text:0x801A8E1C; // type:function size:0x48 +__dt__11RPGrpCameraFv = .text:0x801A8DDC; // type:function size:0x40 scope:weak +__sinit_\RPGrpCamera_cpp = .text:0x801A8E1C; // type:function size:0x48 scope:local fn_801A8E64 = .text:0x801A8E64; // type:function size:0x88 fn_801A8EEC = .text:0x801A8EEC; // type:function size:0x10 fn_801A8EFC = .text:0x801A8EFC; // type:function size:0x214 @@ -7793,17 +7793,17 @@ __ct__10RPGrpModelFUc = .text:0x801A9DD8; // type:function size:0x80 Construct__10RPGrpModelFUsPCcUcUlUl = .text:0x801A9E58; // type:function size:0x94 Construct__10RPGrpModelFUsiUcUlUl = .text:0x801A9EEC; // type:function size:0x94 Construct__10RPGrpModelFUsUcUlUl = .text:0x801A9F80; // type:function size:0xB4 -SetJointVisible__10RPGrpModelFUlb = .text:0x801AA034; // type:function size:0x28 -IsJointVisible__10RPGrpModelCFUl = .text:0x801AA05C; // type:function size:0xC -SetShapeVisible__10RPGrpModelFUlb = .text:0x801AA068; // type:function size:0x28 -IsShapeVisible__10RPGrpModelCFUl = .text:0x801AA090; // type:function size:0xC -GetJointNum__10RPGrpModelCFv = .text:0x801AA09C; // type:function size:0x8 -GetShapeNum__10RPGrpModelCFv = .text:0x801AA0A4; // type:function size:0x8 -GetViewMtxNum__10RPGrpModelCFv = .text:0x801AA0AC; // type:function size:0x8 -DrawDirect__10RPGrpModelFUlPQ34nw4r4math5MTX34 = .text:0x801AA0B4; // type:function size:0x14 -CalcBeforeDraw__10RPGrpModelFv = .text:0x801AA0C8; // type:function size:0x14 -CalcView__10RPGrpModelFRCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x801AA0DC; // type:function size:0x40 -GetShapeMinMax__10RPGrpModelCFUsPQ34nw4r4math4VEC3PQ34nw4r4math4VEC3 = .text:0x801AA11C; // type:function size:0xC +SetJointVisible__10RPGrpModelFUlb = .text:0x801AA034; // type:function size:0x28 scope:weak +IsJointVisible__10RPGrpModelCFUl = .text:0x801AA05C; // type:function size:0xC scope:weak +SetShapeVisible__10RPGrpModelFUlb = .text:0x801AA068; // type:function size:0x28 scope:weak +IsShapeVisible__10RPGrpModelCFUl = .text:0x801AA090; // type:function size:0xC scope:weak +GetJointNum__10RPGrpModelCFv = .text:0x801AA09C; // type:function size:0x8 scope:weak +GetShapeNum__10RPGrpModelCFv = .text:0x801AA0A4; // type:function size:0x8 scope:weak +GetViewMtxNum__10RPGrpModelCFv = .text:0x801AA0AC; // type:function size:0x8 scope:weak +DrawDirect__10RPGrpModelFUlPQ34nw4r4math5MTX34 = .text:0x801AA0B4; // type:function size:0x14 scope:weak +CalcBeforeDraw__10RPGrpModelFv = .text:0x801AA0C8; // type:function size:0x14 scope:weak +CalcView__10RPGrpModelFRCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x801AA0DC; // type:function size:0x40 scope:weak +GetShapeMinMax__10RPGrpModelCFUsPQ34nw4r4math4VEC3PQ34nw4r4math4VEC3 = .text:0x801AA11C; // type:function size:0xC scope:weak fn_801AA128 = .text:0x801AA128; // type:function size:0x1C fn_801AA144 = .text:0x801AA144; // type:function size:0x7C fn_801AA1C0 = .text:0x801AA1C0; // type:function size:0x110 @@ -8030,7 +8030,7 @@ fn_801B25C0 = .text:0x801B25C0; // type:function size:0x14 fn_801B25D4 = .text:0x801B25D4; // type:function size:0x14 fn_801B25E8 = .text:0x801B25E8; // type:function size:0x10 __ct__22RPGrpModelBoundingInfoFUlP10RPGrpModel = .text:0x801B25F8; // type:function size:0x40 -__dt__22RPGrpModelBoundingInfoFv = .text:0x801B2638; // type:function size:0x58 +__dt__22RPGrpModelBoundingInfoFv = .text:0x801B2638; // type:function size:0x58 scope:weak fn_801B2690 = .text:0x801B2690; // type:function size:0x8 fn_801B2698 = .text:0x801B2698; // type:function size:0x8 fn_801B26A0 = .text:0x801B26A0; // type:function size:0x24 @@ -8067,7 +8067,7 @@ __ct__12RPGrpTextureFPCQ23EGG7ResTIMG = .text:0x801B4C34; // type:function size: __ct__12RPGrpTextureFPCQ23EGG10CpuTexture = .text:0x801B4C70; // type:function size:0x50 Capture__19RPGrpCaptureTextureFi = .text:0x801B4CC0; // type:function size:0x10C __ct__19RPGrpCaptureTextureFP11RPGrpScreen9_GXTexFmtUl = .text:0x801B4DCC; // type:function size:0x11C -__dt__19RPGrpCaptureTextureFv = .text:0x801B4EE8; // type:function size:0x40 +__dt__19RPGrpCaptureTextureFv = .text:0x801B4EE8; // type:function size:0x40 scope:weak LoadScnFog__15RPGrpFogManagerFUsPCcf = .text:0x801B4F28; // type:function size:0x70 fn_801B4F98 = .text:0x801B4F98; // type:function size:0x9C fn_801B5034 = .text:0x801B5034; // type:function size:0x70 @@ -18644,7 +18644,7 @@ lbl_803BA008 = .data:0x803BA008; // type:object size:0x18 lbl_803BA020 = .data:0x803BA020; // type:object size:0x18 lbl_803BA038 = .data:0x803BA038; // type:object size:0x18 lbl_803BA050 = .data:0x803BA050; // type:object size:0x10 -lbl_803BA060 = .data:0x803BA060; // type:object size:0xA0 +__vt__10RPGrpModel = .data:0x803BA060; // type:object size:0x9C lbl_803BA100 = .data:0x803BA100; // type:object size:0x88 jumptable_803BA188 = .data:0x803BA188; // type:object size:0x20 scope:local jumptable_803BA1A8 = .data:0x803BA1A8; // type:object size:0x20 scope:local @@ -18687,14 +18687,14 @@ lbl_803BA698 = .data:0x803BA698; // type:object size:0x28 lbl_803BA6C0 = .data:0x803BA6C0; // type:object size:0x18 lbl_803BA6D8 = .data:0x803BA6D8; // type:object size:0x10 data:string lbl_803BA6E8 = .data:0x803BA6E8; // type:object size:0x19 data:string -__vt__22RPGrpModelBoundingInfo = .data:0x803BA708; // type:object size:0x10 +__vt__22RPGrpModelBoundingInfo = .data:0x803BA708; // type:object size:0xC scope:weak lbl_803BA718 = .data:0x803BA718; // type:object size:0x18 lbl_803BA730 = .data:0x803BA730; // type:object size:0x10 lbl_803BA740 = .data:0x803BA740; // type:object size:0x10 lbl_803BA750 = .data:0x803BA750; // type:object size:0x18 lbl_803BA768 = .data:0x803BA768; // type:object size:0x18 __vt__12RPGrpTexture = .data:0x803BA780; // type:object size:0x10 -__vt__19RPGrpCaptureTexture = .data:0x803BA790; // type:object size:0x10 +__vt__19RPGrpCaptureTexture = .data:0x803BA790; // type:object size:0xC scope:weak lbl_803BA7A0 = .data:0x803BA7A0; // type:object size:0x10 lbl_803BA7B0 = .data:0x803BA7B0; // type:object size:0xD0 lbl_803BA880 = .data:0x803BA880; // type:object size:0xC0 @@ -19864,9 +19864,9 @@ sTextBuffer__15RPSysLytTextBox = .bss:0x804A3DE0; // type:object size:0x400 lbl_804A41E0 = .bss:0x804A41E0; // type:object size:0x30 lbl_804A4210 = .bss:0x804A4210; // type:object size:0x10 data:4byte lbl_804A4220 = .bss:0x804A4220; // type:object size:0x10 -lbl_804A4230 = .bss:0x804A4230; // type:object size:0x10 +@16512 = .bss:0x804A4230; // type:object size:0xC scope:local IDENT__11RPGrpCamera = .bss:0x804A4240; // type:object size:0x178 -lbl_804A43B8 = .bss:0x804A43B8; // type:object size:0x110 +cameraData$16612 = .bss:0x804A43B8; // type:object size:0x10C scope:local lbl_804A44C8 = .bss:0x804A44C8; // type:object size:0x30 lbl_804A44F8 = .bss:0x804A44F8; // type:object size:0x10 lbl_804A4508 = .bss:0x804A4508; // type:object size:0x30 data:4byte @@ -21904,14 +21904,14 @@ lbl_804BF5BC = .sbss:0x804BF5BC; // type:object size:0x2 data:2byte lbl_804BF5BE = .sbss:0x804BF5BE; // type:object size:0x1 data:byte gap_11_804BF5BF_sbss = .sbss:0x804BF5BF; // type:object size:0x1 scope:global lbl_804BF5C0 = .sbss:0x804BF5C0; // type:object size:0x8 data:4byte -@GUARD@cameraData$16612 = .sbss:0x804BF5C8; // type:object size:0x8 data:byte +@GUARD@cameraData$16612 = .sbss:0x804BF5C8; // type:object size:0x1 scope:local data:byte spAllocator__10RPGrpModel = .sbss:0x804BF5D0; // type:object size:0x4 data:4byte spEntryHead__10RPGrpModel = .sbss:0x804BF5D4; // type:object size:0x4 data:4byte spEntryTail__10RPGrpModel = .sbss:0x804BF5D8; // type:object size:0x4 data:4byte spGenList__10RPGrpModel = .sbss:0x804BF5DC; // type:object size:0x4 data:4byte spCalcModel__10RPGrpModel = .sbss:0x804BF5E0; // type:object size:0x4 data:4byte spCalcWorldMtxArray__10RPGrpModel = .sbss:0x804BF5E4; // type:object size:0x4 data:4byte -spCalcViewMtxArray__10RPGrpModel = .sbss:0x804BF5E8; // type:object size:0x8 data:4byte +spCalcViewMtxArray__10RPGrpModel = .sbss:0x804BF5E8; // type:object size:0x4 data:4byte lbl_804BF5F0 = .sbss:0x804BF5F0; // type:object size:0x8 data:byte lbl_804BF5F8 = .sbss:0x804BF5F8; // type:object size:0x8 data:4byte spCurrent__20RPGrpModelResManager = .sbss:0x804BF600; // type:object size:0x8 data:4byte @@ -23624,18 +23624,18 @@ lbl_804C180C = .sdata2:0x804C180C; // type:object size:0x4 align:4 data:float @10324 = .sdata2:0x804C1814; // type:object size:0x4 scope:local align:4 data:float @10325 = .sdata2:0x804C1818; // type:object size:0x4 scope:local align:4 data:float @10329 = .sdata2:0x804C1820; // type:object size:0x8 scope:local align:8 data:double -lbl_804C1828 = .sdata2:0x804C1828; // type:object size:0x4 align:4 data:float -lbl_804C182C = .sdata2:0x804C182C; // type:object size:0x4 align:4 data:float -lbl_804C1830 = .sdata2:0x804C1830; // type:object size:0x4 align:4 data:float -lbl_804C1834 = .sdata2:0x804C1834; // type:object size:0x4 align:4 data:float -lbl_804C1838 = .sdata2:0x804C1838; // type:object size:0x4 align:4 data:float -lbl_804C183C = .sdata2:0x804C183C; // type:object size:0x4 align:4 data:float -lbl_804C1840 = .sdata2:0x804C1840; // type:object size:0x4 align:4 data:float -lbl_804C1844 = .sdata2:0x804C1844; // type:object size:0x4 align:4 data:float -lbl_804C1848 = .sdata2:0x804C1848; // type:object size:0x4 align:4 data:float -lbl_804C184C = .sdata2:0x804C184C; // type:object size:0x4 align:4 data:float -lbl_804C1850 = .sdata2:0x804C1850; // type:object size:0x8 align:4 data:float -lbl_804C1858 = .sdata2:0x804C1858; // type:object size:0x8 align:4 data:float +@16643 = .sdata2:0x804C1828; // type:object size:0x4 scope:local align:4 data:float +@16740 = .sdata2:0x804C182C; // type:object size:0x4 scope:local align:4 data:float +@16741 = .sdata2:0x804C1830; // type:object size:0x4 scope:local align:4 data:float +@16742 = .sdata2:0x804C1834; // type:object size:0x4 scope:local align:4 data:float +@16743 = .sdata2:0x804C1838; // type:object size:0x4 scope:local align:4 data:float +@16744 = .sdata2:0x804C183C; // type:object size:0x4 scope:local align:4 data:float +@16745 = .sdata2:0x804C1840; // type:object size:0x4 scope:local align:4 data:float +@16746 = .sdata2:0x804C1844; // type:object size:0x4 scope:local align:4 data:float +@16747 = .sdata2:0x804C1848; // type:object size:0x4 scope:local align:4 data:float +@16881 = .sdata2:0x804C184C; // type:object size:0x4 scope:local align:4 data:float +@16896 = .sdata2:0x804C1850; // type:object size:0x4 scope:local align:4 data:float +@16811 = .sdata2:0x804C1858; // type:object size:0x4 scope:local align:4 data:float lbl_804C1860 = .sdata2:0x804C1860; // type:object size:0x4 align:4 data:float lbl_804C1864 = .sdata2:0x804C1864; // type:object size:0x4 align:4 data:float lbl_804C1868 = .sdata2:0x804C1868; // type:object size:0x8 @@ -23678,7 +23678,7 @@ lbl_804C18DC = .sdata2:0x804C18DC; // type:object size:0x4 align:4 data:float lbl_804C18E0 = .sdata2:0x804C18E0; // type:object size:0x4 align:4 data:float gap_12_804C18E4_sdata2 = .sdata2:0x804C18E4; // type:object size:0x4 scope:global lbl_804C18E8 = .sdata2:0x804C18E8; // type:object size:0x8 align:8 data:double -lbl_804C18F0 = .sdata2:0x804C18F0; // type:object size:0x8 align:4 data:float +@16576 = .sdata2:0x804C18F0; // type:object size:0x4 scope:local align:4 data:float lbl_804C18F8 = .sdata2:0x804C18F8; // type:object size:0x8 align:4 data:float lbl_804C1900 = .sdata2:0x804C1900; // type:object size:0x1 data:byte gap_12_804C1901_sdata2 = .sdata2:0x804C1901; // type:object size:0x3 scope:global From 4fbc5f04d4f84fe8eef0dd33dbd393df04f65231 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sun, 12 Apr 2026 12:18:36 -0400 Subject: [PATCH 11/14] temp --- .clang-format | 2 + config/RSPE01_01/splits.txt | 7 +- config/RSPE01_01/symbols.txt | 160 +-- configure.py | 7 +- include/Pack/RPGraphics.h | 8 + include/Pack/RPGraphics/RPGrpCamera.h | 32 +- include/Pack/RPGraphics/RPGrpDrawPath.h | 19 +- include/Pack/RPGraphics/RPGrpDrawPathBloom.h | 29 + include/Pack/RPGraphics/RPGrpDrawPathDOF.h | 31 + include/Pack/RPGraphics/RPGrpDrawPathHDR.h | 21 + .../Pack/RPGraphics/RPGrpDrawPathLightMap.h | 2 + .../Pack/RPGraphics/RPGrpDrawPathManager.h | 43 +- include/Pack/RPGraphics/RPGrpDrawPathSV.h | 28 + .../RPGraphics/RPGrpDrawPathShadowTexture.h | 70 ++ .../Pack/RPGraphics/RPGrpDrawPathXluSnap.h | 28 + include/Pack/RPGraphics/RPGrpLightManager.h | 13 +- include/Pack/RPGraphics/RPGrpModelAnm.h | 193 ++- .../Pack/RPGraphics/RPGrpModelAnmImplement.h | 154 ++- .../Pack/RPGraphics/RPGrpProjectionObject.h | 32 + include/Pack/RPGraphics/RPGrpRenderer.h | 4 + include/Pack/RPGraphics/RPGrpScreen.h | 93 +- include/Pack/RPGraphics/RPGrpShadowTexture.h | 57 + include/egg/gfxe.h | 4 + include/egg/gfxe/eggDrawGX.h | 16 +- include/egg/gfxe/eggFrustum.h | 2 +- include/egg/gfxe/eggModelSnapshot.h | 8 + include/egg/gfxe/eggScnRenderer.h | 2 +- include/egg/gfxe/eggScnRootEx.h | 10 + include/egg/gfxe/eggShadowTexture.h | 4 +- include/egg/gfxe/eggShadowTextureManager.h | 16 +- include/nw4r/g3d/g3d_anmchr.h | 3 +- include/nw4r/g3d/g3d_anmclr.h | 1 + include/nw4r/g3d/g3d_anmshp.h | 1 + include/nw4r/g3d/g3d_anmtexpat.h | 1 + include/nw4r/g3d/g3d_anmtexsrt.h | 1 + include/nw4r/g3d/g3d_scnmdl.h | 10 +- include/nw4r/g3d/g3d_scnmdlsmpl.h | 11 +- src/Pack/RPGraphics/RPGrpCamera.cpp | 6 +- src/Pack/RPGraphics/RPGrpDrawPathManager.cpp | 75 ++ .../RPGraphics/RPGrpDrawPathShadowTexture.cpp | 35 + src/Pack/RPGraphics/RPGrpModelAnm.cpp | 150 +++ .../RPGraphics/RPGrpModelAnmImplement.cpp | 1058 +++++++++++++++++ src/Pack/RPGraphics/RPGrpProjectionObject.cpp | 26 + src/Pack/RPGraphics/RPGrpScreen.cpp | 105 ++ src/Pack/RPGraphics/RPGrpShadowTexture.cpp | 49 + src/egg/gfxe/eggDrawGX.cpp | 4 +- src/egg/gfxe/eggPostEffectBase.cpp | 3 +- src/egg/gfxe/eggShadowTextureManager.cpp | 6 +- 48 files changed, 2431 insertions(+), 209 deletions(-) create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathBloom.h create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathDOF.h create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathHDR.h create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathSV.h create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathShadowTexture.h create mode 100644 include/Pack/RPGraphics/RPGrpDrawPathXluSnap.h create mode 100644 include/Pack/RPGraphics/RPGrpProjectionObject.h create mode 100644 include/Pack/RPGraphics/RPGrpShadowTexture.h create mode 100644 src/Pack/RPGraphics/RPGrpDrawPathManager.cpp create mode 100644 src/Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp create mode 100644 src/Pack/RPGraphics/RPGrpModelAnm.cpp create mode 100644 src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp create mode 100644 src/Pack/RPGraphics/RPGrpProjectionObject.cpp create mode 100644 src/Pack/RPGraphics/RPGrpShadowTexture.cpp diff --git a/.clang-format b/.clang-format index 977524fc..fe3619d3 100644 --- a/.clang-format +++ b/.clang-format @@ -24,6 +24,8 @@ WhitespaceSensitiveMacros: DECOMP_FORCEACTIVE_DTOR, DECOMP_FORCEACTIVE, DECOMP_FORCELITERAL, + OS_ASSERT, + OS_ERROR, EGG_ASSERT, EGG_ASSERT_MSG, RP_ASSERT, diff --git a/config/RSPE01_01/splits.txt b/config/RSPE01_01/splits.txt index ef322a27..89220a83 100644 --- a/config/RSPE01_01/splits.txt +++ b/config/RSPE01_01/splits.txt @@ -3271,13 +3271,13 @@ Pack/RPGraphics/RPGrpModelAnmImplement.cpp: .text start:0x801AA99C end:0x801ACB40 .rodata start:0x803836B0 end:0x803836E0 .data start:0x803BA188 end:0x803BA2F0 - .sbss start:0x804BF5F0 end:0x804BF5F8 .sdata2 start:0x804C1868 end:0x804C1878 Pack/RPGraphics/RPGrpModelImplement.cpp: .text start:0x801ACB40 end:0x801ADE70 .data start:0x803BA2F0 end:0x803BA3E8 .bss start:0x804A44C8 end:0x804A44F8 + .sbss start:0x804BF5F0 end:0x804BF5F8 Pack/RPGraphics/RPGrpModelMisc.cpp: .text start:0x801ADE70 end:0x801ADE80 @@ -3339,9 +3339,12 @@ Pack/RPGraphics/RPGrpModelBoundingInfo.cpp: .data start:0x803BA708 end:0x803BA718 Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp: - .text start:0x801B2690 end:0x801B284C + .text start:0x801B2690 end:0x801B273C .data start:0x803BA718 end:0x803BA730 +Pack/RPGraphics/RPGrpShadowTexture.cpp: + .text start:0x801B273C end:0x801B284C + Pack/RPGraphics/RPGrpModelMaterial.cpp: .text start:0x801B284C end:0x801B3DF0 .rodata start:0x80383768 end:0x80383778 diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 51bd1b10..bf74f555 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -7029,7 +7029,7 @@ fn_80187C8C = .text:0x80187C8C; // type:function size:0x88 fn_80187D14 = .text:0x80187D14; // type:function size:0x64 fn_80187D78 = .text:0x80187D78; // type:function size:0x44 fn_80187DBC = .text:0x80187DBC; // type:function size:0x128 -__dt__11RPGrpScreenFv = .text:0x80187EE4; // type:function size:0x40 +__dt__11RPGrpScreenFv = .text:0x80187EE4; // type:function size:0x40 scope:weak fn_80187F24 = .text:0x80187F24; // type:function size:0x40 __dt__14RPSysDvdStatusFv = .text:0x80187F64; // type:function size:0x40 draw__14RPSysDvdStatusFv = .text:0x80187FA4; // type:function size:0x1E8 @@ -7748,7 +7748,7 @@ SyncFromMatrix__11RPGrpCameraFUs = .text:0x801A85CC; // type:function size:0x244 GetScreenToWorld__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC2PC11RPGrpScreen = .text:0x801A8810; // type:function size:0x4C GetScreenToWorld__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3PC11RPGrpScreen = .text:0x801A885C; // type:function size:0x4C GetWorldToScreen__11RPGrpCameraCFPQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3PC11RPGrpScreen = .text:0x801A88A8; // type:function size:0x50 -SaveViewMatrix__11RPGrpCameraFv = .text:0x801A88F8; // type:function size:0x8 +SaveCameraMatrix__11RPGrpCameraFv = .text:0x801A88F8; // type:function size:0x8 CalcMatrix__11RPGrpCameraFv = .text:0x801A8900; // type:function size:0x26C Identity__11RPGrpCameraFv = .text:0x801A8B6C; // type:function size:0x90 CopyFromAnother__11RPGrpCameraFRC11RPGrpCamera = .text:0x801A8BFC; // type:function size:0x12C @@ -7759,14 +7759,14 @@ __sinit_\RPGrpCamera_cpp = .text:0x801A8E1C; // type:function size:0x48 scope:lo fn_801A8E64 = .text:0x801A8E64; // type:function size:0x88 fn_801A8EEC = .text:0x801A8EEC; // type:function size:0x10 fn_801A8EFC = .text:0x801A8EFC; // type:function size:0x214 -fn_801A9110 = .text:0x801A9110; // type:function size:0xE8 -fn_801A91F8 = .text:0x801A91F8; // type:function size:0xA0 -fn_801A9298 = .text:0x801A9298; // type:function size:0xF0 -fn_801A9388 = .text:0x801A9388; // type:function size:0xE8 -fn_801A9470 = .text:0x801A9470; // type:function size:0xE0 -fn_801A9550 = .text:0x801A9550; // type:function size:0x40 -fn_801A9590 = .text:0x801A9590; // type:function size:0x40 -fn_801A95D0 = .text:0x801A95D0; // type:function size:0x50 +Construct<15RPGrpDrawPathSV>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P15RPGrpDrawPathSV = .text:0x801A9110; // type:function size:0xE8 +Construct<16RPGrpDrawPathHDR>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P16RPGrpDrawPathHDR = .text:0x801A91F8; // type:function size:0xA0 +Construct<16RPGrpDrawPathDOF>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P16RPGrpDrawPathDOF = .text:0x801A9298; // type:function size:0xF0 +Construct<18RPGrpDrawPathBloom>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P18RPGrpDrawPathBloom = .text:0x801A9388; // type:function size:0xE8 +Construct<20RPGrpDrawPathXluSnap>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P20RPGrpDrawPathXluSnap = .text:0x801A9470; // type:function size:0xE0 +Construct<21RPGrpDrawPathLightMap>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P21RPGrpDrawPathLightMap = .text:0x801A9550; // type:function size:0x40 +Construct<26RPGrpDrawPathShadowTexture>__13RPGrpDrawPathFPQ23EGG11ScnRenderer_P26RPGrpDrawPathShadowTexture = .text:0x801A9590; // type:function size:0x40 +Construct__20RPGrpDrawPathManagerFUlP15RPGrpModelScene = .text:0x801A95D0; // type:function size:0x50 fn_801A9620 = .text:0x801A9620; // type:function size:0x58 fn_801A9678 = .text:0x801A9678; // type:function size:0x40 fn_801A96B8 = .text:0x801A96B8; // type:function size:0x40 @@ -7804,54 +7804,54 @@ DrawDirect__10RPGrpModelFUlPQ34nw4r4math5MTX34 = .text:0x801AA0B4; // type:funct CalcBeforeDraw__10RPGrpModelFv = .text:0x801AA0C8; // type:function size:0x14 scope:weak CalcView__10RPGrpModelFRCQ34nw4r4math5MTX34PQ34nw4r4math5MTX34 = .text:0x801AA0DC; // type:function size:0x40 scope:weak GetShapeMinMax__10RPGrpModelCFUsPQ34nw4r4math4VEC3PQ34nw4r4math4VEC3 = .text:0x801AA11C; // type:function size:0xC scope:weak -fn_801AA128 = .text:0x801AA128; // type:function size:0x1C -fn_801AA144 = .text:0x801AA144; // type:function size:0x7C -fn_801AA1C0 = .text:0x801AA1C0; // type:function size:0x110 -fn_801AA2D0 = .text:0x801AA2D0; // type:function size:0x20 -fn_801AA2F0 = .text:0x801AA2F0; // type:function size:0xF4 -fn_801AA3E4 = .text:0x801AA3E4; // type:function size:0x8C -fn_801AA470 = .text:0x801AA470; // type:function size:0x150 +InternalRegist__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUs = .text:0x801AA128; // type:function size:0x1C +GetBlendIndex__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUsUc = .text:0x801AA144; // type:function size:0x7C +SetBlendAnm__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUcUs = .text:0x801AA1C0; // type:function size:0x110 +Cancel__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUs = .text:0x801AA2D0; // type:function size:0x20 +StartBlend__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUsff = .text:0x801AA2F0; // type:function size:0xF4 +StartNoBlend__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUsf = .text:0x801AA3E4; // type:function size:0x8C +Start__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUsf = .text:0x801AA470; // type:function size:0x150 Calc__13RPGrpModelAnmFv = .text:0x801AA5C0; // type:function size:0x10 -fn_801AA5D0 = .text:0x801AA5D0; // type:function size:0x27C -fn_801AA84C = .text:0x801AA84C; // type:function size:0x8C -fn_801AA8D8 = .text:0x801AA8D8; // type:function size:0x34 -fn_801AA90C = .text:0x801AA90C; // type:function size:0x28 -fn_801AA934 = .text:0x801AA934; // type:function size:0x28 -fn_801AA95C = .text:0x801AA95C; // type:function size:0x40 -fn_801AA99C = .text:0x801AA99C; // type:function size:0x3C -fn_801AA9D8 = .text:0x801AA9D8; // type:function size:0x4 -fn_801AA9DC = .text:0x801AA9DC; // type:function size:0x4C -fn_801AAA28 = .text:0x801AAA28; // type:function size:0x3C -fn_801AAA64 = .text:0x801AAA64; // type:function size:0x4C -fn_801AAAB0 = .text:0x801AAAB0; // type:function size:0xF0 -fn_801AABA0 = .text:0x801AABA0; // type:function size:0xE8 -fn_801AAC88 = .text:0x801AAC88; // type:function size:0x8 -fn_801AAC90 = .text:0x801AAC90; // type:function size:0x8 -fn_801AAC98 = .text:0x801AAC98; // type:function size:0x4 -fn_801AAC9C = .text:0x801AAC9C; // type:function size:0xC8 -fn_801AAD64 = .text:0x801AAD64; // type:function size:0x3C -fn_801AADA0 = .text:0x801AADA0; // type:function size:0x4 -fn_801AADA4 = .text:0x801AADA4; // type:function size:0x19C -fn_801AAF40 = .text:0x801AAF40; // type:function size:0x54 -fn_801AAF94 = .text:0x801AAF94; // type:function size:0x9C -fn_801AB030 = .text:0x801AB030; // type:function size:0x60 -fn_801AB090 = .text:0x801AB090; // type:function size:0x58 -fn_801AB0E8 = .text:0x801AB0E8; // type:function size:0x100 -fn_801AB1E8 = .text:0x801AB1E8; // type:function size:0x58 -fn_801AB240 = .text:0x801AB240; // type:function size:0x110 -fn_801AB350 = .text:0x801AB350; // type:function size:0x1D0 -fn_801AB520 = .text:0x801AB520; // type:function size:0x304 -fn_801AB824 = .text:0x801AB824; // type:function size:0x3E0 -fn_801ABC04 = .text:0x801ABC04; // type:function size:0x3E8 -fn_801ABFEC = .text:0x801ABFEC; // type:function size:0xAC -fn_801AC098 = .text:0x801AC098; // type:function size:0x74 -fn_801AC10C = .text:0x801AC10C; // type:function size:0x4 -fn_801AC110 = .text:0x801AC110; // type:function size:0xA8 -fn_801AC1B8 = .text:0x801AC1B8; // type:function size:0x60 -fn_801AC218 = .text:0x801AC218; // type:function size:0x50 -fn_801AC268 = .text:0x801AC268; // type:function size:0x40 -fn_801AC2A8 = .text:0x801AC2A8; // type:function size:0x44C -fn_801AC6F4 = .text:0x801AC6F4; // type:function size:0x44C +CreateBuffer__13RPGrpModelAnmFQ213RPGrpModelAnm3AnmUs = .text:0x801AA5D0; // type:function size:0x27C +Configure__13RPGrpModelAnmFv = .text:0x801AA84C; // type:function size:0x8C +__ct__13RPGrpModelAnmFv = .text:0x801AA8D8; // type:function size:0x34 +SetEnableQuaternionBlend__13RPGrpModelAnmFb = .text:0x801AA90C; // type:function size:0x28 +SetEnableChrAnm__13RPGrpModelAnmFb = .text:0x801AA934; // type:function size:0x28 +__dt__13RPGrpModelAnmFv = .text:0x801AA95C; // type:function size:0x40 +GetUpdateRate__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AA99C; // type:function size:0x3C +GetAnmObj__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AA9D8; // type:function size:0x4 +SetUpdateRate__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsf = .text:0x801AA9DC; // type:function size:0x4C +GetFrame__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AAA28; // type:function size:0x3C +SetFrame__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsf = .text:0x801AAA64; // type:function size:0x4C +GetAnmPlayPolicy__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AAAB0; // type:function size:0xF0 +GetNumFrame__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AABA0; // type:function size:0xE8 +VF_0x48__25RPGrpModelAnmImplement<1>Fv = .text:0x801AAC88; // type:function size:0x8 +VF_0x44__25RPGrpModelAnmImplement<1>Fv = .text:0x801AAC90; // type:function size:0x8 +VF_0x70__25RPGrpModelAnmImplement<1>Fv = .text:0x801AAC98; // type:function size:0x4 +SetEnableChrAnm__25RPGrpModelAnmImplement<1>Fb = .text:0x801AAC9C; // type:function size:0xC8 +SetEnableQuaternionBlend__25RPGrpModelAnmImplement<1>Fb = .text:0x801AAD64; // type:function size:0x3C +InternalCalc__25RPGrpModelAnmImplement<1>Fv = .text:0x801AADA0; // type:function size:0x4 +UpdateFrame__25RPGrpModelAnmImplement<1>Fv = .text:0x801AADA4; // type:function size:0x19C +ReleaseChrAnmNode__25RPGrpModelAnmImplement<1>FUsUsQ213RPGrpModelAnm8BindType = .text:0x801AAF40; // type:function size:0x54 +ReBindChrAnmNode__25RPGrpModelAnmImplement<1>FUsUsQ213RPGrpModelAnm8BindType = .text:0x801AAF94; // type:function size:0x9C +GetBlendWeight__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUcUc = .text:0x801AB030; // type:function size:0x60 +GetBlendAnm__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUcUc = .text:0x801AB090; // type:function size:0x58 +RemoveBlendAnm__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUcUc = .text:0x801AB0E8; // type:function size:0x100 +SetBlendWeight__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUcfUc = .text:0x801AB1E8; // type:function size:0x58 +SetBlendAnm__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUcUs = .text:0x801AB240; // type:function size:0x110 +Cancel__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUs = .text:0x801AB350; // type:function size:0x1D0 +Start__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsf = .text:0x801AB520; // type:function size:0x304 +Regist__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsUs = .text:0x801AB824; // type:function size:0x3E0 +InternalSetAnmObj__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3Anm = .text:0x801ABC04; // type:function size:0x3E8 +__ct__25RPGrpModelAnmImplement<1>FP10RPGrpModel = .text:0x801ABFEC; // type:function size:0xAC +Configure__25RPGrpModelAnmImplement<1>Fv = .text:0x801AC098; // type:function size:0x74 +VF_0x74__25RPGrpModelAnmImplement<1>Fv = .text:0x801AC10C; // type:function size:0x4 +InternalGetAnmObj__25RPGrpModelAnmImplement<1>CFQ213RPGrpModelAnm3AnmUs = .text:0x801AC110; // type:function size:0xA8 +SetAnmObj__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmPPQ34nw4r3g3d6AnmObj = .text:0x801AC1B8; // type:function size:0x60 +Init__25RPGrpModelAnmImplement<1>Fv = .text:0x801AC218; // type:function size:0x50 +__dt__25RPGrpModelAnmImplement<1>Fv = .text:0x801AC268; // type:function size:0x40 +RegistFromResFile__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsUsUl = .text:0x801AC2A8; // type:function size:0x44C +RegistFromResFile__25RPGrpModelAnmImplement<1>FQ213RPGrpModelAnm3AnmUsUsPCc = .text:0x801AC6F4; // type:function size:0x44C ExecCallbackC__13RPGrpModelG3DFPQ34nw4r4math5MTX34Q34nw4r3g3d6ResMdlPQ34nw4r3g3d16FuncObjCalcWorld = .text:0x801ACB40; // type:function size:0x70 EditWorldMtx__19IRPGrpModelCallbackFP10RPGrpModel = .text:0x801ACBB0; // type:function size:0x4 ExecCallbackB__13RPGrpModelG3DFPQ34nw4r3g3d13WorldMtxManipQ34nw4r3g3d6ResMdlPQ34nw4r3g3d16FuncObjCalcWorld = .text:0x801ACBB4; // type:function size:0x124 @@ -7964,12 +7964,12 @@ fn_801B004C = .text:0x801B004C; // type:function size:0x16C fn_801B01B8 = .text:0x801B01B8; // type:function size:0x40 fn_801B01F8 = .text:0x801B01F8; // type:function size:0x40 fn_801B0238 = .text:0x801B0238; // type:function size:0x30 -DrawQuadTexture__11RPGrpScreenFffffPQ23EGG7ResTIMG8_GXColor = .text:0x801B0268; // type:function size:0xF4 +DrawQuadTexture__11RPGrpScreenCFffffPCQ23EGG7ResTIMG8_GXColor = .text:0x801B0268; // type:function size:0xF4 BeginDrawQuadTexture__11RPGrpScreenCFb = .text:0x801B035C; // type:function size:0x1C -DrawQuad__11RPGrpScreenFffff8_GXColor = .text:0x801B0378; // type:function size:0x70 +DrawQuad__11RPGrpScreenCFffff8_GXColor = .text:0x801B0378; // type:function size:0x70 BeginDrawQuad__11RPGrpScreenCFv = .text:0x801B03E8; // type:function size:0x1C Initialize__11RPGrpScreenFPCUsPCUs = .text:0x801B0404; // type:function size:0xC -__sinit_\RPGrpScreen_cpp = .text:0x801B0410; // type:function size:0x5C +__sinit_\RPGrpScreen_cpp = .text:0x801B0410; // type:function size:0x5C scope:local fn_801B046C = .text:0x801B046C; // type:function size:0x734 fn_801B0BA0 = .text:0x801B0BA0; // type:function size:0x150 fn_801B0CF0 = .text:0x801B0CF0; // type:function size:0x184 @@ -8031,16 +8031,16 @@ fn_801B25D4 = .text:0x801B25D4; // type:function size:0x14 fn_801B25E8 = .text:0x801B25E8; // type:function size:0x10 __ct__22RPGrpModelBoundingInfoFUlP10RPGrpModel = .text:0x801B25F8; // type:function size:0x40 __dt__22RPGrpModelBoundingInfoFv = .text:0x801B2638; // type:function size:0x58 scope:weak -fn_801B2690 = .text:0x801B2690; // type:function size:0x8 -fn_801B2698 = .text:0x801B2698; // type:function size:0x8 -fn_801B26A0 = .text:0x801B26A0; // type:function size:0x24 -fn_801B26C4 = .text:0x801B26C4; // type:function size:0x40 -fn_801B2704 = .text:0x801B2704; // type:function size:0x14 -fn_801B2718 = .text:0x801B2718; // type:function size:0x14 -fn_801B272C = .text:0x801B272C; // type:function size:0x10 -fn_801B273C = .text:0x801B273C; // type:function size:0x4C -fn_801B2788 = .text:0x801B2788; // type:function size:0x8 -fn_801B2790 = .text:0x801B2790; // type:function size:0xBC +SetTexture__26RPGrpDrawPathShadowTextureFP18RPGrpShadowTexture = .text:0x801B2690; // type:function size:0x8 +SetTexture__26RPGrpDrawPathShadowTextureFUsP18RPGrpShadowTexture = .text:0x801B2698; // type:function size:0x8 +__ct__26RPGrpDrawPathShadowTextureFPQ23EGG11ScnRenderer = .text:0x801B26A0; // type:function size:0x24 +__dt__26RPGrpDrawPathShadowTextureFv = .text:0x801B26C4; // type:function size:0x40 +On__26RPGrpDrawPathShadowTextureFv = .text:0x801B2704; // type:function size:0x14 +Off__26RPGrpDrawPathShadowTextureFv = .text:0x801B2718; // type:function size:0x14 +IsEnable__26RPGrpDrawPathShadowTextureCFv = .text:0x801B272C; // type:function size:0x10 +AddModelUseMaterial__18RPGrpShadowTextureFP10RPGrpModelf = .text:0x801B273C; // type:function size:0x4C +AddModel__18RPGrpShadowTextureFP10RPGrpModelf = .text:0x801B2788; // type:function size:0x8 +Replace__18RPGrpShadowTextureFP10RPGrpModelPCce = .text:0x801B2790; // type:function size:0xBC fn_801B284C = .text:0x801B284C; // type:function size:0x7C fn_801B28C8 = .text:0x801B28C8; // type:function size:0xE0 fn_801B29A8 = .text:0x801B29A8; // type:function size:0x1A4 @@ -8069,10 +8069,10 @@ Capture__19RPGrpCaptureTextureFi = .text:0x801B4CC0; // type:function size:0x10C __ct__19RPGrpCaptureTextureFP11RPGrpScreen9_GXTexFmtUl = .text:0x801B4DCC; // type:function size:0x11C __dt__19RPGrpCaptureTextureFv = .text:0x801B4EE8; // type:function size:0x40 scope:weak LoadScnFog__15RPGrpFogManagerFUsPCcf = .text:0x801B4F28; // type:function size:0x70 -fn_801B4F98 = .text:0x801B4F98; // type:function size:0x9C -fn_801B5034 = .text:0x801B5034; // type:function size:0x70 -fn_801B50A4 = .text:0x801B50A4; // type:function size:0x7C -fn_801B5120 = .text:0x801B5120; // type:function size:0x40 +LoadScnCamera__21RPGrpProjectionObjectFUsPCcf = .text:0x801B4F98; // type:function size:0x9C +Calc__21RPGrpProjectionObjectFQ34nw4r3g3d6Camera = .text:0x801B5034; // type:function size:0x70 +__ct__21RPGrpProjectionObjectFUc = .text:0x801B50A4; // type:function size:0x7C +__dt__21RPGrpProjectionObjectFv = .text:0x801B5120; // type:function size:0x40 GetShapeName__13RPGrpModelRflCFUs = .text:0x801B5160; // type:function size:0x8 GetMaterialName__13RPGrpModelRflCFUs = .text:0x801B5168; // type:function size:0x8 GetJointName__13RPGrpModelRflCFUs = .text:0x801B5170; // type:function size:0x8 @@ -18645,7 +18645,7 @@ lbl_803BA020 = .data:0x803BA020; // type:object size:0x18 lbl_803BA038 = .data:0x803BA038; // type:object size:0x18 lbl_803BA050 = .data:0x803BA050; // type:object size:0x10 __vt__10RPGrpModel = .data:0x803BA060; // type:object size:0x9C -lbl_803BA100 = .data:0x803BA100; // type:object size:0x88 +__vt__13RPGrpModelAnm = .data:0x803BA100; // type:object size:0x88 jumptable_803BA188 = .data:0x803BA188; // type:object size:0x20 scope:local jumptable_803BA1A8 = .data:0x803BA1A8; // type:object size:0x20 scope:local jumptable_803BA1C8 = .data:0x803BA1C8; // type:object size:0x20 scope:local @@ -18688,14 +18688,14 @@ lbl_803BA6C0 = .data:0x803BA6C0; // type:object size:0x18 lbl_803BA6D8 = .data:0x803BA6D8; // type:object size:0x10 data:string lbl_803BA6E8 = .data:0x803BA6E8; // type:object size:0x19 data:string __vt__22RPGrpModelBoundingInfo = .data:0x803BA708; // type:object size:0xC scope:weak -lbl_803BA718 = .data:0x803BA718; // type:object size:0x18 +__vt__26RPGrpDrawPathShadowTexture = .data:0x803BA718; // type:object size:0x18 lbl_803BA730 = .data:0x803BA730; // type:object size:0x10 lbl_803BA740 = .data:0x803BA740; // type:object size:0x10 lbl_803BA750 = .data:0x803BA750; // type:object size:0x18 lbl_803BA768 = .data:0x803BA768; // type:object size:0x18 __vt__12RPGrpTexture = .data:0x803BA780; // type:object size:0x10 __vt__19RPGrpCaptureTexture = .data:0x803BA790; // type:object size:0xC scope:weak -lbl_803BA7A0 = .data:0x803BA7A0; // type:object size:0x10 +__vt__21RPGrpProjectionObject = .data:0x803BA7A0; // type:object size:0x10 lbl_803BA7B0 = .data:0x803BA7B0; // type:object size:0xD0 lbl_803BA880 = .data:0x803BA880; // type:object size:0xC0 lbl_803BA940 = .data:0x803BA940; // type:object size:0x11 data:string @@ -19865,13 +19865,13 @@ lbl_804A41E0 = .bss:0x804A41E0; // type:object size:0x30 lbl_804A4210 = .bss:0x804A4210; // type:object size:0x10 data:4byte lbl_804A4220 = .bss:0x804A4220; // type:object size:0x10 @16512 = .bss:0x804A4230; // type:object size:0xC scope:local -IDENT__11RPGrpCamera = .bss:0x804A4240; // type:object size:0x178 +sDefaultCamera__11RPGrpCamera = .bss:0x804A4240; // type:object size:0x178 cameraData$16612 = .bss:0x804A43B8; // type:object size:0x10C scope:local lbl_804A44C8 = .bss:0x804A44C8; // type:object size:0x30 lbl_804A44F8 = .bss:0x804A44F8; // type:object size:0x10 lbl_804A4508 = .bss:0x804A4508; // type:object size:0x30 data:4byte -@16447 = .bss:0x804A4538; // type:object size:0x10 scope:local -g_default_screen__11RPGrpScreen = .bss:0x804A4548; // type:object size:0x68 +@16740 = .bss:0x804A4538; // type:object size:0x10 scope:local +sRootScreen__11RPGrpScreen = .bss:0x804A4548; // type:object size:0x68 lbl_804A45B0 = .bss:0x804A45B0; // type:object size:0xC lbl_804A45BC = .bss:0x804A45BC; // type:object size:0x4C align:4 data:float lbl_804A4608 = .bss:0x804A4608; // type:object size:0x30 align:4 data:float diff --git a/configure.py b/configure.py index a902aa03..6a07ed11 100755 --- a/configure.py +++ b/configure.py @@ -1236,21 +1236,22 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpLightManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpModel.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnm.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpModelAnm.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelAnmImplement.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelImplement.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelMisc.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelManager.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelResManager.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpRenderer.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpScreen.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpScreen.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpView.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpViewRender2D.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpViewRender3D.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelScene.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathLightMap.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpModelBoundingInfo.cpp"), - Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp"), + Object(Matching, "Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp"), + Object(NonMatching, "Pack/RPGraphics/RPGrpShadowTexture.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelMaterial.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpModelRecord.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpTexture.cpp"), diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index 1e96513f..3dc6abaa 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -5,8 +5,14 @@ #include #include #include +#include +#include +#include #include #include +#include +#include +#include #include #include #include @@ -20,8 +26,10 @@ #include #include #include +#include #include #include +#include #include #endif diff --git a/include/Pack/RPGraphics/RPGrpCamera.h b/include/Pack/RPGraphics/RPGrpCamera.h index 2c015ca5..27f6d845 100644 --- a/include/Pack/RPGraphics/RPGrpCamera.h +++ b/include/Pack/RPGraphics/RPGrpCamera.h @@ -32,11 +32,10 @@ class RPGrpCamera { ECameraType_Free, }; -public: - //! Camera with identity transform - static RPGrpCamera IDENT; - private: + //! Default camera + static RPGrpCamera sDefaultCamera; + //! Camera view matrix (world -> cam) nw4r::math::MTX34 mViewMtx; // at 0x0 //! Inverse of the view matrix (cam -> world) @@ -110,7 +109,7 @@ class RPGrpCamera { /** * @brief Saves the current state of the view matrix */ - void SaveViewMatrix(); + void SaveCameraMatrix(); /** * @brief Converts a position from world-space to screen-space @@ -155,6 +154,29 @@ class RPGrpCamera { void LoadScnCameraMatrix(const nw4r::g3d::ResAnmScn scn, u8 refNumber, f32 frame = 0.0f); + /** + * @brief Sets the type of this camera + * + * @param type New camera type + */ + void SetCameraType(ECameraType type) { + mCameraType = type; + } + + /** + * @brief Accesses the saved state of the view matrix + */ + const nw4r::math::MTX34& GetSavedCameraMatrix() const { + return mSavedViewMtx; + } + + /** + * @brief Accesses the default camera object + */ + static RPGrpCamera& GetDefaultCamera() { + return sDefaultCamera; + } + private: /** * @brief Bit flags to control SyncFromMatrix behavior diff --git a/include/Pack/RPGraphics/RPGrpDrawPath.h b/include/Pack/RPGraphics/RPGrpDrawPath.h index 382cfb12..47325d32 100644 --- a/include/Pack/RPGraphics/RPGrpDrawPath.h +++ b/include/Pack/RPGraphics/RPGrpDrawPath.h @@ -12,24 +12,31 @@ */ class RPGrpDrawPath { protected: - EGG::ScnRenderer* mpRenderer; // at 0x0 - EGG::DrawPathBase* mpPathImpl; // at 0x4 + EGG::ScnRenderer* mpRenderer; // at 0x0 + EGG::DrawPathBase* mpDrawPathBase; // at 0x4 public: - template T* Construct(EGG::ScnRenderer* pRenderer); + template static T* Construct(EGG::ScnRenderer* pRenderer); + + template + static T* Construct(EGG::ScnRenderer* pRenderer, bool); + + RPGrpDrawPath(EGG::ScnRenderer* pRenderer, + EGG::DrawPathBase* pDrawPathBase = NULL) + : mpRenderer(pRenderer), mpDrawPathBase(pDrawPathBase) {} virtual ~RPGrpDrawPath() {} // at 0x8 virtual void On() { // at 0xC - mpPathImpl->setEnable(true); + mpDrawPathBase->setEnable(true); } virtual void Off() { // at 0x10 - mpPathImpl->setEnable(false); + mpDrawPathBase->setEnable(false); } virtual bool IsEnable() const { // at 0x10 - return mpPathImpl->isEnable(); + return mpDrawPathBase->isEnable(); } }; diff --git a/include/Pack/RPGraphics/RPGrpDrawPathBloom.h b/include/Pack/RPGraphics/RPGrpDrawPathBloom.h new file mode 100644 index 00000000..83aa62c3 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathBloom.h @@ -0,0 +1,29 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_BLOOM_H +#define RP_GRAPHICS_DRAW_PATH_BLOOM_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpDrawPathBloom : public RPGrpDrawPath { +public: + RPGrpDrawPathBloom(EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer, pRenderer->getDrawPathBase( + EGG::ScnRenderer::DRAW_PATH_BLOOM)) { + + mpBloom = static_cast( + pRenderer->getDrawPathBase(EGG::ScnRenderer::DRAW_PATH_BLOOM)); + } + +private: + char unkC[0x10 - 0xC]; + EGG::DrawPathBloom* mpBloom; // at 0x10 +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpDrawPathDOF.h b/include/Pack/RPGraphics/RPGrpDrawPathDOF.h new file mode 100644 index 00000000..fddd70b8 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathDOF.h @@ -0,0 +1,31 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_DOF_H +#define RP_GRAPHICS_DRAW_PATH_DOF_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpDrawPathDOF : public RPGrpDrawPath { +public: + RPGrpDrawPathDOF(EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer, pRenderer->getDrawPathBase( + EGG::ScnRenderer::DRAW_PATH_DOF)) { + + mpDOF = static_cast( + pRenderer->getDrawPathBase(EGG::ScnRenderer::DRAW_PATH_DOF)); + + // TODO(kiwi) Need to figure out the EGG class layout + // mpDOF->unk80 = 0; + } + +private: + EGG::DrawPathDOF* mpDOF; // at 0xC +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpDrawPathHDR.h b/include/Pack/RPGraphics/RPGrpDrawPathHDR.h new file mode 100644 index 00000000..ce936b96 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathHDR.h @@ -0,0 +1,21 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_HDR_H +#define RP_GRAPHICS_DRAW_PATH_HDR_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpDrawPathHDR : public RPGrpDrawPath { +public: + RPGrpDrawPathHDR(EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer, pRenderer->getDrawPathBase( + EGG::ScnRenderer::DRAW_PATH_HDR)) {} +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpDrawPathLightMap.h b/include/Pack/RPGraphics/RPGrpDrawPathLightMap.h index 2e898e3e..228c1ca1 100644 --- a/include/Pack/RPGraphics/RPGrpDrawPathLightMap.h +++ b/include/Pack/RPGraphics/RPGrpDrawPathLightMap.h @@ -17,6 +17,8 @@ class RPGrpModel; */ class RPGrpDrawPathLightMap : public RPGrpDrawPath { public: + RPGrpDrawPathLightMap(EGG::ScnRenderer* pRenderer); + void ReplaceModelTexture(u16 index, RPGrpModel* pModel); EGG::LightTextureManager* GetLightTextureManager() const { diff --git a/include/Pack/RPGraphics/RPGrpDrawPathManager.h b/include/Pack/RPGraphics/RPGrpDrawPathManager.h index 5ffaf73f..831e2c8d 100644 --- a/include/Pack/RPGraphics/RPGrpDrawPathManager.h +++ b/include/Pack/RPGraphics/RPGrpDrawPathManager.h @@ -8,20 +8,59 @@ //! @{ // Forward declarations +class RPGrpDrawPathBloom; +class RPGrpDrawPathDOF; +class RPGrpDrawPathHDR; class RPGrpDrawPathLightMap; +class RPGrpDrawPathShadowTexture; +class RPGrpDrawPathSV; +class RPGrpDrawPathXluSnap; +class RPGrpModelScene; /** * @brief Draw path manager */ class RPGrpDrawPathManager : public EGG::IScnProc { public: + /** + * @brief Flags to enable draw path types with Construct + */ + enum { + EFlag_DrawPathLightMap = 1 << 0, + EFlag_DrawPathShadowTexture = 1 << 1, + EFlag_DrawPathXluSnap = 1 << 2, + EFlag_DrawPathSV = 1 << 3, + EFlag_DrawPathHDR = 1 << 4, + EFlag_DrawPathBloom = 1 << 5, + EFlag_DrawPathDOF = 1 << 6, + }; + +public: + static RPGrpDrawPathManager* Construct(u32 pathFlags, + RPGrpModelScene* pModelScene); + + virtual ~RPGrpDrawPathManager() override {} // at 0x8 + + virtual void scnProcDraw(u16 idx) override; // at 0xC + RPGrpDrawPathLightMap* GetDrawPathLightMap() const { return mpDrawPathLightMap; } private: - char unkC[0x18 - 0xC]; - RPGrpDrawPathLightMap* mpDrawPathLightMap; // at 0x18 + RPGrpDrawPathManager(u32 pathFlags, RPGrpModelScene* pModelScene); + +private: + u16 unkC; + RPGrpModelScene* mpModelScene; // at 0x10 + u32 unk14; + RPGrpDrawPathLightMap* mpDrawPathLightMap; // at 0x18 + RPGrpDrawPathShadowTexture* mpDrawPathShadowTexture; // at 0x1C + RPGrpDrawPathXluSnap* mpDrawPathXluSnap; // at 0x20 + RPGrpDrawPathSV* mpDrawPathSV; // at 0x24 + RPGrpDrawPathHDR* mpDrawPathHDR; // at 0x28 + RPGrpDrawPathBloom* mpDrawPathBloom; // at 0x2C + RPGrpDrawPathDOF* mpDrawPathDOF; // at 0x30 }; //! @} diff --git a/include/Pack/RPGraphics/RPGrpDrawPathSV.h b/include/Pack/RPGraphics/RPGrpDrawPathSV.h new file mode 100644 index 00000000..9c48cc2c --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathSV.h @@ -0,0 +1,28 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_SV_H +#define RP_GRAPHICS_DRAW_PATH_SV_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpDrawPathSV : public RPGrpDrawPath { +public: + RPGrpDrawPathSV(EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer, pRenderer->getDrawPathBase( + EGG::ScnRenderer::DRAW_PATH_SV)) { + + mpSV = static_cast( + pRenderer->getDrawPathBase(EGG::ScnRenderer::DRAW_PATH_SV)); + } + +private: + EGG::DrawPathShadowVolume* mpSV; // at 0xC +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpDrawPathShadowTexture.h b/include/Pack/RPGraphics/RPGrpDrawPathShadowTexture.h new file mode 100644 index 00000000..9b57710c --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathShadowTexture.h @@ -0,0 +1,70 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_SHADOW_TEXTURE_H +#define RP_GRAPHICS_DRAW_PATH_SHADOW_TEXTURE_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +// Forward declarations +class RPGrpShadowTexture; + +/** + * @brief Shadow texture draw path + */ +class RPGrpDrawPathShadowTexture : public RPGrpDrawPath { +public: + /** + * @brief Constructor + * + * @param pRenderer Scene renderer + */ + RPGrpDrawPathShadowTexture(EGG::ScnRenderer* pRenderer); + + /** + * @brief Inserts a new shadow texture + * + * @param idx Texture index + * @param pTexture Shadow texture + */ + void SetTexture(u16 idx, RPGrpShadowTexture* pTexture); + + /** + * @brief Appends a new shadow texture + * + * @param pTexture Shadow texture + */ + void SetTexture(RPGrpShadowTexture* pTexture); + + /** + * @brief Enables this draw path + */ + virtual void On() override { // at 0xC + mpShadowTextureManager->SetEnable(true); + } + + /** + * @brief Disables this draw path + */ + virtual void Off() override { // at 0x10 + mpShadowTextureManager->SetEnable(false); + } + + /** + * @brief Tests whether this draw path is enabled + */ + virtual bool IsEnable() const override { // at 0x10 + return mpShadowTextureManager->IsEnable(); + } + +private: + //! Shadow texture manager + EGG::ShadowTextureManager* mpShadowTextureManager; // at 0xC +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpDrawPathXluSnap.h b/include/Pack/RPGraphics/RPGrpDrawPathXluSnap.h new file mode 100644 index 00000000..8a0a4667 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpDrawPathXluSnap.h @@ -0,0 +1,28 @@ +#ifndef RP_GRAPHICS_DRAW_PATH_XLU_SNAP_H +#define RP_GRAPHICS_DRAW_PATH_XLU_SNAP_H +#include + +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpDrawPathXluSnap : public RPGrpDrawPath { +public: + RPGrpDrawPathXluSnap(EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer, pRenderer->getDrawPathBase( + EGG::ScnRenderer::DRAW_PATH_XLU_SNAP)) { + + mpXluSnap = static_cast( + pRenderer->getDrawPathBase(EGG::ScnRenderer::DRAW_PATH_XLU_SNAP)); + } + +private: + EGG::DrawPathXluSnap* mpXluSnap; // at 0xC +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpLightManager.h b/include/Pack/RPGraphics/RPGrpLightManager.h index bedf6d4e..0aea7f23 100644 --- a/include/Pack/RPGraphics/RPGrpLightManager.h +++ b/include/Pack/RPGraphics/RPGrpLightManager.h @@ -17,10 +17,12 @@ class RPGrpLightManager : public EGG::LightManager { /** * @brief Constructor * + * @param lightNum Maximum number of light objects + * @param ambientNum Maximum number of ambient light objects * @param viewNum Maximum number of renderer views */ - explicit RPGrpLightManager(u8 viewNum) - : EGG::LightManager(LIGHT_NUM, AMBIENT_NUM, viewNum) {} + RPGrpLightManager(u32 lightNum, u32 ambientNum, u8 viewNum) + : EGG::LightManager(lightNum, ambientNum, viewNum) {} /** * @brief Applies light settings from the specified scene resource @@ -32,13 +34,6 @@ class RPGrpLightManager : public EGG::LightManager { */ void LoadScnLight(RPGrpHandle handle, const char* pName, f32 frame = 0.0f, u32 lightSetRef = -1); - -private: - //! Maximum number of light objects - static const int LIGHT_NUM = 16; - - //! Maximum number of ambient light objects - static const int AMBIENT_NUM = 8; }; //! @} diff --git a/include/Pack/RPGraphics/RPGrpModelAnm.h b/include/Pack/RPGraphics/RPGrpModelAnm.h index 8157ec07..314c6169 100644 --- a/include/Pack/RPGraphics/RPGrpModelAnm.h +++ b/include/Pack/RPGraphics/RPGrpModelAnm.h @@ -2,6 +2,10 @@ #define RP_GRAPHICS_MODEL_ANM_H #include +#include + +#include + #include //! @addtogroup rp_graphics @@ -16,64 +20,131 @@ class RPGrpModel; class RPGrpModelAnm { public: enum Anm { - Anm_ResAnmChr, - Anm_ResAnmClr, - Anm_ResAnmTexPat, - Anm_ResAnmTexSrt, - Anm_4, - Anm_ResAnmShp, + Anm_Chr, + Anm_Clr, + Anm_TexPat, + Anm_TexSrt, + Anm_Vis, + Anm_Shp, Anm_6, Anm_7, + + Anm_Max, }; + //! Animation index + typedef u16 AnmIdx; + enum AnmPlayPolicy { AnmPlayPolicy_OneTime, AnmPlayPolicy_Loop, + + AnmPlayPolicy_2, + AnmPlayPolicy_3, + AnmPlayPolicy_4, + + AnmPlayPolicy_Max + }; + + enum BindType { + BindType_One, + BindType_Partial, + + BindType_Max }; protected: - char _00[0x68]; + //! State flags + u8 mFlags; // at 0x0 + + //! Number of binds per animation type + u16 mAnmNum[Anm_Max]; // at 0x2 + + //! Index of the currently playing animation + s16 mPlayIndex[Anm_Max]; // at 0x12 + //! Index of the previous animation + s16 mPrevPlayIndex[Anm_Max]; // at 0x22 + + //! Flag set per animation type + u8* mpAnmFlags[Anm_Max]; // at 0x34 + + u8 unk54; + u8* mpBlendIndices; // at 0x58 + u32 unk5C; + f32 unk60; + f32 unk64; public: - virtual void Configure() = 0; // at 0x8 - virtual void Construct(Anm anm, u16 idx, u16 rd) = 0; + virtual void Configure(); // at 0x8 + + virtual void Regist(Anm anm, u16 idx, RPGrpHandle handle) = 0; // at 0xC + + virtual void RegistFromResFile(Anm anm, u16 idx, RPGrpHandle handle, + const char* pName) = 0; // at 0x10 + + virtual void RegistFromResFile(Anm anm, u16 idx, RPGrpHandle handle, + u32 id) = 0; // at 0x14 + + virtual s16 SetBlendAnm(Anm anm, u8, u16 idx); // at 0x18 + + virtual s16 RemoveBlendAnm(Anm anm, u8, u8) = 0; // at 0x1C + + virtual void SetBlendWeight(Anm anm, u8, f32, u8) = 0; // at 0x20 + + virtual s16 GetBlendAnm(Anm, u8, u8) = 0; // at 0x24 + + virtual f32 GetBlendWeight(Anm, u8, u8) = 0; // at 0x28 + + virtual void ReBindChrAnmNode(u16, u16, BindType) = 0; // at 0x2C + + virtual void ReleaseChrAnmNode(u16, u16, BindType) = 0; // at 0x30 - virtual void Regist(Anm anm, u16 idx, u16 rd, char const* pName, - u32 arg4 = 0) = 0; // at 0x10 - virtual void VF_0x14(UNKTYPE) = 0; - virtual void VF_0x18(UNKTYPE) = 0; - virtual void VF_0x1C(UNKTYPE) = 0; + virtual bool StartNoBlend(Anm anm, u16 idx, f32 frame = 0.0f); // at 0x34 - virtual void VF_0x20(UNKTYPE) = 0; - virtual void VF_0x24(UNKTYPE) = 0; - virtual void VF_0x28(UNKTYPE) = 0; - virtual void VF_0x2C(UNKTYPE) = 0; + virtual bool StartBlend(Anm anm, u16 idx, f32 weight = 0.0f, + f32 frame = 0.0f); // at 0x38 - virtual void VF_0x30(UNKTYPE) = 0; - virtual void VF_0x34(UNKTYPE) = 0; - virtual void VF_0x38(UNKTYPE) = 0; + virtual bool Cancel(Anm anm, u16 idx); // at 0x3C - virtual void Cancel(Anm anm, u16 idx) = 0; - virtual void Start(Anm anm, u16 idx, f32 frame = 1.0f) = 0; // at 0x40 + virtual bool Start(Anm anm, u16 idx, f32 frame = 0.0f); // at 0x40 virtual f32 VF_0x44(UNKTYPE) = 0; + virtual f32 VF_0x48(UNKTYPE) = 0; - virtual u16 GetNumFrame(Anm anm, u16 idx) const = 0; // at 0x4C + virtual int GetNumFrame(Anm anm, u16 idx) const = 0; // at 0x4C + virtual AnmPlayPolicy GetAnmPlayPolicy(Anm anm, u16 idx) const = 0; // at 0x50 virtual void SetFrame(Anm anm, u16 idx, f32 frame) = 0; // at 0x54 - virtual f32 GetFrame(Anm anm, u16 idx) const = 0; // at 0x58 + + virtual f32 GetFrame(Anm anm, u16 idx) const = 0; // at 0x58 virtual void SetUpdateRate(Anm anm, u16 idx, f32 rate) = 0; // at 0x5C - virtual f32 GetUpdateRate(Anm anm, u16 idx) const = 0; // at 0x60 - virtual void SetEnableQuaternionBlend(bool enable) = 0; // at 0x64 + virtual f32 GetUpdateRate(Anm anm, u16 idx) const = 0; // at 0x60 + + virtual void SetEnableQuaternionBlend(bool enable) { // at 0x64 + if (enable) { + mFlags |= Flag_EnableQuaternionBlend; + } else { + mFlags &= ~Flag_EnableQuaternionBlend; + } + } + + virtual void SetEnableChrAnm(bool enable) { // at 0x68 + if (!enable) { + mFlags |= Flag_DisableChrAnm; + } else { + mFlags &= ~Flag_DisableChrAnm; + } + } + + virtual void UpdateFrame() = 0; // at 0x6C - virtual void VF_0x68(UNKTYPE) = 0; // at 0x68 - virtual void UpdateFrame() = 0; // at 0x6C virtual void VF_0x70(UNKTYPE) = 0; // at 0x70 + virtual void VF_0x74(UNKTYPE) = 0; // at 0x74 virtual nw4r::g3d::AnmObj* GetAnmObj(Anm anm, u16 idx) const = 0; // at 0x78 @@ -82,12 +153,68 @@ class RPGrpModelAnm { void Calc(); + s8 GetBlendIndex(Anm anm, AnmIdx idx, u8); + + void InternalRegist(Anm anm, u16 idx); + + bool StartNoSame(Anm anm, AnmIdx idx, f32 frame = 0.0f) { + if (mPlayIndex[anm] != idx) { + return StartNoBlend(anm, idx, frame); + } + + return false; + } + + bool StartBlendNoSame(Anm anm, AnmIdx idx, f32 frame = 0.0f) { + if (mPlayIndex[anm] != idx) { + return StartBlend(anm, idx, frame); + } + + return false; + } + + bool IsEnableQuaternionBlend() const { + return mFlags & Flag_EnableQuaternionBlend; + } + + bool IsEnableChrAnm() const { + return !(mFlags & Flag_DisableChrAnm); + } + + bool IsBlending(Anm anm) const { + if (anm == Anm_Chr) { + return unk60 > 0.0f; + } + + return false; + } + protected: - RPGrpModelAnm(RPGrpModel* pModel); - virtual ~RPGrpModelAnm(); // at 0x7C + /** + * @brief Bitflags + */ + enum { + Flag_EnableQuaternionBlend = 1 << 0, + Flag_DisableChrAnm = 1 << 1, + }; + + enum { + AnmFlag_PlayingG3D = 1 << 0, + AnmFlag_Playing = 1 << 1, + AnmFlag_Regist = 1 << 2, + }; + +protected: + RPGrpModelAnm(); + virtual ~RPGrpModelAnm() {} // at 0x7C + + virtual void SetAnmObj(Anm anm, + nw4r::g3d::AnmObj** ppAnmObjs) = 0; // at 0x80 + virtual void InternalCalc() = 0; // at 0x84 - virtual void SetAnmObj(Anm anm, nw4r::g3d::AnmObj* pAnmObj) = 0; // at 0x80 - virtual void InternalCalc() = 0; // at 0x84 + u16 GetAnmNum(Anm anm) const { + return mAnmNum[anm]; + } }; //! @} diff --git a/include/Pack/RPGraphics/RPGrpModelAnmImplement.h b/include/Pack/RPGraphics/RPGrpModelAnmImplement.h index 249e29cb..df27e48f 100644 --- a/include/Pack/RPGraphics/RPGrpModelAnmImplement.h +++ b/include/Pack/RPGraphics/RPGrpModelAnmImplement.h @@ -5,20 +5,36 @@ #include #include +#include + //! @addtogroup rp_graphics //! @{ -// Forward declarations -class RPGrpModel; +/****************************************************************************** + * + * RPGrpModelAnmImplement + * + ******************************************************************************/ /** * @brief Model animation implementation */ -template -class RPGrpModelAnmImplement : public RPGrpModelAnm { -protected: - char _6C[0xE8 - 0x6C]; +template class RPGrpModelAnmImplement {}; + +/****************************************************************************** + * + * RPGrpModelAnmG3D + * + ******************************************************************************/ + +// Shorthand name for specialization +typedef RPGrpModelAnmImplement RPGrpModelAnmG3D; +/** + * @brief Model animation implementation for nw4r::g3d + */ +template <> +class RPGrpModelAnmImplement : public RPGrpModelAnm { public: static RPGrpModelAnm* Construct(RPGrpModel* pModel) DECOMP_DONT_INLINE { RPGrpModelAnm* pAnm = new RPGrpModelAnmImplement(pModel); @@ -26,63 +42,121 @@ class RPGrpModelAnmImplement : public RPGrpModelAnm { return pAnm; } - virtual void Configure(); // at 0x8 - virtual void Construct(Anm anm, u16 idx, u16 rd); + virtual void Configure(); // at 0x8 + virtual void Regist(Anm anm, AnmIdx idx, RPGrpHandle handle); // at 0xC + virtual void RegistFromResFile(Anm anm, AnmIdx idx, RPGrpHandle handle, + const char* pName); // at 0x10 + virtual void RegistFromResFile(Anm anm, AnmIdx idx, RPGrpHandle handle, + u32 id); // at 0x14 + virtual s16 SetBlendAnm(Anm anm, u8, AnmIdx idx); // at 0x18 + virtual s16 RemoveBlendAnm(Anm anm, u8, u8); // at 0x1C - virtual void Regist(Anm anm, u16 idx, u16 rd, char const* pName, - u32 arg4); // at 0x10 - virtual void VF_0x14(UNKTYPE); - virtual void VF_0x18(UNKTYPE); - virtual void VF_0x1C(UNKTYPE); + virtual void SetBlendWeight(Anm anm, u8, f32, u8); // at 0x20 + virtual s16 GetBlendAnm(Anm, u8, u8); // at 0x24 + virtual f32 GetBlendWeight(Anm, u8, u8); // at 0x28 + virtual void ReBindChrAnmNode(u16, u16, BindType type); // at 0x2C - virtual void VF_0x20(UNKTYPE); - virtual void VF_0x24(UNKTYPE); - virtual void VF_0x28(UNKTYPE); - virtual void VF_0x2C(UNKTYPE); + virtual void ReleaseChrAnmNode(u16, u16, BindType type); // at 0x30 + virtual bool StartNoBlend(Anm anm, u16 idx, f32 frame = 0.0f); // at 0x34 + virtual bool StartBlend(Anm anm, u16 idx, f32 weight = 0.0f, + f32 frame = 0.0f); // at 0x38 - virtual void VF_0x30(UNKTYPE); - virtual void VF_0x34(UNKTYPE); - virtual void VF_0x38(UNKTYPE); - - virtual void Cancel(Anm anm, u16 idx); - virtual void Start(Anm anm, u16 idx, f32 frame = 1.0f); // at 0x40 + virtual bool Cancel(Anm anm, AnmIdx idx); // at 0x3C + virtual bool Start(Anm anm, AnmIdx idx, f32 frame = 0.0f); // at 0x40 virtual f32 VF_0x44(UNKTYPE); virtual f32 VF_0x48(UNKTYPE); - virtual u16 GetNumFrame(Anm anm, u16 idx) const; // at 0x4C + virtual int GetNumFrame(Anm anm, AnmIdx idx) const; // at 0x4C virtual AnmPlayPolicy GetAnmPlayPolicy(Anm anm, - u16 idx) const; // at 0x50 + AnmIdx idx) const; // at 0x50 - virtual void SetFrame(Anm anm, u16 idx, f32 frame); // at 0x54 - virtual f32 GetFrame(Anm anm, u16 idx) const; // at 0x58 + virtual void SetFrame(Anm anm, AnmIdx idx, f32 frame); // at 0x54 + virtual f32 GetFrame(Anm anm, AnmIdx idx) const; // at 0x58 - virtual void SetUpdateRate(Anm anm, u16 idx, f32 rate); // at 0x5C - virtual f32 GetUpdateRate(Anm anm, u16 idx) const; // at 0x60 + virtual void SetUpdateRate(Anm anm, AnmIdx idx, f32 rate); // at 0x5C + virtual f32 GetUpdateRate(Anm anm, AnmIdx idx) const; // at 0x60 virtual void SetEnableQuaternionBlend(bool enable); // at 0x64 - virtual void VF_0x68(UNKTYPE); // at 0x68 - virtual void UpdateFrame(); // at 0x6C + virtual void SetEnableChrAnm(bool enable); // at 0x68 + virtual void UpdateFrame(); // at 0x6C + virtual void VF_0x70(UNKTYPE); // at 0x70 virtual void VF_0x74(UNKTYPE); // at 0x74 - virtual nw4r::g3d::AnmObj* GetAnmObj(Anm anm, u16 idx) const; // at 0x78 + virtual nw4r::g3d::AnmObj* GetAnmObj(Anm anm, AnmIdx idx) const; // at 0x78 + + void Init(); - void CreateBuffer(Anm anm, u16 num); + nw4r::g3d::AnmObj* InternalGetAnmObj(Anm anm, AnmIdx idx) const; + void InternalSetAnmObj(Anm anm); - void Calc(); + bool IsPlayingG3D(Anm anm, u16 idx) const { + return mpAnmFlags[anm][idx] & AnmFlag_PlayingG3D; + } private: - RPGrpModelAnmImplement(RPGrpModel* pModel); + struct ChrBlendInfo { + nw4r::g3d::AnmObjChrBlend* pAnmObj; // at 0x0 + s16 toAnmIdx[8]; // at 0x4 + }; + + struct ShpBlendInfo { + nw4r::g3d::AnmObjShpBlend* pAnmObj; // at 0x0 + s16 toAnmIdx[8]; // at 0x4 + }; + +private: + explicit RPGrpModelAnmImplement(RPGrpModel* pModel); virtual ~RPGrpModelAnmImplement() {} // at 0x7C - virtual void SetAnmObj(Anm anm, nw4r::g3d::AnmObj* pAnmObj); // at 0x80 - virtual void InternalCalc(); // at 0x84 -}; + virtual void SetAnmObj(Anm anm, nw4r::g3d::AnmObj** ppAnmObjs); // at 0x80 + virtual void InternalCalc(); // at 0x84 -// Shorthand names for specializations -typedef RPGrpModelAnmImplement RPGrpModelAnmG3D; + void RegistAnmChr(AnmIdx idx, const nw4r::g3d::ResAnmChr chr); + + void RegistAnmClr(AnmIdx idx, const nw4r::g3d::ResAnmClr clr); + + void RegistAnmTexPat(AnmIdx idx, const nw4r::g3d::ResAnmTexPat pat); + + void RegistAnmTexSrt(AnmIdx idx, const nw4r::g3d::ResAnmTexSrt srt); + + void RegistAnmVis(AnmIdx idx, const nw4r::g3d::ResAnmVis vis); + + void RegistAnmShp(AnmIdx idx, const nw4r::g3d::ResAnmShp shp); + +private: + //! Animation object type conversion table + static const nw4r::g3d::ScnMdlSimple::AnmObjType TO_G3D_TYPE[Anm_Max]; + //! Animation play policy conversion table + static const AnmPlayPolicy FROM_G3D_POLICY[]; + + //! Scene model that this animation controls + nw4r::g3d::ScnMdlSimple* mpScnMdlSimple; // at 0x6C + + nw4r::g3d::AnmObjChrRes** mppAnmObjChrRes; // at 0x70 + nw4r::g3d::AnmObjMatClrRes** mppAnmObjMatClrRes; // at 0x74 + nw4r::g3d::AnmObjTexPatRes** mppAnmObjTexPatRes; // at 0x78 + nw4r::g3d::AnmObjTexSrtRes** mppAnmObjTexSrtRes; // at 0x7C + nw4r::g3d::AnmObjVisRes** mppAnmObjVisRes; // at 0x80 + nw4r::g3d::AnmObjShpRes** mppAnmObjShpRes; // at 0x84 + + nw4r::g3d::AnmObjVisRes** unk88; + nw4r::g3d::AnmObjVisRes** unk8C; + u32 unk90[Anm_Max]; + + //! Map from RP animation index to G3D index + s8* mpToIndexG3D[Anm_Max]; // at 0xB0 + + nw4r::g3d::AnmObjMatClrOverride* mpAnmObjMatClrOverride; // at 0xD0 + nw4r::g3d::AnmObjTexPatOverride* mpAnmObjTexPatOverride; // at 0xD4 + nw4r::g3d::AnmObjTexSrtOverride* mpAnmObjTexSrtOverride; // at 0xD8 + nw4r::g3d::AnmObjVisOR* mpAnmObjVisOR; // at 0xDC + + ChrBlendInfo* mpChrBlendInfo; // at 0xE0 + ShpBlendInfo* mpShpBlendInfo; // at 0xE4 +}; //! @} diff --git a/include/Pack/RPGraphics/RPGrpProjectionObject.h b/include/Pack/RPGraphics/RPGrpProjectionObject.h new file mode 100644 index 00000000..683ccd12 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpProjectionObject.h @@ -0,0 +1,32 @@ +#ifndef RP_GRAPHICS_PROJECTION_OBJECT_H +#define RP_GRAPHICS_PROJECTION_OBJECT_H +#include + +#include +#include +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpProjectionObject { +private: + u8 mViewNo; // at 0x0 + RPGrpCamera mCamera; // at 0x4 + RPGrpScreen mScreen; // at 0x17C + +public: + RPGrpProjectionObject(u8 viewNo); + + virtual ~RPGrpProjectionObject() {} // at 0x8 + + void Calc(nw4r::g3d::Camera cam); + + void LoadScnCamera(RPGrpHandle handle, const char* pName, f32 frame = 0.0f); +}; + +//! @} + +#endif diff --git a/include/Pack/RPGraphics/RPGrpRenderer.h b/include/Pack/RPGraphics/RPGrpRenderer.h index d3473ee6..984a707f 100644 --- a/include/Pack/RPGraphics/RPGrpRenderer.h +++ b/include/Pack/RPGraphics/RPGrpRenderer.h @@ -12,6 +12,10 @@ class RPGrpScreen; * @brief Rendering engine */ class RPGrpRenderer { +public: + //! Maximum number of renderer views + static const int MAX_VIEW = 32; + public: /** * @brief Gets the currently active manager instance diff --git a/include/Pack/RPGraphics/RPGrpScreen.h b/include/Pack/RPGraphics/RPGrpScreen.h index 9f690487..145592dd 100644 --- a/include/Pack/RPGraphics/RPGrpScreen.h +++ b/include/Pack/RPGraphics/RPGrpScreen.h @@ -7,14 +7,28 @@ //! @addtogroup rp_graphics //! @{ +<<<<<<< HEAD +======= +// Forward declarations +class RPGrpTexture; + +>>>>>>> 082cf7d8 (temp) /** - * @brief Screen extension + * @brief Screen rendering surface */ class RPGrpScreen : public EGG::Screen { public: + /** + * @brief Initializes the screen system + * + * @param maxX Screen width limits for all TV modes + * @param maxY Screen height limits for all TV modes + */ + static void Initialize(const u16 maxX[TV_MODE_MAX], + const u16 maxY[TV_MODE_MAX]); + /** * @brief Constructor - * @note The far Z defaults to 100,000 */ RPGrpScreen() { SetFarZ(100000.0f); @@ -31,16 +45,17 @@ class RPGrpScreen : public EGG::Screen { * @param canvasMode Coordinate system */ RPGrpScreen(f32 x, f32 y, f32 width, f32 height, - const Screen* pParent = NULL, + const EGG::Screen* pParent = NULL, CanvasMode canvasMode = CANVASMODE_LU) : EGG::Screen(x, y, width, height, pParent, canvasMode) {} /** - * @brief Destructor + * @brief Configures the GX rendering state to draw a quad */ - virtual ~RPGrpScreen() override; // at 0x8 + void BeginDrawQuad() const; /** +<<<<<<< HEAD * @brief Sets up the screen to draw a solid color quad. */ void BeginDrawQuad() const; @@ -60,10 +75,27 @@ class RPGrpScreen : public EGG::Screen { * @brief Sets up the screen to draw a texture quad. * * @param alpha Does the texture have an alpha channel +======= + * @brief Draws a colored quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param color Fill color + */ + void DrawQuad(f32 x1, f32 y1, f32 x2, f32 y2, GXColor color) const; + + /** + * @brief Configures the GX rendering state to draw a textured quad + * + * @param alpha Whether to enable the raster alpha channel +>>>>>>> 082cf7d8 (temp) */ void BeginDrawQuadTexture(bool alpha) const; /** +<<<<<<< HEAD * @brief Draws a texture on a quad to the screen * * @param x Quad X position @@ -88,6 +120,57 @@ class RPGrpScreen : public EGG::Screen { public: //! Default screen settings static RPGrpScreen g_default_screen; +======= + * @brief Draws a textured quad to this screen + * @details It is assumed the texture has already been loaded to GX_TEXMAP0. + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param color Material color + */ + void DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, GXColor color) const; + + /** + * @brief Draws a textured quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param rTexture Fill texture + * @param color Material color + */ + void DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, + const RPGrpTexture& rTexture, GXColor color) const; + + /** + * @brief Draws a textured quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param pResTIMG Fill texture + * @param color Material color + */ + void DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, + const EGG::ResTIMG* pResTIMG, GXColor color) const; + + /** + * @brief Accesses the root of the screen hierarchy + */ + static RPGrpScreen& GetRootScreen() { + return sRootScreen; + } + +private: + //! Screen hierarchy root + static RPGrpScreen sRootScreen; +>>>>>>> 082cf7d8 (temp) }; +//! @} + #endif diff --git a/include/Pack/RPGraphics/RPGrpShadowTexture.h b/include/Pack/RPGraphics/RPGrpShadowTexture.h new file mode 100644 index 00000000..abc2c259 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpShadowTexture.h @@ -0,0 +1,57 @@ +#ifndef RP_GRAPHICS_SHADOW_TEXTURE_H +#define RP_GRAPHICS_SHADOW_TEXTURE_H +#include + +#include + +//! @addtogroup rp_graphics +//! @{ + +class RPGrpModel; + +class RPGrpShadowTexture : public EGG::ShadowTexture { +public: + /** + * @brief Constructor + * + * @param size Texture size (width/height) + * @param format Texture format + * @param mdlNum Maximum number of scene models to gather + */ + RPGrpShadowTexture(u16 size, int format, u16 mdlNum) + : EGG::ShadowTexture(size, format, mdlNum) {} + + /** + * @brief Destructor + */ + virtual ~RPGrpShadowTexture() {} // at 0x8 + + /** + * @brief Replaces a texture on the specified model + * + * @param pModel Target model + * @param pName Texture name (format string) + * @param ... Format string arguments + */ + void Replace(RPGrpModel* pModel, const char* pName, ...); + + /** + * @brief Adds a new model to the shadow texture + * + * @param pModel Model + * @param density Model density + */ + void AddModel(RPGrpModel* pModel, f32 density); + + /** + * @brief Adds a new model with materials to the shadow texture + * + * @param pModel Model + * @param density Model density + */ + void AddModelUseMaterial(RPGrpModel* pModel, f32 density); +}; + +//! @} + +#endif diff --git a/include/egg/gfxe.h b/include/egg/gfxe.h index ea31b261..62d66806 100644 --- a/include/egg/gfxe.h +++ b/include/egg/gfxe.h @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -27,6 +29,8 @@ #include #include #include +#include +#include #include #include diff --git a/include/egg/gfxe/eggDrawGX.h b/include/egg/gfxe/eggDrawGX.h index 7a668099..6a82b1ad 100644 --- a/include/egg/gfxe/eggDrawGX.h +++ b/include/egg/gfxe/eggDrawGX.h @@ -129,11 +129,23 @@ class DrawGX { const nw4r::math::VEC3& rP1, const nw4r::math::VEC3& rP2, GXColor color); - static void DrawScreenTexture(const nw4r::math::MTX34& rMtx) { - GXLoadPosMtxImm(rMtx, GX_PNMTX0); + static void DrawScreen() { + GXCallDisplayList(s_DL[DL_SCREEN].m_list, s_DL[DL_SCREEN].m_size); + } + static void DrawScreen(const nw4r::math::MTX34& rMtx) { + DrawDL(DL_SCREEN, rMtx); + } + static void DrawScreen(const nw4r::math::MTX34& rMtx, GXColor color) { + DrawDL(DL_SCREEN, rMtx, color); + } + + static void DrawScreenTexture() { GXCallDisplayList(s_DL[DL_SCREEN_TEXTURE].m_list, s_DL[DL_SCREEN_TEXTURE].m_size); } + static void DrawScreenTexture(const nw4r::math::MTX34& rMtx) { + DrawDL(DL_SCREEN_TEXTURE, rMtx); + } static void DrawScreenTexture(const nw4r::math::MTX34& rMtx, GXColor color) { DrawDL(DL_SCREEN_TEXTURE, rMtx, color); diff --git a/include/egg/gfxe/eggFrustum.h b/include/egg/gfxe/eggFrustum.h index b430fc13..677e0a65 100644 --- a/include/egg/gfxe/eggFrustum.h +++ b/include/egg/gfxe/eggFrustum.h @@ -49,7 +49,7 @@ class Frustum { virtual void CopyToG3D(nw4r::g3d::Camera camera) const; // at 0x10 void LoadScnCamera(const nw4r::g3d::ResAnmScn scn, u8 refNumber, f32 frame, - u32 flags); + u32 flags = 0); void CopyFromAnother(const Frustum& rOther); diff --git a/include/egg/gfxe/eggModelSnapshot.h b/include/egg/gfxe/eggModelSnapshot.h index dde2437d..38f7149e 100644 --- a/include/egg/gfxe/eggModelSnapshot.h +++ b/include/egg/gfxe/eggModelSnapshot.h @@ -24,6 +24,14 @@ class ModelSnapshot : public CapTexture { void AddModelEx(ModelEx* pModel, f32 density); void GatherModel(f32); + u16 GetModelNum() const { + return m_mdlNum; + } + + ModelBind* GetModelBind(u32 idx) const { + return &m_mdlList[idx]; + } + private: u16 m_mdlMax; // at 0x2C u16 m_width; // at 0x2E diff --git a/include/egg/gfxe/eggScnRenderer.h b/include/egg/gfxe/eggScnRenderer.h index 284bbb9b..1d928a52 100644 --- a/include/egg/gfxe/eggScnRenderer.h +++ b/include/egg/gfxe/eggScnRenderer.h @@ -7,7 +7,7 @@ #include namespace EGG { -class ScnRenderer : ScnRootEx { +class ScnRenderer : public ScnRootEx { public: enum DrawPathType { DRAW_PATH_XLU_SNAP, diff --git a/include/egg/gfxe/eggScnRootEx.h b/include/egg/gfxe/eggScnRootEx.h index 90d74dbc..13d1820b 100644 --- a/include/egg/gfxe/eggScnRootEx.h +++ b/include/egg/gfxe/eggScnRootEx.h @@ -86,6 +86,16 @@ class ScnRootEx : public IDrawGX { void setDrawSettingGX(bool) const; + LightManager* getLightManager() const { + return mpLightManager; + } + FogManager* getFogManager() const { + return mpFogManager; + } + ShadowTextureManager* getShadowTextureManager() const { + return mpShadowTextureManager; + } + Screen& getScreen() const { #line 171 EGG_ASSERT(mpScreen); diff --git a/include/egg/gfxe/eggShadowTexture.h b/include/egg/gfxe/eggShadowTexture.h index be968518..88614419 100644 --- a/include/egg/gfxe/eggShadowTexture.h +++ b/include/egg/gfxe/eggShadowTexture.h @@ -7,11 +7,13 @@ namespace EGG { class ShadowTexture : public ModelSnapshot { public: - ShadowTexture(u16, u16, u16); + ShadowTexture(u16, int, u16); void Calc(); void Draw(Screen*, bool, bool, bool); + void Replace(EGG::ModelEx* pModelEx, const char* pName); + // Temporary names, needed for regalloc void SetCapTexture0(CapTexture* pCapTexture) { POST_EFF_0xE4->setCapTexture(pCapTexture); diff --git a/include/egg/gfxe/eggShadowTextureManager.h b/include/egg/gfxe/eggShadowTextureManager.h index b8f512eb..bce076e3 100644 --- a/include/egg/gfxe/eggShadowTextureManager.h +++ b/include/egg/gfxe/eggShadowTextureManager.h @@ -3,9 +3,10 @@ #include "types_egg.h" namespace EGG { + class ShadowTextureManager { public: - enum EShadowMgrFlag { SHADOW_MGR_ACTIVE = (1 << 0) }; + enum EShadowMgrFlag { SHADOW_MGR_ENABLE = (1 << 0) }; private: static const int GROUP_MAX = 16; @@ -25,10 +26,19 @@ class ShadowTextureManager { void Calc(); void Draw(Screen*); - bool IsActive() const { - return mFlags & SHADOW_MGR_ACTIVE; + bool IsEnable() const { + return mFlags & SHADOW_MGR_ENABLE; + } + + void SetEnable(bool enable) { + if (enable) { + mFlags |= SHADOW_MGR_ENABLE; + } else { + mFlags &= ~SHADOW_MGR_ENABLE; + } } }; + } // namespace EGG #endif diff --git a/include/nw4r/g3d/g3d_anmchr.h b/include/nw4r/g3d/g3d_anmchr.h index e31a77fe..808e1610 100644 --- a/include/nw4r/g3d/g3d_anmchr.h +++ b/include/nw4r/g3d/g3d_anmchr.h @@ -122,6 +122,7 @@ class AnmObjChrNode : public AnmObjChr { * ******************************************************************************/ class AnmObjChrBlend : public AnmObjChrNode { +public: static AnmObjChrBlend* Construct(MEMAllocator* pAllocator, u32* pSize, ResMdl mdl, int numChildren); @@ -166,7 +167,7 @@ class AnmObjChrRes : public AnmObjChr, protected FrameCtrl { virtual f32 GetUpdateRate() const; // at 0x2C virtual bool Bind(const ResMdl mdl); // at 0x30 - using AnmObjChr::Release; // at 0x40 + using AnmObjChr::Release; // at 0x34 virtual const ChrAnmResult* GetResult(ChrAnmResult* pResult, u32 idx); // at 0x38 diff --git a/include/nw4r/g3d/g3d_anmclr.h b/include/nw4r/g3d/g3d_anmclr.h index a3851d76..f3f6eae8 100644 --- a/include/nw4r/g3d/g3d_anmclr.h +++ b/include/nw4r/g3d/g3d_anmclr.h @@ -102,6 +102,7 @@ class AnmObjMatClrNode : public AnmObjMatClr { * ******************************************************************************/ class AnmObjMatClrOverride : public AnmObjMatClrNode { +public: static AnmObjMatClrOverride* Construct(MEMAllocator* pAllocator, u32* pSize, ResMdl mdl, int numChildren); diff --git a/include/nw4r/g3d/g3d_anmshp.h b/include/nw4r/g3d/g3d_anmshp.h index b23780be..a79639c0 100644 --- a/include/nw4r/g3d/g3d_anmshp.h +++ b/include/nw4r/g3d/g3d_anmshp.h @@ -101,6 +101,7 @@ class AnmObjShpNode : public AnmObjShp { * ******************************************************************************/ class AnmObjShpBlend : public AnmObjShpNode { +public: static AnmObjShpBlend* Construct(MEMAllocator* pAllocator, u32* pSize, ResMdl mdl, int numChildren); diff --git a/include/nw4r/g3d/g3d_anmtexpat.h b/include/nw4r/g3d/g3d_anmtexpat.h index e4bf0ec1..b376c042 100644 --- a/include/nw4r/g3d/g3d_anmtexpat.h +++ b/include/nw4r/g3d/g3d_anmtexpat.h @@ -101,6 +101,7 @@ class AnmObjTexPatNode : public AnmObjTexPat { * ******************************************************************************/ class AnmObjTexPatOverride : public AnmObjTexPatNode { +public: static AnmObjTexPatOverride* Construct(MEMAllocator* pAllocator, u32* pSize, ResMdl mdl, int numChildren); diff --git a/include/nw4r/g3d/g3d_anmtexsrt.h b/include/nw4r/g3d/g3d_anmtexsrt.h index cd401692..c980e587 100644 --- a/include/nw4r/g3d/g3d_anmtexsrt.h +++ b/include/nw4r/g3d/g3d_anmtexsrt.h @@ -103,6 +103,7 @@ class AnmObjTexSrtNode : public AnmObjTexSrt { * ******************************************************************************/ class AnmObjTexSrtOverride : public AnmObjTexSrtNode { +public: static AnmObjTexSrtOverride* Construct(MEMAllocator* pAllocator, u32* pSize, ResMdl mdl, int numChildren); diff --git a/include/nw4r/g3d/g3d_scnmdl.h b/include/nw4r/g3d/g3d_scnmdl.h index b74a0dce..e681df4f 100644 --- a/include/nw4r/g3d/g3d_scnmdl.h +++ b/include/nw4r/g3d/g3d_scnmdl.h @@ -105,9 +105,13 @@ class ScnMdl : public ScnMdlSimple { virtual bool SetScnObjOption(u32 option, u32 value); // at 0x20 virtual bool GetScnObjOption(u32 option, u32* pValue) const; // at 0x24 - virtual bool SetAnmObj(AnmObj* pObj, AnmObjType type); // at 0x34 - virtual bool RemoveAnmObj(AnmObj* pObj); // at 0x38 - virtual AnmObj* RemoveAnmObj(AnmObjType type); // at 0x3C + virtual bool + SetAnmObj(AnmObj* pObj, + AnmObjType type = ANMOBJTYPE_NOT_SPECIFIED); // at 0x34 + + virtual bool RemoveAnmObj(AnmObj* pObj); // at 0x38 + virtual AnmObj* RemoveAnmObj(AnmObjType type); // at 0x3C + virtual AnmObj* GetAnmObj(AnmObjType type); // at 0x40 virtual const AnmObj* GetAnmObj(AnmObjType type) const; // at 0x44 diff --git a/include/nw4r/g3d/g3d_scnmdlsmpl.h b/include/nw4r/g3d/g3d_scnmdlsmpl.h index 1191c333..db6be7df 100644 --- a/include/nw4r/g3d/g3d_scnmdlsmpl.h +++ b/include/nw4r/g3d/g3d_scnmdlsmpl.h @@ -5,7 +5,6 @@ #include #include #include - #include namespace nw4r { @@ -63,9 +62,13 @@ class ScnMdlSimple : public ScnLeaf { virtual bool SetScnObjOption(u32 option, u32 value); // at 0x20 virtual bool GetScnObjOption(u32 option, u32* pValue) const; // at 0x24 - virtual bool SetAnmObj(AnmObj* pObj, AnmObjType type); // at 0x34 - virtual bool RemoveAnmObj(AnmObj* pObj); // at 0x38 - virtual AnmObj* RemoveAnmObj(AnmObjType type); // at 0x3C + virtual bool + SetAnmObj(AnmObj* pObj, + AnmObjType type = ANMOBJTYPE_NOT_SPECIFIED); // at 0x34 + + virtual bool RemoveAnmObj(AnmObj* pObj); // at 0x38 + virtual AnmObj* RemoveAnmObj(AnmObjType type); // at 0x3C + virtual AnmObj* GetAnmObj(AnmObjType type); // at 0x40 virtual const AnmObj* GetAnmObj(AnmObjType type) const; // at 0x44 diff --git a/src/Pack/RPGraphics/RPGrpCamera.cpp b/src/Pack/RPGraphics/RPGrpCamera.cpp index b3b4bae2..6395fc38 100644 --- a/src/Pack/RPGraphics/RPGrpCamera.cpp +++ b/src/Pack/RPGraphics/RPGrpCamera.cpp @@ -6,9 +6,9 @@ #include /** - * @brief Camera with identity transform + * @brief Default camera */ -RPGrpCamera RPGrpCamera::IDENT; +RPGrpCamera RPGrpCamera::sDefaultCamera; /** * @brief Initializes the camera system @@ -156,7 +156,7 @@ void RPGrpCamera::CalcMatrix() { /** * @brief Saves the current state of the view matrix */ -void RPGrpCamera::SaveViewMatrix() { +void RPGrpCamera::SaveCameraMatrix() { nw4r::math::MTX34Copy(&mSavedViewMtx, &mViewMtx); } diff --git a/src/Pack/RPGraphics/RPGrpDrawPathManager.cpp b/src/Pack/RPGraphics/RPGrpDrawPathManager.cpp new file mode 100644 index 00000000..6d3aa5db --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpDrawPathManager.cpp @@ -0,0 +1,75 @@ +#include + +RPGrpDrawPathManager* +RPGrpDrawPathManager::Construct(u32 pathFlags, RPGrpModelScene* pModelScene) { + + return new RPGrpDrawPathManager(pathFlags, pModelScene); +} + +template <> +RPGrpDrawPathShadowTexture* +RPGrpDrawPath::Construct( + EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathShadowTexture(pRenderer); +} + +template <> +RPGrpDrawPathLightMap* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathLightMap(pRenderer); +} + +template <> +RPGrpDrawPathXluSnap* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathXluSnap(pRenderer); +} + +template <> +RPGrpDrawPathBloom* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathBloom(pRenderer); +} + +template <> +RPGrpDrawPathDOF* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathDOF(pRenderer); +} + +template <> +RPGrpDrawPathHDR* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathHDR(pRenderer); +} + +template <> +RPGrpDrawPathSV* +RPGrpDrawPath::Construct(EGG::ScnRenderer* pRenderer) { + + return new RPGrpDrawPathSV(pRenderer); +} + +// RPGrpDrawPathManager::RPGrpDrawPathManager(u32 pathFlags, +// RPGrpModelScene* pModelScene) +// : unkC(1), +// mpModelScene(pModelScene), +// unk14(0), +// mpDrawPathLightMap(NULL), +// mpDrawPathShadowTexture(NULL), +// mpDrawPathXluSnap(NULL), +// mpDrawPathSV(NULL), +// mpDrawPathHDR(NULL), +// mpDrawPathBloom(NULL), +// mpDrawPathDOF(NULL) { + +// if (pathFlags & EFlag_DrawPathSV) { +// mpDrawPathSV = RPGrpDrawPath::Construct() +// } +// } diff --git a/src/Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp b/src/Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp new file mode 100644 index 00000000..b8795d25 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpDrawPathShadowTexture.cpp @@ -0,0 +1,35 @@ +#include + +#include + +/** + * @brief Constructor + * + * @param pRenderer Scene renderer + */ +RPGrpDrawPathShadowTexture::RPGrpDrawPathShadowTexture( + EGG::ScnRenderer* pRenderer) + : RPGrpDrawPath(pRenderer) { + + mpShadowTextureManager = pRenderer->getShadowTextureManager(); +} + +/** + * @brief Inserts a new shadow texture + * + * @param idx Texture index + * @param pTexture Shadow texture + */ +void RPGrpDrawPathShadowTexture::SetTexture(u16 idx, + RPGrpShadowTexture* pTexture) { + mpShadowTextureManager->Set(idx, pTexture); +} + +/** + * @brief Appends a new shadow texture + * + * @param pTexture Shadow texture + */ +void RPGrpDrawPathShadowTexture::SetTexture(RPGrpShadowTexture* pTexture) { + mpShadowTextureManager->Append(pTexture); +} diff --git a/src/Pack/RPGraphics/RPGrpModelAnm.cpp b/src/Pack/RPGraphics/RPGrpModelAnm.cpp new file mode 100644 index 00000000..423bf399 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpModelAnm.cpp @@ -0,0 +1,150 @@ +#include + +RPGrpModelAnm::RPGrpModelAnm() + : mFlags(0), + unk54(1), + mpBlendIndices(NULL), + unk5C(0), + unk60(0.0f), + unk64(0.0f) {} + +void RPGrpModelAnm::Configure() { + for (int i = 0; i < Anm_Max; i++) { + mAnmNum[i] = 0; + mPrevPlayIndex[i] = -1; + mPlayIndex[i] = -1; + mpAnmFlags[i] = 0; + } +} + +void RPGrpModelAnm::CreateBuffer(Anm anm, u16 num) { + nw4r::g3d::AnmObj** ppAnmObjs = new nw4r::g3d::AnmObj*[num]; + mpAnmFlags[anm] = new u8[num]; + + for (int i = 0; i < num; i++) { + ppAnmObjs[i] = NULL; + mpAnmFlags[anm][i] = 0; + } + + mAnmNum[anm] = num; + SetAnmObj(anm, ppAnmObjs); + + if (anm == Anm_Chr) { + mpBlendIndices = new u8[num]; + + for (int i = 0; i < num; i++) { + mpBlendIndices[i] = 0; + } + } +} + +void RPGrpModelAnm::Calc() { + InternalCalc(); +} + +bool RPGrpModelAnm::Start(Anm anm, u16 idx, f32 frame) { + mPrevPlayIndex[anm] = mPlayIndex[anm]; + mPlayIndex[anm] = idx; + + mpAnmFlags[anm][idx] |= AnmFlag_Playing; + + SetFrame(anm, idx, frame); + SetUpdateRate(anm, idx, 1.0f); + + unk64 = 0.0f; + unk60 = 0.0f; + + if (anm == Anm_Chr) { + u8 blend = mpBlendIndices[idx]; + + SetBlendAnm(anm, 0, idx); + SetBlendWeight(anm, 0, 1.0f, blend); + } else if (anm == Anm_Shp) { + SetBlendAnm(anm, 0, idx); + SetBlendWeight(anm, 0, 1.0f, 0); + } + + return true; +} + +bool RPGrpModelAnm::StartNoBlend(Anm anm, u16 idx, f32 frame) { + bool success = Start(anm, idx, frame); + + if (anm == Anm_Chr) { + RemoveBlendAnm(anm, 1, mpBlendIndices[idx]); + } + + return success; +} + +bool RPGrpModelAnm::StartBlend(Anm anm, u16 idx, f32 weight, f32 frame) { + StartNoBlend(anm, idx, frame); + + s16 sVar1 = mPrevPlayIndex[anm]; + + if (idx != sVar1) { + unk64 = weight; + unk60 = weight; + + switch (anm) { + case Anm_Chr: { + if (weight > 0.0f && sVar1 != -1) { + SetBlendAnm(anm, 1, sVar1); + SetBlendWeight(anm, 1, 1.0f, 0); + } + + break; + } + + default: { + break; + } + } + + return true; + } + + return false; +} + +bool RPGrpModelAnm::Cancel(Anm anm, u16 idx) { + bool success = mpAnmFlags[anm][idx] & AnmFlag_Playing; + mpAnmFlags[anm][idx] &= ~AnmFlag_Playing; + return success; +} + +s16 RPGrpModelAnm::SetBlendAnm(Anm anm, u8 arg1, u16 idx) { + s16 uVar1 = GetBlendAnm(anm, arg1, 0); + + if (uVar1 != idx) { + s8 blendIdx = GetBlendIndex(anm, idx, 0); + + if (blendIdx != -1) { + RemoveBlendAnm(anm, blendIdx, 0); + } + + if (uVar1 != -1) { + RemoveBlendAnm(anm, arg1, 0); + } + + mpAnmFlags[anm][idx] |= 0x1; + } + + return uVar1; +} + +s8 RPGrpModelAnm::GetBlendIndex(Anm anm, AnmIdx idx, u8 blend) { + for (int i = 0; i < 8; i++) { + s16 blendAnm = GetBlendAnm(anm, i, blend); + + if (idx == blendAnm) { + return i; + } + } + + return -1; +} + +void RPGrpModelAnm::InternalRegist(Anm anm, u16 idx) { + mpAnmFlags[anm][idx] |= AnmFlag_Regist; +} diff --git a/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp b/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp new file mode 100644 index 00000000..93fab698 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp @@ -0,0 +1,1058 @@ +#include + +#include + +/****************************************************************************** + * + * RPGrpModelAnmG3D + * + ******************************************************************************/ + +//! Animation object type conversion table +// clang-format off +const nw4r::g3d::ScnMdlSimple::AnmObjType RPGrpModelAnmG3D::TO_G3D_TYPE[Anm_Max] = { + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_CHR, // Anm_Chr + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_MATCLR, // Anm_Clr + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_TEXPAT, // Anm_TexPat + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_TEXSRT, // Anm_TexSrt + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_VIS, // Anm_Vis + nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_SHP, // Anm_Shp +}; +// clang-format on + +//! Animation play policy conversion table +const RPGrpModelAnm::AnmPlayPolicy RPGrpModelAnmG3D::FROM_G3D_POLICY[] = { + AnmPlayPolicy_OneTime, // nw4r::g3d::ANM_POLICY_ONETIME + AnmPlayPolicy_Loop, // nw4r::g3d::ANM_POLICY_LOOP + AnmPlayPolicy_2, // ??? + AnmPlayPolicy_3, // ??? + AnmPlayPolicy_4, // ??? +}; + +void RPGrpModelAnmG3D::RegistFromResFile(Anm anm, AnmIdx idx, + RPGrpHandle handle, + const char* pName) { + InternalRegist(anm, idx); + + switch (anm) { + case Anm_Chr: { + const nw4r::g3d::ResAnmChr chr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmChr(idx, chr); + break; + } + + case Anm_Clr: { + const nw4r::g3d::ResAnmClr clr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmClr(idx, clr); + break; + } + + case Anm_TexPat: { + const nw4r::g3d::ResAnmTexPat pat = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, + pName); + + RegistAnmTexPat(idx, pat); + break; + } + + case Anm_TexSrt: { + const nw4r::g3d::ResAnmTexSrt srt = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, + pName); + + RegistAnmTexSrt(idx, srt); + break; + } + + case Anm_Vis: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_Shp: { + const nw4r::g3d::ResAnmShp shp = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmShp(idx, shp); + break; + } + + case Anm_6: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_7: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + RegistAnmVis(idx, vis); + break; + } + + default: { + break; + } + } +} + +void RPGrpModelAnmG3D::RegistFromResFile(Anm anm, AnmIdx idx, + RPGrpHandle handle, u32 id) { + InternalRegist(anm, idx); + + switch (anm) { + case Anm_Chr: { + const nw4r::g3d::ResAnmChr chr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmChr(idx, chr); + break; + } + + case Anm_Clr: { + const nw4r::g3d::ResAnmClr clr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmClr(idx, clr); + break; + } + + case Anm_TexPat: { + const nw4r::g3d::ResAnmTexPat pat = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmTexPat(idx, pat); + break; + } + + case Anm_TexSrt: { + const nw4r::g3d::ResAnmTexSrt srt = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmTexSrt(idx, srt); + break; + } + + case Anm_Vis: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_Shp: { + const nw4r::g3d::ResAnmShp shp = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmShp(idx, shp); + break; + } + + case Anm_6: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_7: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, id); + + RegistAnmVis(idx, vis); + break; + } + + default: { + break; + } + } +} + +void RPGrpModelAnmG3D::Init() { + mppAnmObjChrRes = NULL; + mppAnmObjMatClrRes = NULL; + mppAnmObjTexPatRes = NULL; + mppAnmObjTexSrtRes = NULL; + mppAnmObjVisRes = NULL; + mppAnmObjShpRes = NULL; + unk88 = NULL; + unk8C = NULL; + + for (int i = 0; i < Anm_Max; i++) { + unk90[i] = 0; + } + + mpChrBlendInfo = NULL; + mpShpBlendInfo = NULL; +} + +void RPGrpModelAnmG3D::SetAnmObj(Anm anm, nw4r::g3d::AnmObj** ppAnmObjs) { + switch (anm) { + case Anm_Chr: { + mppAnmObjChrRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_Clr: { + mppAnmObjMatClrRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_TexPat: { + mppAnmObjTexPatRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_TexSrt: { + mppAnmObjTexSrtRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_Vis: { + mppAnmObjVisRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_Shp: { + mppAnmObjShpRes = + reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_6: { + unk88 = reinterpret_cast(ppAnmObjs); + break; + } + + case Anm_7: { + unk8C = reinterpret_cast(ppAnmObjs); + break; + } + + default: { + break; + } + } + + InternalSetAnmObj(anm); +} + +nw4r::g3d::AnmObj* RPGrpModelAnmG3D::InternalGetAnmObj(Anm anm, + AnmIdx idx) const { + switch (anm) { + case Anm_Chr: { + return mppAnmObjChrRes[idx]; + } + + case Anm_Clr: { + return mppAnmObjMatClrRes[idx]; + } + + case Anm_TexPat: { + return mppAnmObjTexPatRes[idx]; + break; + } + + case Anm_TexSrt: { + return mppAnmObjTexSrtRes[idx]; + break; + } + + case Anm_Vis: { + return mppAnmObjVisRes[idx]; + break; + } + + case Anm_Shp: { + return mppAnmObjShpRes[idx]; + break; + } + + case Anm_6: { + return unk88[idx]; + break; + } + + case Anm_7: { + return unk8C[idx]; + break; + } + + default: { + return NULL; + } + } +} + +void RPGrpModelAnmG3D::VF_0x74(UNKTYPE) {} + +void RPGrpModelAnmG3D::Configure() { + RPGrpModelAnm::Configure(); + + for (int i = 0; i < Anm_Max; i++) { + unk90[i] = 0; + } + + mppAnmObjChrRes = NULL; + mppAnmObjMatClrRes = NULL; + mppAnmObjTexPatRes = NULL; + mppAnmObjTexSrtRes = NULL; + mppAnmObjVisRes = NULL; + mppAnmObjShpRes = NULL; + unk88 = NULL; + unk8C = NULL; + + mpChrBlendInfo = NULL; +#if defined(BUG_FIX) + mpShpBlendInfo = NULL; +#endif +} + +RPGrpModelAnmG3D::RPGrpModelAnmImplement(RPGrpModel* pModel) { + mpScnMdlSimple = pModel->GetScnMdlSimple(); + Init(); + + for (int i = 0; i < Anm_Max; i++) { + mpToIndexG3D[i] = NULL; + } +} + +void RPGrpModelAnmG3D::InternalSetAnmObj(Anm anm) { + mpToIndexG3D[anm] = new s8[GetAnmNum(anm)]; + + for (int i = 0; i < GetAnmNum(anm); i++) { + mpToIndexG3D[anm][i] = -1; + } + + switch (anm) { + case Anm_Chr: { + // TODO(kiwi) Why only one? SetBlendWeight could write way out of bounds + mpChrBlendInfo = new ChrBlendInfo[1]; + + mpChrBlendInfo[0].pAnmObj = nw4r::g3d::AnmObjChrBlend::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl(), 8); + + for (int i = 0; i < 8; i++) { + mpChrBlendInfo[0].toAnmIdx[i] = -1; + } + break; + } + + case Anm_Clr: { + if (GetAnmNum(Anm_Clr) >= 2) { + + mpAnmObjMatClrOverride = nw4r::g3d::AnmObjMatClrOverride::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl(), + GetAnmNum(Anm_Clr)); + + mpAnmObjMatClrOverride->Bind(mpScnMdlSimple->GetResMdl()); + mpScnMdlSimple->SetAnmObj(mpAnmObjMatClrOverride); + } else { + mpAnmObjMatClrOverride = NULL; + } + break; + } + + case Anm_TexPat: { + if (GetAnmNum(Anm_TexPat) >= 2) { + + mpAnmObjTexPatOverride = nw4r::g3d::AnmObjTexPatOverride::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl(), + GetAnmNum(Anm_TexPat)); + + mpAnmObjTexPatOverride->Bind(mpScnMdlSimple->GetResMdl()); + mpScnMdlSimple->SetAnmObj(mpAnmObjTexPatOverride); + } else { + mpAnmObjTexPatOverride = NULL; + } + break; + } + + case Anm_TexSrt: { + if (GetAnmNum(Anm_TexSrt) >= 2) { + + mpAnmObjTexSrtOverride = nw4r::g3d::AnmObjTexSrtOverride::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl(), + GetAnmNum(Anm_TexSrt)); + + mpAnmObjTexSrtOverride->Bind(mpScnMdlSimple->GetResMdl()); + mpScnMdlSimple->SetAnmObj(mpAnmObjTexSrtOverride); + } else { + mpAnmObjTexSrtOverride = NULL; + } + break; + } + + case Anm_Vis: { + if (GetAnmNum(Anm_Vis) >= 2) { + + mpAnmObjVisOR = nw4r::g3d::AnmObjVisOR::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl()); + + mpAnmObjVisOR->Bind(mpScnMdlSimple->GetResMdl()); + mpScnMdlSimple->SetAnmObj(mpAnmObjVisOR); + } else { + mpAnmObjVisOR = NULL; + } + break; + } + + case Anm_Shp: { + // TODO(kiwi) Why only one? SetBlendWeight could write way out of bounds + mpShpBlendInfo = new ShpBlendInfo[1]; + + mpShpBlendInfo[0].pAnmObj = nw4r::g3d::AnmObjShpBlend::Construct( + RPGrpModel::GetAllocator(), NULL, mpScnMdlSimple->GetResMdl(), 8); + + mpShpBlendInfo[0].pAnmObj->Bind(mpScnMdlSimple->GetResMdl()); + mpScnMdlSimple->SetAnmObj(mpShpBlendInfo[0].pAnmObj); + + for (int i = 0; i < 8; i++) { + mpShpBlendInfo[0].toAnmIdx[i] = -1; + } + break; + } + + default: { + break; + } + } +} + +void RPGrpModelAnmG3D::Regist(Anm anm, AnmIdx idx, RPGrpHandle handle) { + InternalRegist(anm, idx); + + switch (anm) { + case Anm_Chr: { + const nw4r::g3d::ResAnmChr chr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmChr(idx, chr); + break; + } + + case Anm_Clr: { + const nw4r::g3d::ResAnmClr clr = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmClr(idx, clr); + break; + } + + case Anm_TexPat: { + const nw4r::g3d::ResAnmTexPat pat = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmTexPat(idx, pat); + break; + } + + case Anm_TexSrt: { + const nw4r::g3d::ResAnmTexSrt srt = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmTexSrt(idx, srt); + break; + } + + case Anm_Vis: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_Shp: { + const nw4r::g3d::ResAnmShp shp = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmShp(idx, shp); + break; + } + + case Anm_6: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmVis(idx, vis); + break; + } + + case Anm_7: { + const nw4r::g3d::ResAnmVis vis = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + RegistAnmVis(idx, vis); + break; + } + + default: { + break; + } + } +} + +bool RPGrpModelAnmG3D::Start(Anm anm, AnmIdx idx, f32 frame) { + if (anm != Anm_Chr && anm != Anm_Shp) { + mpAnmFlags[anm][idx] |= AnmFlag_PlayingG3D; + + if (GetAnmNum(anm) >= 2) { + switch (anm) { + case Anm_Clr: { + u8 g3dIdx = 0; + mpAnmObjMatClrOverride->DetachAll(); + + for (int i = 0; i < GetAnmNum(Anm_Clr); i++) { + if (!IsPlayingG3D(Anm_Clr, i)) { + continue; + } + + mpAnmObjMatClrOverride->Attach(g3dIdx, + mppAnmObjMatClrRes[i]); + mpToIndexG3D[Anm_Clr][idx] = g3dIdx++; + } + break; + } + + case Anm_TexPat: { + u8 g3dIdx = 0; + mpAnmObjTexPatOverride->DetachAll(); + + for (int i = 0; i < GetAnmNum(Anm_TexPat); i++) { + if (!IsPlayingG3D(Anm_TexPat, i)) { + continue; + } + + mpAnmObjTexPatOverride->Attach(g3dIdx, + mppAnmObjTexPatRes[i]); + mpToIndexG3D[Anm_TexPat][idx] = g3dIdx++; + } + break; + } + + case Anm_TexSrt: { + u8 g3dIdx = 0; + mpAnmObjTexSrtOverride->DetachAll(); + + for (int i = 0; i < GetAnmNum(Anm_TexSrt); i++) { + if (!IsPlayingG3D(Anm_TexSrt, i)) { + continue; + } + + mpAnmObjTexSrtOverride->Attach(g3dIdx, + mppAnmObjTexSrtRes[i]); + mpToIndexG3D[Anm_TexSrt][idx] = g3dIdx++; + } + break; + } + + case Anm_Vis: { + u8 g3dIdx = 0; + mpAnmObjVisOR->DetachAll(); + + for (int i = 0; i < GetAnmNum(Anm_Vis); i++) { + if (!IsPlayingG3D(Anm_Vis, i)) { + continue; + } + + mpAnmObjVisOR->Attach(g3dIdx, mppAnmObjVisRes[i]); + mpToIndexG3D[Anm_Vis][idx] = g3dIdx++; + } + break; + } + + default: { + break; + } + } + + } else if (anm != Anm_Chr && anm != Anm_Shp) { + nw4r::g3d::AnmObj* pAnmObj = InternalGetAnmObj(anm, idx); + + if (pAnmObj != mpScnMdlSimple->GetAnmObj(TO_G3D_TYPE[anm])) { + mpScnMdlSimple->RemoveAnmObj(TO_G3D_TYPE[anm]); + mpScnMdlSimple->SetAnmObj(pAnmObj); + } + } + } + + return RPGrpModelAnm::Start(anm, idx, frame); +} + +bool RPGrpModelAnmG3D::Cancel(Anm anm, AnmIdx idx) { + bool success = RPGrpModelAnm::Cancel(anm, idx); + + if (!success) { + return false; + } + + if (anm == Anm_Chr || anm == Anm_Shp) { + s8 blendIdx = GetBlendIndex(anm, idx, 0); + + if (blendIdx != -1) { + RemoveBlendAnm(anm, blendIdx, 0); + } + + } else if (IsPlayingG3D(anm, idx)) { + mpAnmFlags[anm][idx] &= ~AnmFlag_PlayingG3D; + + if (GetAnmNum(anm) >= 2) { + switch (anm) { + case Anm_Clr: { + mpAnmObjMatClrOverride->Detach(mpToIndexG3D[Anm_Clr][idx]); + break; + } + + case Anm_TexPat: { + mpAnmObjTexPatOverride->Detach(mpToIndexG3D[Anm_TexPat][idx]); + break; + } + + case Anm_TexSrt: { + mpAnmObjTexSrtOverride->Detach(mpToIndexG3D[Anm_TexSrt][idx]); + break; + } + + case Anm_Vis: { + mpAnmObjVisOR->Detach(mpToIndexG3D[Anm_Vis][idx]); + break; + } + + default: { + break; + } + } + + mpToIndexG3D[anm][idx] = -1; + + } else { + // @bug Messed up the expression somehow? +#if defined(BUG_FIX) + success = mpScnMdlSimple->RemoveAnmObj(TO_G3D_TYPE[anm]) != NULL; +#else + mpScnMdlSimple->RemoveAnmObj(TO_G3D_TYPE[anm]); + success = success != 0; +#endif + } + + } else { + success = false; + } + + return success; +} + +s16 RPGrpModelAnmG3D::SetBlendAnm(Anm anm, u8 arg1, AnmIdx idx) { + s16 uVar1 = RPGrpModelAnm::SetBlendAnm(anm, arg1, idx); + + if (uVar1 != idx) { + switch (anm) { + case Anm_Chr: { + mpChrBlendInfo[0].pAnmObj->Attach(arg1, mppAnmObjChrRes[idx]); + mpChrBlendInfo[0].toAnmIdx[arg1] = idx; + + if (IsEnableChrAnm() && + mpChrBlendInfo[0].pAnmObj->GetParent() == NULL) { + + mpScnMdlSimple->SetAnmObj(mpChrBlendInfo[0].pAnmObj); + } + break; + } + + case Anm_Shp: { + mpShpBlendInfo[0].pAnmObj->Attach(arg1, mppAnmObjShpRes[idx]); + mpShpBlendInfo[0].toAnmIdx[arg1] = idx; + break; + } + + default: { + break; + } + } + } + + return uVar1; +} + +void RPGrpModelAnmG3D::SetBlendWeight(Anm anm, u8 g3dIndex, f32 weight, + u8 blendIdx) { + switch (anm) { + case Anm_Chr: { + mpChrBlendInfo[blendIdx].pAnmObj->SetWeight(g3dIndex, weight); + break; + } + + case Anm_Shp: { + mpShpBlendInfo[blendIdx].pAnmObj->SetWeight(g3dIndex, weight); + break; + } + + default: { + break; + } + } +} + +s16 RPGrpModelAnmG3D::RemoveBlendAnm(Anm anm, u8 arg1, u8 arg2) { + s16 idx = GetBlendAnm(anm, arg1, arg2); + + if (idx != -1) { + mpAnmFlags[anm][static_cast(idx)] &= ~AnmFlag_PlayingG3D; + + switch (anm) { + case Anm_Chr: { + mpChrBlendInfo[arg2].pAnmObj->Detach(arg1); + mpChrBlendInfo[arg2].toAnmIdx[arg1] = -1; + break; + } + + case Anm_Shp: { + mpShpBlendInfo[arg2].pAnmObj->Detach(arg1); + mpShpBlendInfo[arg2].toAnmIdx[arg1] = -1; + break; + } + + default: { + break; + } + } + } + + return idx; +} + +s16 RPGrpModelAnmG3D::GetBlendAnm(Anm anm, u8 arg1, u8 arg2) { + switch (anm) { + case Anm_Chr: { + return mpChrBlendInfo[arg2].toAnmIdx[arg1]; + } + + case Anm_Shp: { + return mpShpBlendInfo[arg2].toAnmIdx[arg1]; + } + + default: { + return -1; + } + } +} + +f32 RPGrpModelAnmG3D::GetBlendWeight(Anm anm, u8 arg1, u8 arg2) { + switch (anm) { + case Anm_Chr: { + return mpChrBlendInfo[arg2].pAnmObj->GetWeight(arg1); + } + + case Anm_Shp: { + return mpShpBlendInfo[arg2].pAnmObj->GetWeight(arg1); + } + + default: { + return 0.0f; + } + } +} + +// clang-format off +static nw4r::g3d::AnmObjChr::BindOption TO_BIND_OPTION[RPGrpModelAnm::BindType_Max] = { + nw4r::g3d::AnmObjChr::BIND_ONE, // BindType_One + nw4r::g3d::AnmObjChr::BIND_PARTIAL, // BindType_Partial +}; +// clang-format on + +void RPGrpModelAnmG3D::ReBindChrAnmNode(u16 arg0, u16 arg1, BindType type) { + mppAnmObjChrRes[arg0]->Release(); + mppAnmObjChrRes[arg0]->Bind(mpScnMdlSimple->GetResMdl(), arg1, + TO_BIND_OPTION[type]); +} + +void RPGrpModelAnmG3D::ReleaseChrAnmNode(u16 arg0, u16 arg1, BindType type) { + mppAnmObjChrRes[arg0]->Release(mpScnMdlSimple->GetResMdl(), arg1, + TO_BIND_OPTION[type]); +} + +void RPGrpModelAnmG3D::UpdateFrame() { + for (int i = 0; i < Anm_Max; i++) { + if (i == Anm_Chr && IsBlending(Anm_Chr) && IsEnableChrAnm()) { + s16 idx = GetBlendAnm(Anm_Chr, 0, 0); + f32 rate = GetUpdateRate(Anm_Chr, idx); + + rate = unk60 - nw4r::math::FAbs(rate); + unk60 = rate; + + if (rate <= 0.0f) { + unk64 = 0.0f; + unk60 = 0.0f; + + SetBlendWeight(Anm_Chr, 0, 1.0f, 0); + RemoveBlendAnm(Anm_Chr, 1, 0); + } else { + f32 weight = rate / unk64; + SetBlendWeight(Anm_Chr, 0, 1.0f - weight, 0); + SetBlendWeight(Anm_Chr, 1, weight, 0); + } + } + } +} + +void RPGrpModelAnmG3D::InternalCalc() {} + +void RPGrpModelAnmG3D::SetEnableQuaternionBlend(bool enable) { + RPGrpModelAnm::SetEnableQuaternionBlend(enable); + + mpChrBlendInfo[0].pAnmObj->SetAnmFlag( + nw4r::g3d::AnmObj::FLAG_USE_QUATERNION_ROTATION_BLEND, + IsEnableQuaternionBlend()); +} + +void RPGrpModelAnmG3D::SetEnableChrAnm(bool enable) { + RPGrpModelAnm::SetEnableChrAnm(enable); + + if (IsEnableChrAnm()) { + if (mpChrBlendInfo[0].pAnmObj->GetParent() == NULL && + mpChrBlendInfo[0].pAnmObj->TestAnmFlag( + nw4r::g3d::AnmObj::FLAG_ANM_BOUND)) { + + mpScnMdlSimple->SetAnmObj(mpChrBlendInfo[0].pAnmObj); + } + } else if (mpChrBlendInfo[0].pAnmObj->GetParent() != NULL) { + mpScnMdlSimple->RemoveAnmObj(mpChrBlendInfo[0].pAnmObj); + } +} + +void RPGrpModelAnmG3D::VF_0x70(UNKTYPE) {} + +void RPGrpModelAnmG3D::RegistAnmChr(AnmIdx idx, + const nw4r::g3d::ResAnmChr chr) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjChrRes[idx] = nw4r::g3d::AnmObjChrRes::Construct( + RPGrpModel::GetAllocator(), &size, chr, mdl, false); + + mppAnmObjChrRes[idx]->Bind(mdl); +} + +void RPGrpModelAnmG3D::RegistAnmClr(AnmIdx idx, + const nw4r::g3d::ResAnmClr clr) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjMatClrRes[idx] = nw4r::g3d::AnmObjMatClrRes::Construct( + RPGrpModel::GetAllocator(), &size, clr, mdl, false); + + mppAnmObjMatClrRes[idx]->Bind(mdl); +} + +void RPGrpModelAnmG3D::RegistAnmTexPat(AnmIdx idx, + const nw4r::g3d::ResAnmTexPat pat) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjTexPatRes[idx] = nw4r::g3d::AnmObjTexPatRes::Construct( + RPGrpModel::GetAllocator(), &size, pat, mdl, false); + + mppAnmObjTexPatRes[idx]->Bind(mdl); +} + +void RPGrpModelAnmG3D::RegistAnmTexSrt(AnmIdx idx, + const nw4r::g3d::ResAnmTexSrt srt) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjTexSrtRes[idx] = nw4r::g3d::AnmObjTexSrtRes::Construct( + RPGrpModel::GetAllocator(), &size, srt, mdl, false); + + mppAnmObjTexSrtRes[idx]->Bind(mdl); +} + +void RPGrpModelAnmG3D::RegistAnmVis(AnmIdx idx, + const nw4r::g3d::ResAnmVis vis) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjVisRes[idx] = nw4r::g3d::AnmObjVisRes::Construct( + RPGrpModel::GetAllocator(), &size, vis, mdl); + + mppAnmObjVisRes[idx]->Bind(mdl); +} + +void RPGrpModelAnmG3D::RegistAnmShp(AnmIdx idx, + const nw4r::g3d::ResAnmShp chr) { + const nw4r::g3d::ResMdl mdl = mpScnMdlSimple->GetResMdl(); + + u32 size; + mppAnmObjShpRes[idx] = nw4r::g3d::AnmObjShpRes::Construct( + RPGrpModel::GetAllocator(), &size, chr, mdl, false); + + mppAnmObjShpRes[idx]->Bind(mdl); +} + +f32 RPGrpModelAnmG3D::VF_0x44(UNKTYPE) { + return 0.0f; +} + +f32 RPGrpModelAnmG3D::VF_0x48(UNKTYPE) { + return 0.0f; +} + +int RPGrpModelAnmG3D::GetNumFrame(Anm anm, AnmIdx idx) const { + switch (anm) { + case Anm_Chr: { + return mppAnmObjChrRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_Clr: { + return mppAnmObjMatClrRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_TexPat: { + return mppAnmObjTexPatRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_TexSrt: { + return mppAnmObjTexSrtRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_Vis: { + return mppAnmObjVisRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_Shp: { + return mppAnmObjShpRes[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_6: { + return unk88[idx]->GetResAnm().GetNumFrame(); + } + + case Anm_7: { + return unk8C[idx]->GetResAnm().GetNumFrame(); + } + + default: { + return 0; + } + } +} + +RPGrpModelAnmG3D::AnmPlayPolicy +RPGrpModelAnmG3D::GetAnmPlayPolicy(Anm anm, AnmIdx idx) const { + nw4r::g3d::AnmPolicy policy; + + switch (anm) { + case Anm_Chr: { + policy = mppAnmObjChrRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_Clr: { + policy = mppAnmObjMatClrRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_TexPat: { + policy = mppAnmObjTexPatRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_TexSrt: { + policy = mppAnmObjTexSrtRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_Vis: { + policy = mppAnmObjVisRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_Shp: { + policy = mppAnmObjShpRes[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_6: { + policy = unk88[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + case Anm_7: { + policy = unk8C[idx]->GetResAnm().GetAnmPolicy(); + break; + } + + // @bug Policy variable is possibly uninitialized +#if defined(BUG_FIX) + default: { + policy = nw4r::g3d::ANM_POLICY_ONETIME; + break; + } +#endif + } + + return FROM_G3D_POLICY[policy]; +} + +void RPGrpModelAnmG3D::SetFrame(Anm anm, AnmIdx idx, f32 frame) { + GetAnmObj(anm, idx)->SetFrame(frame); +} + +f32 RPGrpModelAnmG3D::GetFrame(Anm anm, AnmIdx idx) const { + return GetAnmObj(anm, idx)->GetFrame(); +} + +void RPGrpModelAnmG3D::SetUpdateRate(Anm anm, AnmIdx idx, f32 rate) { + GetAnmObj(anm, idx)->SetUpdateRate(rate); +} + +nw4r::g3d::AnmObj* RPGrpModelAnmG3D::GetAnmObj(Anm anm, AnmIdx idx) const { + return InternalGetAnmObj(anm, idx); +} + +f32 RPGrpModelAnmG3D::GetUpdateRate(Anm anm, AnmIdx idx) const { + return GetAnmObj(anm, idx)->GetUpdateRate(); +} diff --git a/src/Pack/RPGraphics/RPGrpProjectionObject.cpp b/src/Pack/RPGraphics/RPGrpProjectionObject.cpp new file mode 100644 index 00000000..09b0fad5 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpProjectionObject.cpp @@ -0,0 +1,26 @@ +#include + +#include + +RPGrpProjectionObject::RPGrpProjectionObject(u8 viewNo) : mViewNo(viewNo) { + mCamera.Identity(); + mCamera.SetCameraType(RPGrpCamera::ECameraType_Anm); +} + +void RPGrpProjectionObject::Calc(nw4r::g3d::Camera cam) { + mCamera.CalcMatrix(); + mCamera.SaveCameraMatrix(); + + cam.SetCameraMtxDirectly(mCamera.GetSavedCameraMatrix()); + mScreen.CopyToG3D(cam); +} + +void RPGrpProjectionObject::LoadScnCamera(RPGrpHandle handle, const char* pName, + f32 frame) { + const nw4r::g3d::ResAnmScn scn = + RPGrpModelResManager::GetCurrent() + ->GetData(handle, pName); + + mCamera.LoadScnCameraMatrix(scn, mViewNo, frame); + mScreen.LoadScnCamera(scn, mViewNo, frame); +} diff --git a/src/Pack/RPGraphics/RPGrpScreen.cpp b/src/Pack/RPGraphics/RPGrpScreen.cpp index 4191fdcf..d79b32a8 100644 --- a/src/Pack/RPGraphics/RPGrpScreen.cpp +++ b/src/Pack/RPGraphics/RPGrpScreen.cpp @@ -2,6 +2,7 @@ #include +<<<<<<< HEAD RPGrpScreen RPGrpScreen::g_default_screen; void RPGrpScreen::Initialize(const u16 maxX[TV_MODE_MAX], @@ -37,4 +38,108 @@ void RPGrpScreen::DrawQuadTexture(f32 x, f32 y, f32 width, f32 height, CalcMatrixForDrawQuad(&mtx, x, y, nw4r::math::FAbs(width - x), nw4r::math::FAbs(height - y)); EGG::DrawGX::DrawDL(EGG::DrawGX::DL_SCREEN_TEXTURE, mtx, colorTemp); +======= +/** + * @brief Screen hierarchy root + */ +RPGrpScreen RPGrpScreen::sRootScreen; + +/** + * @brief Initializes the screen system + * + * @param maxX Screen width limits for all TV modes + * @param maxY Screen height limits for all TV modes + */ +void RPGrpScreen::Initialize(const u16 maxX[TV_MODE_MAX], + const u16 maxY[TV_MODE_MAX]) { + + EGG::Screen::Initialize(maxX, maxY, &sRootScreen); +} + +/** + * @brief Configures the GX rendering state to draw a quad + */ +void RPGrpScreen::BeginDrawQuad() const { + EGG::DrawGX::BeginDrawScreen(mCanvasMode == CANVASMODE_LU, false, false); +} + +/** + * @brief Draws a colored quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param color Fill color + */ +void RPGrpScreen::DrawQuad(f32 x1, f32 y1, f32 x2, f32 y2, + GXColor color) const { + nw4r::math::MTX34 mtx; + CalcMatrixForDrawQuad(&mtx, x1, y1, nw4r::math::FAbs(x2 - x1), + nw4r::math::FAbs(y2 - y1)); + + EGG::DrawGX::DrawScreen(mtx, color); +} + +/** + * @brief Configures the GX rendering state to draw a textured quad + * + * @param alpha Whether to enable the raster alpha channel + */ +void RPGrpScreen::BeginDrawQuadTexture(bool alpha) const { + EGG::DrawGX::BeginDrawScreen(mCanvasMode == CANVASMODE_LU, true, alpha); +} + +/** + * @brief Draws a textured quad to this screen + * @details It is assumed the texture has already been loaded to GX_TEXMAP0. + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param color Material color + */ +void RPGrpScreen::DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, + GXColor color) const { + nw4r::math::MTX34 mtx; + CalcMatrixForDrawQuad(&mtx, x1, y1, nw4r::math::FAbs(x2 - x1), + nw4r::math::FAbs(y2 - y1)); + + EGG::DrawGX::DrawScreenTexture(mtx, color); +} + +/** + * @brief Draws a textured quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param rTexture Fill texture + * @param color Material color + */ +void RPGrpScreen::DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, + const RPGrpTexture& rTexture, + GXColor color) const { + GXLoadTexObj(&rTexture.GetTexObj(), GX_TEXMAP0); + DrawQuadTexture(x1, y1, x2, y2, color); +} + +/** + * @brief Draws a textured quad to this screen + * + * @param x1 Left point of the quad + * @param y1 Top point of the quad + * @param x2 Right point of the quad + * @param y2 Bottom point of the quad + * @param pResTIMG Fill texture + * @param color Material color + */ +void RPGrpScreen::DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, + const EGG::ResTIMG* pResTIMG, + GXColor color) const { + RPGrpTexture texture(pResTIMG); + DrawQuadTexture(x1, y1, x2, y2, texture, color); +>>>>>>> 082cf7d8 (temp) } diff --git a/src/Pack/RPGraphics/RPGrpShadowTexture.cpp b/src/Pack/RPGraphics/RPGrpShadowTexture.cpp new file mode 100644 index 00000000..59f28df6 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpShadowTexture.cpp @@ -0,0 +1,49 @@ +#include + +#include + +/** + * @brief Replaces a texture on the specified model + * + * @param pModel Target model + * @param pName Texture name (format string) + * @param ... Format string arguments + */ +void RPGrpShadowTexture::Replace(RPGrpModel* pModel, const char* pName, ...) { + char buffer[256]; + + std::va_list list; + va_start(list, pName); + + // @bug Unsafe string operations +#if defined(BUG_FIX) + std::vsnprintf(buffer, sizeof(buffer), pName, list); +#else + std::vsprintf(buffer, pName, list); +#endif + + EGG::ShadowTexture::Replace(pModel->GetModelEx(), buffer); + + va_end(list); +} + +/** + * @brief Adds a new model to the shadow texture + * + * @param pModel Model + * @param density Model density + */ +void RPGrpShadowTexture::AddModel(RPGrpModel* pModel, f32 density) { + AddModelEx(pModel->GetModelEx(), density); +} + +/** + * @brief Adds a new model with materials to the shadow texture + * + * @param pModel Model + * @param density Model density + */ +void RPGrpShadowTexture::AddModelUseMaterial(RPGrpModel* pModel, f32 density) { + AddModelEx(pModel->GetModelEx(), density); + GetModelBind(GetModelNum() - 1)->useMat = true; +} diff --git a/src/egg/gfxe/eggDrawGX.cpp b/src/egg/gfxe/eggDrawGX.cpp index 00bf582c..25f9decf 100644 --- a/src/egg/gfxe/eggDrawGX.cpp +++ b/src/egg/gfxe/eggDrawGX.cpp @@ -503,7 +503,9 @@ void DrawGX::ClearEfb(const nw4r::math::MTX34& rMtx, bool colorUpdate, SetBlendMode(BLEND_NONE); SetVtxState(lu ? VTX_TYPE_SCREEN_TEXTURE_LU : VTX_TYPE_SCREEN_TEXTURE); - DrawScreenTexture(rMtx); + + GXLoadPosMtxImm(rMtx, GX_PNMTX0); + DrawScreenTexture(); if (texture) { GXSetZTexture(GX_ZT_DISABLE, GX_TF_Z24X8, 0); diff --git a/src/egg/gfxe/eggPostEffectBase.cpp b/src/egg/gfxe/eggPostEffectBase.cpp index 932da51b..70484375 100644 --- a/src/egg/gfxe/eggPostEffectBase.cpp +++ b/src/egg/gfxe/eggPostEffectBase.cpp @@ -52,7 +52,8 @@ void PostEffectBase::drawScreenInternal(f32 x, f32 y, f32 w, f32 h) { PSMTXScale(mtx, w, h, 1.0f); PSMTXTransApply(mtx, mtx, x, y, 0.0f); - DrawGX::DrawScreenTexture(mtx); + GXLoadPosMtxImm(mtx, GX_PNMTX0); + DrawGX::DrawScreenTexture(); } void PostEffectBase::loadTextureInternal() { diff --git a/src/egg/gfxe/eggShadowTextureManager.cpp b/src/egg/gfxe/eggShadowTextureManager.cpp index c4541b14..4281ed1b 100644 --- a/src/egg/gfxe/eggShadowTextureManager.cpp +++ b/src/egg/gfxe/eggShadowTextureManager.cpp @@ -10,7 +10,7 @@ namespace EGG { ShadowTextureManager::ShadowTextureManager() : - mFlags(SHADOW_MGR_ACTIVE), + mFlags(SHADOW_MGR_ENABLE), mFreeGroup(GROUP_MAX), mShadowIdx(0) { @@ -52,7 +52,7 @@ namespace EGG void ShadowTextureManager::Calc() { - if (!IsActive()) return; + if (!IsEnable()) return; mShadowIdx = 0; for (int i = 0; i < GROUP_MAX; i++) @@ -67,7 +67,7 @@ namespace EGG void ShadowTextureManager::Draw(Screen *screen) { - if (!IsActive() || mShadowIdx == 0) return; + if (!IsEnable() || mShadowIdx == 0) return; StateGX::ScopedDitherUpdate dither(true); From 28d68263079f29aa1df950c9b77c9b6bd2c20d8b Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 12:29:41 -0400 Subject: [PATCH 12/14] a --- include/Pack/RPGraphics/RPGrpScreen.h | 52 ------------------- .../RPGraphics/RPGrpModelAnmImplement.cpp | 6 +-- src/Pack/RPGraphics/RPGrpScreen.cpp | 38 -------------- 3 files changed, 3 insertions(+), 93 deletions(-) diff --git a/include/Pack/RPGraphics/RPGrpScreen.h b/include/Pack/RPGraphics/RPGrpScreen.h index 145592dd..88df0b65 100644 --- a/include/Pack/RPGraphics/RPGrpScreen.h +++ b/include/Pack/RPGraphics/RPGrpScreen.h @@ -7,12 +7,9 @@ //! @addtogroup rp_graphics //! @{ -<<<<<<< HEAD -======= // Forward declarations class RPGrpTexture; ->>>>>>> 082cf7d8 (temp) /** * @brief Screen rendering surface */ @@ -55,27 +52,6 @@ class RPGrpScreen : public EGG::Screen { void BeginDrawQuad() const; /** -<<<<<<< HEAD - * @brief Sets up the screen to draw a solid color quad. - */ - void BeginDrawQuad() const; - - /** - * @brief Draws a solid color quad to the screen - * - * @param x Quad X position - * @param y Quad Y position - * @param width Quad width - * @param height Quad height - * @param color Quad color - */ - void DrawQuad(f32 x, f32 y, f32 width, f32 height, GXColor color); - - /** - * @brief Sets up the screen to draw a texture quad. - * - * @param alpha Does the texture have an alpha channel -======= * @brief Draws a colored quad to this screen * * @param x1 Left point of the quad @@ -90,37 +66,10 @@ class RPGrpScreen : public EGG::Screen { * @brief Configures the GX rendering state to draw a textured quad * * @param alpha Whether to enable the raster alpha channel ->>>>>>> 082cf7d8 (temp) */ void BeginDrawQuadTexture(bool alpha) const; /** -<<<<<<< HEAD - * @brief Draws a texture on a quad to the screen - * - * @param x Quad X position - * @param y Quad Y position - * @param width Quad width - * @param height Quad height - * @param pTextureRes Texture image resource - * @param color Quad color - */ - void DrawQuadTexture(f32 x, f32 y, f32 width, f32 height, - EGG::ResTIMG* pTextureRes, GXColor color); - - /** - * @brief Initalizes the default screen. - * - * @param maxX Maximum X - * @param maxY Maximun Y - */ - static void Initialize(const u16 maxX[TV_MODE_MAX], - const u16 maxY[TV_MODE_MAX]); - -public: - //! Default screen settings - static RPGrpScreen g_default_screen; -======= * @brief Draws a textured quad to this screen * @details It is assumed the texture has already been loaded to GX_TEXMAP0. * @@ -168,7 +117,6 @@ class RPGrpScreen : public EGG::Screen { private: //! Screen hierarchy root static RPGrpScreen sRootScreen; ->>>>>>> 082cf7d8 (temp) }; //! @} diff --git a/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp b/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp index 93fab698..c6c869bc 100644 --- a/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp +++ b/src/Pack/RPGraphics/RPGrpModelAnmImplement.cpp @@ -1025,13 +1025,13 @@ RPGrpModelAnmG3D::GetAnmPlayPolicy(Anm anm, AnmIdx idx) const { break; } - // @bug Policy variable is possibly uninitialized -#if defined(BUG_FIX) default: { + // @bug Policy variable is possibly uninitialized +#if defined(BUG_FIX) policy = nw4r::g3d::ANM_POLICY_ONETIME; +#endif break; } -#endif } return FROM_G3D_POLICY[policy]; diff --git a/src/Pack/RPGraphics/RPGrpScreen.cpp b/src/Pack/RPGraphics/RPGrpScreen.cpp index d79b32a8..ed5c4184 100644 --- a/src/Pack/RPGraphics/RPGrpScreen.cpp +++ b/src/Pack/RPGraphics/RPGrpScreen.cpp @@ -2,43 +2,6 @@ #include -<<<<<<< HEAD -RPGrpScreen RPGrpScreen::g_default_screen; - -void RPGrpScreen::Initialize(const u16 maxX[TV_MODE_MAX], - const u16 maxY[TV_MODE_MAX]) { - EGG::Screen::Initialize(maxX, maxY, &g_default_screen); -} - -void RPGrpScreen::BeginDrawQuad() const { - EGG::DrawGX::BeginDrawScreen(GetCanvasMode() == CANVASMODE_LU, false, - false); -} - -void RPGrpScreen::DrawQuad(f32 x, f32 y, f32 width, f32 height, GXColor color) { - nw4r::math::MTX34 mtx; - - CalcMatrixForDrawQuad(&mtx, x, y, nw4r::math::FAbs(width - x), - nw4r::math::FAbs(height - y)); - EGG::DrawGX::DrawDL(EGG::DrawGX::DL_SCREEN, mtx, color); -} - -void RPGrpScreen::BeginDrawQuadTexture(bool alpha) const { - EGG::DrawGX::BeginDrawScreen(GetCanvasMode() == CANVASMODE_LU, true, alpha); -} - -void RPGrpScreen::DrawQuadTexture(f32 x, f32 y, f32 width, f32 height, - EGG::ResTIMG* pTextureRes, GXColor color) { - RPGrpTexture tex = RPGrpTexture(pTextureRes); - nw4r::math::MTX34 mtx; - - GXColor colorTemp = color; - - GXLoadTexObj(&tex.GetTexObj(), GX_TEXMAP0); - CalcMatrixForDrawQuad(&mtx, x, y, nw4r::math::FAbs(width - x), - nw4r::math::FAbs(height - y)); - EGG::DrawGX::DrawDL(EGG::DrawGX::DL_SCREEN_TEXTURE, mtx, colorTemp); -======= /** * @brief Screen hierarchy root */ @@ -141,5 +104,4 @@ void RPGrpScreen::DrawQuadTexture(f32 x1, f32 y1, f32 x2, f32 y2, GXColor color) const { RPGrpTexture texture(pResTIMG); DrawQuadTexture(x1, y1, x2, y2, texture, color); ->>>>>>> 082cf7d8 (temp) } From dee541e4f804d647f2176a81905a93966db37967 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 12:33:51 -0400 Subject: [PATCH 13/14] Update RPGrpModelMisc.cpp --- src/Pack/RPGraphics/RPGrpModelMisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pack/RPGraphics/RPGrpModelMisc.cpp b/src/Pack/RPGraphics/RPGrpModelMisc.cpp index 5eb82f71..d386cf67 100644 --- a/src/Pack/RPGraphics/RPGrpModelMisc.cpp +++ b/src/Pack/RPGraphics/RPGrpModelMisc.cpp @@ -10,6 +10,6 @@ template <> const char* EGG::IBinary::spExtension = "pmmisc"; /** * @brief Gets the binary signature of this object */ -const char* RPGrpModelMisc::GetBinaryType() const override { +const char* RPGrpModelMisc::GetBinaryType() const { return "MMSC"; } From 0555068d968ffe6b74d51cf65524012a53683ded Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 12:38:22 -0400 Subject: [PATCH 14/14] Update RPGrpDrawPathManager.h --- include/Pack/RPGraphics/RPGrpDrawPathManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Pack/RPGraphics/RPGrpDrawPathManager.h b/include/Pack/RPGraphics/RPGrpDrawPathManager.h index 831e2c8d..cc18fd8e 100644 --- a/include/Pack/RPGraphics/RPGrpDrawPathManager.h +++ b/include/Pack/RPGraphics/RPGrpDrawPathManager.h @@ -51,6 +51,7 @@ class RPGrpDrawPathManager : public EGG::IScnProc { RPGrpDrawPathManager(u32 pathFlags, RPGrpModelScene* pModelScene); private: + u16 unkA; u16 unkC; RPGrpModelScene* mpModelScene; // at 0x10 u32 unk14;