diff --git a/config/RSPE01_00/splits.txt b/config/RSPE01_00/splits.txt index a0bc5dd4b..4d220c6ae 100644 --- a/config/RSPE01_00/splits.txt +++ b/config/RSPE01_00/splits.txt @@ -919,12 +919,23 @@ Pack/RPKernel/RPSysKokeshiIcon.cpp: .text start:0x8016D500 end:0x8016EBF4 .data start:0x80381DA0 end:0x80381DB4 +Pack/RPGraphics/RPGrpModel.cpp: + .text start:0x801809E8 end:0x80181190 + Pack/RPGraphics/RPGrpModelAnm.cpp: .text start:0x80181190 end:0x80181984 .data start:0x803823B0 end:0x80382438 + .sdata2 start:0x804E1A88 end:0x804E1A90 Pack/RPGraphics/RPGrpModelResManager.cpp: .text start:0x80185AE4 end:0x80186924 + .data start:0x803826F0 end:0x803827A4 + +Pack/RPGraphics/RPGrpCpuTexture.cpp: + .text start:0x8018F1A0 end:0x801900F0 + +Pack/RPGraphics/RPGrpFog.cpp: + .text start:0x801900F0 end:0x80190344 Pack/RPAudio/RPSndAudioMgr.cpp: .text start:0x8019C7E0 end:0x8019E630 @@ -935,3 +946,24 @@ Pack/RPAudio/RPSndSpeakerMgr.cpp: .data start:0x80383060 end:0x8038306C .sbss start:0x804DFC68 end:0x804DFC6C .sdata2 start:0x804E1EA8 end:0x804E1EAC + +Pack/RPUtility/RPUtlDohMath.cpp: + .text start:0x8019F8D4 end:0x8019FE84 + .ctors start:0x80330160 end:0x80330164 + .bss start:0x804D6F08 end:0x804D6FC8 + .sbss start:0x804DFC78 end:0x804DFC80 + .sdata2 start:0x804E1EE0 end:0x804E1EF0 + +Pack/RPUtility/RPUtlMapData.cpp: + .text start:0x801A5000 end:0x801A546C + +Pack/RPUtility/RPUtlShadowDrawer.cpp: + .text start:0x801A546C end:0x801A5580 + .ctors start:0x8033016C end:0x80330170 + .bss start:0x804D7078 end:0x804D70A8 + +Pack/RPSports/RPSportsCommon/RPSysPlayerSelectScene.cpp: + .text start:0x801B8778 end:0x801BB064 + +Pack/RPSports/RPSportsCommon/RPSportsMenuBgModel.cpp: + .text start:0x801BB064 end:0x801BB644 diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index ec42efd5e..ddbbc93bb 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -2894,7 +2894,7 @@ __ct__Q23EGG12LightManagerFUlUlUc = .text:0x8008FF24; // type:function size:0x23 Reset__Q23EGG12LightManagerFv = .text:0x80090160; // type:function size:0x12C scope:global Calc__Q23EGG12LightManagerFPQ34nw4r3g3d7ScnRoot = .text:0x8009028C; // type:function size:0xB0 scope:global CalcView__Q23EGG12LightManagerFRCQ34nw4r4math5MTX34UcPQ34nw4r3g3d7ScnRoot = .text:0x8009033C; // type:function size:0x140 scope:global -fn_8009047C = .text:0x8009047C; // type:function size:0x78 +SetChanAmbColor__Q23EGG12LightManagerCFv = .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 @@ -6864,7 +6864,7 @@ fn_80183534 = .text:0x80183534; // type:function size:0x50 fn_80183584 = .text:0x80183584; // type:function size:0x24 getFBHeight__11RPSysSystemCFv = .text:0x801835A8; // type:function size:0xC getFBWidth__11RPSysSystemCFv = .text:0x801835B4; // type:function size:0xC -fn_801835C0 = .text:0x801835C0; // type:function size:0x14 +getModifyRatio__11RPSysSystemCFv = .text:0x801835C0; // type:function size:0x14 fn_801835D4 = .text:0x801835D4; // type:function size:0x8 setupRenderMode__11RPSysSystemFv = .text:0x801835DC; // type:function size:0x130 setupTVMode__11RPSysSystemFv = .text:0x8018370C; // type:function size:0x6C @@ -7774,8 +7774,8 @@ fn_801A96B8 = .text:0x801A96B8; // type:function size:0x40 fn_801A96F8 = .text:0x801A96F8; // type:function size:0x40 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 +On__13RPGrpDrawPathFv = .text:0x801A97B8; // type:function size:0x14 +Off__13RPGrpDrawPathFv = .text:0x801A97CC; // type:function size:0x14 LoadScnLight__17RPGrpLightManagerFUsPCcfUl = .text:0x801A97E0; // type:function size:0x80 RemoveGenList__10RPGrpModelFv = .text:0x801A9860; // type:function size:0x44 ReplaceTexture__10RPGrpModelFPCcRC12RPGrpTextureb = .text:0x801A98A4; // type:function size:0x94 @@ -7947,7 +7947,7 @@ fn_801AF40C = .text:0x801AF40C; // type:function size:0x24 AppendDrawObject__13RPGrpRendererFP16IRPGrpDrawObject = .text:0x801AF430; // type:function size:0x24 fn_801AF454 = .text:0x801AF454; // type:function size:0x138 fn_801AF58C = .text:0x801AF58C; // type:function size:0x9C -fn_801AF628 = .text:0x801AF628; // type:function size:0x98 +CreateView3D__13RPGrpRendererFUcP11RPGrpCameraP11RPGrpScreen = .text:0x801AF628; // type:function size:0x98 fn_801AF6C0 = .text:0x801AF6C0; // type:function size:0x54 CalculateInPause__13RPGrpRendererFv = .text:0x801AF714; // type:function size:0x58 PostCalculate__13RPGrpRendererFv = .text:0x801AF76C; // type:function size:0x84 @@ -8007,19 +8007,19 @@ GetCamera__17RPGrpViewRender3DCFv = .text:0x801B18BC; // type:function size:0x8 __ct__17RPGrpViewRender3DFUc = .text:0x801B18C4; // type:function size:0x4C __dt__17RPGrpViewRender3DFv = .text:0x801B1910; // type:function size:0x40 scope:weak GetType__17RPGrpViewRender3DCFv = .text:0x801B1950; // type:function size:0x8 scope:weak -fn_801B1958 = .text:0x801B1958; // type:function size:0x98 +setupEnvironment__15RPGrpModelSceneCFv = .text:0x801B1958; // type:function size:0x98 fn_801B19F0 = .text:0x801B19F0; // type:function size:0x24 -fn_801B1A14 = .text:0x801B1A14; // type:function size:0x80 +setDrawPriority__15RPGrpModelSceneCFP10RPGrpModel = .text:0x801B1A14; // type:function size:0x80 fn_801B1A94 = .text:0x801B1A94; // type:function size:0x18 fn_801B1AAC = .text:0x801B1AAC; // type:function size:0x14 fn_801B1AC0 = .text:0x801B1AC0; // type:function size:0x14 fn_801B1AD4 = .text:0x801B1AD4; // type:function size:0x120 DrawPrepare__15RPGrpModelSceneFPC11RPGrpCameraPC11RPGrpScreen = .text:0x801B1BF4; // type:function size:0x50 -fn_801B1C44 = .text:0x801B1C44; // type:function size:0x40 +g_calc_background__15RPGrpModelSceneFv = .text:0x801B1C44; // type:function size:0x40 fn_801B1C84 = .text:0x801B1C84; // type:function size:0x100 -fn_801B1D84 = .text:0x801B1D84; // type:function size:0x38 +CalcView__15RPGrpModelSceneFv = .text:0x801B1D84; // type:function size:0x38 fn_801B1DBC = .text:0x801B1DBC; // type:function size:0xC4 -fn_801B1E80 = .text:0x801B1E80; // type:function size:0x80 +__dt__15RPGrpModelSceneFv = .text:0x801B1E80; // type:function size:0x80 fn_801B1F00 = .text:0x801B1F00; // type:function size:0x4E0 fn_801B23E0 = .text:0x801B23E0; // type:function size:0x4 fn_801B23E4 = .text:0x801B23E4; // type:function size:0x40 @@ -8800,11 +8800,11 @@ fn_801D5744 = .text:0x801D5744; // type:function size:0x5C fn_801D57A0 = .text:0x801D57A0; // type:function size:0x34 fn_801D57D4 = .text:0x801D57D4; // type:function size:0x8 fn_801D57DC = .text:0x801D57DC; // type:function size:0x8 -fn_801D57E4 = .text:0x801D57E4; // type:function size:0xA4 -fn_801D5888 = .text:0x801D5888; // type:function size:0x130 -fn_801D59B8 = .text:0x801D59B8; // type:function size:0x1F8 -fn_801D5BB0 = .text:0x801D5BB0; // type:function size:0x1CC -fn_801D5D7C = .text:0x801D5D7C; // type:function size:0x58 +calcView__19RPSportsMenuBgModelFv = .text:0x801D57E4; // type:function size:0xA4 +initCamera__19RPSportsMenuBgModelFv = .text:0x801D5888; // type:function size:0x130 +createData__19RPSportsMenuBgModelFPQ23EGG7Archive = .text:0x801D59B8; // type:function size:0x1F8 +__ct__19RPSportsMenuBgModelFUcUcUs = .text:0x801D5BB0; // type:function size:0x1CC +__dt__19RPSportsMenuBgModelFv = .text:0x801D5D7C; // type:function size:0x58 fn_801D5DD4 = .text:0x801D5DD4; // type:function size:0x20 fn_801D5DF4 = .text:0x801D5DF4; // type:function size:0xA8 fn_801D5E9C = .text:0x801D5E9C; // type:function size:0xA8 @@ -17895,12 +17895,19 @@ __FilterSizeTable = .data:0x803AEAA0; // type:object size:0x100 scope:local __SinTableFixedPoint = .data:0x803AEBA0; // type:object size:0x200 scope:local align:8 __SrcTab12khz = .data:0x803AEDA0; // type:object size:0x800 scope:local align:8 @472 = .data:0x803AF5A0; // type:object size:0x37 scope:local align:4 data:string -lbl_803AF5D8 = .data:0x803AF5D8; // type:object size:0x15 data:string -lbl_803AF5F0 = .data:0x803AF5F0; // type:object size:0x98 -lbl_803AF688 = .data:0x803AF688; // type:object size:0x1B data:string -lbl_803AF6A4 = .data:0x803AF6A4; // type:object size:0x1D data:string -lbl_803AF6C4 = .data:0x803AF6C4; // type:object size:0x44 -lbl_803AF708 = .data:0x803AF708; // type:object size:0x12 data:string +@844 = .data:0x803AF5D8; // type:object size:0x15 data:string +@845 = .data:0x803AF5F0; // type:object size:0x18 data:string +@873 = .data:0x803AF608; // type:object size:0x15 data:string +@874 = .data:0x803AF620; // type:object size:0x13 data:string +@875 = .data:0x803AF634; // type:object size:0xC data:string +@917 = .data:0x803AF640; // type:object size:0x18 data:string +@918 = .data:0x803AF658; // type:object size:0x18 align:8 data:string +@919 = .data:0x803AF670; // type:object size:0x15 data:string +@966 = .data:0x803AF688; // type:object size:0x1B data:string +@967 = .data:0x803AF6A4; // type:object size:0x1D data:string +@987 = .data:0x803AF6C4; // type:object size:0x22 align:4 data:string +@1043 = .data:0x803AF6E8; // type:object size:0x1D data:string +@1157 = .data:0x803AF708; // type:object size:0x12 data:string lbl_803AF720 = .data:0x803AF720; // type:object size:0x3A data:string lbl_803AF75C = .data:0x803AF75C; // type:object size:0x2F data:string lbl_803AF790 = .data:0x803AF790; // type:object size:0x5D0 @@ -18674,8 +18681,8 @@ lbl_803BA550 = .data:0x803BA550; // type:object size:0xE data:string lbl_803BA560 = .data:0x803BA560; // type:object size:0xD data:string lbl_803BA570 = .data:0x803BA570; // type:object size:0xE data:string lbl_803BA580 = .data:0x803BA580; // type:object size:0xD data:string -lbl_803BA590 = .data:0x803BA590; // type:object size:0x1F data:string -lbl_803BA5B0 = .data:0x803BA5B0; // type:object size:0xD data:string +@STRING@setModifyRatio__Q23EGG7StateGXFf@0 = .data:0x803BA590; // type:object size:0x1F data:string +@STRING@setModifyRatio__Q23EGG7StateGXFf = .data:0x803BA5B0; // type:object size:0xD data:string lbl_803BA5C0 = .data:0x803BA5C0; // type:object size:0x2C lbl_803BA5EC = .data:0x803BA5EC; // type:object size:0xC lbl_803BA5F8 = .data:0x803BA5F8; // type:object size:0x10 @@ -18777,7 +18784,7 @@ lbl_803C1F78 = .data:0x803C1F78; // type:object size:0x28 lbl_803C1FA0 = .data:0x803C1FA0; // type:object size:0x38 lbl_803C1FD8 = .data:0x803C1FD8; // type:object size:0x28 lbl_803C2000 = .data:0x803C2000; // type:object size:0x38 -lbl_803C2038 = .data:0x803C2038; // type:object size:0xC +__vt__19RPSportsMenuBgModel = .data:0x803C2038; // type:object size:0xC lbl_803C2044 = .data:0x803C2044; // type:object size:0x22 data:string lbl_803C2068 = .data:0x803C2068; // type:object size:0x12 data:string lbl_803C2080 = .data:0x803C2080; // type:object size:0x20 @@ -19902,7 +19909,7 @@ lbl_804A4788 = .bss:0x804A4788; // type:object size:0xC align:4 data:float lbl_804A4794 = .bss:0x804A4794; // type:object size:0xC align:4 data:float lbl_804A47A0 = .bss:0x804A47A0; // type:object size:0xC align:4 data:float lbl_804A47AC = .bss:0x804A47AC; // type:object size:0x54 data:4byte -sGlobalMtx__17RPUtlShadowDrawer = .bss:0x804A4800; // type:object size:0x30 data:4byte +sCameraMtx__17RPUtlShadowDrawer = .bss:0x804A4800; // type:object size:0x30 data:4byte lbl_804A4830 = .bss:0x804A4830; // type:object size:0x18 data:4byte lbl_804A4848 = .bss:0x804A4848; // type:object size:0x20 data:4byte lbl_804A4868 = .bss:0x804A4868; // type:object size:0x18 align:4 data:float @@ -20464,7 +20471,7 @@ lbl_804BDBF0 = .sdata:0x804BDBF0; // type:object size:0x8 sSoundHeapSize__16RPSysHomeMenuMgr = .sdata:0x804BDBF8; // type:object size:0x4 data:4byte sSuccess__17RPSysNWC24Manager = .sdata:0x804BDC00; // type:object size:0x4 data:4byte lbl_804BDC08 = .sdata:0x804BDC08; // type:object size:0x4 data:4byte -lbl_804BDC0C = .sdata:0x804BDC0C; // type:object size:0x4 data:4byte +sRenderPass__13RPGrpRenderer = .sdata:0x804BDC0C; // type:object size:0x4 data:4byte lbl_804BDC10 = .sdata:0x804BDC10; // type:object size:0x8 align:4 data:float lbl_804BDC18 = .sdata:0x804BDC18; // type:object size:0x8 lbl_804BDC20 = .sdata:0x804BDC20; // type:object size:0x8 align:4 data:float @@ -21891,7 +21898,7 @@ sAddrWork__16RPSysCoreAddress = .sbss:0x804BF580; // type:object size:0x6 data:b lbl_804BF588__18RPSysLytDynamicAnm = .sbss:0x804BF588; // type:object size:0x4 align:4 data:4byte OUT_OF_SCREEN_POS__18RPSysCursorDrawMgr = .sbss:0x804BF590; // type:object size:0x8 align:4 data:float spInstance__18RPSysCursorDrawMgr = .sbss:0x804BF598; // type:object size:0x4 data:4byte -lbl_804BF5A0 = .sbss:0x804BF5A0; // type:object size:0x8 data:4byte +spInstance__17RPSysSystemWinMgr = .sbss:0x804BF5A0; // type:object size:0x8 data:4byte spInstance__16RPSysHomeMenuMgr = .sbss:0x804BF5A8; // type:object size:0x4 data:4byte spHomeMenuArcMgr__16RPSysHomeMenuMgr = .sbss:0x804BF5AC; // type:object size:0x4 data:4byte sIsBusy__15RPSysPairingMgr = .sbss:0x804BF5B0; // type:object size:0x1 data:byte @@ -21913,7 +21920,7 @@ spCurrent__17RPGrpModelManager = .sbss:0x804BF5F8; // type:object size:0x8 data: spCurrent__20RPGrpModelResManager = .sbss:0x804BF600; // type:object size:0x8 data:4byte lbl_804BF608 = .sbss:0x804BF608; // type:object size:0x8 data:4byte spCurrent__13RPGrpRenderer = .sbss:0x804BF610; // type:object size:0x4 data:4byte -lbl_804BF614 = .sbss:0x804BF614; // type:object size:0x1 data:byte +sRendering__13RPGrpRenderer = .sbss:0x804BF614; // type:object size:0x1 data:byte lbl_804BF615 = .sbss:0x804BF615; // type:object size:0x1 data:byte gap_11_804BF616_sbss = .sbss:0x804BF616; // type:object size:0x2 scope:global spCurrentView__13RPGrpRenderer = .sbss:0x804BF618; // type:object size:0x4 data:4byte @@ -23640,8 +23647,8 @@ lbl_804C1888 = .sdata2:0x804C1888; // type:object size:0x1 data:byte lbl_804C1889 = .sdata2:0x804C1889; // type:object size:0x1 data:byte lbl_804C188A = .sdata2:0x804C188A; // type:object size:0x1 data:byte lbl_804C188B = .sdata2:0x804C188B; // type:object size:0x1 data:byte -lbl_804C188C = .sdata2:0x804C188C; // type:object size:0x4 align:4 data:float -lbl_804C1890 = .sdata2:0x804C1890; // type:object size:0x8 align:4 data:float +@26961 = .sdata2:0x804C188C; // type:object size:0x4 align:4 data:float +@26962 = .sdata2:0x804C1890; // type:object size:0x4 align:4 data:float @16652 = .sdata2:0x804C1898; // type:object size:0x4 scope:local align:4 data:float lbl_804C18A0 = .sdata2:0x804C18A0; // type:object size:0x1 data:byte lbl_804C18A1 = .sdata2:0x804C18A1; // type:object size:0x1 data:byte diff --git a/configure.py b/configure.py index 2f95528ad..7c28e47f2 100755 --- a/configure.py +++ b/configure.py @@ -1276,13 +1276,15 @@ def MatchingFor(*versions): Object(Matching, "Pack/RPGraphics/RPGrpCamera.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpDrawPathManager.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpLightManager.cpp"), - Object(Matching, "Pack/RPGraphics/RPGrpModel.cpp"), + Object(not MatchingFor("RSPE01_00"), "Pack/RPGraphics/RPGrpModel.cpp"), Object(not MatchingFor("RSPE01_00"), "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/RPGrpCpuTexture.cpp"), + Object(NonMatching, "Pack/RPGraphics/RPGrpFog.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpRenderer.cpp"), Object(Matching, "Pack/RPGraphics/RPGrpScreen.cpp"), Object(NonMatching, "Pack/RPGraphics/RPGrpView.cpp"), diff --git a/include/Pack/RPGraphics.h b/include/Pack/RPGraphics.h index 87c6b3d33..ffc9041df 100644 --- a/include/Pack/RPGraphics.h +++ b/include/Pack/RPGraphics.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Pack/RPGraphics/RPGrpCamera.h b/include/Pack/RPGraphics/RPGrpCamera.h index 27f6d845b..192a00b23 100644 --- a/include/Pack/RPGraphics/RPGrpCamera.h +++ b/include/Pack/RPGraphics/RPGrpCamera.h @@ -154,6 +154,19 @@ class RPGrpCamera { void LoadScnCameraMatrix(const nw4r::g3d::ResAnmScn scn, u8 refNumber, f32 frame = 0.0f); + /** + * @brief Getter for position + * + * @return nw4r::math::VEC3 Camera position + */ + nw4r::math::VEC3 GetPosition() { + return mPosition; + } + + void SetPosition(nw4r::math::VEC3 newPos) { + mPosition = newPos; + } + /** * @brief Sets the type of this camera * diff --git a/include/Pack/RPGraphics/RPGrpCpuTexture.h b/include/Pack/RPGraphics/RPGrpCpuTexture.h new file mode 100644 index 000000000..bc48b1e16 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpCpuTexture.h @@ -0,0 +1,156 @@ +#ifndef RP_GRAPHICS_CPU_TEXTURE_H +#define RP_GRAPHICS_CPU_TEXTURE_H + +#include + +#include + +#include + +//! TODO(texline) Confirm this + +/** + * @note Superseded by EGG::CpuTexture in rev 1. + */ +class RPGrpCpuTexture { +private: + u16 mFlags; // at 0x0 + u16 mWidth; // at 0x2 + u16 mHeight; // at 0x4 + u8 mFormat; // at 0x6 + u8 mWrapS; // at 0x7 + u8 mWrapT; // at 0x8 + u8 mMinFilter; // at 0x9 + u8 mMagFilter; // at 0xA + char UNK_0xB[0x10 - 0xB]; + void* mpBuffer; // at 0x10 + +public: + enum EGradationKind { + GRADATION_LINEAR, // y=x + GRADATION_QUADRATIC, // y=x^2 + GRADATION_CUBIC, // y=x^3 + GRADATION_QUARTIC, // y=x^4 + GRADATION_QUINTIC, // y=x^5 + GRADATION_QUADRATIC_EASEOUT, // y=1-(1-x)^2 + GRADATION_QUARTIC_EASEOUT, // y=1-(1-x)^4 + }; + +public: + //! @bug Texture buffer is leaked + virtual ~RPGrpCpuTexture() {} // at 0x8 + virtual void configure(); // at 0xC + virtual void getTexObj(GXTexObj* pObj) const; // at 0x10 + virtual void load(GXTexMapID map); // at 0x14 + + RPGrpCpuTexture(); + RPGrpCpuTexture(u16 width, u16 height, GXTexFmt format); + + void alloc(); + void allocWithHeaderDebug(); + + RPGrpResTIMG* getResTIMG() const; + u32 getTexBufferSize() const; + + void fillNormalMapSphere(); + void fillGradationTable(EGradationKind kind, int dir, u16 tableStart, + u16 tableGoal, const GXColor& c1, const GXColor& c2, + bool wrap, bool setAll); + + void setColor(u16 x, u16 y, GXColor color); + + void invalidate() const; + void flush() const; + + bool checkIsConfigure() const { + return testFlag(cFlag_Configured); + } + bool checkHasHeader() const { + return testFlag(cFlag_HasHeader); + } + + void setFlag(u8 flag) { + mFlags |= flag; + } + void clearFlag(u8 flag) { + mFlags &= ~flag; + } + bool testFlag(u8 flag) const { + return (mFlags & flag) ? true : false; + } + + u16 getWidth() const { + return mWidth; + } + void setWidth(u16 w) { + mWidth = w; + } + + u16 getHeight() const { + return mHeight; + } + void setHeight(u16 h) { + mHeight = h; + } + + GXTexFmt getFormat() const { + return static_cast(mFormat); + } + void setFormat(GXTexFmt format) { + mFormat = format; + } + + GXTexWrapMode getWrapS() const { + return static_cast(mWrapS); + } + void setWrapS(u8 wrap) { + mWrapS = wrap; + } + + GXTexWrapMode getWrapT() const { + return static_cast(mWrapT); + } + void setWrapT(u8 wrap) { + mWrapT = wrap; + } + + GXTexFilter getMinFilter() const { + return static_cast(mMinFilter); + } + void setMinFilter(u8 filter) { + mMinFilter = filter; + } + + GXTexFilter getMagFilter() const { + return static_cast(mMagFilter); + } + void setMagFilter(u8 filter) { + mMagFilter = filter; + } + + void* getBuffer() const { + return mpBuffer; + } + void setBuffer(void* pBuffer) { + mpBuffer = pBuffer; + clearFlag(cFlag_HasHeader); + } + +private: + enum { + cFlag_Configured = 1 << 0, + cFlag_HasHeader = 1 << 1, + }; + +private: + void initResTIMG() const; + + RPGrpResTIMG* getHeader() const { + // clang-format off + return reinterpret_cast( + reinterpret_cast(mpBuffer) - sizeof(RPGrpResTIMG)); + // clang-format on + } +}; + +#endif diff --git a/include/Pack/RPGraphics/RPGrpModel.h b/include/Pack/RPGraphics/RPGrpModel.h index 87bb930b5..2480bee72 100644 --- a/include/Pack/RPGraphics/RPGrpModel.h +++ b/include/Pack/RPGraphics/RPGrpModel.h @@ -53,15 +53,38 @@ class RPGrpModel { }; protected: +#if defined(VERSION_RSPE01_00) + u8 unk0; + u8 unk1; + u16 mFlags; + u16 unk4; + u32 unkFlag; + RPGrpModel* mpEntryNext; // at 0xC + RPGrpModel* mpGenNext; // at 0x10 + nw4r::math::MTX34 mtx14; + nw4r::math::VEC3 mBaseScale; // at 0x44 + RPGrpModelAnm* mpModelAnm; // at 0x50 + RPGrpModelMaterial** mppMaterials; // at 0x54 + RPGrpModelBoundingInfo* mpBoundingInfo; // at 0x58 + RPGrpModelRecord* mpRecord; // at 0x5C + BOOL mReverseCulling; // at 0x60 + IRPGrpModelCallback* mpCallback; // at 0x64 + u8 mDrawScene; // at 0x68 + u8 mDrawGroup; // at 0x69 + u8 mViewNo; // at 0x6A + u8 padding; + u32 unk6C; + +#elif defined(VERSION_RSPE01_01) u8 mViewNo; // at 0x0 u8 mDrawScene; // at 0x1 u8 mDrawGroup; // at 0x2 - char unk3; + u8 unk3; char unk4; char unk5[0x8 - 0x5]; u16 mFlags; // at 0x8 u16 unkA; - u32 unkC; + u32 unkFlag; u32 unk10; RPGrpModel* mpEntryNext; // at 0x14 RPGrpModel* mpGenNext; // at 0x18 @@ -73,6 +96,7 @@ class RPGrpModel { RPGrpModelRecord* mpRecord; // at 0x38 BOOL mReverseCulling; // at 0x3C EGG::ModelEx* mpModelEx; // at 0x40 +#endif public: static RPGrpModel* Construct(RPGrpHandle handle, u8 viewNo, u32 typeOption, @@ -135,9 +159,15 @@ class RPGrpModel { nw4r::math::MTX34* pMtx) const = 0; // at 0x48 virtual void GetViewMtx(nw4r::math::MTX34* pMtx) const = 0; // at 0x4C +#if defined(VERSION_RSPE01_00) virtual u16 GetJointNum() const { // at 0x50 + return 0; // stubbed in rev 0 + } +#elif defined(VERSION_RSPE01_01) + virtual u16 GetJointNum() const { return mpModelEx->getNumNode(); } +#endif virtual const char* GetJointName(u16 idx) const = 0; // at 0x54 virtual u16 GetJointIndex(const char* pName) const = 0; // at 0x58 @@ -146,24 +176,39 @@ class RPGrpModel { virtual const char* GetMaterialName(u16 idx) const = 0; // at 0x60 virtual u16 GetMaterialIndex(const char* pName) const = 0; // at 0x64 +#if defined(VERSION_RSPE01_00) + virtual u16 GetShapeNum() const { // at 0x68 + return 0; + } +#elif defined(VERSION_RSPE01_01) virtual u16 GetShapeNum() const { // at 0x68 return mpModelEx->getNumShape(); } +#endif virtual const char* GetShapeName(u16 idx) const = 0; // at 0x6C virtual u16 GetShapeIndex(const char* pName) const = 0; // at 0x70 +#if defined(VERSION_RSPE01_00) + virtual u16 GetViewMtxNum() const { // at 0x74 + return 0; + } +#elif defined(VERSION_RSPE01_01) virtual u16 GetViewMtxNum() const { // at 0x74 return mpModelEx->getNumViewMtx(); } +#endif +#if defined(VERSION_RSPE01_01) virtual void DrawDirect(u32 drawFlag, nw4r::math::MTX34* pViewMtx) { // at 0x78 mpModelEx->drawShapeDirectly(drawFlag, true, true, pViewMtx); } +#endif virtual void CalcMaterial(); // at 0x7C +#if defined(VERSION_RSPE01_01) virtual void CalcBeforeDraw() { // at 0x80 mpModelEx->setVisible(mFlags & EFlag_Visible); } @@ -181,6 +226,7 @@ class RPGrpModel { const_cast(&rViewMtx)); } } +#endif void RemoveGenList(); void CreateMaterial(u16 idx); @@ -190,6 +236,15 @@ class RPGrpModel { void Calc(); void Entry(); +//! This is a bit hacky, but it's meant for nw4r functions +//! that require a pointer, not the matrix itself (texline) +#if defined(VERSION_RSPE01_00) + nw4r::math::MTX34* GetMtxPtr() { + return &mtx14; + } +#endif + +#if defined(VERSION_RSPE01_01) EGG::ModelEx* GetModelEx() const { return mpModelEx; } @@ -213,6 +268,11 @@ class RPGrpModel { nw4r::g3d::ScnRfl* GetScnRfl() const { return mpModelEx->getScnRfl(); } +#endif + + RPGrpModelAnm* GetModelAnm() const { + return mpModelAnm; + } const nw4r::math::VEC3& GetBaseScale() const { return mBaseScale; @@ -243,6 +303,22 @@ class RPGrpModel { return (mFlags & EFlag_Visible) ? true : false; } + u8 GetDrawScene() const { + return mDrawScene; + } + + void SetDrawScene(u8 drawScene) { + mDrawScene = drawScene; + } + + u8 GetUnk4() const { + return unk4; + } + + u8 GetDrawGroup() const { + return mDrawGroup; + } + /** * @brief Gets the allocator used for model-related allocations */ @@ -266,10 +342,12 @@ class RPGrpModel { virtual void CreateAnm() = 0; // at 0x90 virtual void InternalCalc() = 0; // at 0x94 +#if defined(VERSION_RSPE01_01) virtual void GetShapeMinMax(u16 shapeIdx, nw4r::math::VEC3* pMin, nw4r::math::VEC3* pMax) const { // at 0x98 mpModelEx->getShapeMinMax(shapeIdx, pMin, pMax, false); } +#endif protected: enum { diff --git a/include/Pack/RPGraphics/RPGrpModelAnm.h b/include/Pack/RPGraphics/RPGrpModelAnm.h index 314c6169f..6ebb60de4 100644 --- a/include/Pack/RPGraphics/RPGrpModelAnm.h +++ b/include/Pack/RPGraphics/RPGrpModelAnm.h @@ -133,6 +133,12 @@ class RPGrpModelAnm { } } +#if defined(VERSION_RSPE01_00) + virtual void Calc(); +#elif defined(VERSION_RSPE01_01) + void Calc(); +#endif + virtual void SetEnableChrAnm(bool enable) { // at 0x68 if (!enable) { mFlags |= Flag_DisableChrAnm; @@ -151,8 +157,6 @@ class RPGrpModelAnm { void CreateBuffer(Anm anm, u16 num); - void Calc(); - s8 GetBlendIndex(Anm anm, AnmIdx idx, u8); void InternalRegist(Anm anm, u16 idx); diff --git a/include/Pack/RPGraphics/RPGrpModelG3D.h b/include/Pack/RPGraphics/RPGrpModelG3D.h index aa2febc9d..fcabd43c2 100644 --- a/include/Pack/RPGraphics/RPGrpModelG3D.h +++ b/include/Pack/RPGraphics/RPGrpModelG3D.h @@ -39,6 +39,7 @@ class RPGrpModelG3D : public RPGrpModel, virtual IRPGrpModelCallback* SetCallback(IRPGrpModelCallback* pCallback) override; // at 0x18 +#if defined(VERSION_RSPE01_01) virtual void SetCallbackJointIndex(u16 idx) override { // at 0x24 GetScnMdlSimple()->SetScnMdlCallbackNodeID(idx); } @@ -114,6 +115,7 @@ class RPGrpModelG3D : public RPGrpModel, virtual void Configure() override; // at 0x8C virtual void CreateAnm() override; // at 0x90 virtual void InternalCalc() override; // at 0x94 +#endif virtual void ExecCallback_CALC_WORLD(nw4r::g3d::ScnObj::Timing timing, nw4r::g3d::ScnObj* pObj, u32 param, diff --git a/include/Pack/RPGraphics/RPGrpModelRfl.h b/include/Pack/RPGraphics/RPGrpModelRfl.h index cc15f6746..04b4e4b74 100644 --- a/include/Pack/RPGraphics/RPGrpModelRfl.h +++ b/include/Pack/RPGraphics/RPGrpModelRfl.h @@ -49,6 +49,7 @@ class RPGrpModelRfl : public RPGrpModel, public nw4r::g3d::IScnObjCallback { return 0; } +#if defined(VERSION_RSPE01_01) virtual void GetWorldMtx(u16 /* idx */, nw4r::math::MTX34* pMtx) const override { // at 0x3C @@ -61,12 +62,14 @@ class RPGrpModelRfl : public RPGrpModel, public nw4r::g3d::IScnObjCallback { GetWorldMtx(u16 /* nodeIdx */) const override { // at 0x40 return GetScnObj()->GetMtxPtr(nw4r::g3d::ScnObj::MTX_LOCAL); } +#endif virtual nw4r::math::MTX34* ReferWorldMtx(u16 /* nodeIdx */) const override { // at 0x44 return &spCalcWorldMtxArray[0]; } +#if defined(VERSION_RSPE01_01) virtual void GetViewMtx(nw4r::math::MTX34* pMtx) const override { // at 0x4C GetScnObj()->GetMtx(nw4r::g3d::ScnObj::MTX_VIEW, pMtx); } @@ -75,6 +78,7 @@ class RPGrpModelRfl : public RPGrpModel, public nw4r::g3d::IScnObjCallback { nw4r::math::MTX34* pMtx) const override { // at 0x48 GetViewMtx(pMtx); } +#endif virtual const char* GetJointName(u16 idx) const override; // at 0x54 diff --git a/include/Pack/RPGraphics/RPGrpModelScene.h b/include/Pack/RPGraphics/RPGrpModelScene.h index 2f4fed433..d86ff2b4a 100644 --- a/include/Pack/RPGraphics/RPGrpModelScene.h +++ b/include/Pack/RPGraphics/RPGrpModelScene.h @@ -2,6 +2,10 @@ #define RP_GRAPHICS_MODEL_SCENE_H #include +#include + +#include + //! @addtogroup rp_graphics //! @{ @@ -14,7 +18,18 @@ class RPGrpScreen; */ class RPGrpModelScene { private: - char unk00[0xA4]; + char unk00[0x2]; + char mIdx; // at 0x2 + char unk03; + u8 unk04; + char unk05[0x3]; + u8 unk08; + char unk09[0x3]; + EGG::LightManager* mpLightManager; // at 0xC + EGG::FogManager* mpFogManager; // at 0x10 + char unk14[0x88]; + EGG::ScnRootEx* mpScnRootEx; // at 0x9C + char unkA0[0x4]; public: virtual ~RPGrpModelScene(); // at 0x8 @@ -24,7 +39,17 @@ class RPGrpModelScene { virtual void DrawFinish(); // at 0x18 virtual void PreConditionForRenderingGX() const; // at 0x1C + void g_calc_background(); + void DrawPrepare(const RPGrpCamera* pCamera, const RPGrpScreen* pScreen); + + void setDrawPriority(RPGrpModel* pModel) const; + + /** + * @brief Initializes a scene's projection matrix, + * ambient lights, and fog GX + */ + void setupGX() const; }; //! @} diff --git a/include/Pack/RPGraphics/RPGrpRenderer.h b/include/Pack/RPGraphics/RPGrpRenderer.h index 24fd2ed83..bbc8c9c46 100644 --- a/include/Pack/RPGraphics/RPGrpRenderer.h +++ b/include/Pack/RPGraphics/RPGrpRenderer.h @@ -2,6 +2,9 @@ #define RP_GRAPHICS_RENDERER_H #include +#include +#include + #include //! @addtogroup rp_graphics @@ -17,8 +20,27 @@ class RPGrpView; */ class RPGrpRenderer { public: + enum RenderPassState { + RENDERPASS_SYSCALC, + RENDERPASS_SYSDRAW, + RENDERPASS_DRAWBEFORE, + RENDERPASS_DRAW, + RENDERPASS_DRAWDONE, + RENDERPASS_DRAW2D, + RENDERPASS_3DOPA, + RENDERPASS_3DXLU, + RENDERPASS_SVBEFORE, + RENDERPASS_SV, + RENDERPASS_EFFECT_2, + RENDERPASS_BEGIN, + RENDERPASS_END, + RENDERPASS_NULL, + }; + //! Maximum number of renderer views static const int MAX_VIEW = 32; + static bool sRendering; + static RenderPassState sRenderPass; public: /** @@ -46,6 +68,9 @@ class RPGrpRenderer { return spCurrentScreen; } + /** + * @brief Sets up a GX context for rendering + */ static void Begin(); static void End(); @@ -62,6 +87,9 @@ class RPGrpRenderer { AppendDrawObject(&rObject); } + RPGrpViewRender3D* CreateView3D(u8 viewNo, RPGrpCamera* camera, + RPGrpScreen* screen); + void PreCalculate(); void PostCalculate(); void CalculateInPause(); @@ -76,8 +104,8 @@ class RPGrpRenderer { static RPGrpScreen* spCurrentScreen; char unk0[0xC]; - IRPGrpDrawObject* mpDrawList; // at 0xC - char unk10[0x14 - 0x10]; + IRPGrpDrawObject* mpDrawList; // at 0xC + IRPGrpDrawObject* mpDrawObj; // at 0x10 RPGrpView* mpDrawViews[MAX_VIEW]; // at 0x14 }; diff --git a/include/Pack/RPGraphics/RPGrpResTIMG.h b/include/Pack/RPGraphics/RPGrpResTIMG.h new file mode 100644 index 000000000..1cf745878 --- /dev/null +++ b/include/Pack/RPGraphics/RPGrpResTIMG.h @@ -0,0 +1,39 @@ +#ifndef RP_GRAPHICS_RES_TIMG_H +#define RP_GRAPHICS_RES_TIMG_H +#include + +/** + * @note Superseded by EGG::ResTIMG in rev 1. + */ +struct RPGrpResTIMG { + + enum JUTTransparency { + JUT_TRANSPARENCY_DISABLE, + JUT_TRANSPARENCY_ENABLE, + }; + + u8 format; // at 0x0 + u8 transparency; // at 0x1 + u16 width; // at 0x2 + u16 height; // at 0x4 + u8 wrapS; // at 0x6 + u8 wrapT; // at 0x7 + u8 tlutName; // at 0x8 + u8 tlutFormat; // at 0x9 + u16 paletteEntryNum; // at 0xA + s32 paletteOffset; // at 0xC + u8 mipMap; // at 0x10 + u8 edgeLODEnable; // at 0x11 + u8 biasClampEnable; // at 0x12 + u8 anisotropy; // at 0x13 + u8 minFilter; // at 0x14 + u8 magFilter; // at 0x15 + s8 minLOD; // at 0x16 + s8 maxLOD; // at 0x17 + u8 mipMapLevel; // at 0x18 + u8 BYTE_0x19; + s16 LODBias; // at 0x1A + s32 imageOffset; // at 0x1C +}; + +#endif diff --git a/include/egg/gfxe/eggFogManager.h b/include/egg/gfxe/eggFogManager.h index 887ea665d..b4a42e16d 100644 --- a/include/egg/gfxe/eggFogManager.h +++ b/include/egg/gfxe/eggFogManager.h @@ -29,6 +29,10 @@ class FogManager { void LoadScnFog(const nw4r::g3d::ResAnmScn scn, f32 frame); void DoneDraw(); + Fog* GetFog(int id) const { + return mFog[id]; + } + private: enum { cFlag_CalcDone = 1 << 2, diff --git a/include/egg/gfxe/eggLightManager.h b/include/egg/gfxe/eggLightManager.h index 07d3c08aa..37a7ad6b0 100644 --- a/include/egg/gfxe/eggLightManager.h +++ b/include/egg/gfxe/eggLightManager.h @@ -26,6 +26,10 @@ class LightManager : IBinary { void Calc(nw4r::g3d::ScnRoot*); void CalcView(const nw4r::math::MTX34&, u8, nw4r::g3d::ScnRoot*); + void SetChanAmbColor() const; + + void LoadObjIndxGX() const; + void DoneDraw(); void LoadScnLightInner(nw4r::g3d::ResAnmScn, f32, u32); @@ -50,7 +54,8 @@ class LightManager : IBinary { u16 m_numLight; // at 0x4 char UNK_0x8[0xC - 0x8]; LightObj** m_ppLightSet; // at 0xC - char UNK_0X10[0x18 - 0x10]; + GXColor* m_pAmbColor0; // at 0x10 + char UNK_0X14[0x18 - 0x14]; u8 m_viewNum; // at 0x18 u8 m_currentView; // at 0x19 char UNK_0x1A[0x20 - 0x1A]; diff --git a/include/egg/gfxe/eggLightObject.h b/include/egg/gfxe/eggLightObject.h index 263b83e3e..235f61cef 100644 --- a/include/egg/gfxe/eggLightObject.h +++ b/include/egg/gfxe/eggLightObject.h @@ -5,6 +5,8 @@ #include #include +#include + #include namespace EGG { @@ -44,13 +46,29 @@ class LightObject : IBinary { void Reset(); void Calc(); + /** + * @brief Calculates direction vectors using camera viewpoint + * + * @param rCameraMtx Matrix used for creating position vector + */ void CalcView(const nw4r::math::MTX34& rCameraMtx); void CalcFinalDirColor(const EGG::LightTexture& rTexture, nw4r::math::VEC3* pDir, GXColor* pColor); + void InitGX(GXLightObj* pObj) const; + + void CopyToG3D_World(nw4r::g3d::ScnRoot* pScnRoot) const; + + void CopyFromG3D(nw4r::g3d::LightAnmResult* pResult, f32 frame); + void CalcDirDist(); + /** + * @brief Calculates attenuation for light object + */ + void CalcAt(); + void SetPosAt(const nw4r::math::VEC3& rPos, const nw4r::math::VEC3& rAt); private: @@ -74,9 +92,9 @@ class LightObject : IBinary { private: u16 mAmbIndex; // at 0x4 - Vector3f mAt; // at 0x8 - Vector3f mPos; // at 0x14 - Vector3f mDir; // at 0x20 + nw4r::math::VEC3 mAt; // at 0x8 + nw4r::math::VEC3 mPos; // at 0x14 + nw4r::math::VEC3 mDir; // at 0x20 GXColor mBrightnessColor; // at 0x2C f32 mIntensity; // at 0x30 LightType mLightType; // at 0x34 diff --git a/include/egg/gfxe/eggLightTexture.h b/include/egg/gfxe/eggLightTexture.h index 6d5f930a6..fac80854c 100644 --- a/include/egg/gfxe/eggLightTexture.h +++ b/include/egg/gfxe/eggLightTexture.h @@ -1,9 +1,9 @@ #ifndef EGG_GFXE_LIGHT_TEXTURE_H #define EGG_GFXE_LIGHT_TEXTURE_H -#include "eggCapTexture.h" -#include "eggIBinary.h" -#include "eggScreen.h" -#include "types_egg.h" +#include + +#include +#include namespace EGG { class LightTexture : public CapTexture, public IBinary { diff --git a/include/egg/gfxe/eggPostEffectBlur.h b/include/egg/gfxe/eggPostEffectBlur.h index 5949ddfcd..0869184d7 100644 --- a/include/egg/gfxe/eggPostEffectBlur.h +++ b/include/egg/gfxe/eggPostEffectBlur.h @@ -1,8 +1,9 @@ #ifndef EGG_GFXE_POST_EFFECT_BLUR_H #define EGG_GFXE_POST_EFFECT_BLUR_H -#include "eggAssert.h" -#include "eggPostEffectBase.h" -#include "types_egg.h" +#include + +#include +#include namespace EGG { class PostEffectBlur : public PostEffectBase { diff --git a/include/egg/gfxe/eggPostEffectBlurGather.h b/include/egg/gfxe/eggPostEffectBlurGather.h index 3408905b3..6805d54c4 100644 --- a/include/egg/gfxe/eggPostEffectBlurGather.h +++ b/include/egg/gfxe/eggPostEffectBlurGather.h @@ -1,9 +1,10 @@ #ifndef EGG_GFXE_POST_EFFECT_BLUR_GATHER_H #define EGG_GFXE_POST_EFFECT_BLUR_GATHER_H -#include "eggAssert.h" -#include "eggDrawGX.h" -#include "eggPostEffectBase.h" -#include "types_egg.h" +#include + +#include +#include +#include namespace EGG { class PostEffectBlurGather : public PostEffectBase { diff --git a/include/egg/gfxe/eggPostEffectBlurSimple.h b/include/egg/gfxe/eggPostEffectBlurSimple.h index 011661b7b..c682b920d 100644 --- a/include/egg/gfxe/eggPostEffectBlurSimple.h +++ b/include/egg/gfxe/eggPostEffectBlurSimple.h @@ -1,7 +1,8 @@ #ifndef EGG_GFXE_POST_EFFECT_BLUR_SIMPLE_H #define EGG_GFXE_POST_EFFECT_BLUR_SIMPLE_H -#include "eggPostEffectBase.h" -#include "types_egg.h" +#include + +#include namespace EGG { diff --git a/include/egg/gfxe/eggShadowTexture.h b/include/egg/gfxe/eggShadowTexture.h index 88614419b..076943325 100644 --- a/include/egg/gfxe/eggShadowTexture.h +++ b/include/egg/gfxe/eggShadowTexture.h @@ -1,8 +1,9 @@ #ifndef EGG_GFXE_SHADOW_TEXTURE_H #define EGG_GFXE_SHADOW_TEXTURE_H -#include "eggModelSnapshot.h" -#include "eggPostEffectBase.h" -#include "types_egg.h" +#include + +#include +#include namespace EGG { class ShadowTexture : public ModelSnapshot { diff --git a/include/egg/gfxe/eggShadowTextureManager.h b/include/egg/gfxe/eggShadowTextureManager.h index bce076e38..b39e23eb3 100644 --- a/include/egg/gfxe/eggShadowTextureManager.h +++ b/include/egg/gfxe/eggShadowTextureManager.h @@ -1,6 +1,6 @@ #ifndef EGG_GFXE_SHADOW_TEXTURE_MANAGER_H #define EGG_GFXE_SHADOW_TEXTURE_MANAGER_H -#include "types_egg.h" +#include namespace EGG { diff --git a/include/egg/gfxe/eggStateGX.h b/include/egg/gfxe/eggStateGX.h index 51f2d36c8..8231a3b6e 100644 --- a/include/egg/gfxe/eggStateGX.h +++ b/include/egg/gfxe/eggStateGX.h @@ -1,10 +1,15 @@ #ifndef EGG_GFXE_STATE_GX_H #define EGG_GFXE_STATE_GX_H +#include + +#include + #include #include #include + namespace EGG { class StateGX { @@ -107,6 +112,15 @@ class StateGX { s_heightEfb = height; } + static f32 getModifyRatio() { + return s_modifyRatio; + } + static void setModifyRatio(f32 modify) { +#line 261 + EGG_ASSERT(0.f <= modify && modify <= 1.f); + s_modifyRatio = modify; + } + private: struct GXCache { u32 flags; // at 0x0 diff --git a/src/Pack/RPGraphics/RPGrpCpuTexture.cpp b/src/Pack/RPGraphics/RPGrpCpuTexture.cpp new file mode 100644 index 000000000..721063bf3 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpCpuTexture.cpp @@ -0,0 +1,228 @@ +#include + +RPGrpCpuTexture::RPGrpCpuTexture() + : mFlags(NULL), + mWrapT(GX_CLAMP), + mWrapS(GX_CLAMP), + mMagFilter(GX_LINEAR), + mMinFilter(GX_LINEAR) {} + +void blendColor(GXColor* pColor, const GXColor& c1, const GXColor& c2, + f32 scale) { + + if (scale <= 0.0f) { + *pColor = c1; + } else if (scale >= 1.0f) { + *pColor = c2; + } else { + pColor->r = c1.r + scale * (c2.r - c1.r); + pColor->g = c1.g + scale * (c2.g - c1.g); + pColor->b = c1.b + scale * (c2.b - c1.b); + pColor->a = c1.a + scale * (c2.a - c1.a); + } +} + +void makeGradationTable(RPGrpCpuTexture::EGradationKind kind, GXColor* pTable, + u16 tableSize, u16 tableStart, u16 tableGoal, + const GXColor& c1, const GXColor& c2) { + + for (int i = 0; i < tableStart + 1; i++) { + pTable[i] = c1; + } + + for (int i = tableGoal - 1; i < tableSize; i++) { + pTable[i] = c2; + } + + for (int i = tableStart + 1; i < tableGoal - 1; i++) { + f32 scale = static_cast(i - tableStart) / + static_cast(tableGoal - tableStart); + + switch (kind) { + case RPGrpCpuTexture::GRADATION_LINEAR: { + break; + } + + case RPGrpCpuTexture::GRADATION_QUADRATIC: { + scale *= scale; + break; + } + + case RPGrpCpuTexture::GRADATION_CUBIC: { + scale *= scale; + scale *= scale; + break; + } + + case RPGrpCpuTexture::GRADATION_QUARTIC: { + scale *= scale; + scale *= scale; + scale *= scale; + break; + } + + case RPGrpCpuTexture::GRADATION_QUINTIC: { + scale *= scale; + scale *= scale; + scale *= scale; + scale *= scale; + break; + } + + case RPGrpCpuTexture::GRADATION_QUADRATIC_EASEOUT: { + f32 minusOne = scale - 1.0f; + scale = -minusOne * minusOne + 1.0f; + break; + } + + case RPGrpCpuTexture::GRADATION_QUARTIC_EASEOUT: { + f32 minusOne = scale - 1.0f; + scale = -minusOne * minusOne * minusOne * minusOne + 1.0f; + break; + } + } + + blendColor(&pTable[i], c1, c2, scale); + } +} + +void RPGrpCpuTexture::configure() { + mFlags = cFlag_Configured; +} + +void RPGrpCpuTexture::getTexObj(GXTexObj* pObj) const { + GXInitTexObj(pObj, getBuffer(), getWidth(), getHeight(), getFormat(), + getWrapS(), getWrapT(), GX_FALSE); + + GXInitTexObjLOD(pObj, getMinFilter(), getMagFilter(), 0.0f, 0.0f, 0.0f, + GX_FALSE, GX_FALSE, GX_ANISO_1); +} + +void RPGrpCpuTexture::load(GXTexMapID map) { + GXTexObj obj; + getTexObj(&obj); + + GXLoadTexObj(&obj, map); +} + +void RPGrpCpuTexture::invalidate() const { + DCInvalidateRange(mpBuffer, getTexBufferSize()); +} + +void RPGrpCpuTexture::flush() const { + DCFlushRange(mpBuffer, getTexBufferSize()); +} + +u32 RPGrpCpuTexture::getTexBufferSize() const { + return GXGetTexBufferSize(getWidth(), getHeight(), getFormat(), GX_FALSE, + 1); +} + +void RPGrpCpuTexture::initResTIMG() const { + RPGrpResTIMG* pHeader = getHeader(); + + pHeader->format = getFormat(); + pHeader->transparency = RPGrpResTIMG::JUT_TRANSPARENCY_DISABLE; + pHeader->width = getWidth(); + pHeader->height = getHeight(); + pHeader->wrapS = getWrapS(); + pHeader->wrapT = getWrapT(); + pHeader->tlutName = GX_TLUT0; + pHeader->tlutFormat = GX_TL_IA8; + pHeader->paletteEntryNum = 0; + pHeader->paletteOffset = 0; + pHeader->mipMap = GX_FALSE; + pHeader->edgeLODEnable = GX_FALSE; + pHeader->biasClampEnable = GX_FALSE; + pHeader->anisotropy = GX_ANISO_1; + pHeader->minFilter = getMinFilter(); + pHeader->magFilter = getMagFilter(); + pHeader->minLOD = 0; + pHeader->maxLOD = 0; + pHeader->mipMapLevel = 1; + pHeader->LODBias = 0; + pHeader->imageOffset = sizeof(RPGrpResTIMG); +} + +void RPGrpCpuTexture::fillGradationTable(EGradationKind kind, int dir, + u16 tableStart, u16 tableGoal, + const GXColor& c1, const GXColor& c2, + bool wrap, bool setAll) { + + bool isSLine = dir == 's' || dir == 'S'; + + u16 tableSize = isSLine ? getWidth() : getHeight(); + + u16 tableHeight = isSLine ? getHeight() : getWidth(); + u16 tableMid = tableSize / 2; + + GXColor table[1024]; + makeGradationTable(kind, table, tableSize, tableStart, tableGoal, c1, c2); + + if (wrap) { + GXColor colors[256]; + + for (int i = 0; i < tableSize; i++) { + colors[i] = table[i < tableMid ? i + tableMid : i - tableMid]; + } + + for (int i = 0; i < tableSize; i++) { + table[i] = colors[i]; + } + } + + u16 setStart = setAll ? 0 : tableStart; + u16 setGoal = setAll ? tableSize : tableGoal; + + for (u16 x = setStart; x < setGoal; x++) { + for (u16 y = 0; y < tableHeight; y++) { + setColor(y, x, table[x]); + } + } + flush(); +} + +void RPGrpCpuTexture::alloc() { + u8* pBuffer = new (32) u8[getTexBufferSize()]; + setBuffer(pBuffer); +} + +void RPGrpCpuTexture::allocWithHeaderDebug() { + + u8* pBuffer = new (32) u8[getTexBufferSize() + sizeof(RPGrpResTIMG)]; + + setBuffer(pBuffer + sizeof(RPGrpResTIMG)); + setFlag(cFlag_HasHeader); + initResTIMG(); +} + +void RPGrpCpuTexture::setColor(u16 x, u16 y, GXColor color) { + switch (getFormat()) { + case GX_TF_RGBA8: { + int offset = ((x >> 2) + (y >> 2) * (getWidth() / 4)) * 0x40 + // block + (y & 3) * 8 + (x & 3) * 2; // pixel + + u8* pData = static_cast(getBuffer()) + offset; + + pData[0] = color.a; + pData[1] = color.r; + pData[32] = color.g; + pData[33] = color.b; + break; + } + + case GX_TF_I8: { + int offset = (x & 0x7) + (y & 0x3) * 8; // pixel + offset += ((x >> 3) + ((y >> 2) * (getWidth() / 8))) * 32; // block + + u8* pData = static_cast(getBuffer()) + offset; + + pData[0] = color.r; + break; + } + + default: { + break; + } + } +} diff --git a/src/Pack/RPGraphics/RPGrpModel.cpp b/src/Pack/RPGraphics/RPGrpModel.cpp index e05b51c4c..cfc0c5016 100644 --- a/src/Pack/RPGraphics/RPGrpModel.cpp +++ b/src/Pack/RPGraphics/RPGrpModel.cpp @@ -19,11 +19,13 @@ const nw4r::math::_VEC3 RPGrpModel::GEOMETRY_MAGNIFY[/* ??? */] = { {0.0f, 0.0f, 0.0f}, }; +#ifdef VERSION_RSPE01_01 RPGrpModel* RPGrpModel::Construct(RPGrpHandle handle, u8 viewNo, u32 typeOption, u32 bufferOption) { RPGrpModel* p = NULL; switch (RPGrpModelResManager::GetCurrent()->GetType(handle)) { + case RPGrpModelResManager::Type_ResMdl: { p = new RPGrpModelG3D(handle, viewNo, typeOption, bufferOption); break; @@ -59,8 +61,37 @@ RPGrpModel* RPGrpModel::Construct(RPGrpHandle handle, const char* pName, p->CreateAnm(); return p; } +#endif RPGrpModel::RPGrpModel(u8 viewNo) +#if defined(VERSION_RSPE01_00) + : unk0(0), + unk1(0), + mFlags(1), + unk4(0), + unkFlag(0), + mpEntryNext(NULL), + mpGenNext(NULL), + mBaseScale(1.0f, 1.0f, 1.0f), + mpModelAnm(NULL), + mppMaterials(NULL), + mpBoundingInfo(NULL), + mpRecord(NULL), + mReverseCulling(FALSE), + mpCallback(NULL), + mDrawGroup(8), + mDrawScene(8), + mViewNo(viewNo), + unk6C(NULL) { + + mpGenNext = spGenList; + spGenList = this; + nw4r::math::MTX34Identity(&mtx14); + //! @bug only in rev 0: mBaseScale was already initialized + mBaseScale.x = mBaseScale.y = mBaseScale.z = 1.0f; +} + +#elif defined(VERSION_RSPE01_01) : mViewNo(viewNo), mDrawScene(0), mDrawGroup(0), @@ -68,7 +99,7 @@ RPGrpModel::RPGrpModel(u8 viewNo) unk4(8), mFlags(EFlag_Visible), unkA(0), - unkC(0), + unkFlag(0), unk10(0), mpEntryNext(NULL), mpGenNext(NULL), @@ -84,6 +115,7 @@ RPGrpModel::RPGrpModel(u8 viewNo) mpGenNext = spGenList; spGenList = this; } +#endif RPGrpModel::~RPGrpModel() {} @@ -147,10 +179,12 @@ void RPGrpModel::UpdateFrame() { mpModelAnm->UpdateFrame(); } +#if defined(VERSION_RSPE01_01) nw4r::g3d::ScnObj* pScnObj = GetScnObj(); if (pScnObj != NULL) { pScnObj->G3dProc(nw4r::g3d::G3dObj::G3DPROC_UPDATEFRAME, 0, NULL); } +#endif } void RPGrpModel::Calc() { @@ -180,15 +214,19 @@ void RPGrpModel::Entry() { mFlags |= EFlag_Entered; } +//! TODO(texline) vtable is different in rev 0 +//! (offset should be 0x4c there, but is 0x5c) void RPGrpModel::CalcMaterial() { for (int i = 0; i < GetMaterialNum(); i++) { mppMaterials[i]->Calc(); } } +#if defined(VERSION_RSPE01_01) u16 RPGrpModel::GetMaterialNum() const { return mpModelEx->getNumMaterial(); } +#endif void RPGrpModel::SetReverseCulling(bool reverse) { if (reverse == mReverseCulling) { @@ -211,6 +249,7 @@ void RPGrpModel::SetReverseCulling(bool reverse) { mReverseCulling = reverse; } +#if defined(VERSION_RSPE01_01) u16 RPGrpModel::ReplaceTexture(const char* pName, const RPGrpTexture& rTexture, bool keepFilterWrap) { @@ -218,6 +257,7 @@ u16 RPGrpModel::ReplaceTexture(const char* pName, const RPGrpTexture& rTexture, return mpModelEx->replaceTexture(pName, texObj, keepFilterWrap, NULL, 0, true); } +#endif void RPGrpModel::RemoveGenList() { RPGrpModel* pIt = spGenList; diff --git a/src/Pack/RPGraphics/RPGrpModelImplement.cpp b/src/Pack/RPGraphics/RPGrpModelImplement.cpp index dbe2b5af3..3d7cbfa46 100644 --- a/src/Pack/RPGraphics/RPGrpModelImplement.cpp +++ b/src/Pack/RPGraphics/RPGrpModelImplement.cpp @@ -21,7 +21,9 @@ RPGrpModelG3D::RPGrpModelG3D(RPGrpHandle handle, u8 viewNo, u32 typeOption, bufferOption, viewNo); } +#if defined(VERSION_RSPE01_01) mpModelEx = new EGG::ModelEx(pScnObj); +#endif } RPGrpModelG3D::RPGrpModelG3D(RPGrpHandle handle, int idx, u8 viewNo, @@ -45,7 +47,9 @@ RPGrpModelG3D::RPGrpModelG3D(RPGrpHandle handle, int idx, u8 viewNo, bufferOption, viewNo); } +#if defined(VERSION_RSPE01_01) mpModelEx = new EGG::ModelEx(pScnObj); +#endif } RPGrpModelG3D::RPGrpModelG3D(RPGrpHandle handle, const char* pName, u8 viewNo, @@ -69,9 +73,12 @@ RPGrpModelG3D::RPGrpModelG3D(RPGrpHandle handle, const char* pName, u8 viewNo, bufferOption, viewNo); } +#if defined(VERSION_RSPE01_01) mpModelEx = new EGG::ModelEx(pScnObj); +#endif } +#ifdef VERSION_RSPE01_01 void RPGrpModelG3D::Configure() { RPGrpModel::Configure(); @@ -90,12 +97,13 @@ void RPGrpModelG3D::Configure() { void RPGrpModelG3D::CreateAnm() { mpModelAnm = RPGrpModelAnmG3D::Construct(this); } +#endif IRPGrpModelCallback* RPGrpModelG3D::SetCallback(IRPGrpModelCallback* pCallback) { IRPGrpModelCallback* pOldCallback = mpCallback; mpCallback = pCallback; - +#if defined(VERSION_RSPE01_01) if (pCallback == NULL) { GetScnMdlSimple()->DisableScnMdlCallbackTiming( nw4r::g3d::ScnObj::CALLBACK_TIMING_ALL); @@ -103,10 +111,12 @@ RPGrpModelG3D::SetCallback(IRPGrpModelCallback* pCallback) { GetScnMdlSimple()->EnableScnMdlCallbackTiming( nw4r::g3d::ScnObj::CALLBACK_TIMING_ALL); } +#endif return pOldCallback; } +#if defined(VERSION_RSPE01_01) void RPGrpModelG3D::InternalCalc() { if (!mReverseCulling) { if (GetScnLeaf() != NULL) { @@ -164,6 +174,7 @@ bool RPGrpModelG3D::IsJointVisible(u32 idx) const { return GetScnMdlSimple()->GetResMdl().GetResNode(idx).IsVisible(); } } +#endif void RPGrpModelG3D::ExecCallback_CALC_WORLD( nw4r::g3d::ScnObj::Timing /* timing */, nw4r::g3d::ScnObj* /* pObj */, @@ -173,7 +184,7 @@ void RPGrpModelG3D::ExecCallback_CALC_MAT(nw4r::g3d::ScnObj::Timing timing, nw4r::g3d::ScnObj* /* pObj */, u32 /* param */, void* /* pInfo */) { - if (!(unkC & 0x40)) { + if (!(unkFlag & 0x40)) { if (timing & nw4r::g3d::ScnObj::CALLBACK_TIMING_A) { CalcMaterial(); } diff --git a/src/Pack/RPGraphics/RPGrpModelResManager.cpp b/src/Pack/RPGraphics/RPGrpModelResManager.cpp index e20fe86bf..316d17984 100644 --- a/src/Pack/RPGraphics/RPGrpModelResManager.cpp +++ b/src/Pack/RPGraphics/RPGrpModelResManager.cpp @@ -167,7 +167,7 @@ void* RPGrpModelResManager::GetPtr(Type type, RPGrpHandle handle, } case Type_ResAnmScn: { - return mpResList[handle].pResFile->Get().GetResAnmShp(pName).ptr(); + return mpResList[handle].pResFile->Get().GetResAnmScn(pName).ptr(); } default: { @@ -223,7 +223,7 @@ void* RPGrpModelResManager::GetPtr(Type type, RPGrpHandle handle, } case Type_ResAnmScn: { - return mpResList[handle].pResFile->Get().GetResAnmShp(index).ptr(); + return mpResList[handle].pResFile->Get().GetResAnmScn(index).ptr(); } default: { @@ -404,7 +404,7 @@ bool RPGrpModelResManager::HasFile(Type type, RPGrpHandle handle, } case Type_ResAnmScn: { - return mpResList[handle].pResFile->Get().GetResAnmShp(pName).IsValid(); + return mpResList[handle].pResFile->Get().GetResAnmScn(pName).IsValid(); } default: { diff --git a/src/Pack/RPGraphics/RPGrpModelRfl.cpp b/src/Pack/RPGraphics/RPGrpModelRfl.cpp index 7111faac3..235ff9920 100644 --- a/src/Pack/RPGraphics/RPGrpModelRfl.cpp +++ b/src/Pack/RPGraphics/RPGrpModelRfl.cpp @@ -21,6 +21,7 @@ nw4r::math::MTX34 RPGrpModelRfl::lbl_804A4608( ); // clang-format on +#if defined(VERSION_RSPE01_01) RPGrpModelRfl* RPGrpModelRfl::Construct(RFLDataSource src, u16 index, RFLMiddleDB* pMiddleDB, RFLResolution resolution, u32 exprFlags, @@ -50,6 +51,7 @@ RPGrpModelRfl* RPGrpModelRfl::Construct(RFLDataSource src, u16 index, return p; } +#endif RPGrpModelRfl::RPGrpModelRfl(RFLResolution resolution, u32 exprFlags, u8 viewNo) : RPGrpModel(viewNo), @@ -66,7 +68,9 @@ RPGrpModelRfl::RPGrpModelRfl(RFLResolution resolution, u32 exprFlags, u8 viewNo) *static_cast(pScnRfl->GetUserData()) = this; +#if defined(VERSION_RSPE01_01) mpModelEx = new EGG::ModelEx(pScnRfl); +#endif } void RPGrpModelRfl::Configure() { @@ -82,9 +86,11 @@ void RPGrpModelRfl::Configure() { sDrawCoreSetting.posNrmMtxID = GX_PNMTX0; sDrawCoreSetting.reverseCulling = false; +#if defined(VERSION_RSPE01_01) GetScnRfl()->SetLightSetIdx(LIGHT_SET_IDX); GetScnRfl()->SetFogIdx(FOG_IDX); GetScnRfl()->SetAmbientColor((GXColor){255, 255, 255, 255}); +#endif mBrightnessColor = (GXColor){255, 255, 255, 255}; InternalCalc(); @@ -108,6 +114,7 @@ u16 RPGrpModelRfl::ReplaceTexture(const char* pName, return 1; } +#if defined(VERSION_RSPE01_01) void RPGrpModelRfl::InternalCalc() { if (!mReverseCulling) { nw4r::math::VEC3 scale(mBaseScale.x * sBaseScale, @@ -148,7 +155,9 @@ void RPGrpModelRfl::InternalCalc() { spCalcWorldMtxArray = NULL; } } +#endif +#if defined(VERSION_RSPE01_01) void RPGrpModelRfl::CalcBeforeDraw() { RPGrpModel::CalcBeforeDraw(); @@ -159,6 +168,7 @@ void RPGrpModelRfl::CalcBeforeDraw() { mFlagsRfl &= ~0x200; } } +#endif void RPGrpModelRfl::DrawProc(nw4r::g3d::ScnRfl* pScnRfl, const RFLCharModel* pModel, u32 diffMask, @@ -188,7 +198,7 @@ void RPGrpModelRfl::DrawGX(const RFLCharModel* pModel, u32 diffMask, bool useMat = !(EGG::ModelEx::getDrawFlag() & EGG::ModelEx::cDrawFlag_IgnoreMaterial); - bool bVar3 = ((unkC & 0x20) || (mFlagsRfl & 0x8)) && mDrawGroup == 1; + bool bVar3 = ((unkFlag & 0x20) || (mFlagsRfl & 0x8)) && mDrawGroup == 1; bool bVar2 = !(mFlagsRfl & 0x400) || mDrawGroup == 1; bool bVar3_2 = opa && (mFlagsRfl & 0x40); @@ -252,7 +262,9 @@ void RPGrpModelRfl::DrawGX(const RFLCharModel* pModel, u32 diffMask, } nw4r::math::MTX34 viewMtx; +#if defined(VERSION_RSPE01_01) GetScnRfl()->GetMtx(nw4r::g3d::ScnObj::MTX_VIEW, &viewMtx); +#endif viewMtx._03 = viewMtx._13 = viewMtx._23 = 0.0f; GXLoadTexMtxImm(viewMtx, GX_TEXMTX0, GX_MTX_3x4); @@ -407,6 +419,7 @@ void RPGrpModelRfl::DrawGX(const RFLCharModel* pModel, u32 diffMask, } } +#if defined(VERSION_RSPE01_01) const char* RPGrpModelRfl::GetJointName(u16 /* idx */) const { static const char JOINT_NAME[] = "dummy"; return JOINT_NAME; @@ -421,3 +434,4 @@ const char* RPGrpModelRfl::GetShapeName(u16 /* idx */) const { static const char SHAPE_NAME[] = "dummy"; return SHAPE_NAME; } +#endif diff --git a/src/Pack/RPGraphics/RPGrpModelScene.cpp b/src/Pack/RPGraphics/RPGrpModelScene.cpp new file mode 100644 index 000000000..34a54f820 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpModelScene.cpp @@ -0,0 +1,21 @@ +#include + +RPGrpModelScene::~RPGrpModelScene() {} + +void RPGrpModelScene::CalcView() { + mpScnRootEx->UpdateFrame(); + mpScnRootEx->CalcWorld(); +} + +void RPGrpModelScene::g_calc_background() { + mIdx = 0; + mpScnRootEx->CalcVtx(); + mpScnRootEx->CalcMaterial(); +} + +void RPGrpModelScene::setupGX() const { + mpScnRootEx->getScreen().SetProjectionGX(); + mpLightManager->SetChanAmbColor(); + mpLightManager->LoadObjIndxGX(); + mpFogManager->GetFog(0)->SetGX(); +} diff --git a/src/Pack/RPGraphics/RPGrpRenderer.cpp b/src/Pack/RPGraphics/RPGrpRenderer.cpp new file mode 100644 index 000000000..9a1aaa500 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpRenderer.cpp @@ -0,0 +1,53 @@ +#include +#include + +static bool renderState; + +void RPGrpRenderer::Begin() { + f32 modify; + + sRendering = FALSE; + sRenderPass = RENDERPASS_BEGIN; + spCurrentScreen = &RPGrpScreen::GetRootScreen(); + EGG::GfxEngine::beginDraw(); + modify = RP_GET_INSTANCE(RPSysSystem)->getModifyRatio(); + EGG::StateGX::setModifyRatio(modify); +} + +void RPGrpRenderer::StartDebugDraw() { + EGG::Matrix34f mtx; + + RPGrpScreen clone(RPGrpScreen::GetRootScreen()); + clone.SetNearZ(0.0f); + clone.SetFarZ(1.0f); + clone.SetProjectionType(EGG::Frustum::PROJ_ORTHO); + clone.SetProjectionGX(); + + nw4r::math::MTX34Identity(&mtx); + GXLoadPosMtxImm(mtx, GX_PNMTX0); + GXLoadNrmMtxImm(mtx, GX_PNMTX0); +} + +void RPGrpRenderer::End() { + sRenderPass = RENDERPASS_END; +} + +RPGrpViewRender3D* RPGrpRenderer::CreateView3D(u8 viewNo, RPGrpCamera* camera, + RPGrpScreen* screen) { + RPGrpViewRender3D* render = new RPGrpViewRender3D(viewNo); + + render->Configure(); + render->AttachCamera(camera); + render->AttachScreen(screen); + + return render; +} + +void RPGrpRenderer::AppendDrawObject(IRPGrpDrawObject* pObject) { + if (pObject) { + mpDrawObj = pObject; + } else { + mpDrawObj = pObject; + mpDrawList = pObject; + } +} diff --git a/src/Pack/RPKernel/RPSysKokeshiIcon.cpp b/src/Pack/RPKernel/RPSysKokeshiIcon.cpp index ab703d688..443e7eedb 100644 --- a/src/Pack/RPKernel/RPSysKokeshiIcon.cpp +++ b/src/Pack/RPKernel/RPSysKokeshiIcon.cpp @@ -234,6 +234,7 @@ void RPSysKokeshiIcon::MakeTexture(RPGrpModel* pModel, BeginMakeTexture(); { pScnRoot->Clear(); +#if defined(VERSION_RSPE01_01) nw4r::g3d::ScnObj* pScnObj = NULL; if (pModel->GetKind() == RPGrpModel::Kind_RFL) { @@ -243,6 +244,7 @@ void RPSysKokeshiIcon::MakeTexture(RPGrpModel* pModel, } pScnRoot->PushBack(pScnObj); +#endif pScnRoot->CalcWorld(); pScnRoot->CalcMaterial(); diff --git a/src/egg/gfxe/eggLightObject.cpp b/src/egg/gfxe/eggLightObject.cpp new file mode 100644 index 000000000..a780ccc21 --- /dev/null +++ b/src/egg/gfxe/eggLightObject.cpp @@ -0,0 +1,61 @@ +#include + +namespace EGG { + +void LightObject::Calc() { + mLightVector = mDir; + + mLightColor.a = mBrightnessColor.a; +} + +void LightObject::CalcView(const nw4r::math::MTX34& cameraMTX) { + nw4r::math::VEC3 camVec; + nw4r::math::VEC3 sumVec; + + if (mLightType == cLightType_Dir) { + camVec.z = -cameraMTX._22; + camVec.x = -cameraMTX._20; + camVec.y = -cameraMTX._21; + + if (nw4r::math::VEC3Len(&camVec) > 0.0f) { + C_VECHalfAngle(mDir, camVec, sumVec); + PSVECScale(sumVec, mLightVector, -1.0f); + } else { + mLightVector.y = 0.0f; + mLightVector.x = 0.0f; + mLightVector.z = 1.0f; + } + } +} + +void LightObject::InitGX(GXLightObj* pObj) const { +#line 281 + EGG_ASSERT(pObj); + if ((mFlags & 1) && (mFlags & 64)) { + GXInitLightColor(pObj, mLightColor); + //! TODO(texline) Variables are incomplete + } +} + +void LightObject::CalcDirDist() { + mDir.x = mAt.x - mPos.x; + mDir.y = mAt.y - mPos.y; + mDir.z = mAt.z - mPos.z; + + mDistance = nw4r::math::VEC3Len(&mDir); + if (mDistance > 0.0f) { + mDir /= mDistance; + } else { + mDir.z = 0.0f; + mDir.y = 0.0f; + mDir.x = 0.0f; + } +} + +void LightObject::CalcAt() { + mAt.x = (mDir.x * mDistance) + mPos.x; + mAt.y = (mDir.y * mDistance) + mPos.y; + mAt.z = (mDir.z * mDistance) + mPos.z; +} + +} // namespace EGG