g3d initial pullover (#115)

* g3d Headers

* initial g3d source files -- NOT YET FIXED

* change ResFile static_cast to explicit ctor
This commit is contained in:
Elijah Thomas
2025-02-09 12:40:41 -05:00
committed by GitHub
parent 85bef3afb9
commit cec09ad023
269 changed files with 30456 additions and 4825 deletions
+37
View File
@@ -44,13 +44,16 @@ BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: False
BreakStringLiterals: True
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 4
FixNamespaceComments: true
IncludeBlocks: Regroup
IndentAccessModifiers: False
IndentCaseLabels: True
IndentGotoLabels: True
IndentWidth: 4
InsertBraces: True
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: False
MaxEmptyLinesToKeep: 1
Language: Cpp
@@ -74,3 +77,37 @@ SpacesInLineCommentPrefix:
SpacesInParentheses: False
SpacesInSquareBrackets: False
UseTab: Never
WhitespaceSensitiveMacros: [
NW4R_UT_LINKLIST_FOREACH,
NW4R_UT_LINKLIST_FOREACH_SAFE,
NW4R_UT_LIST_FOREACH,
NW4R_UT_LIST_FOREACH_SAFE,
NW4R_EF_LIST_FOREACH,
NW4R_EF_LIST_FOREACH_SAFE
]
AttributeMacros: [DECOMP_INLINE, DECOMP_DONT_INLINE]
# Taken from ogws :)
IncludeCategories:
- Regex: '^<(nw4r|egg|Pack)?(\/)?types' # "Types" headers
Priority: 0
CaseSensitive: true
- Regex: '<egg\/[[:lower:].]+h>' # EGG public headers
Priority: 2
CaseSensitive: true
- Regex: '<nw4r\/[[:lower:].]+h>' # NW4R public headers
Priority: 3
CaseSensitive: true
- Regex: '^<rvl\/[[:upper:].]+h>' # RVL SDK public headers
Priority: 4
CaseSensitive: true
- Regex: '<[[:alnum:].]+>' # STL headers
Priority: 5 # Priority 0 is header mapped to src file
CaseSensitive: true
- Regex: '.*' # All other headers
Priority: 1
+20 -1
View File
@@ -4,5 +4,24 @@ CompileFlags:
"-Wno-c++11-compat-deprecated-writable-strings",
"-Wno-trigraphs",
"-fno-trigraphs",
"-Wno-c++11-extensions"
"-Wno-c++11-extensions",
"-Wno-shadow",
"-Wno-register"
]
---
# Fragment for suppressing some warning generated in rvl
If:
PathMatch: [
".*/rvl/.*",
".*/g3d/platform/.*",
".*/math/.*",
]
Diagnostics:
Suppress: [
"unknown_typename",
"expected_unqualified_id",
"expected_semi_declaration",
"undeclared_var_use",
]
+1 -1
View File
@@ -5,7 +5,7 @@
#include "m/m_angle.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcPy_c : public dAcObjBase_c {
// See Below for some info
+1 -1
View File
@@ -6,7 +6,7 @@
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "toBeSorted/actor_event.h"
#include "toBeSorted/stage_render_stuff.h"
+1 -1
View File
@@ -6,7 +6,7 @@
#include "d/col/c/c_cc_d.h"
#include "d/col/cc/d_cc_d.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateID.hpp"
#include "toBeSorted/effects_struct.h"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcObambooIsland_c : public dAcObjBase_c {
public:
+1 -1
View File
@@ -10,7 +10,7 @@
#include "d/d_shadow.h"
#include "m/m3d/m_smdl.h"
#include "m/m_mtx.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateID.hpp"
#include "toBeSorted/effects_struct.h"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_shadow.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dMyShadowCircle_c : public m3d::mShadowCircle_c {};
+1 -1
View File
@@ -5,7 +5,7 @@
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcOlavaF200_c : public dAcObjBase_c {
public:
+1 -1
View File
@@ -5,7 +5,7 @@
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcOmegamiIsland_c : public dAcObjBase_c {
public:
+1 -1
View File
@@ -3,7 +3,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOmoleSoil_c : public dAcObjBase_c {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOPoolCock_c : public dAcObjBase_c {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOPumpkinLeaf_c : public dAcObjBase_c {
+1 -1
View File
@@ -10,7 +10,7 @@
#include "m/m3d/m_smdl.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/math/math_types.h"
#include "rvl/MTX/mtx.h"
#include "s/s_State.hpp"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOsmoke_c : public dAcObjBase_c {
+1 -1
View File
@@ -5,7 +5,7 @@
#include "d/col/cc/d_cc_d.h"
#include "m/m3d/m_smdl.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateID.hpp"
+1 -1
View File
@@ -3,7 +3,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOstageCover_c : public dAcObjBase_c {
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
class dAcOsunLight_c : public dAcObjBase_c {
+1 -1
View File
@@ -5,7 +5,7 @@
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_smdl.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
#include "toBeSorted/stage_render_stuff.h"
+1 -1
View File
@@ -5,7 +5,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/cc/d_cc_d.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+5 -3
View File
@@ -7,7 +7,7 @@
#include "m/m_angle.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "toBeSorted/effects_struct.h"
@@ -31,8 +31,10 @@ public:
class dAcOTowerGearD101_c : public dAcObjBase_c {
public:
dAcOTowerGearD101_c()
: mStateMgr(*this, sStateID::null), field_0x3A0(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z),
field_0x3AC(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z), field_0x3B8(mAng3_c::Zero) {}
: mStateMgr(*this, sStateID::null),
field_0x3A0(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z),
field_0x3AC(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z),
field_0x3B8(mAng3_c::Zero) {}
virtual ~dAcOTowerGearD101_c() {}
STATE_FUNC_DECLARE(dAcOTowerGearD101_c, Wait);
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "m/m_angle.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "toBeSorted/effects_struct.h"
class dAcOtriforce_c : public dAcObjBase_c {
+1 -1
View File
@@ -13,7 +13,7 @@
#include "m/m3d/m_smdl.h"
#include "m/m_quat.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "toBeSorted/effects_struct.h"
+1 -1
View File
@@ -10,7 +10,7 @@
#include "m/m_mtx.h"
#include "m/m_quat.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "toBeSorted/dowsing_target.h"
#include "toBeSorted/time_area_mgr.h"
+2 -2
View File
@@ -4,8 +4,8 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "s/s_State.hpp"
class dAcOUgSwitch_c : public dAcObjBase_c {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcOutaDemoPedest_c : public dAcObjBase_c {
public:
+1 -2
View File
@@ -5,7 +5,7 @@
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcOutajima_c : public dAcObjBase_c {
public:
@@ -19,7 +19,6 @@ public:
virtual int draw() override;
private:
static void rideCallback(dBgW *, dAcObjBase_c *, dAcObjBase_c *);
m3d::smdl_c mMdls[2];
+1 -1
View File
@@ -8,7 +8,7 @@
#include "m/m3d/m_smdl.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
class dAcOutajimaLv2_c : public dAcObjBase_c {
public:
+1 -1
View File
@@ -6,7 +6,7 @@
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "toBeSorted/stage_render_stuff.h"
class dAcOwaterShield_c : public dAcObjBase_c {
+1 -1
View File
@@ -5,7 +5,7 @@
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmmdl.h"
#include "m/m3d/m_anmtexsrt.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+1 -1
View File
@@ -3,7 +3,7 @@
#include "m/m3d/m_bmdl.h"
#include "m/m3d/m_fanm.h"
#include "nw4r/g3d/g3d_resanmchr.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"
namespace m3d {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "m/m3d/m_anmchr.h"
#include "m/m3d/m_mdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resfile.h"
namespace m3d {
+1 -1
View File
@@ -4,7 +4,7 @@
#include "common.h"
#include "m/m3d/m_bmdl.h"
#include "m/m3d/m_fanm.h"
#include "nw4r/g3d/g3d_resanmshp.h"
#include "nw4r/g3d/res/g3d_resanmshp.h"
namespace m3d {
+1 -1
View File
@@ -6,7 +6,7 @@
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_anmchr.h"
#include "nw4r/g3d/g3d_calcworld.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
namespace m3d {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "m/m3d/m_bmdl.h"
#include "m/m3d/m_scnleaf.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d.h" // IWYU pragma: export
class UnkClass2 {};
+81
View File
@@ -0,0 +1,81 @@
#ifndef NW4R_PUBLIC_G3D_H
#define NW4R_PUBLIC_G3D_H
#include <nw4r/g3d/g3d_3dsmax.h>
#include <nw4r/g3d/g3d_anmchr.h>
#include <nw4r/g3d/g3d_anmclr.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/g3d_anmscn.h>
#include <nw4r/g3d/g3d_anmshp.h>
#include <nw4r/g3d/g3d_anmtexpat.h>
#include <nw4r/g3d/g3d_anmtexsrt.h>
#include <nw4r/g3d/g3d_anmvis.h>
#include <nw4r/g3d/g3d_basic.h>
#include <nw4r/g3d/g3d_calcmaterial.h>
#include <nw4r/g3d/g3d_calcview.h>
#include <nw4r/g3d/g3d_calcvtx.h>
#include <nw4r/g3d/g3d_calcworld.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_dcc.h>
#include <nw4r/g3d/g3d_draw.h>
#include <nw4r/g3d/g3d_draw1mat1shp.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_init.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_maya.h>
#include <nw4r/g3d/g3d_obj.h>
#include <nw4r/g3d/g3d_rtti.h>
#include <nw4r/g3d/g3d_scnmdl.h>
#include <nw4r/g3d/g3d_scnmdl1mat1shp.h>
#include <nw4r/g3d/g3d_scnmdlsmpl.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/g3d_scnproc.h>
#include <nw4r/g3d/g3d_scnrfl.h>
#include <nw4r/g3d/g3d_scnroot.h>
#include <nw4r/g3d/g3d_state.h>
#include <nw4r/g3d/g3d_workmem.h>
#include <nw4r/g3d/g3d_xsi.h>
/******************************************************************************
*
* Resources
*
******************************************************************************/
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_resanmamblight.h>
#include <nw4r/g3d/res/g3d_resanmcamera.h>
#include <nw4r/g3d/res/g3d_resanmchr.h>
#include <nw4r/g3d/res/g3d_resanmclr.h>
#include <nw4r/g3d/res/g3d_resanmfog.h>
#include <nw4r/g3d/res/g3d_resanmlight.h>
#include <nw4r/g3d/res/g3d_resanmscn.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include <nw4r/g3d/res/g3d_resanmtexpat.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resanmvis.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include <nw4r/g3d/res/g3d_resfile.h>
#include <nw4r/g3d/res/g3d_reslightset.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include <nw4r/g3d/res/g3d_respltt.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include <nw4r/g3d/res/g3d_restev.h>
#include <nw4r/g3d/res/g3d_restex.h>
#include <nw4r/g3d/res/g3d_resvtx.h>
/******************************************************************************
*
* Platform-specific
*
******************************************************************************/
#include <nw4r/g3d/platform/g3d_allocator.h>
#include <nw4r/g3d/platform/g3d_cpu.h>
#include <nw4r/g3d/platform/g3d_gpu.h>
#include <nw4r/g3d/platform/g3d_tmem.h>
#endif
+7 -5
View File
@@ -1,15 +1,17 @@
#ifndef NW4R_G3D_3DSMAX_H
#define NW4R_G3D_3DSMAX_H
#include "common.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
#include "nw4r/math.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
namespace nw4r {
namespace g3d {
namespace detail {
namespace dcc {
bool CalcTexMtx_3dsmax(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag);
}
bool CalcTexMtx_3dsmax(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag);
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
+178 -60
View File
@@ -1,90 +1,208 @@
#ifndef NW4R_G3D_ANMCHR_H
#define NW4R_G3D_ANMCHR_H
#include "common.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/math/math_types.h"
#ifndef NW4R_G3D_ANM_CHR_H
#define NW4R_G3D_ANM_CHR_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmchr.h>
namespace nw4r {
namespace g3d {
struct ChrAnmResult {
u32 mFlags; // at 0x0
math::VEC3 VEC3_0x4;
math::VEC3 VEC3_0x10;
math::MTX34 mMtx; // at 0x1C
};
/******************************************************************************
*
* AnmObjChr
*
******************************************************************************/
// Forward declarations
class AnmObjChrRes;
class AnmObjChr : public AnmObj {
public:
enum BindOption {
BIND_ONE,
BIND_PARTIAL,
NUM_OF_BIND_OPTION
};
enum BindOption {};
public:
AnmObjChr(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObjChr() {} // at 0x10
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual const ChrAnmResult *GetResult(ChrAnmResult *pResult,
u32 idx) = 0; // at 0x38
virtual AnmObjChrRes *Attach(int idx, AnmObjChrRes *pRes); // at 0x3C
virtual AnmObjChrRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
virtual void SetWeight(int idx, f32 weight); // at 0x48
virtual f32 GetWeight(int idx) const; // at 0x4C
virtual bool Bind(const ResMdl mdl, u32 target,
BindOption option) = 0; // at 0x50
virtual void Release(const ResMdl mdl, u32 target,
BindOption option) = 0; // at 0x54
bool TestExistence(u32 idx) const;
bool TestDefined(u32 idx) const;
void UseQuaternionBlend(bool enable) {
SetAnmFlag(FLAG_USE_QUATERNION_ROTATION_BLEND, enable);
}
virtual ChrAnmResult *GetResult(ChrAnmResult *, u32); // at 0x38
virtual void Attach(int, AnmObjChrRes*); // at 0x3C
virtual void Detach(int); // at 0x40
virtual void DetachAll(); // at 0x44
virtual void SetWeight(int, f32); // at 0x48
virtual f32 GetWeight(int) const; // at 0x4C
virtual void Bind(ResMdl, u32, BindOption) = 0; // at 0x50
virtual void Release(ResMdl, u32, BindOption) = 0; // at 0x54
private:
UNKWORD field_0x10;
UNKWORD field_0x14;
void UseAccurateScaleBlend(bool enable) {
SetAnmFlag(FLAG_USE_ACCURATE_SCALE_BLEND, enable);
}
protected:
NW4R_G3D_TYPE_OBJ_DECL(AnmObjChr);
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
protected:
static const int DEFAULT_MAX_CHILDREN = 4;
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjChr, AnmObj);
};
/******************************************************************************
*
* AnmObjChrNode
*
******************************************************************************/
class AnmObjChrNode : public AnmObjChr {
public:
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
AnmObjChrNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjChrRes **ppChildrenBuf, int numChildren
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjChrNode(); // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
virtual AnmObjChrRes *Attach(int idx, AnmObjChrRes *pRes); // at 0x3C
virtual AnmObjChrRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
virtual bool Bind(const ResMdl mdl, u32 target,
BindOption option); // at 0x50
virtual void Release(const ResMdl mdl, u32 target,
BindOption option); // at 0x54
inline int Size() {
return mNodeArraySize;
return mChildrenArraySize;
}
AnmObjChrRes *GetNode(int i) {
return mpNodes[i];
return mpChildrenArray[i];
}
protected:
int mChildrenArraySize; // at 0x18
AnmObjChrRes **mpChildrenArray; // at 0x1C
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjChrNode, AnmObjChr);
};
/******************************************************************************
*
* AnmObjChrBlend
*
******************************************************************************/
class AnmObjChrBlend : public AnmObjChrNode {
public:
static AnmObjChrBlend *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren);
AnmObjChrBlend(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjChrRes **ppChildrenBuf, int numChildren,
f32 *pWeightBuf
);
virtual ~AnmObjChrBlend() {} // at 0x10
virtual const ChrAnmResult *GetResult(ChrAnmResult *pResult,
u32 idx); // at 0x38
virtual void SetWeight(int idx, f32 weight); // at 0x48
virtual f32 GetWeight(int idx) const; // at 0x4C
private:
f32 *mpWeightArray; // at 0x20
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjChrBlend, AnmObjChrNode);
};
/******************************************************************************
*
* AnmObjChrRes
*
******************************************************************************/
class AnmObjChrRes : public AnmObjChr, protected FrameCtrl {
public:
static AnmObjChrRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmChr chr, ResMdl mdl, bool cache);
AnmObjChrRes(MEMAllocator *pAllocator, ResAnmChr chr, u16 *pBindingBuf, int numBinding, ChrAnmResult *pCacheBuf);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjChrRes() {} // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
using AnmObjChr::Release; // at 0x40
virtual const ChrAnmResult *GetResult(ChrAnmResult *pResult,
u32 idx); // at 0x38
virtual bool Bind(const ResMdl mdl, u32 target,
BindOption option); // at 0x50
virtual void Release(const ResMdl mdl, u32 target,
BindOption option); // at 0x54
void UpdateCache();
ResAnmChr GetResAnm() {
return mRes;
}
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
private:
int mNodeArraySize;
AnmObjChrRes **mpNodes;
ResAnmChr mRes; // at 0x2C
ChrAnmResult *const mpResultCache; // at 0x30
protected:
NW4R_G3D_TYPE_OBJ_DECL(AnmObjChrNode);
};
class AnmObjChrBlend : public AnmObjChrNode {
public:
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
static AnmObjChrBlend *Construct(MEMAllocator*, u32*, ResMdl, int);
protected:
NW4R_G3D_TYPE_OBJ_DECL(AnmObjChrBlend);
};
class AnmObjChrRes : public AnmObjChr, public FrameCtrl {
public:
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
static AnmObjChrRes *Construct(MEMAllocator*, u32*, ResAnmChr, ResMdl, bool);
protected:
NW4R_G3D_TYPE_OBJ_DECL(AnmObjChrRes);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjChrRes, AnmObjChr);
};
} // namespace g3d
+138 -54
View File
@@ -1,83 +1,167 @@
#ifndef NW4R_G3D_ANMCLR_H
#define NW4R_G3D_ANMCLR_H
#include "common.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_resanmclr.h"
#ifndef NW4R_G3D_ANM_CLR_H
#define NW4R_G3D_ANM_CLR_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmclr.h>
#include <nw4r/g3d/res/g3d_resmat.h>
namespace nw4r {
namespace g3d {
struct ClrAnmResult {
enum { ANM_COUNT = 11 };
u32 mFlags; // at 0x0
u32 COLORS_0x4[ANM_COUNT];
UNKWORD WORDS_0x30[ANM_COUNT];
};
void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev, const ClrAnmResult *pResult);
/******************************************************************************
*
* AnmObjMatClr
*
******************************************************************************/
// Forward declarations
class AnmObjMatClrRes;
class AnmObjMatClr : public AnmObj {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
AnmObjMatClr(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObjMatClr() {} // at 0x10
virtual ClrAnmResult *GetResult(); // at 0x38
virtual void Attach(s32, AnmObjMatClrRes *res); // at 0x3C
virtual void Detach(s32); // at 0x40
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
private:
int mChildrenArraySize;
u16 *mpChildrenArray;
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
NW4R_G3D_TYPE_OBJ_DECL(AnmObjMatClr);
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual const ClrAnmResult *GetResult(ClrAnmResult *pResult,
u32 idx) = 0; // at 0x38
virtual AnmObjMatClrRes *Attach(int idx, AnmObjMatClrRes *pRes); // at 0x3C
virtual AnmObjMatClrRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
bool TestExistence(u32 idx) const;
bool TestDefined(u32 idx) const;
protected:
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
protected:
static const int DEFAULT_MAX_CHILDREN = 4;
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjMatClr, AnmObj);
};
/******************************************************************************
*
* AnmObjMatClrNode
*
******************************************************************************/
class AnmObjMatClrNode : public AnmObjMatClr {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
AnmObjMatClrNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjMatClrRes **ppChildrenBuf, int numChildren
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjMatClrNode(); // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
virtual AnmObjMatClrRes *Attach(int idx, AnmObjMatClrRes *pRes); // at 0x3C
virtual AnmObjMatClrRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
int Size() const {
return mChildrenArraySize;
}
inline int Size() {
return mNodeArraySize;
}
protected:
int mChildrenArraySize; // at 0x18
AnmObjMatClrRes **mpChildrenArray; // at 0x1C
AnmObjMatClrRes *GetNode(int i) {
return mpNodes[i];
}
private:
int mNodeArraySize;
AnmObjMatClrRes **mpNodes;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjMatClrNode);
};
class AnmObjMatClrRes : public AnmObjMatClr, public FrameCtrl {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
static AnmObjMatClrRes *Construct(MEMAllocator *, u32 *, ResAnmClr, ResMdl, bool);
private:
ResAnmClr mRes;
TexSrtAnmResult *mpResultCache;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjMatClrRes);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjMatClrNode, AnmObjMatClr);
};
/******************************************************************************
*
* AnmObjMatClrOverride
*
******************************************************************************/
class AnmObjMatClrOverride : public AnmObjMatClrNode {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
static AnmObjMatClrOverride *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren);
AnmObjMatClrOverride(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjMatClrRes **ppChildrenBuf, int numChildren
)
: AnmObjMatClrNode(pAllocator, pBindingBuf, numBinding, ppChildrenBuf, numChildren) {}
virtual ~AnmObjMatClrOverride() {} // at 0x10
virtual const ClrAnmResult *GetResult(ClrAnmResult *pResult,
u32 idx); // at 0x38
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjMatClrOverride, AnmObjMatClrNode);
};
/******************************************************************************
*
* AnmObjMatClrRes
*
******************************************************************************/
class AnmObjMatClrRes : public AnmObjMatClr, protected FrameCtrl {
public:
static AnmObjMatClrRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmClr clr, ResMdl mdl, bool cache);
AnmObjMatClrRes(MEMAllocator *pAllocator, ResAnmClr clr, u16 *pBindingBuf, int numBinding, ClrAnmResult *pCacheBuf);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjMatClrRes() {} // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual const ClrAnmResult *GetResult(ClrAnmResult *pResult,
u32 idx); // at 0x38
void UpdateCache();
ResAnmClr GetResAnm() {
return mRes;
}
static AnmObjMatClrOverride *Construct(MEMAllocator *, u32 *, ResMdl, int);
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
NW4R_G3D_TYPE_OBJ_DECL(AnmObjMatClrOverride);
private:
ResAnmClr mRes; // at 0x2C
ClrAnmResult *const mpResultCache; // at 0x30
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjMatClrRes, AnmObjMatClr);
};
} // namespace g3d
+84 -73
View File
@@ -1,102 +1,113 @@
#ifndef NW4R_G3D_ANMOBJ_H
#define NW4R_G3D_ANMOBJ_H
#include "common.h"
#include "nw4r/g3d/g3d_obj.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/g3d/g3d_resmdl.h"
#ifndef NW4R_G3D_ANM_OBJ_H
#define NW4R_G3D_ANM_OBJ_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_obj.h>
#include <nw4r/g3d/res/g3d_resanm.h>
namespace nw4r {
namespace g3d {
enum AnmPolicy { ANM_POLICY_ONETIME, ANM_POLICY_LOOP, ANM_POLICY_MAX };
typedef f32 (*PlayPolicyFunc)(f32, f32, f32);
f32 PlayPolicy_Onetime(f32, f32, f32);
f32 PlayPolicy_Loop(f32, f32, f32);
/******************************************************************************
*
* AnmObj
*
******************************************************************************/
class AnmObj : public G3dObj {
NW4R_G3D_RTTI_DECL_DERIVED(AnmObj, G3dObj);
public:
enum AnmFlag {
FLAG_NEED_UPDATE = (1 << 0),
FLAG_CACHE_OBSOLETE = (1 << 1),
FLAG_ANM_BOUND = (1 << 2),
FLAG_USE_QUATERNION_ROTATION_BLEND = (1 << 3),
FLAG_USE_ACCURATE_SCALE_BLEND = (1 << 4)
};
public:
AnmObj(MEMAllocator *pAllocator, G3dObj *pParent) : G3dObj(pAllocator, pParent), mFlags(0) {}
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObj() {} // at 0x10
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
void SetAnmFlag(AnmFlag flag, bool value);
bool TestAnmFlag(AnmFlag flag) const;
bool IsBound() const {
return TestAnmFlag(FLAG_ANM_BOUND);
}
private:
u32 mFlags; // at 0xC
};
/******************************************************************************
*
* PlayPolicy
*
******************************************************************************/
f32 PlayPolicy_Onetime(f32 start, f32 end, f32 frame);
f32 PlayPolicy_Loop(f32 start, f32 end, f32 frame);
typedef f32 (*PlayPolicyFunc)(f32 start, f32 end, f32 frame);
inline PlayPolicyFunc GetAnmPlayPolicy(AnmPolicy policy) {
static PlayPolicyFunc policyTable[ANM_POLICY_MAX] = {PlayPolicy_Onetime, PlayPolicy_Loop};
return policyTable[policy];
}
struct FrameCtrl {
FrameCtrl(f32 f1, f32 f2, PlayPolicyFunc policy)
: mFrame(0.0f), mRate(1.0f), FLOAT_0x8(f1), mEndFrame(f2), mPolicy(policy) {}
/******************************************************************************
*
* FrameCtrl
*
******************************************************************************/
class FrameCtrl {
public:
FrameCtrl(f32 start, f32 end, PlayPolicyFunc pPolicy)
: mFrame(0.0f), mUpdateRate(1.0f), mStartFrame(start), mEndFrame(end), mpPlayPolicy(pPolicy) {}
f32 GetFrm() const {
return mFrame;
}
void SetFrm(f32 frame) {
mFrame = mpPlayPolicy(mStartFrame, mEndFrame, frame);
}
void UpdateFrm() {
SetFrm(mUpdateRate * smBaseUpdateRate + mFrame);
}
f32 GetRate() const {
return mRate;
return mUpdateRate;
}
void SetFrm(f32 frm) {
f32 newFrm = mPolicy(FLOAT_0x8, mEndFrame, frm);
mFrame = newFrm;
}
void SetRate(f32 rate) {
mRate = rate;
mUpdateRate = rate;
}
void SetPolicy(PlayPolicyFunc func) {
mPolicy = func;
void SetPlayPolicy(PlayPolicyFunc func) {
mpPlayPolicy = func;
}
void UpdateFrm() {
SetFrm(mFrame + mRate * smBaseUpdateRate);
}
f32 mFrame; // at 0x0
f32 mRate; // at 0x4
f32 FLOAT_0x8;
f32 mEndFrame;
PlayPolicyFunc mPolicy; // at 0x10
private:
f32 mFrame; // at 0x0
f32 mUpdateRate; // at 0x4
f32 mStartFrame; // at 0x8
f32 mEndFrame; // at 0xC
PlayPolicyFunc mpPlayPolicy; // at 0x10
static f32 smBaseUpdateRate;
};
class AnmObj : public G3dObj {
public:
enum AnmFlag { ANMFLAG_2 = 0x2, ANMFLAG_ISBOUND = 0x4 };
public:
AnmObj(MEMAllocator *pAllocator, G3dObj *pParent) : G3dObj(pAllocator, pParent), mFlags(0) {}
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : G3dObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *) = 0; // at 0xC
virtual ~AnmObj() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(ResMdl) = 0; // at 0x30
virtual void Release(); // at 0x34
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
void SetAnmFlag(AnmFlag, bool);
bool TestAnmFlag(AnmFlag) const;
private:
u32 mFlags; // at 0x4
NW4R_G3D_TYPE_OBJ_DECL(AnmObj);
};
} // namespace g3d
} // namespace nw4r
+62 -45
View File
@@ -1,55 +1,72 @@
#ifndef NW4R_G3D_ANMSCN_H
#define NW4R_G3D_ANMSCN_H
#include "common.h"
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/g3d_light.h"
#include "nw4r/g3d/g3d_obj.h"
#ifndef NW4R_G3D_ANM_SCN_H
#define NW4R_G3D_ANM_SCN_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_obj.h>
namespace nw4r {
namespace g3d {
class AnmScnRes // : public AnmScn
{};
class AnmScn : G3dObj {
// Forward declarations
class AnmScnRes;
class AnmScn : public G3dObj {
public:
AnmScn(MEMAllocator *);
virtual bool IsDerivedFrom(TypeObj other) const; // at 0x8
virtual ~AnmScn(); // at 0x10
virtual const TypeObj GetTypeObj() const; // at 0x14
virtual const char *GetTypeName() const; // at 0x18
virtual void SetFrame(f32) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void SetUpdateRate(f32) = 0; // at 0x24
virtual f32 GetUpdateRate() const = 0; // at 0x28
virtual void UpdateFrame() = 0; // at 0x2C
virtual void Attach(int, AnmScnRes); // at 0x30
virtual void Detach(); // at 0x34
virtual int GetNumLightSet() const = 0; // at 0x38
virtual int GetNumAmbLight() const = 0; // at 0x3C
virtual int GetNumDiffuseLight() const = 0; // at 0x40
virtual int GetNumSpecularLight() const = 0; // at 0x44
virtual int GetNumFog() const = 0; // at 0x48
virtual int GetNumCamera() const = 0; // at 0x4C
virtual int GetLightSetMaxRefNumber() const = 0; // at 0x50
virtual int GetAmbLightMaxRefNumber() const = 0; // at 0x54
virtual int GetDiffuseLightMaxRefNumber() const = 0; // at 0x58
virtual int GetFogMaxRefNumber() const = 0; // at 0x5C
virtual int GetCameraMaxRefNumber() const = 0; // at 0x60
virtual void GetLightSet(LightSet, u32) = 0; // at 0x64
virtual ut::Color GetAmbLightColor(u32) = 0; // at 0x68
virtual void GetLight(LightObj *, LightObj *, u32) = 0; // at 0x6C
virtual void GetFog(Fog, u32) = 0; // at 0x70
virtual void GetCamera(Camera, u32) = 0; // at 0x74
virtual int GetSpecularLightID(u32) const = 0; // at 0x78
virtual bool HasSpecularLight(u32) const = 0; // at 0x7C
virtual void GetAmbLightResult(AmbLightAnmResult *, u32) = 0; // at 0x80
virtual void GetLightResult(LightAnmResult *, u32) = 0; // at 0x84
virtual void GetFogResult(FogAnmResult *, u32) = 0; // at 0x88
virtual void GetFogResult(CameraAnmResult *, u32) = 0; // at 0x8C
explicit AnmScn(MEMAllocator *pAllocator);
virtual ~AnmScn(); // at 0x10
void GetLightSetting(LightSetting *);
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void SetUpdateRate(f32 rate) = 0; // at 0x24
virtual f32 GetUpdateRate() const = 0; // at 0x28
virtual void UpdateFrame() = 0; // at 0x2C
virtual AnmScnRes *Attach(int idx, AnmScnRes *pRes); // at 0x30
virtual AnmScnRes *Detach(); // at 0x34
virtual u32 GetNumLightSet() const = 0; // at 0x38
virtual u32 GetNumAmbLight() const = 0; // at 0x3C
virtual u32 GetNumDiffuseLight() const = 0; // at 0x40
virtual u32 GetNumSpecularLight() const = 0; // at 0x44
virtual u32 GetNumFog() const = 0; // at 0x48
virtual u32 GetNumCamera() const = 0; // at 0x4C
virtual u32 GetLightSetMaxRefNumber() const = 0; // at 0x50
virtual u32 GetAmbLightMaxRefNumber() const = 0; // at 0x54
virtual u32 GetDiffuseLightMaxRefNumber() const = 0; // at 0x58
virtual u32 GetFogMaxRefNumber() const = 0; // at 0x5C
virtual u32 GetCameraMaxRefNumber() const = 0; // at 0x60
virtual bool GetLightSet(LightSet set, u32 refNumber) = 0; // at 0x64
virtual ut::Color GetAmbLightColor(u32 refNumber) = 0; // at 0x68
virtual void GetLight(LightObj *pDiff, LightObj *pSpec,
u32 refNumber) = 0; // at 0x6C
virtual void GetFog(Fog fog, u32 refNumber) = 0; // at 0x70
virtual bool GetCamera(Camera camera, u32 refNumber) = 0; // at 0x74
virtual u32 GetSpecularLightID(u32 refNumber) const = 0; // at 0x78
virtual bool HasSpecularLight(u32 refNumber) const = 0; // at 0x7C
virtual AmbLightAnmResult *GetAmbLightResult(AmbLightAnmResult *pResult,
u32 refNumber) = 0; // at 0x80
virtual LightAnmResult *GetLightResult(LightAnmResult *pResult,
u32 refNumber) = 0; // at 0x84
virtual FogAnmResult *GetFogResult(FogAnmResult *pResult,
u32 refNumber) = 0; // at 0x88
virtual CameraAnmResult *GetCameraResult(CameraAnmResult *pResult,
u32 refNumber) = 0; // at 0x8C
void GetLightSetting(LightSetting *pSetting);
private:
NW4R_G3D_RTTI_DECL_DERIVED(AnmScn, G3dObj);
};
} // namespace g3d
} // namespace nw4r
+145 -69
View File
@@ -1,98 +1,174 @@
#ifndef NW4R_G3D_ANMSHP_H
#define NW4R_G3D_ANMSHP_H
#include "common.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_resanmshp.h"
#ifndef NW4R_G3D_ANM_SHP_H
#define NW4R_G3D_ANM_SHP_H
#include <nw4r/types_nw4r.h>
// This header is based on the SS ghidra, the TypeNames in the binary,
// and an assumed symmetry to AnmObjVis. Everything about it could be wrong.
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
namespace nw4r {
namespace g3d {
/******************************************************************************
*
* AnmObjShp
*
******************************************************************************/
// Forward declarations
class AnmObjShpRes;
class AnmObjShp : public AnmObj {
public:
AnmObjShp(MEMAllocator *, u16 *, int);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~AnmObjShp() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(ResMdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual bool GetResult(u32) = 0; // at 0x38
virtual AnmObjShpRes *Attach(int, AnmObjShpRes *); // at 0x3C
virtual AnmObjShpRes *Detach(int); // at 0x40
AnmObjShp(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObjShp() {} // at 0x10
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual const ShpAnmResult *GetResult(ShpAnmResult *pResult,
u32 idx) = 0; // at 0x38
virtual AnmObjShpRes *Attach(int idx, AnmObjShpRes *pRes); // at 0x3C
virtual AnmObjShpRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
virtual void SetWeight(int idx, f32 weight); // at 0x48
virtual f32 GetWeight(int idx) const; // at 0x4C
bool TestDefined(u32 idx) const;
bool TestExistence(u32 idx) const;
void DetachAll();
bool TestDefined(u32 idx) const;
protected:
static const int MAX_RESOURCES = 4;
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
int mNumBinds; // at 0x10
u16 *mBinds; // at 0x14
protected:
static const int DEFAULT_MAX_CHILDREN = 4;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjShp);
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjShp, AnmObj);
};
class AnmObjShpRes : public AnmObjShp, public FrameCtrl {
/******************************************************************************
*
* AnmObjShpNode
*
******************************************************************************/
class AnmObjShpNode : public AnmObjShp {
public:
AnmObjShpRes(MEMAllocator *, ResAnmShp, u16 *, int);
AnmObjShpNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjShpRes **ppChildrenBuf, int numChildren
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjShpNode(); // at 0x10
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObjShp::IsDerivedFrom(other);
}
virtual ~AnmObjShpRes() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(ResMdl); // at 0x30
virtual bool GetResult(u32); // at 0x38
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
static AnmObjShpRes *Construct(MEMAllocator *, u32 *, ResAnmShp, ResMdl, bool);
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
virtual AnmObjShpRes *Attach(int idx, AnmObjShpRes *pRes); // at 0x3C
virtual AnmObjShpRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
protected:
int mChildrenArraySize; // at 0x18
AnmObjShpRes **mpChildrenArray; // at 0x1C
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjShpNode, AnmObjShp);
};
/******************************************************************************
*
* AnmObjShpBlend
*
******************************************************************************/
class AnmObjShpBlend : public AnmObjShpNode {
static AnmObjShpBlend *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren);
AnmObjShpBlend(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjShpRes **ppChildrenBuf, int numChildren,
f32 *pWeightBuf
);
virtual ~AnmObjShpBlend() {} // at 0x10
virtual const ShpAnmResult *GetResult(ShpAnmResult *pResult,
u32 idx); // at 0x38
virtual void SetWeight(int idx, f32 weight); // at 0x48
virtual f32 GetWeight(int idx) const; // at 0x4C
private:
ResAnmShp mResAnmShp; // at 0x2C
f32 *mpWeightArray; // at 0x20
NW4R_G3D_TYPE_OBJ_DECL(AnmObjShpRes);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjShpBlend, AnmObjShpNode);
};
/******************************************************************************
*
* AnmObjShpRes
*
******************************************************************************/
class AnmObjShpRes : public AnmObjShp, protected FrameCtrl {
public:
static AnmObjShpRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmShp shp, ResMdl mdl, bool cache);
AnmObjShpRes(
MEMAllocator *pAllocator, ResAnmShp shp, u16 *pBindingBuf, ShpAnmVtxSet *pVtxSetBuf, int numBinding,
ShpAnmResult *pCacheBuf
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjShpRes() {} // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual const ShpAnmResult *GetResult(ShpAnmResult *pResult,
u32 idx); // at 0x38
void UpdateCache();
ResAnmShp GetResAnm() {
return mRes;
}
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
private:
ResAnmShp mRes; // at 0x2C
ShpAnmVtxSet *const mpVtxSetArray; // at 0x30
ShpAnmResult *const mpResultCache; // at 0x34
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjShpRes, AnmObjShp);
};
} // namespace g3d
} // namespace nw4r
+153 -72
View File
@@ -1,94 +1,175 @@
#ifndef NW4R_G3D_ANMTEXPAT_H
#define NW4R_G3D_ANMTEXPAT_H
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_restex.h"
#include "nw4r/g3d/g3d_resanmtexpat.h"
#ifndef NW4R_G3D_ANM_TEX_PAT_H
#define NW4R_G3D_ANM_TEX_PAT_H
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace g3d
{
struct TexPatAnmResult
{
enum
{
ANM_COUNT = 8
};
u8 mTexFlags; // at 0x0
u8 mPlttFlags; // at 0x1
ResTex mTexs[ANM_COUNT]; // at 0x4
ResPltt mPltts[ANM_COUNT]; // at 0x24
};
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmtexpat.h>
class AnmObjTexPatRes;
namespace nw4r {
namespace g3d {
class AnmObjTexPat : public AnmObj {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
void ApplyTexPatAnmResult(ResTexObj texObj, ResTlutObj tlutObj, const TexPatAnmResult *pResult);
virtual TexPatAnmResult *GetResult(); // at 0x38
virtual void Attach(s32, AnmObjTexPatRes *res); // at 0x3C
virtual void Detach(s32); // at 0x40
/******************************************************************************
*
* AnmObjTexPat
*
******************************************************************************/
// Forward declarations
class AnmObjTexPatRes;
private:
int mChildrenArraySize;
u16 *mpChildrenArray;
class AnmObjTexPat : public AnmObj {
public:
AnmObjTexPat(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObjTexPat() {} // at 0x10
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPat);
};
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
class AnmObjTexPatNode : public AnmObjTexPat {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
inline int Size() {
return mNodeArraySize;
}
virtual const TexPatAnmResult *GetResult(TexPatAnmResult *pResult,
u32 idx) = 0; // at 0x38
AnmObjTexPatRes *GetNode(int i) {
return mpNodes[i];
}
virtual AnmObjTexPatRes *Attach(int idx, AnmObjTexPatRes *pRes); // at 0x3C
virtual AnmObjTexPatRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
private:
int mNodeArraySize;
AnmObjTexPatRes **mpNodes;
bool TestExistence(u32 idx) const;
bool TestDefined(u32 idx) const;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatNode);
};
protected:
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
class AnmObjTexPatRes : public AnmObjTexPat, public FrameCtrl {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
protected:
static const int MAX_CHILD = 4;
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
static AnmObjTexPatRes *Construct(MEMAllocator*, u32*, ResAnmTexPat, ResMdl, bool);
private:
ResAnmTexPat mRes;
TexPatAnmResult *mpResultCache;
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexPat, AnmObj);
};
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatRes);
};
/******************************************************************************
*
* AnmObjTexPatNode
*
******************************************************************************/
class AnmObjTexPatNode : public AnmObjTexPat {
public:
AnmObjTexPatNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjTexPatRes **ppChildrenBuf, int numChildren
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjTexPatNode(); // at 0x10
class AnmObjTexPatOverride : public AnmObjTexPatNode {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
static AnmObjTexPatOverride *Construct(MEMAllocator*, u32*, ResMdl, int);
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatOverride);
};
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
}
}
virtual AnmObjTexPatRes *Attach(int idx, AnmObjTexPatRes *pRes); // at 0x3C
virtual AnmObjTexPatRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
inline int Size() {
return mChildrenArraySize;
}
AnmObjTexPatRes *GetNode(int i) {
return mpChildrenArray[i];
}
protected:
int mChildrenArraySize; // at 0x18
AnmObjTexPatRes **mpChildrenArray; // at 0x1C
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexPatNode, AnmObjTexPat);
};
/******************************************************************************
*
* AnmObjTexPatOverride
*
******************************************************************************/
class AnmObjTexPatOverride : public AnmObjTexPatNode {
public:
static AnmObjTexPatOverride *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren);
AnmObjTexPatOverride(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjTexPatRes **ppChildrenBuf, int numChildren
)
: AnmObjTexPatNode(pAllocator, pBindingBuf, numBinding, ppChildrenBuf, numChildren) {}
virtual ~AnmObjTexPatOverride() {} // at 0x10
virtual const TexPatAnmResult *GetResult(TexPatAnmResult *pResult,
u32 idx); // at 0x38
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexPatOverride, AnmObjTexPatNode);
};
/******************************************************************************
*
* AnmObjTexPatRes
*
******************************************************************************/
class AnmObjTexPatRes : public AnmObjTexPat, protected FrameCtrl {
public:
static AnmObjTexPatRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmTexPat pat, ResMdl mdl, bool cache);
AnmObjTexPatRes(
MEMAllocator *pAllocator, ResAnmTexPat pat, u16 *pBindingBuf, int numBinding, TexPatAnmResult *pCacheBuf
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjTexPatRes() {} // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual const TexPatAnmResult *GetResult(TexPatAnmResult *pResult,
u32 idx); // at 0x38
void UpdateCache();
ResAnmTexPat GetResAnm() {
return mRes;
}
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
private:
ResAnmTexPat mRes; // at 0x2C
TexPatAnmResult *const mpResultCache; // at 0x30
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexPatRes, AnmObjTexPat);
};
} // namespace g3d
} // namespace nw4r
#endif
+149 -93
View File
@@ -1,117 +1,173 @@
#ifndef NW4R_G3D_ANMTEXSRT_H
#define NW4R_G3D_ANMTEXSRT_H
#include "nw4r/g3d/g3d_restex.h"
#include "nw4r/g3d/g3d_resanmtexsrt.h"
#ifndef NW4R_G3D_ANM_TEX_SRT_H
#define NW4R_G3D_ANM_TEX_SRT_H
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace g3d
{
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resmat.h>
class AnmObjTexSrtRes;
struct TexSrtAnmResult;
namespace nw4r {
namespace g3d {
class AnmObjTexSrt : public AnmObj {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
void ApplyTexSrtAnmResult(ResTexSrt srt, const TexSrtAnmResult *pResult);
void ApplyTexSrtAnmResult(ResTexSrt srt, ResMatIndMtxAndScale ind, const TexSrtAnmResult *pResult);
virtual TexSrtAnmResult *GetResult(); // at 0x38
virtual void Attach(s32, AnmObjTexSrtRes *res); // at 0x3C
virtual void Detach(s32); // at 0x40
/******************************************************************************
*
* AnmObjTexSrt
*
******************************************************************************/
// Forward declarations
class AnmObjTexSrtRes;
private:
int mChildrenArraySize;
u16 *mpChildrenArray;
class AnmObjTexSrt : public AnmObj {
public:
AnmObjTexSrt(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~AnmObjTexSrt() {} // at 0x10
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexSrt);
};
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
class AnmObjTexSrtNode : public AnmObjTexSrt {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
inline int Size() {
return mNodeArraySize;
}
virtual const TexSrtAnmResult *GetResult(TexSrtAnmResult *pResult,
u32 idx) = 0; // at 0x38
AnmObjTexSrtRes *GetNode(int i) {
return mpNodes[i];
}
virtual AnmObjTexSrtRes *Attach(int idx, AnmObjTexSrtRes *pRes); // at 0x3C
virtual AnmObjTexSrtRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
private:
int mNodeArraySize;
AnmObjTexSrtRes **mpNodes;
bool TestExistence(u32 idx) const;
bool TestDefined(u32 idx) const;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexSrtNode);
};
protected:
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
class AnmObjTexSrtRes : public AnmObjTexSrt, public FrameCtrl {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
protected:
static const int MAX_CHILD = 4;
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
static AnmObjTexSrtRes *Construct(MEMAllocator*, u32*, ResAnmTexSrt, ResMdl, bool);
private:
ResAnmTexSrt mRes;
TexSrtAnmResult *mpResultCache;
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexSrt, AnmObj);
};
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexSrtRes);
};
/******************************************************************************
*
* AnmObjTexSrtNode
*
******************************************************************************/
class AnmObjTexSrtNode : public AnmObjTexSrt {
public:
AnmObjTexSrtNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjTexSrtRes **ppChildrenBuf, int numChildren
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjTexSrtNode(); // at 0x10
class AnmObjTexSrtOverride : public AnmObjTexSrtNode {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
static AnmObjTexSrtOverride *Construct(MEMAllocator*, u32*, ResMdl, int);
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexSrtOverride);
};
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
struct TexSrtTypedef
{
enum TexMatrixMode
{
TEX_MTX_MAYA,
TEX_MTX_XSI,
TEX_MTX_3DSMAX
};
};
virtual AnmObjTexSrtRes *Attach(int idx, AnmObjTexSrtRes *pRes); // at 0x3C
virtual AnmObjTexSrtRes *Detach(int idx); // at 0x40
virtual void DetachAll(); // at 0x44
struct TexSrt
{
enum Flag
{
FLAG_ANM_EXISTS,
};
int Size() const {
return mChildrenArraySize;
}
float mScaleX; // at 0x0
float mScaleY; // at 0x4
float mRotation; // at 0x8
float mTranslationX; // at 0xc
float mTranslationY; // at 0x10
};
struct TexSrtAnmResult
{
enum
{
ANM_COUNT = 8
};
UNKWORD FLAGS_0x0;
UNKWORD FLAGS_0x4;
TexSrt mSrts[ANM_COUNT * 2]; // at 0x8
};
}
}
protected:
int mChildrenArraySize; // at 0x18
AnmObjTexSrtRes **mpChildrenArray; // at 0x1C
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexSrtNode, AnmObjTexSrt);
};
/******************************************************************************
*
* AnmObjTexSrtOverride
*
******************************************************************************/
class AnmObjTexSrtOverride : public AnmObjTexSrtNode {
public:
static AnmObjTexSrtOverride *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren);
AnmObjTexSrtOverride(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjTexSrtRes **ppChildrenBuf, int numChildren
)
: AnmObjTexSrtNode(pAllocator, pBindingBuf, numBinding, ppChildrenBuf, numChildren) {}
virtual ~AnmObjTexSrtOverride() {} // at 0x10
virtual const TexSrtAnmResult *GetResult(TexSrtAnmResult *pResult,
u32 idx); // at 0x38
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexSrtOverride, AnmObjTexSrtNode);
};
/******************************************************************************
*
* AnmObjTexSrtRes
*
******************************************************************************/
class AnmObjTexSrtRes : public AnmObjTexSrt, protected FrameCtrl {
public:
static AnmObjTexSrtRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmTexSrt srt, ResMdl mdl, bool cache);
AnmObjTexSrtRes(
MEMAllocator *pAllocator, ResAnmTexSrt srt, u16 *pBindingBuf, int numBinding, TexSrtAnmResult *pCacheBuf
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjTexSrtRes() {} // at 0x10
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual const TexSrtAnmResult *GetResult(TexSrtAnmResult *pResult,
u32 idx); // at 0x38
void UpdateCache();
ResAnmTexSrt GetResAnm() {
return mRes;
}
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
private:
ResAnmTexSrt mRes; // at 0x2C
TexSrtAnmResult *const mpResultCache; // at 0x30
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjTexSrtRes, AnmObjTexSrt);
};
} // namespace g3d
} // namespace nw4r
#endif
+110 -125
View File
@@ -1,169 +1,154 @@
#ifndef NW4R_G3D_ANMVIS_H
#define NW4R_G3D_ANMVIS_H
#include "common.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_resanmvis.h"
#ifndef NW4R_G3D_ANM_VIS_H
#define NW4R_G3D_ANM_VIS_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmvis.h>
namespace nw4r {
namespace g3d {
void ApplyVisAnmResult(ResMdl, AnmObjVis *);
void ApplyVisAnmResult(u8 *, ResMdl, AnmObjVis *);
void ApplyVisAnmResult(ResMdl mdl, AnmObjVis *pObj);
void ApplyVisAnmResult(u8 *pByteVec, ResMdl mdl, AnmObjVis *pObj);
/******************************************************************************
*
* AnmObjVis
*
******************************************************************************/
// Forward declarations
class AnmObjVisRes;
class AnmObjVis : public AnmObj {
public:
AnmObjVis(MEMAllocator *, u16 *, int);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~AnmObjVis() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
virtual void SetUpdateRate(f32) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(ResMdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual bool GetResult(u32) = 0; // at 0x38
virtual AnmObjVisRes *Attach(int, AnmObjVisRes *); // at 0x3C
virtual AnmObjVisRes *Detach(int); // at 0x40
AnmObjVis(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjVis() {} // at 0x10
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetFrame(f32 frame) = 0; // at 0x1C
virtual f32 GetFrame() const = 0; // at 0x20
virtual void UpdateFrame() = 0; // at 0x24
bool TestDefined(u32 idx) const;
bool TestExistence(u32 idx) const;
virtual void SetUpdateRate(f32 rate) = 0; // at 0x28
virtual f32 GetUpdateRate() const = 0; // at 0x2C
virtual bool Bind(const ResMdl mdl) = 0; // at 0x30
virtual void Release(); // at 0x34
virtual bool GetResult(u32 idx) = 0; // at 0x38
virtual AnmObjVisRes *Attach(int idx, AnmObjVisRes *pRes); // at 0x3C
virtual AnmObjVisRes *Detach(int idx); // at 0x40
void DetachAll();
bool TestExistence(u32 idx) const;
bool TestDefined(u32 idx) const;
protected:
static const int MAX_RESOURCES = 4;
enum BindingFlag {
BINDING_ID_MASK = (1 << 14) - 1,
BINDING_INVALID = (1 << 14),
BINDING_UNDEFINED = (1 << 15),
};
int mNumBinds; // at 0x10
u16 *mBinds; // at 0x14
protected:
static const int MAX_CHILD = 4;
NW4R_G3D_TYPE_OBJ_DECL(AnmObjVis);
protected:
int mNumBinding; // at 0x10
u16 *const mpBinding; // at 0x14
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjVis, AnmObj);
};
/******************************************************************************
*
* AnmObjVisNode
*
******************************************************************************/
class AnmObjVisNode : public AnmObjVis {
public:
AnmObjVisNode(MEMAllocator *allocator, u16 *bindBuffer, int numBinds) : AnmObjVis(allocator, bindBuffer, numBinds) {
mResources[0] = NULL;
mResources[1] = NULL;
mResources[2] = NULL;
mResources[3] = NULL;
}
AnmObjVisNode(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~AnmObjVisNode(); // at 0x10
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObjVis::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~AnmObjVisNode(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(ResMdl); // at 0x30
virtual void Release(); // at 0x34
virtual bool GetResult(u32) = 0; // at 0x38
virtual AnmObjVisRes *Attach(int, AnmObjVisRes *); // at 0x3C
virtual AnmObjVisRes *Detach(int); // at 0x40
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual void Release(); // at 0x34
virtual bool GetResult(u32 idx) = 0; // at 0x38
virtual AnmObjVisRes *Attach(int idx, AnmObjVisRes *pRes); // at 0x3C
virtual AnmObjVisRes *Detach(int idx); // at 0x40
protected:
AnmObjVisRes *mResources[MAX_RESOURCES]; // at 0x18
AnmObjVisRes *mpChildren[MAX_CHILD]; // at 0x18
NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisNode);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjVisNode, AnmObjVis);
};
/******************************************************************************
*
* AnmObjVisOR
*
******************************************************************************/
class AnmObjVisOR : public AnmObjVisNode {
public:
AnmObjVisOR(MEMAllocator *allocator, u16 *bindBuffer, int numBinds)
: AnmObjVisNode(allocator, bindBuffer, numBinds) {}
static AnmObjVisOR *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObjVisNode::IsDerivedFrom(other);
}
virtual ~AnmObjVisOR() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual bool GetResult(u32); // at 0x38
AnmObjVisOR(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding)
: AnmObjVisNode(pAllocator, pBindingBuf, numBinding) {}
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual ~AnmObjVisOR() {} // at 0x10
static AnmObjVisOR *Construct(MEMAllocator *, u32 *, ResMdl);
virtual bool GetResult(u32 idx); // at 0x38
private:
NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisOR);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjVisOR, AnmObjVisNode);
};
class AnmObjVisRes : public AnmObjVis, public FrameCtrl {
/******************************************************************************
*
* AnmObjVisRes
*
******************************************************************************/
class AnmObjVisRes : public AnmObjVis, protected FrameCtrl {
public:
AnmObjVisRes(MEMAllocator *, ResAnmVis, u16 *, int);
static AnmObjVisRes *Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmVis vis, ResMdl mdl);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : AnmObjVis::IsDerivedFrom(other);
}
virtual ~AnmObjVisRes() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual void SetFrame(f32); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(ResMdl); // at 0x30
virtual bool GetResult(u32); // at 0x38
AnmObjVisRes(MEMAllocator *pAllocator, ResAnmVis vis, u16 *pBindingBuf, int numBinding);
virtual ~AnmObjVisRes() {} // at 0x10
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual void SetFrame(f32 frame); // at 0x1C
virtual f32 GetFrame() const; // at 0x20
virtual void UpdateFrame(); // at 0x24
virtual void SetUpdateRate(f32 rate); // at 0x28
virtual f32 GetUpdateRate() const; // at 0x2C
virtual bool Bind(const ResMdl mdl); // at 0x30
virtual bool GetResult(u32 idx); // at 0x38
ResAnmVis GetResAnm() {
return mRes;
}
static AnmObjVisRes *Construct(MEMAllocator *, u32 *, ResAnmVis, ResMdl);
void SetPlayPolicy(PlayPolicyFunc pFunc) {
FrameCtrl::SetPlayPolicy(pFunc);
}
private:
ResAnmVis mResAnmVis; // at 0x2C
ResAnmVis mRes; // at 0x2C
NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisRes);
NW4R_G3D_RTTI_DECL_DERIVED(AnmObjVisRes, AnmObjVis);
};
} // namespace g3d
} // namespace nw4r
+16 -38
View File
@@ -1,48 +1,26 @@
#ifndef NW4R_G3D_BASIC_H
#define NW4R_G3D_BASIC_H
#include "nw4r/math/math_types.h"
#include "nw4r/g3d/g3d_anmchr.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace g3d
{
namespace detail
{
namespace WorldMtxAttr
{
inline bool IsScaleOne(u32 flags)
{
return (flags & 0x40000000);
}
#include <nw4r/math.h>
inline u32 AnmScaleOne(u32 flags)
{
return (flags | 0x40000000);
}
namespace nw4r {
namespace g3d {
inline u32 AnmNotScaleOne(u32 flags)
{
return (flags & 0x3fffffff);
}
// Forward declarations
struct ChrAnmResult;
inline u32 AnmScaleUniform(u32 flags)
{
return (flags | 0x10000000);
}
namespace detail {
namespace dcc {
inline u32 AnmNotScaleUniform(u32 flags)
{
return (flags & 0x0fffffff);
}
}
u32 CalcWorldMtx_Basic(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
);
namespace dcc
{
u32 CalcWorldMtx_Basic(math::MTX34 *, math::VEC3 *, const math::MTX34 *, const math::VEC3 *, u32, const ChrAnmResult *);
}
}
}
}
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
+20
View File
@@ -0,0 +1,20 @@
#ifndef NW4R_G3D_CALC_MATERIAL_H
#define NW4R_G3D_CALC_MATERIAL_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
namespace nw4r {
namespace g3d {
// Forward declarations
class AnmObjTexPat;
class AnmObjTexSrt;
class AnmObjMatClr;
void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat *pAnmTexPat, AnmObjTexSrt *pAnmTexSrt, AnmObjMatClr *pAnmMatClr);
} // namespace g3d
} // namespace nw4r
#endif
+41 -6
View File
@@ -1,14 +1,49 @@
#ifndef NW4R_G3D_CALC_VIEW_H
#define NW4R_G3D_CALC_VIEW_H
#include "common.h"
#include "nw4r/math.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
void CalcView(math::MTX34 *pViewPosArray, math::MTX33 *pViewNrmArray, const math::MTX34 *pModelMtxArray,
const u32 *pModelMtxAttribArray, u32 numMtx, const math::MTX34 *pView, ResMdl resMdl,
math::MTX34 *pVewTexMtxArray);
}
namespace detail {
/**
* Locked cache memory layout
*/
struct MtxCacheMap {
u8 currDmaArray[32 * sizeof(math::MTX44)]; // at 0x0
u8 currViewArray[32 * sizeof(math::MTX44)]; // at 0x800
u8 currNrmArray[32 * sizeof(math::MTX44)]; // at 0x1000
u8 currTexArray[32 * sizeof(math::MTX44)]; // at 0x1800
u8 prevDmaArray[32 * sizeof(math::MTX44)]; // at 0x2000
u8 prevViewArray[32 * sizeof(math::MTX44)]; // at 0x2800
u8 prevNrmArray[32 * sizeof(math::MTX44)]; // at 0x3000
u8 prevTexArray[32 * sizeof(math::MTX44)]; // at 0x3800
};
} // namespace detail
void CalcView(
math::MTX34 *pViewPosArray, math::MTX33 *pViewNrmArray, const math::MTX34 *pModelMtxArray,
const u32 *pModelMtxAttribArray, u32 numMtx, const math::MTX34 *pViewMtx, const ResMdl mdl,
math::MTX34 *pViewTexMtxArray
);
void CalcView_LC(
math::MTX34 *pViewPosArray, math::MTX33 *pViewNrmArray, const math::MTX34 *pModelMtxArray,
const u32 *pModelMtxAttribArray, u32 numMtx, const math::MTX34 *pViewMtx, const ResMdl mdl,
math::MTX34 *pViewTexMtxArray
);
void CalcView_LC_DMA_ModelMtx(
math::MTX34 *pViewPosArray, math::MTX33 *pViewNrmArray, const math::MTX34 *pModelMtxArray,
const u32 *pModelMtxAttribArray, u32 numMtx, const math::MTX34 *pViewMtx, const ResMdl mdl,
math::MTX34 *pViewTexMtxArray
);
} // namespace g3d
} // namespace nw4r
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef NW4R_G3D_CALC_VTX_H
#define NW4R_G3D_CALC_VTX_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
namespace nw4r {
namespace g3d {
// Forward declarations
class AnmObjShp;
struct ResVtxPosData;
struct ResVtxNrmData;
struct ResVtxClrData;
void CalcVtx(
ResMdl mdl, AnmObjShp *pAnmShp, ResVtxPosData **ppVtxPosTable, ResVtxNrmData **ppVtxNrmTable,
ResVtxClrData **ppVtxClrTable
);
} // namespace g3d
} // namespace nw4r
#endif
+96 -27
View File
@@ -1,28 +1,67 @@
#ifndef NW4R_G3D_CALC_WORLD_H
#define NW4R_G3D_CALC_WORLD_H
#include "common.h"
#include "nw4r/math.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
struct FuncObjCalcWorld {
private:
u8 UNK_0x00[0x06];
/** 0x06 */ u16 mNodeId;
// Forward declarations
class AnmObjChr;
struct ChrAnmResult;
class FuncObjCalcWorld;
class WorldMtxManip;
/******************************************************************************
*
* Functions
*
******************************************************************************/
void CalcWorld(
math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const u8 *pByteCode, const math::MTX34 *pBaseMtx,
ResMdl mdl, AnmObjChr *pAnmChr, FuncObjCalcWorld *pFuncObj, u32 rootAttrib
);
void CalcWorld(
math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const u8 *pByteCode, const math::MTX34 *pBaseMtx,
ResMdl mdl, AnmObjChr *pAnmChr, FuncObjCalcWorld *pFuncObj
);
void CalcSkinning(math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const ResMdl mdl, const u8 *pByteCode);
/******************************************************************************
*
* ICalcWorldCallback
*
******************************************************************************/
class ICalcWorldCallback {
public:
u32 GetNodeId() const {
return mNodeId;
}
virtual ~ICalcWorldCallback(){}; // at 0x8
void SetNodeId(u32 n) {
mNodeId = n;
}
virtual void ExecCallbackA(ChrAnmResult *pResult, ResMdl mdl,
FuncObjCalcWorld *pFuncObj) = 0; // at 0xC
virtual void ExecCallbackB(WorldMtxManip *pManip, ResMdl mdl,
FuncObjCalcWorld *pFuncObj) = 0; // at 0x10
virtual void ExecCallbackC(math::MTX34 *pMtxArray, ResMdl mdl,
FuncObjCalcWorld *pFuncObj) = 0; // at 0x14
};
/******************************************************************************
*
* WorldMtxManip
*
******************************************************************************/
class WorldMtxManip {
public:
WorldMtxManip(math::MTX34 *pM, math::VEC3 *pS, u32 *pWMAttr) : mpM(pM), mpS(pS), mpWMAttr(pWMAttr) {}
void SetScale(f32, f32, f32);
void GetMtx(nw4r::math::MTX34 *out) {
if (out != nullptr) {
PSMTXCopy(*mpM, *out);
@@ -38,27 +77,57 @@ public:
}
private:
nw4r::math::MTX34 *mpM;
nw4r::math::VEC3 *mpS;
u32 *mpWMAttr;
math::MTX34 *mpM; // at 0x0
math::VEC3 *mpS; // at 0x4
u32 *mpWMAttr; // at 0x8
};
// Name from ketteiban
class ICalcWorldCallback {
/******************************************************************************
*
* FuncObjCalcWorld
*
******************************************************************************/
class FuncObjCalcWorld {
public:
virtual ~ICalcWorldCallback() {}
FuncObjCalcWorld(ICalcWorldCallback *pCallback, u32 timing, u32 nodeID)
: mpCallback(pCallback), mTiming(timing), mNodeID(nodeID) {}
virtual void ExecCallbackA(nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
virtual void ExecCallbackB(nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
virtual void ExecCallbackC(nw4r::math::MTX34 *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
~FuncObjCalcWorld() {}
u16 GetCallbackNodeID() const {
return mNodeID;
}
void SetCallbackNodeID(u16 id) {
mNodeID = id;
}
void CheckCallbackA(u32 nodeID, ChrAnmResult *pResult, ResMdl mdl) {
if (nodeID == mNodeID && (mTiming & ScnObj::CALLBACK_TIMING_A)) {
mpCallback->ExecCallbackA(pResult, mdl, this);
}
}
void CheckCallbackB(u32 nodeID, math::MTX34 *pM, math::VEC3 *pS, u32 *pWMAttr, ResMdl mdl) {
if (nodeID == mNodeID && (mTiming & ScnObj::CALLBACK_TIMING_B)) {
WorldMtxManip manip(pM, pS, pWMAttr);
mpCallback->ExecCallbackB(&manip, mdl, this);
}
}
void CheckCallbackC(math::MTX34 *pMtxArray, ResMdl mdl) {
if (mTiming & ScnObj::CALLBACK_TIMING_C) {
mpCallback->ExecCallbackC(pMtxArray, mdl, this);
}
}
private:
ICalcWorldCallback *mpCallback; // at 0x0
u8 mTiming; // at 0x4
u8 PADDING_0x5; // at 0x5
u16 mNodeID; // at 0x6
};
void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *, u32);
void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *);
void CalcSkinning(math::MTX34 *, u32 *, ResMdl, const u8 *);
} // namespace g3d
} // namespace nw4r
+99 -89
View File
@@ -1,111 +1,121 @@
#ifndef NW4R_G3D_CAMERA_H
#define NW4R_G3D_CAMERA_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/math/math_types.h"
#include "rvl/MTX.h" // IWYU pragma: export
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/math.h>
#include <rvl/MTX.h>
namespace nw4r {
namespace g3d {
struct CameraData {
math::MTX34 mCamMtx; // at 0x0
math::MTX44 mProjMtx; // at 0x30
u32 mFlags;
math::VEC3 mPos; // at 0x74
math::VEC3 VEC3_0x80;
math::VEC3 VEC3_0x8C;
math::VEC3 VEC3_0x98;
f32 FLOAT_0xA4;
u32 INT_0xA8;
f32 FLOAT_0xAC;
f32 FLOAT_0xB0;
f32 FLOAT_0xB4;
f32 FLOAT_0xB8;
f32 FLOAT_0xBC;
f32 FLOAT_0xC0;
f32 FLOAT_0xC4;
f32 FLOAT_0xC8;
f32 FLOAT_0xCC;
f32 FLOAT_0xD0;
f32 FLOAT_0xD4;
f32 FLOAT_0xD8;
f32 FLOAT_0xDC;
f32 FLOAT_0xE0;
f32 FLOAT_0xE4;
f32 FLOAT_0xE8;
f32 FLOAT_0xEC;
f32 FLOAT_0xF0;
u32 INT_0xF4;
u32 INT_0xF8;
u32 INT_0xFC;
u32 INT_0x100;
u32 INT_0x104;
u32 INT_0x108;
};
struct Camera {
struct PostureInfo {
u32 INT_0x0;
math::VEC3 VEC3_0x04;
math::VEC3 VEC3_0x10;
math::VEC3 VEC3_0x1C;
f32 FLOAT_0x28;
// . . .
struct CameraData {
enum Flag {
FLAG_CAM_LOOKAT = (1 << 0),
FLAG_CAM_ROTATE = (1 << 1),
FLAG_CAM_AIM = (1 << 2),
FLAG_CAM_MTX_READY = (1 << 3),
FLAG_PROJ_FRUSTUM = (1 << 4),
FLAG_PROJ_PERSP = (1 << 5),
FLAG_PROJ_ORTHO = (1 << 6),
FLAG_PROJ_MTX_READY = (1 << 7),
FLAG_VI_ODD_FIELD = (1 << 8),
};
ResCommon<CameraData> mCamData;
math::MTX34 cameraMtx; // at 0x0
math::MTX44 projMtx; // at 0x30
u32 flags; // at 0x70
math::VEC3 cameraPos; // at 0x74
math::VEC3 cameraUp; // at 0x80
math::VEC3 cameraTarget; // at 0x8C
math::VEC3 cameraRotate; // at 0x98
f32 cameraTwist; // at 0xA4
GXProjectionType projType; // at 0xA8
f32 projFovy; // at 0xAC
f32 projAspect; // at 0xB0
f32 projNear; // at 0xB4
f32 projFar; // at 0xB8
f32 projTop; // at 0xBC
f32 projBottom; // at 0xC0
f32 projLeft; // at 0xC4
f32 projRight; // at 0xC8
f32 lightScaleS; // at 0xCC
f32 lightScaleT; // at 0xD0
f32 lightTransS; // at 0xD4
f32 lightTransT; // at 0xD8
math::VEC2 viewportOrigin; // at 0xDC
math::VEC2 viewportSize; // at 0xE4
f32 viewportNear; // at 0xEC
f32 viewportFar; // at 0xF0
u32 scissorX; // at 0xF4
u32 scissorY; // at 0xF8
u32 scissorWidth; // at 0xFC
u32 scissorHeight; // at 0x100
s32 scissorOffsetX; // at 0x104
s32 scissorOffsetY; // at 0x108
};
inline Camera(void *vptr) : mCamData(vptr) {}
inline void UpdateProjectionMtx() const {
CameraData &rCamData = mCamData.ref();
class Camera : public ResCommon<CameraData> {
public:
enum PostureType {
POSTURE_LOOKAT,
POSTURE_ROTATE,
POSTURE_AIM
};
if (rCamData.mFlags & 0x40) {
C_MTXOrtho(
rCamData.mProjMtx, rCamData.FLOAT_0xBC, rCamData.FLOAT_0xC0, rCamData.FLOAT_0xC4, rCamData.FLOAT_0xC8,
rCamData.FLOAT_0xB4, rCamData.FLOAT_0xB8
);
} else {
if (rCamData.mFlags & 0x10) {
C_MTXFrustum(
rCamData.mProjMtx, rCamData.FLOAT_0xBC, rCamData.FLOAT_0xC0, rCamData.FLOAT_0xC4,
rCamData.FLOAT_0xC8, rCamData.FLOAT_0xB4, rCamData.FLOAT_0xB8
);
} else {
C_MTXPerspective(
rCamData.mProjMtx, rCamData.FLOAT_0xAC, rCamData.FLOAT_0xB0, rCamData.FLOAT_0xB4,
rCamData.FLOAT_0xB8
);
}
}
struct PostureInfo {
PostureType tp; // at 0x0
math::VEC3 cameraUp; // at 0x4
math::VEC3 cameraTarget; // at 0x10
math::VEC3 cameraRotate; // at 0x1C
f32 cameraTwist; // at 0x28
};
rCamData.mFlags |= 0x80;
}
public:
explicit Camera(CameraData *pData);
Camera(CameraData *);
void Init();
void Init(u16, u16, u16, u16, u16, u16);
void SetPosition(f32, f32, f32);
void SetPosition(const math::VEC3 &);
void SetPosture(const PostureInfo &);
void SetCameraMtxDirectly(const math::MTX34 &);
void SetPerspective(f32, f32, f32, f32);
void SetOrtho(f32, f32, f32, f32, f32, f32);
void SetProjectionMtxDirectly(const math::MTX44 *);
void SetScissor(u32, u32, u32, u32);
void SetScissorBoxOffset(s32, s32);
void SetViewport(f32, f32, f32, f32);
void SetViewportZRange(f32, f32);
void GetViewport(f32 *, f32 *, f32 *, f32 *, f32 *, f32 *) const;
void GetCameraMtx(math::MTX34 *) const;
void GetProjectionMtx(math::MTX44 *) const;
void GetProjectionTexMtx(math::MTX34 *) const;
void GetEnvironmentTexMtx(math::MTX34 *) const;
void Init(u16 efbWidth, u16 efbHeight, u16 xfbWidth, u16 xfbHeight, u16 viWidth, u16 viHeight);
void SetPosition(f32 x, f32 y, f32 z);
void SetPosition(const math::VEC3 &rPos);
void SetPosture(const PostureInfo &rInfo);
void SetCameraMtxDirectly(const math::MTX34 &rMtx);
void SetPerspective(f32 fovy, f32 aspect, f32 near, f32 far);
void SetOrtho(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
void SetProjectionMtxDirectly(const math::MTX44 *pMtx);
void SetScissor(u32 x, u32 y, u32 width, u32 height);
void SetScissorBoxOffset(s32 ox, s32 oy);
void SetViewport(f32 x, f32 y, f32 width, f32 height);
void SetViewportZRange(f32 near, f32 far);
void GetViewport(f32 *pX, f32 *pY, f32 *pWidth, f32 *pHeight, f32 *pNear, f32 *pFar) const;
void GetCameraMtx(math::MTX34 *pMtx) const;
void GetProjectionMtx(math::MTX44 *pMtx) const;
void GetProjectionTexMtx(math::MTX34 *pMtx) const;
void GetEnvironmentTexMtx(math::MTX34 *pMtx) const;
void GXSetViewport() const;
void GXSetProjection() const;
void GXSetScissor() const;
void GXSetScissorBoxOffset() const;
GXProjectionType GetProjectionType() const {
return ref().projType;
}
private:
void UpdateCameraMtx() const;
void UpdateProjectionMtx() const;
};
} // namespace g3d
} // namespace nw4r
-14
View File
@@ -1,14 +0,0 @@
#ifndef NW4R_G3D_CPU_H
#define NW4R_G3D_CPU_H
#include "common.h"
namespace nw4r {
namespace g3d {
namespace detail {
void Copy32ByteBlocks(void *, const void *, u32);
void ZeroMemory32ByteBlocks(void *, u32);
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
+86 -5
View File
@@ -1,13 +1,94 @@
#ifndef NW4R_G3D_DCC_H
#define NW4R_G3D_DCC_H
#include "common.h"
#include "nw4r/math.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resnode.h>
namespace nw4r {
namespace g3d {
void CalcTexMtx(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag, TexSrtTypedef::TexMatrixMode);
}
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag, TexSrtTypedef::TexMatrixMode mode);
namespace detail {
class WorldMtxAttr {
public:
enum Attr {
ATTR_BILLBOARD_MASK = (1 << 8) - 1,
ATTR_T_IGNORE = (1 << 27),
ATTR_S_UNIFORM = (1 << 28),
ATTR_ALL_S_UNIFORM = (1 << 29),
ATTR_S_ONE = (1 << 30),
ATTR_ALL_S_ONE = (1 << 31),
};
public:
static ResNodeData::Billboard GetBillboard(u32 attr) {
return static_cast<ResNodeData::Billboard>(attr & ATTR_BILLBOARD_MASK);
}
static u32 SetBillboard(u32 attr, ResNodeData::Billboard billboard) {
return (attr & ~ATTR_BILLBOARD_MASK) | billboard;
}
static bool IsIgnoreTrans(u32 attr) {
return (attr & ATTR_T_IGNORE) ? true : false;
}
static u32 AnmIgnoreTrans(u32 attr) {
return attr | ATTR_T_IGNORE;
}
static u32 AnmNotIgnoreTrans(u32 attr) {
return attr & ~ATTR_T_IGNORE;
}
static bool IsScaleUniform(u32 attr) {
return (attr & ATTR_S_UNIFORM) ? true : false;
}
static u32 AnmScaleUniform(u32 attr) {
return attr | ATTR_S_UNIFORM;
}
static u32 AnmNotScaleUniform(u32 attr) {
return attr & ~(ATTR_S_UNIFORM | ATTR_ALL_S_UNIFORM | ATTR_S_ONE | ATTR_ALL_S_ONE);
}
static bool IsAllScaleUniform(u32 attr) {
return (attr & ATTR_ALL_S_UNIFORM) ? true : false;
}
static u32 AnmAllScaleUniform(u32 attr) {
return attr | ATTR_ALL_S_UNIFORM;
}
static u32 AnmNotAllScaleUniform(u32 attr) {
return attr & ~(ATTR_ALL_S_UNIFORM | ATTR_ALL_S_ONE);
}
static bool IsScaleOne(u32 attr) {
return (attr & ATTR_S_ONE) ? true : false;
}
static u32 AnmScaleOne(u32 attr) {
return attr | ATTR_S_ONE;
}
static u32 AnmNotScaleOne(u32 attr) {
return attr & ~(ATTR_S_ONE | ATTR_ALL_S_ONE);
}
static bool IsAllScaleOne(u32 attr) {
return (attr & ATTR_ALL_S_ONE) ? true : false;
}
static u32 AnmAllScaleOne(u32 attr) {
return attr | ATTR_ALL_S_ONE;
}
static u32 AnmNotAllScaleOne(u32 attr) {
return attr & ~ATTR_ALL_S_ONE;
}
static u32 GetRootMtxAttr() {
return ATTR_S_UNIFORM | ATTR_ALL_S_UNIFORM | ATTR_S_ONE | ATTR_ALL_S_ONE;
}
};
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
+43 -5
View File
@@ -1,14 +1,52 @@
#ifndef NW4R_G3D_DRAW_H
#define NW4R_G3D_DRAW_H
#include "common.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
struct DrawResMdlReplacement {};
void DrawResMdlDirectly(ResMdl mdl, const math::MTX34 *pViewPos, const math::MTX33 *pViewNrm,
const math::MTX34 *pViewEnv, const u8 *pOpa, const u8 *pXlu, DrawResMdlReplacement *pRep, u32 resMdlDrawMode);
// Forward declarations
namespace G3DState {
class IndMtxOp;
}
namespace detail {
G3DState::IndMtxOp *GetIndMtxOp(ResMat mat, ResNode node, ResShp shp);
} // namespace detail
struct DrawResMdlReplacement {
u8 *visArray; // at 0x0
ResTexObjData *texObjDataArray; // at 0x4
ResTlutObjData *tlutObjDataArray; // at 0x8
ResTexSrtData *texSrtDataArray; // at 0xC
ResChanData *chanDataArray; // at 0x10
ResGenModeData *genModeDataArray; // at 0x14
ResMatMiscData *matMiscDataArray; // at 0x18
ResPixDL *pixDLArray; // at 0x1C
ResTevColorDL *tevColorDLArray; // at 0x20
ResIndMtxAndScaleDL *indMtxAndScaleDLArray; // at 0x24
ResTexCoordGenDL *texCoordGenDLArray; // at 0x28
ResTevData *tevDataArray; // at 0x2C
ResVtxPosData **vtxPosTable; // at 0x30
ResVtxNrmData **vtxNrmTable; // at 0x34
ResVtxClrData **vtxClrTable; // at 0x38
};
void DrawResMdlDirectly(
const ResMdl mdl, const math::MTX34 *pViewPosMtxArray, const math::MTX33 *pViewNrmMtxArray,
const math::MTX34 *pViewEnvMtxArray, const u8 *pByteCodeOpa, const u8 *pByteCodeXlu,
DrawResMdlReplacement *pReplacement, u32 drawMode
);
} // namespace g3d
} // namespace nw4r
+44 -8
View File
@@ -1,15 +1,51 @@
#ifndef NW4R_G3D_DRAW1_MAT1_SHP_H
#define NW4R_G3D_DRAW1_MAT1_SHP_H
#include "common.h"
#include "nw4r/g3d/g3d_resmat.h"
#include "nw4r/g3d/g3d_resshp.h"
#ifndef NW4R_G3D_DRAW_1MAT_1SHP_H
#define NW4R_G3D_DRAW_1MAT_1SHP_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
struct Draw1Mat1ShpSwap {};
void Draw1Mat1ShpDirectly(ResMat, ResShp, const math::MTX34 *, const math::MTX34 *, u32, Draw1Mat1ShpSwap *,
G3DState::IndMtxOp *);
// Forward declarations
namespace G3DState {
class IndMtxOp;
}
enum Draw1Mat1ShpCtrl {
DRAW1MAT1SHP_CTRL_NOPPCSYNC = (1 << 0),
DRAW1MAT1SHP_CTRL_NOSWAPSHP = (1 << 1),
DRAW1MAT1SHP_CTRL_CULL_FRONT = (1 << 2),
DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF = (1 << 3),
};
struct Draw1Mat1ShpSwap {
ResTexObj texObj; // at 0x0
ResTlutObj tlutObj; // at 0x4
ResGenMode genMode; // at 0x8
ResTev tev; // at 0xC
ResMatPix pix; // at 0x10
ResMatTevColor tevColor; // at 0x14
ResMatIndMtxAndScale indMtxAndScale; // at 0x18
ResMatChan chan; // at 0x1C
ResMatTexCoordGen texCoordGen; // at 0x20
ResMatMisc misc; // at 0x24
ResTexSrt texSrt; // at 0x28
ResVtxPosData **vtxPosTable; // at 0x2C
ResVtxNrmData **vtxNrmTable; // at 0x30
ResVtxClrData **vtxClrTable; // at 0x34
Draw1Mat1ShpSwap() : vtxPosTable(NULL), vtxNrmTable(NULL), vtxClrTable(NULL) {}
};
void Draw1Mat1ShpDirectly(
ResMat mat, ResShp shp, const math::MTX34 *pViewPos, const math::MTX34 *pViewNrm, u32 ctrl, Draw1Mat1ShpSwap *pSwap,
G3DState::IndMtxOp *pIndMtxOp
);
} // namespace g3d
} // namespace nw4r
+63 -52
View File
@@ -1,72 +1,83 @@
#ifndef NW4R_G3D_FOG_H
#define NW4R_G3D_FOG_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX.h" // IWYU pragma: export
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/math.h>
#include <nw4r/ut.h>
#include <rvl/GX.h>
namespace nw4r {
namespace g3d {
struct FogData {
GXFogType mFogType; // at 0x0
f32 mStartZ; // at 0x4
f32 mEndZ; // at 0x8
f32 mNear; // at 0xC
f32 mFar; // at 0x10
GXColor mColor; // at 0x14
u8 mFogRangeAdjEnable; // at 0x18
u8 BYTE_0x19;
u16 mAdjTableWidth; // at 0x1A
GXFogAdjTable mAdjTable; // at 0x1C
GXFogType type; // at 0x0
f32 startz; // at 0x4
f32 endz; // at 0x8
f32 nearz; // at 0xC
f32 farz; // at 0x10
GXColor color; // at 0x14
GXBool adjEnable; // at 0x18
u8 PADDING_0x19; // at 0x19
u16 adjCenter; // at 0x1A
GXFogAdjTable adjTable; // at 0x1C
};
struct Fog {
ResCommon<FogData> mFogData;
class Fog : public ResCommon<FogData> {
public:
explicit Fog(FogData *pData);
inline Fog(void *vptr) : mFogData(vptr) {}
Fog(FogData *);
void Init();
void *CopyTo(void *) const;
void SetFogRangeAdjParam(u16, u16, const math::MTX44 &);
Fog CopyTo(void *pDst) const;
void SetFogRangeAdjParam(u16 width, u16 center, const math::MTX44 &rProjMtx);
void SetGP() const;
bool IsValid() const {
return mFogData.IsValid();
void SetFogType(GXFogType type) {
if (!IsValid()) {
return;
}
ref().type = type;
}
void SetZ(f32 startZ, f32 endZ) {
if (!IsValid()) {
return;
}
FogData &r = ref();
r.startz = startZ;
r.endz = endZ;
}
void SetNearFar(f32 nearZ, f32 farZ) {
if (!IsValid()) {
return;
}
FogData &r = ref();
r.nearz = nearZ;
r.farz = farZ;
}
void SetFogColor(GXColor color) {
if (!IsValid()) {
return;
}
ref().color = color;
}
bool IsFogRangeAdjEnable() const {
return (IsValid() && mFogData.ref().mFogRangeAdjEnable != 1) ? true : false;
}
void SetFogColor(GXColor c) {
if (IsValid()) {
mFogData.ref().mColor = c;
}
}
void SetFogType(GXFogType fog) {
if (IsValid()) {
mFogData.ref().mFogType = fog;
}
}
void SetNearFar(f32 near, f32 far) {
if (IsValid()) {
FogData &ref = mFogData.ref();
ref.mNear = near;
ref.mFar = far;
}
}
void SetZ(f32 start, f32 end) {
if (IsValid()) {
FogData &ref = mFogData.ref();
ref.mStartZ = start;
ref.mEndZ = end;
}
return IsValid() && ref().adjEnable == TRUE;
}
};
} // namespace g3d
} // namespace nw4r
-48
View File
@@ -1,48 +0,0 @@
#ifndef NW4R_G3D_GPU_H
#define NW4R_G3D_GPU_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX.h"
namespace nw4r {
namespace g3d {
namespace fifo {
const u8 cm2hw[] = {0x00, 0x02, 0x01, 0x03};
inline void LoadXFCmd(u16 us, u32 ul) {
GXCmd1u8(FIFO_ACCESS_XF);
GXCmd1u16(0);
GXCmd1u16(us);
GXCmd1u32(ul);
}
inline void LoadBPCmd(u32 ul) {
GXCmd1u8(FIFO_ACCESS_BP);
GXCmd1u32(ul);
}
inline void LoadXFCmdHdr(u16 us, u8 uc) {
GXCmd1u8(FIFO_ACCESS_XF);
GXCmd1u16((u16)(uc - 1));
GXCmd1u16(us);
}
inline void LoadCPCmd(u8 uc, u32 ul) {
GXCmd1u8(FIFO_ACCESS_CP);
GXCmd1u8(uc);
GXCmd1u32(ul);
}
void GDSetGenMode2(u8, u8, u8, u8, GXCullMode);
void GDSetCullMode(GXCullMode);
void GDSetTexCoordScale2(GXTexCoordID, u16, u8, u8, u16, u8, u8);
void GDSetIndTexMtx(u32, const math::MTX34 &);
void GDResetCurrentMtx();
void GDSetCurrentMtx(const u32 *);
void GDLoadTexMtxImm3x3(const math::MTX33 &, u32);
} // namespace fifo
} // namespace g3d
} // namespace nw4r
#endif
+6 -1
View File
@@ -1,10 +1,15 @@
#ifndef NW4R_G3D_INIT_H
#define NW4R_G3D_INIT_H
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
namespace nw4r {
namespace g3d {
void G3dInit(bool);
void G3dInit(bool enableLockedCache);
void G3dReset();
} // namespace g3d
} // namespace nw4r
+121 -88
View File
@@ -1,150 +1,183 @@
#ifndef NW4R_G3D_LIGHT_H
#define NW4R_G3D_LIGHT_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h" // IWYU pragma: export
#include "nw4r/math.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_state.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <rvl/GX.h>
namespace nw4r {
namespace g3d {
struct LightSetData {
static const int NUM_LIGHTS = 8;
s8 mLights[NUM_LIGHTS]; // at 0x0
s8 mAmbient; // at 0x8
char UNK_0x8[3]; // at 0x9
};
struct AmbLightObj {
u8 r, g, b, a;
};
struct AmbLightAnmResult {};
/******************************************************************************
*
* LightObj
*
******************************************************************************/
class LightObj {
private:
enum LightObjFlag {
SPOT_LIGHT = 0x1,
SPECULAR_LIGHT = 0x2,
ENABLED = 0x4,
SPECULAR_DIR = 0x8,
COLOR_ENABLE = 0x10,
ALPHA_ENABLE = 0x20
};
public:
LightObj() : mFlags() {}
LightObj() : mFlag(0) {}
~LightObj() {}
LightObj &operator=(const LightObj &rOther);
operator GXLightObj *() {
return &mLightObj;
return &mObj;
}
operator const GXLightObj *() const {
return &mLightObj;
return &mObj;
}
LightObj &operator=(const LightObj &rhs);
void Clear();
void InitLightColor(GXColor color);
void InitLightPos(f32 x, f32 y, f32 z);
void InitLightDir(f32 nx, f32 ny, f32 nz);
void InitSpecularDir(f32 nx, f32 ny, f32 nz);
void InitLightSpot(f32 cutoff, GXSpotFn spotFn);
void InitLightAttnA(f32 aa, f32 ab, f32 ac);
void InitLightDistAttn(f32 distance, f32 brightness, GXDistAttnFn distAttnFn);
void InitLightAttnK(f32 ka, f32 kb, f32 kc);
void InitLightShininess(f32 shininess);
void GetLightPos(math::VEC3 *pPos) const;
void GetLightDir(math::VEC3 *pDir) const;
void ApplyViewMtx(const math::MTX34 &rCamera);
void Enable() {
mFlag |= FLAG_ENABLE_LIGHT;
}
void Disable() {
mFlag &= ~FLAG_ENABLE_LIGHT;
}
bool IsEnable() const {
return (mFlag & FLAG_ENABLE_LIGHT) ? true : false;
}
bool IsSpotLight() const {
return mFlags & SPOT_LIGHT;
return (mFlag & FLAG_SPOT) ? true : false;
}
bool IsSpecularLight() const {
return mFlags & SPECULAR_LIGHT;
}
bool IsEnable() const {
return mFlags & ENABLED;
return (mFlag & FLAG_SPECULAR) ? true : false;
}
bool IsSpecularDir() const {
return mFlags & SPECULAR_DIR;
return (mFlag & FLAG_SPECULAR_DIR) ? true : false;
}
bool IsColorEnable() const {
return mFlags & COLOR_ENABLE;
return !(mFlag & FLAG_DISABLE_COLOR);
}
void DisableColor() {
mFlag |= FLAG_DISABLE_COLOR;
}
bool IsAlphaEnable() const {
return mFlags & ALPHA_ENABLE;
return !(mFlag & FLAG_DISABLE_ALPHA);
}
void DisableAlpha() {
mFlag |= FLAG_DISABLE_ALPHA;
}
bool IsDiffuseLight() const {
return !IsSpotLight() && !IsSpecularLight();
}
void Enable() {
mFlags |= ENABLED;
}
void Disable() {
mFlags &= ~ENABLED;
}
void Clear();
void InitLightColor(GXColor);
void InitLightPos(f32, f32, f32);
void InitLightDir(f32, f32, f32);
void InitSpecularDir(f32, f32, f32);
void InitLightSpot(f32, GXSpotFn);
void InitLightAttnA(f32, f32, f32);
void InitLightDistAttn(f32, f32, GXDistAttnFn);
void InitLightAttnK(f32, f32, f32);
void InitLightShininess(f32);
void GetLightPos(math::VEC3 *) const;
void GetLightDir(math::VEC3 *) const;
void ApplyViewMtx(const math::MTX34 &rMtx);
private:
enum LightObjFlag {
FLAG_SPOT = (1 << 0),
FLAG_SPECULAR = (1 << 1),
FLAG_ENABLE_LIGHT = (1 << 2),
FLAG_SPECULAR_DIR = (1 << 3),
FLAG_DISABLE_COLOR = (1 << 4),
FLAG_DISABLE_ALPHA = (1 << 5)
};
private:
u32 mFlags; // at 0x0
GXLightObj mLightObj; // at 0x4
u32 mFlag; // at 0x0
GXLightObj mObj; // at 0x4
};
struct LightAnmResult {};
/******************************************************************************
*
* LightSet
*
******************************************************************************/
struct LightSetData {
s8 idxLight[G3DState::NUM_LIGHT_IN_LIGHT_SET]; // at 0x0
s8 idxAmbLight; // at 0x8
u8 PADDING_0x9[0xC - 0X9]; // at 0x9
};
struct LightSet {
LightSet(LightSetting *setting, LightSetData *data) : mSetting(setting), mLightSetData(data) {}
class LightSet {
public:
LightSet(LightSetting *pSetting, LightSetData *pData) : mpSetting(pSetting), mpLightSetData(pData) {}
~LightSet() {}
bool IsValid() const {
return mSetting != NULL && mLightSetData != NULL;
return mpSetting != NULL && mpLightSetData != NULL;
}
bool SelectLightObj(u32, int);
bool SelectAmbLightObj(int);
bool SelectLightObj(u32 lightIdx, int lightObjIdx);
bool SelectAmbLightObj(int lightObjIdx);
LightSetting *mSetting; // at 0x0
LightSetData *mLightSetData; // at 0x4
private:
LightSetting *mpSetting; // at 0x0
LightSetData *mpLightSetData; // at 0x4
};
/******************************************************************************
*
* LightSetting
*
******************************************************************************/
struct AmbLightObj {
u8 r, g, b, a;
};
class LightSetting {
public:
LightSetting(LightObj *, AmbLightObj *, u32, LightSetData *, u32);
bool Import(const LightSetting &);
void ApplyViewMtx(const math::MTX34 &, u32);
LightSetting(
LightObj *pLightObjArray, AmbLightObj *pAmbLightObjArray, u32 numLight, LightSetData *pLightSetDataArray,
u32 numLightSet
);
~LightSetting() {}
u16 GetNumLightObj() const {
return mNumLightObj;
bool Import(const LightSetting &rSetting);
void ApplyViewMtx(const math::MTX34 &rCamera, u32 numLight);
u32 GetNumLightObj() const {
return mNumLight;
}
u16 GetNumLightSet() const {
u32 GetNumLightSet() const {
return mNumLightSet;
}
LightObj *GetLightObjArray() const {
return mLightObjArray;
return mpLightObjArray;
}
AmbLightObj *GetAmbLightObjArray() const {
return mAmbLightObjArray;
}
LightSetData *GetLightSetDataArray() const {
return mLightSetDataArray;
return mpAmbLightObjArray;
}
LightSet GetLightSet(int i) {
if (i < mNumLightSet && i > 0) {
return LightSet(this, &mLightSetDataArray[i]);
LightSet GetLightSet(int idx) {
if (idx < mNumLightSet && idx >= 0) {
return LightSet(this, &mpLightSetDataArray[idx]);
}
return LightSet(this, NULL);
}
private:
u16 mNumLightObj; // at 0x0
u16 mNumLightSet; // at 0x2
LightObj *mLightObjArray; // at 0x4
AmbLightObj *mAmbLightObjArray; // at 0x8
LightSetData *mLightSetDataArray; // at 0xC
u16 mNumLight; // at 0x0
u16 mNumLightSet; // at 0x2
LightObj *mpLightObjArray; // at 0x4
AmbLightObj *mpAmbLightObjArray; // at 0x8
LightSetData *mpLightSetDataArray; // at 0xC
};
} // namespace g3d
} // namespace nw4r
+12 -5
View File
@@ -1,15 +1,22 @@
#ifndef NW4R_G3D_MAYA_H
#define NW4R_G3D_MAYA_H
#include "common.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
#include "nw4r/math.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
namespace nw4r {
namespace g3d {
namespace detail {
namespace dcc {
bool CalcTexMtx_Maya(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag);
}
bool CalcTexMtx_Maya(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag);
u32 CalcWorldMtx_Maya_SSC_Apply(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
);
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
+102 -87
View File
@@ -1,133 +1,148 @@
#ifndef NW4R_G3D_G3DOBJ_H
#define NW4R_G3D_G3DOBJ_H
#include "common.h"
#include "rvl/MEM/mem_allocator.h"
#ifndef NW4R_G3D_OBJ_H
#define NW4R_G3D_OBJ_H
#include <nw4r/types_nw4r.h>
#define NW4R_G3D_TYPE_OBJ_DECL(VAL) static const nw4r::g3d::G3dObj::ResNameDataT<sizeof(#VAL)> TYPE_NAME
#define NW4R_G3D_TYPE_OBJ_DEF(VAL) \
const nw4r::g3d::G3dObj::ResNameDataT<sizeof(#VAL)> VAL::TYPE_NAME = {sizeof(#VAL), #VAL}
#include <nw4r/g3d/g3d_rtti.h>
#include <nw4r/g3d/platform/g3d_allocator.h>
namespace nw4r {
namespace g3d {
namespace detail {
inline void *AllocFromAllocator(MEMAllocator *pAllocator, u32 size) {
return MEMAllocFromAllocator(pAllocator, size);
namespace {
/******************************************************************************
*
* Alignment
*
******************************************************************************/
inline u32 align4(u32 x) {
return ROUND_UP(x, 4);
}
inline u32 align32(u32 x) {
return ROUND_UP(x, 32);
}
inline void FreeToAllocator(MEMAllocator *pAllocator, void *pBlock) {
return MEMFreeToAllocator(pAllocator, pBlock);
}
} // namespace detail
} // namespace
/******************************************************************************
*
* G3dObj
*
******************************************************************************/
class G3dObj {
public:
template <u32 N>
struct ResNameDataT {
u32 len; // at 0x0
// @bug 'N' already includes the null terminator
char str[ROUND_UP(N + 1, 4)]; // at 0x4
};
class TypeObj {
public:
struct ResNameDataPT {
u32 len; // at 0x0
char str[4]; // at 0x4
};
public:
template <u32 N>
explicit TypeObj(const ResNameDataT<N> &rName) : mName(reinterpret_cast<const ResNameDataPT *>(&rName)) {}
u32 GetTypeID() const {
// @note Address is used for comparing TypeObjs
return reinterpret_cast<u32>(mName);
}
const char *GetTypeName() const {
return mName->str;
}
bool operator==(const TypeObj &rOther) const {
return GetTypeID() == rOther.GetTypeID();
}
private:
const ResNameDataPT *mName; // at 0x0
};
enum G3dProcTask {
G3DPROC_CALC_WORLD = 0x1,
G3DPROC_CALC_MAT = 0x2,
G3DPROC_CALC_VTX = 0x3,
G3DPROC_CALC_VIEW = 0x4,
G3DPROC_GATHER_SCNOBJ = 0x5,
G3DPROC_DRAW_OPA = 0x6,
G3DPROC_DRAW_XLU = 0x7,
G3DPROC_UPDATEFRAME = 0x8,
G3DPROC_NONE = 0x00000,
G3DPROC_CALC_WORLD = 0x00001,
G3DPROC_CALC_MAT = 0x00002,
G3DPROC_CALC_VTX = 0x00003,
G3DPROC_CALC_VIEW = 0x00004,
G3DPROC_GATHER_SCNOBJ = 0x00005,
G3DPROC_DRAW_OPA = 0x00006,
G3DPROC_DRAW_XLU = 0x00007,
G3DPROC_UPDATEFRAME = 0x00008,
// Tasks below cannot be disabled
__G3DPROC_OPTIONAL_END,
G3DPROC_CHILD_DETACHED = 0x10001,
G3DPROC_ATTACH_PARENT = 0x10002,
G3DPROC_DETACH_PARENT = 0x10003,
G3DPROC_0x10004 = 0x10004
};
template <u32 N>
struct ResNameDataT {
u32 mLength;
// Bug? +1 seemingly for null terminator,
// but size N already includes it
char mName[N + 1 + 3 & ~3];
};
struct TypeObj {
struct TypeObjData {
u32 mLength; // at 0x0
char mName[]; // at 0x4
};
template <u32 N>
TypeObj(const ResNameDataT<N> &pRes) : mData((const TypeObjData *)&pRes) {}
u32 GetTypeID() const {
return (u32)mData;
}
const char *GetTypeName() const {
return mData->mName;
}
bool operator==(const TypeObj &rhs) const {
return GetTypeID() == rhs.GetTypeID();
}
const TypeObjData *mData; // at 0x0
G3DPROC_ZSORT = 0x10004
};
public:
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
virtual bool IsDerivedFrom(TypeObj other) const {
return other == GetTypeObjStatic();
}
virtual void G3dProc(u32, u32, void *) = 0; // at 0xC
virtual ~G3dObj(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
} // at 0x8
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~G3dObj(); // at 0x10
virtual const TypeObj GetTypeObj() const {
return TypeObj(TYPE_NAME);
} // at 0x14
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const {
return GetTypeObj().GetTypeName();
} // at 0x18
G3dObj(MEMAllocator *pAllocator, G3dObj *pParent) : mpHeap(pAllocator), mpParent(pParent) {}
G3dObj *GetParent() const {
return mpParent;
}
void SetParent(G3dObj *pParent) {
mpParent = pParent;
}
void Destroy();
void DetachFromParent();
G3dObj(MEMAllocator *pAllocator, G3dObj *pParent) : mAllocator(pAllocator), mParent(pParent) {}
G3dObj *GetParent() const {
return mParent;
}
void SetParent(G3dObj *parent) {
mParent = parent;
}
static void *Alloc(MEMAllocator *pAllocator, u32 size) {
return detail::AllocFromAllocator(pAllocator, size);
}
static void Dealloc(MEMAllocator *pAllocator, void *pBlock) {
detail::FreeToAllocator(pAllocator, pBlock);
}
static inline void *operator new(size_t size, void *pBlock) {
static inline void *operator new(size_t /* size */, void *pBlock) {
return pBlock;
}
static inline void operator delete(void *pBlock) {}
static inline void operator delete(void * /* pBlock */) {}
template <typename T>
static T *DynamicCast(G3dObj *obj) {
if (obj != nullptr && obj->IsDerivedFrom(T::GetTypeObjStatic())) {
return static_cast<T *>(obj);
template <typename TTo>
static TTo *DynamicCast(G3dObj *pObj) {
if (pObj != NULL && pObj->IsDerivedFrom(TTo::GetTypeObjStatic())) {
return static_cast<TTo *>(pObj);
}
return nullptr;
}
private:
G3dObj *mParent; // at 0x4
MEMAllocator *mAllocator; // at 0x8
G3dObj *mpParent; // at 0x4
MEMAllocator *mpHeap; // at 0x8
NW4R_G3D_TYPE_OBJ_DECL(G3dObj);
__NW4R_G3D_TYPEOBJ_DECL(G3dObj);
};
} // namespace g3d
} // namespace nw4r
-83
View File
@@ -1,83 +0,0 @@
#ifndef NW4R_G3D_RESANM_H
#define NW4R_G3D_RESANM_H
#include "common.h"
namespace nw4r {
namespace g3d {
struct ResKeyFrameAnmFramesData {
float mTime; // at 0x0
float mValue; // at 0x4
float mDerivative; // at 0x8
};
struct ResKeyFrameAnmData {
u16 mCount; // at 0x0
float FLOAT_0x4;
ResKeyFrameAnmFramesData mFrames[]; // at 0x8
};
struct ResColorAnmFramesData {
u32 mColor; // at 0x0
};
union ResColorAnmData {
u32 mColor;
s32 mOffset;
};
struct ResBoolAnmFramesData {
u32 mFlags; // at 0x0
};
union ResAnmData {
float mValue;
s32 mOffset;
};
namespace detail {
float GetResKeyFrameAnmResult(const ResKeyFrameAnmData *, float);
u32 GetResColorAnmResult(const ResColorAnmFramesData *, float);
inline u32 GetResColorAnmResult(const ResColorAnmData *pData, float time, bool b) {
if (b) {
return pData->mColor;
}
return GetResColorAnmResult((const ResColorAnmFramesData *)((u8 *)pData + pData->mOffset), time);
}
inline bool GetResBoolAnmFramesResult(const ResBoolAnmFramesData *pData, int i) {
u32 index = i;
u32 mask = 0x80000000 >> (index % 32);
u32 flags = pData[index / 32].mFlags;
return flags & mask;
}
template <typename T>
inline float ClipFrame(T &info, float time) {
if (time <= 0.0f) {
return 0.0f;
}
if (info.mNumFrames <= time) {
return info.mNumFrames;
}
return time;
}
inline float GetResAnmResult(const ResAnmData *pData, float time, bool b) {
if (b) {
return pData->mValue;
}
return GetResKeyFrameAnmResult((const ResKeyFrameAnmData *)((u8 *)pData + pData->mOffset), time);
}
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef NW4R_G3D_RESANMCAMERA_H
#define NW4R_G3D_RESANMCAMERA_H
#include "common.h"
#include "nw4r/g3d/g3d_anmcamera.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResAnmCameraData {
char UNK_0x0[0xC];
u32 mID; // at 0xC
};
struct ResAnmCamera {
ResCommon<ResAnmCameraData> mAnmCamera;
inline ResAnmCamera(void *vptr) : mAnmCamera(vptr) {}
bool IsValid() const {
return mAnmCamera.IsValid();
}
void GetAnmResult(CameraAnmResult *, f32) const;
};
} // namespace g3d
} // namespace nw4r
#endif
-42
View File
@@ -1,42 +0,0 @@
#ifndef NW4R_G3D_RESANMCHR_H
#define NW4R_G3D_RESANMCHR_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResAnmChrData {
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x4];
s32 mMatDictOffset; // at 0x10
char UNK_0x14[0x0C];
u16 mNumFrames; // at 0x20
AnmPolicy mAnmPolicy; // at 0x24
};
struct ResAnmChr {
enum { REVISION = 4 };
ResCommon<ResAnmChrData> mAnmChr;
inline ResAnmChr(void *vptr) : mAnmChr(vptr) {}
inline bool CheckRevision() const {
return mAnmChr.ref().mRevision == REVISION;
}
AnmPolicy GetAnmPolicy() const
{
return mAnmChr.ref().mAnmPolicy;
}
int GetNumFrame() const
{
return mAnmChr.ref().mNumFrames;
}
};
} // namespace g3d
} // namespace nw4r
#endif
-82
View File
@@ -1,82 +0,0 @@
#ifndef NW4R_G3D_RESANMCLR_H
#define NW4R_G3D_RESANMCLR_H
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/g3d/g3d_resanm.h"
#include "nw4r/g3d/g3d_anmclr.h"
namespace nw4r
{
namespace g3d
{
struct ResAnmClrInfoData
{
char UNK_0x0[0x8];
u16 mNumFrames;
};
struct ResAnmClrMatData
{
char UNK_0x0[0x4];
u32 mFlags; // at 0x4
struct AnmData
{
UNKWORD WORD_0x0;
ResColorAnmData mColor; // at 0x4
} mAnms[]; // at 0x8
};
struct ResAnmClrData
{
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x4];
s32 mMatDictOffset; // at 0x10
ResAnmClrInfoData mInfo; // at 0x14
char UNK_0x1E[0x2];
u16 mNumFrames; // at 0x20
AnmPolicy mAnmPolicy; // at 0x24
};
struct ResAnmClr
{
enum
{
REVISION = 3
};
ResCommon<ResAnmClrData> mAnmClr;
inline ResAnmClr(void * vptr) : mAnmClr(vptr) {}
inline ResAnmClrData & ref() const
{
return mAnmClr.ref();
}
inline bool CheckRevision() const
{
return ref().mRevision == REVISION;
}
AnmPolicy GetAnmPolicy() const
{
return ref().mAnmPolicy;
}
int GetNumFrame() const
{
return ref().mNumFrames;
}
inline const ResAnmClrMatData * GetMatAnm(u32 i) const
{
return static_cast<const ResAnmClrMatData *>(mAnmClr.ofs_to_obj<ResDic>(ref().mMatDictOffset)[i]);
}
void GetAnmResult(ClrAnmResult *, u32, float) const;
};
}
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef NW4R_G3D_RESANMFOG_H
#define NW4R_G3D_RESANMFOG_H
#include "common.h"
#include "nw4r/g3d/g3d_anmfog.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResAnmFogData {
char UNK_0x0[0xC];
u32 mID; // at 0xC
};
struct ResAnmFog {
ResCommon<ResAnmFogData> mAnmFog;
inline ResAnmFog(void *vptr) : mAnmFog(vptr) {}
void GetAnmResult(FogAnmResult *, f32) const;
bool IsValid() const {
return mAnmFog.IsValid();
}
};
} // namespace g3d
} // namespace nw4r
#endif
-41
View File
@@ -1,41 +0,0 @@
#ifndef NW4R_G3D_RESANMSCN_H
#define NW4R_G3D_RESANMSCN_H
#include "common.h"
#include "nw4r/g3d/g3d_resanmcamera.h"
#include "nw4r/g3d/g3d_resanmfog.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResAnmScnData {
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x3E - 0xC];
u16 mFogMaxRefNum; // at 0x3E
};
struct ResAnmScn {
enum { REVISION = 4 };
ResCommon<ResAnmScnData> mAnmScn;
ResAnmFog GetResAnmFogByRefNumber(u32) const;
ResAnmCamera GetResAnmCameraByRefNumber(u32) const;
inline ResAnmScn(void *vptr) : mAnmScn(vptr) {}
inline bool IsValid() const {
return mAnmScn.IsValid();
}
inline bool CheckRevision() const {
return mAnmScn.ref().mRevision == REVISION;
}
u16 GetResAnmFogMaxRefNumber() const {
return mAnmScn.ref().mFogMaxRefNum;
}
};
} // namespace g3d
} // namespace nw4r
#endif
-39
View File
@@ -1,39 +0,0 @@
#ifndef NW4R_G3D_RESANMSHP_H
#define NW4R_G3D_RESANMSHP_H
#include "common.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResAnmShpData {
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x24 - 0xC];
u16 mNumFrames; // at 0x24
AnmPolicy mAnmPolicy; // at 0x28
};
struct ResAnmShp {
enum { REVISION = 3 };
ResCommon<ResAnmShpData> mAnmShp;
inline ResAnmShp(void *vptr) : mAnmShp(vptr) {}
inline bool CheckRevision() const {
return mAnmShp.ref().mRevision == REVISION;
}
AnmPolicy GetAnmPolicy() const {
return mAnmShp.ref().mAnmPolicy;
}
int GetNumFrame() const {
return mAnmShp.ref().mNumFrames;
}
};
} // namespace g3d
} // namespace nw4r
#endif
-103
View File
@@ -1,103 +0,0 @@
#ifndef NW4R_G3D_RESANMTEXPAT_H
#define NW4R_G3D_RESANMTEXPAT_H
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "nw4r/g3d/g3d_resanm.h"
namespace nw4r
{
namespace g3d
{
struct ResAnmTexPatAnmFramesData
{
float mTime; // at 0x0
u16 mTexIndex; // at 0x4
u16 mPlttIndex; // at 0x6
};
struct ResAnmTexPatAnmData
{
u16 mCount; // at 0x0
float FLOAT_0x4;
ResAnmTexPatAnmFramesData mFrames[]; // at 0x8
};
struct ResAnmTexPatMatData
{
char UNK_0x0[0x4];
u32 mFlags; // at 0x4
union AnmData
{
struct
{
u16 mTexIndex; // at 0x0
u16 mPlttIndex; // at 0x2
};
s32 mOffset;
} mAnms[]; // at 0x8
};
struct ResAnmTexPatData
{
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x4];
s32 mMatDictOffset; // at 0x10
s32 mTexNameArrayOffset; // at 0x14
s32 mPlttNameArrayOffset; // at 0x18
s32 mTexArrayOffset; // at 0x1c
s32 mPlttArrayOffset; // at 0x20
char UNK_0x24[0xC];
u16 mTexCount; // at 0x30
u16 mPlttCount; // at 0x32
char UNK_0x34[0x4];
AnmPolicy mAnmPolicy; // at 0x38
};
struct ResAnmTexPat
{
enum
{
REVISION = 3
};
ResCommon<ResAnmTexPatData> mAnmTexPat;
inline ResAnmTexPat(void * vptr) : mAnmTexPat(vptr) {}
inline ResAnmTexPatData & ref() const
{
return mAnmTexPat.ref();
}
inline bool CheckRevision() const
{
return ref().mRevision == REVISION;
}
inline const ResAnmTexPatMatData * GetMatAnm(u32 i) const
{
return static_cast<const ResAnmTexPatMatData *>(mAnmTexPat.ofs_to_obj<ResDic>(ref().mMatDictOffset)[i]);
}
AnmPolicy GetAnmPolicy() const
{
return ref().mAnmPolicy;
}
int GetNumFrame() const
{
return ref().mTexCount;
}
void GetAnmResult(TexPatAnmResult *, u32, float) const;
bool Bind(ResFile);
void Release();
};
}
}
#endif
-78
View File
@@ -1,78 +0,0 @@
#ifndef NW4R_G3D_RESANMTEXSRT_H
#define NW4R_G3D_RESANMTEXSRT_H
#include "nw4r/g3d/g3d_resanm.h"
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
namespace nw4r
{
namespace g3d
{
struct ResAnmTexSrtTexData
{
u32 mFlags; // at 0x0
ResAnmData mAnms[]; // at 0x4
};
struct ResAnmTexSrtMatData
{
char UNK_0x0[0x4];
UNKWORD FLAGS_0x4;
UNKWORD FLAGS_0x8;
s32 mTexOffsets[]; // at 0xc
};
struct ResAnmTexSrtData
{
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x4];
s32 mMatDictOffset; // at 0x10
char UNK_0x14[0x0C];
u16 mNumFrames; // at 0x20
UNKWORD UNK_0x24;
AnmPolicy mAnmPolicy; // at 0x28
};
struct ResAnmTexSrt
{
enum
{
REVISION = 4
};
ResCommon<ResAnmTexSrtData> mAnmTexSrt;
inline ResAnmTexSrt(void * vptr) : mAnmTexSrt(vptr) {}
inline ResAnmTexSrtData & ref() const
{
return mAnmTexSrt.ref();
}
inline bool CheckRevision() const
{
return mAnmTexSrt.ref().mRevision == REVISION;
}
inline const ResAnmTexSrtMatData * GetMatAnm(u32 i) const
{
return static_cast<const ResAnmTexSrtMatData *>(mAnmTexSrt.ofs_to_obj<ResDic>(ref().mMatDictOffset)[i]);
}
AnmPolicy GetAnmPolicy() const
{
return ref().mAnmPolicy;
}
int GetNumFrame() const
{
return ref().mNumFrames;
}
void GetAnmResult(TexSrtAnmResult *, u32, float) const;
};
}
}
#endif
-82
View File
@@ -1,82 +0,0 @@
#ifndef NW4R_G3D_RESANMVIS_H
#define NW4R_G3D_RESANMVIS_H
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/g3d/g3d_resanm.h"
#include "nw4r/g3d/g3d_anmobj.h"
namespace nw4r
{
namespace g3d
{
struct ResAnmVisInfoData
{
char UNK_0x0[0xC];
u16 mNumFrames; // at 0x20
u16 mNumNodes;
AnmPolicy mAnmPolicy; // at 0x24
};
struct ResAnmVisNodeData
{
UNKWORD WORD_0x0;
u32 mFlags; // at 0x4
ResBoolAnmFramesData mBoolFrames[]; // at 0x8
};
struct ResAnmVisData
{
char UNK_0x0[0x8];
u32 mRevision; // at 0x8
char UNK_0xC[0x4];
s32 mNodeDictOffset; // at 0x10
ResAnmVisInfoData mInfo; // at 0x14
};
struct ResAnmVis
{
enum
{
REVISION = 3
};
ResCommon<ResAnmVisData> mAnmVis;
inline ResAnmVis(void * vptr) : mAnmVis(vptr) {}
bool IsValid() const { return mAnmVis.IsValid(); }
inline ResAnmVisData & ref() const
{
return mAnmVis.ref();
}
inline bool CheckRevision() const
{
return ref().mRevision == REVISION;
}
inline const ResAnmVisNodeData * GetNodeAnm(u32 i) const
{
return static_cast<const ResAnmVisNodeData *>(mAnmVis.ofs_to_obj<ResDic>(ref().mNodeDictOffset)[i]);
}
AnmPolicy GetAnmPolicy() const
{
return ref().mInfo.mAnmPolicy;
}
int GetNumFrame() const
{
return ref().mInfo.mNumFrames;
}
int GetNumNode() const
{
return ref().mInfo.mNumNodes;
}
bool GetAnmResult(u32, float) const;
};
}
}
#endif
-134
View File
@@ -1,134 +0,0 @@
#ifndef NW4R_G3D_RESCOMMON_H
#define NW4R_G3D_RESCOMMON_H
#include "common.h"
#define NW4R_G3D_CREATE_RES_NAME_DATA(VAR, VAL) ResNameData ResNameData_##VAR = {sizeof(VAL) - 1, VAL}
#define FIFO_ACCESS_BP 0x61
#define FIFO_ACCESS_CP 0x8
#define FIFO_ACCESS_XF 0x10
namespace nw4r {
namespace g3d {
template <typename T>
class ResCommon {
T *mPtr;
public:
inline ResCommon(void *vptr) : mPtr(static_cast<T *>(vptr)) {}
inline ResCommon(const void *vptr) : mPtr(static_cast<T *>(vptr)) {}
inline T &ref() const {
return *mPtr;
}
inline T *ptr() const {
return mPtr;
}
inline bool IsValid() const {
return mPtr != NULL;
}
template <typename TPtr>
inline const TPtr *ofs_to_ptr_raw(s32 ofs) const {
return (const TPtr *)((u8 *)mPtr + ofs);
}
template <typename TPtr>
inline TPtr *ofs_to_ptr(s32 ofs) {
if (ofs) {
return (TPtr *)((u8 *)mPtr + ofs);
}
return NULL;
}
template <typename TPtr>
inline const TPtr *ofs_to_ptr(s32 ofs) const {
if (ofs) {
return (const TPtr *)((u8 *)mPtr + ofs);
}
return NULL;
}
template <typename TObj>
inline TObj ofs_to_obj(s32 ofs) const {
if (ofs) {
return (u8 *)mPtr + ofs;
}
return NULL;
}
};
struct ResNameData {
u32 mLength;
char mName[0x1C];
};
struct ResName {
ResCommon<const ResNameData> mRes;
inline ResName(const void *vptr) : mRes(vptr) {}
inline u32 GetLength() const {
return mRes.ref().mLength;
}
inline const char *GetName() const {
return mRes.ref().mName;
}
bool operator==(ResName) const;
};
namespace detail {
typedef u8 CPCmd[6];
typedef u8 BPCmd[5];
inline void ResWrite_u8(u8 *res, u8 arg) {
*res = arg;
}
inline void ResWrite_u16(u8 *res, u16 arg) {
ResWrite_u8(res + 0, arg >> 8);
ResWrite_u8(res + 1, arg >> 0);
}
inline void ResWrite_u32(u8 *res, u32 arg) {
ResWrite_u8(res + 0, arg >> 24);
ResWrite_u8(res + 1, arg >> 16);
ResWrite_u8(res + 2, arg >> 8);
ResWrite_u8(res + 3, arg >> 0);
}
inline u8 ResRead_u8(const u8 *res) {
return *res;
}
inline u32 ResRead_u32(const u8 *res) {
int ret = ResRead_u8(res) << 24;
ret |= ResRead_u8(res + 1) << 16;
ret |= ResRead_u8(res + 2) << 8;
ret |= ResRead_u8(res + 3);
return ret;
}
inline void ResReadBPCmd(const u8 *res, u32 *out) {
*out = ResRead_u32(res + 1);
}
inline void ResReadCPCmd(const u8 *res, u32 *out) {
*out = ResRead_u32(res + 2);
}
void ResWriteBPCmd(u8 *, u32);
void ResWriteBPCmd(u8 *, u32, u32);
void ResWriteCPCmd(u8 *, u8, u32);
void ResWriteXFCmd(u8 *, u16, u32);
void ResWriteSSMask(u8 *, u32);
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
-54
View File
@@ -1,54 +0,0 @@
#ifndef NW4R_G3D_RESDICT_H
#define NW4R_G3D_RESDICT_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "string.h"
namespace nw4r {
namespace g3d {
struct ResDicNodeData {
u16 ref; // at 0x0
u16 flag; // at 0x2
u16 idxLeft; // at 0x4
u16 idxRight; // at 0x6
u32 ofsString; // at 0x8
u32 ofsData; // at 0xC
};
struct ResDicData {
u32 size; // at 0x0
u32 numData; // at 0x4
ResDicNodeData data[1]; // 0x8
};
struct ResDic {
ResCommon<ResDicData> mDict;
ResDicNodeData *Get(ResName) const;
ResDicNodeData *Get(const char *, u32) const;
void *operator[](const char *) const;
void *operator[](ResName) const;
s32 GetIndex(ResName) const;
inline ResDic(void *vptr) : mDict(vptr) {}
inline void *operator[](int i) const {
if (mDict.IsValid()) {
return (void *)mDict.ofs_to_ptr<void>(mDict.ref().data[i + 1].ofsData);
}
return NULL;
}
inline u32 GetNumData() const {
if (mDict.IsValid()) {
return mDict.ref().numData;
}
return 0;
}
};
} // namespace g3d
} // namespace nw4r
#endif
-93
View File
@@ -1,93 +0,0 @@
#ifndef NW4R_G3D_RESFILE_H
#define NW4R_G3D_RESFILE_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/ut/ut_binaryFileFormat.h"
namespace nw4r {
namespace g3d {
struct ResFileData {
ut::BinaryFileHeader mHeader; // at 0x0
ut::BinaryBlockHeader mRootHeader; // at 0x10
ResDicData mRootData; // at 0x18
};
struct ResFile {
ResCommon<ResFileData> mFile; // at 0x0
ResFile() : mFile((void *)nullptr) {}
ResFile(void *ptr) : mFile(ptr) {}
inline ResFileData &ref() const {
return mFile.ref();
}
ResMdl GetResMdl(const char *) const;
ResMdl GetResMdl(int) const;
ResMdl GetResMdl(u32) const; // inlined
ResPltt GetResPltt(const char *) const;
ResPltt GetResPltt(ResName) const;
ResPltt GetResPltt(int) const;
ResPltt GetResPltt(u32) const; // inlined
ResTex GetResTex(const char *) const;
ResTex GetResTex(ResName) const;
ResTex GetResTex(int) const;
ResTex GetResTex(u32) const; // inlined
ResAnmChr GetResAnmChr(const char *) const;
ResAnmChr GetResAnmChr(int) const;
ResAnmChr GetResAnmChr(u32) const; // inlined
ResAnmVis GetResAnmVis(const char *) const;
ResAnmVis GetResAnmVis(int) const;
ResAnmVis GetResAnmVis(u32) const; // inlined
ResAnmClr GetResAnmClr(const char *) const;
ResAnmClr GetResAnmClr(int) const;
ResAnmClr GetResAnmClr(u32) const; // inlined
ResAnmTexPat GetResAnmTexPat(const char *) const;
ResAnmTexPat GetResAnmTexPat(int) const;
ResAnmTexPat GetResAnmTexPat(u32) const; // inlined
ResAnmTexSrt GetResAnmTexSrt(const char *) const;
ResAnmTexSrt GetResAnmTexSrt(int) const;
ResAnmTexSrt GetResAnmTexSrt(u32) const; // inlined
ResAnmShp GetResAnmShp(const char *) const;
ResAnmShp GetResAnmShp(int) const;
ResAnmShp GetResAnmShp(u32) const; // inlined
ResAnmScn GetResAnmScn(const char *) const;
ResAnmScn GetResAnmScn(int) const;
ResAnmScn GetResAnmScn(u32) const; // inlined
u32 GetResMdlNumEntries() const; // inlined
u32 GetResPlttNumEntries() const; // inlined
u32 GetResTexNumEntries() const; // inlined
u32 GetResAnmChrNumEntries() const; // inlined
u32 GetResAnmVisNumEntries() const; // inlined
u32 GetResAnmClrNumEntries() const; // inlined
u32 GetResAnmTexPatNumEntries() const; // inlined
u32 GetResAnmTexSrtNumEntries() const; // inlined
u32 GetResAnmShpNumEntries() const; // inlined
u32 GetResAnmScnNumEntries() const;
bool Bind(ResFile);
bool Bind() {
return Bind(*this);
}
void Release();
void Init();
void Terminate();
bool CheckRevision() const;
};
} // namespace g3d
} // namespace nw4r
#endif
-193
View File
@@ -1,193 +0,0 @@
#ifndef NW4R_G3D_RESMAT_H
#define NW4R_G3D_RESMAT_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/math/math_types.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
struct ResTevColorDL {
union {
struct {
u8 tevColor[3][20]; // offset 0x0, size 0x3C
u8 _0[4]; // offset 0x3C, size 0x4
u8 tevKColor[4][10]; // offset 0x40, size 0x28
u8 _1[24]; // offset 0x68, size 0x18
} dl;
u8 data[128];
};
};
struct ResMatTevColor : public ResCommon<ResTevColorDL> {
ResMatTevColor(void *vptr) : ResCommon<ResTevColorDL>(vptr) {}
void DCStore(bool sync);
void CallDisplayList(bool bSync) const;
ResMatTevColor CopyTo(void *p) const;
void GXGetTevColor(GXTevRegID id, GXColor *color);
void GXSetTevColor(GXTevRegID id, GXColor color);
void GXSetTevKColor(GXTevKColorID id, GXColor color);
};
struct ResPixDL {
union {
struct {
unsigned char alphaCompare[5]; // offset 0x0, size 0x5
unsigned char zMode[5]; // offset 0x5, size 0x5
unsigned char blendMode[10]; // offset 0xA, size 0xA
unsigned char setDstAlpha[5]; // offset 0x14, size 0x5
unsigned char _[7]; // offset 0x19, size 0x7
} dl; // offset 0x0, size 0x20
unsigned char data[32]; // offset 0x0, size 0x20
};
};
struct ResMatPix : public ResCommon<ResPixDL> {
ResMatPix(void *vptr) : ResCommon(vptr) {}
void DCStore(bool sync);
void GXGetDstAlpha(u8 *, u8 *) const;
void GXSetDstAlpha(u8, u8);
void CallDisplayList(bool bSync) const;
ResMatPix CopyTo(void *p) const;
void GXSetBlendMode(GXBlendMode, GXBlendFactor, GXBlendFactor, GXLogicOp);
};
struct ResTexCoordGenDL {};
struct ResMatTexCoordGen : public ResCommon<ResTexCoordGenDL> {
inline ResMatTexCoordGen(void *vptr) : ResCommon(vptr) {}
bool IsValid() const {
return ResCommon::IsValid();
}
bool GXGetTexCoordGen2(GXTexCoordID, GXTexGenType *, GXTexGenSrc *, u8 *, u32 *);
void GXSetTexCoordGen2(GXTexCoordID, GXTexGenType, GXTexGenSrc, u8, u32);
void DCStore(bool);
};
struct ResTexSrtData {
union {
struct {
unsigned char texCoordGen[8][18]; // offset 0x0, size 0x90
unsigned char _[16]; // offset 0x90, size 0x10
} dl; // offset 0x0, size 0xA0
unsigned char data[160]; // offset 0x0, size 0xA0
};
};
struct ResTexSrt : public ResCommon<ResTexSrtData> {
inline ResTexSrt(void *vptr) : ResCommon(vptr) {}
void SetMapMode(u32, u32, int, int);
};
struct ResTexPlttInfoData {
u32 mNumOffsets; // at 0x0
struct InfoOffset {
u32 mResOffset; // at 0x0
u32 mTexOffset; // at 0x4
} mOffsets[]; // at 0x4
};
struct ResTexPlttInfo {
ResCommon<ResTexPlttInfoData> mInfo;
inline ResTexPlttInfo(void *vptr) : mInfo(vptr) {}
};
struct ResMatDLData {
ResPixDL dlPix; // offset 0x0, size 0x20
ResTevColorDL dlTevColor; // offset 0x20, size 0x80
/* ResIndMtxAndScaleDL */ u8 dlIndMtxAndScale[0x40]; // offset 0xA0, size 0x40
ResTexCoordGenDL dlTexCoordGen; // offset 0xE0, size 0xA0
};
struct ResGenModeData {
u8 nTexGens; // offset 0x0, size 0x1
u8 nChans; // offset 0x1, size 0x1
u8 nTevs; // offset 0x2, size 0x1
u8 nInds; // offset 0x3, size 0x1
GXCullMode cullMode; // offset 0x4, size 0x4
};
struct ResGenMode : public ResCommon<ResGenModeData> {
ResGenMode(void *vptr) : ResCommon(vptr) {}
void DCStore(bool sync);
ResGenMode CopyTo(void *p) const;
GXCullMode GXGetCullMode();
u8 GXGetNumIndStages() const;
u8 GXGetNumTevStages() const;
u8 GXGetNumChans() const;
u8 GXGetNumTexGens() const;
void GXSetCullMode(GXCullMode);
};
struct ResTexObjData {};
struct ResTexObj {
ResCommon<ResTexObjData> mTexObj;
inline ResTexObj(void *vptr) : mTexObj(vptr) {}
GXTexObj *GetTexObj(GXTexMapID);
};
struct ResMatData {
u32 size; // offset 0x0, size 0x4
s32 toResMdlData; // offset 0x4, size 0x4
s32 name; // offset 0x8, size 0x4
u32 id; // offset 0xC, size 0x4
u32 flag; // offset 0x10, size 0x
ResGenModeData genMode; // offset 0x14, size 0x8
/* ResMatMiscData */ u8 misc[0xC]; // offset 0x1C, size 0xC
s32 toResTevData; // offset 0x28, size 0x4
u32 numResTexPlttInfo; // offset 0x2C, size 0x4
s32 toResTexPlttInfo; // offset 0x30, size 0x4
s32 toResMatFurData; // offset 0x34, size 0x4
u32 toResUserData; // offset 0x38, size 0x4
u32 toResMatDLData; // offset 0x3C, size 0x4
/* ResTexObjData */ u8 texObjData[0x104]; // offset 0x40, size 0x104
/* ResTlutObjData */ u8 tlutObjData[0x64]; // offset 0x144, size 0x64
ResTexSrtData texSrtData; // offset 0x1A8, size 0x248
/* ResChanData */ u8 chan[0x20]; // offset 0x3F0, size 0x28
};
struct ResMat : public ResCommon<ResMatData> {
ResMat(void *ptr) : ResCommon<ResMatData>(ptr) {}
ResMatTevColor GetResMatTevColor() {
return ResMatTevColor(&ofs_to_ptr<ResMatDLData>(ref().toResMatDLData)->dlTevColor);
}
ResMatPix GetResMatPix() {
return ResMatPix(&ofs_to_ptr<ResMatDLData>(ref().toResMatDLData)->dlPix);
}
ResGenMode GetResGenMode() {
return ResGenMode(&ref().genMode);
}
ResTexSrt GetResTexSrt() {
return ResTexSrt(&ref().texSrtData);
}
ResTexObj GetResTexObj() {
return ResTexObj(&ref().texObjData);
}
ResMatTexCoordGen GetResMatTexCoordGen() {
return ResMatTexCoordGen(&ofs_to_ptr<ResMatDLData>(ref().toResMatDLData)->dlTexCoordGen);
}
bool IsOpaque() const;
bool Bind(ResFile);
UNKTYPE Release();
UNKTYPE Init();
};
} // namespace g3d
} // namespace nw4r
#endif
-107
View File
@@ -1,107 +0,0 @@
#ifndef NW4R_G3D_RESMDL_H
#define NW4R_G3D_RESMDL_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/g3d/g3d_resdict.h"
#include "nw4r/g3d/g3d_resnode.h"
namespace nw4r {
namespace g3d {
enum ResMdlDrawMode {
RESMDL_DRAWMODE_SORT_OPA_NONE = 0,
RESMDL_DRAWMODE_SORT_OPA_Z = 1,
RESMDL_DRAWMODE_SORT_XLU_NONE = 0,
RESMDL_DRAWMODE_SORT_XLU_Z = 2,
RESMDL_DRAWMODE_IGNORE_MATERIAL = 4,
RESMDL_DRAWMODE_FORCE_LIGHTOFF = 8,
RESMDL_DRAWMODE_NOPPCSYNC = 16,
RESMDL_DRAWMODE_DEFAULT = 2,
REDMDL_DRAWMODE_SORT_NONE = 0,
RESMDL_DRAWMODE_SORT_Z = 3,
};
struct ResMdlData {
char mMagic[4]; // "MDL0"
u32 INT_0x4;
u32 mRevision; // at 0x8
s32 INT_0xC;
u32 mByteCodeDictOfs; // at 0x10
u32 mNodeDictOfs; // at 0x14
u32 mVtxPosDictOfs; // at 0x18
u32 mVtxNrmDictOfs; // at 0x1C
u32 mVtxClrDictOfs; // at 0x20
u32 mVtxTexCoordDictOfs; // at 0x24
u32 mMatDictOfs; // at 0x28
u32 mTevDictOfs; // at 0x2C
u32 mShpDictOfs; // at 0x30
u32 mPlttTexInfoOfs; // at 0x34
};
struct ResMdl {
enum { REVISION = 9 };
ResCommon<ResMdlData> mMdl;
inline ResMdl(void *vptr) : mMdl(vptr) {}
bool IsValid() const {
return mMdl.IsValid();
}
u8 *GetResByteCode(const char *) const;
ResNode GetResNode(const char *) const;
ResNode GetResNode(ResName) const;
ResNode GetResNode(int) const;
ResNode GetResNode(u32) const;
u32 GetResNodeNumEntries() const;
ResVtxPos GetResVtxPos(ResName) const;
ResVtxPos GetResVtxPos(int) const;
ResVtxPos GetResVtxPos(u32) const;
u32 GetResVtxPosNumEntries() const;
ResVtxNrm GetResVtxNrm(ResName) const;
ResVtxNrm GetResVtxNrm(int) const;
ResVtxNrm GetResVtxNrm(u32) const;
u32 GetResVtxNrmNumEntries() const;
ResVtxClr GetResVtxClr(ResName) const;
ResVtxClr GetResVtxClr(int) const;
ResVtxClr GetResVtxClr(u32) const;
u32 GetResVtxClrNumEntries() const;
ResVtxTexCoord GetResVtxTexCoord(int) const;
ResMat GetResMat(const char *) const;
ResMat GetResMat(ResName) const;
ResMat GetResMat(int) const;
ResMat GetResMat(u32) const;
u32 GetResMatNumEntries() const;
ResShp GetResShp(const char *) const;
ResShp GetResShp(int) const;
ResShp GetResShp(u32) const;
u32 GetResShpNumEntries() const;
ResTexPlttInfo GetResTexPlttInfoOffsetFromTexName(int) const;
u32 GetResTexPlttInfoOffsetFromTexNameNumEntries() const;
bool Bind(ResFile);
void Release();
void Init();
void Terminate();
inline bool CheckRevision() const {
return mMdl.ref().mRevision == REVISION;
}
inline u32 GetResVtxTexCoordNumEntries() const {
ResMdlData &ref = mMdl.ref();
return mMdl.ofs_to_obj<ResDic>(ref.mVtxTexCoordDictOfs).GetNumData();
}
};
} // namespace g3d
} // namespace nw4r
#endif
-65
View File
@@ -1,65 +0,0 @@
#ifndef NW4R_G3D_RESNODE_H
#define NW4R_G3D_RESNODE_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/math/math_types.h"
namespace nw4r {
namespace g3d {
class ChrAnmResult;
struct ResNodeData {
u32 INT_0x0;
s32 INT_0x4;
u16 SHORT_0x8;
u16 SHORT_0xA;
UNKWORD WORD_0xC;
UNKWORD WORD_0x10;
u32 mFlags; // at 0x14
UNKWORD WORD_0x18;
UNKWORD WORD_0x1C;
math::VEC3 VEC3_0x20;
math::VEC3 VEC3_0x2C;
f32 FLOAT_0x38;
f32 FLOAT_0x3C;
f32 FLOAT_0x40;
math::VEC3 VEC3_0x44;
math::VEC3 VEC3_0x50;
};
struct ResNode {
enum ResNodeFlags { NODE_IS_VISIBLE = 0x100 };
ResCommon<ResNodeData> mNode;
inline ResNode(void *vptr) : mNode(vptr) {}
bool IsValid() const {
return mNode.IsValid();
}
UNKWORD GetID() const {
if (IsValid()) {
return mNode.ptr()->WORD_0xC;
}
return 0;
}
void SetVisibility(bool visible) {
if (IsValid()) {
if (visible) {
mNode.ptr()->mFlags |= NODE_IS_VISIBLE;
} else {
mNode.ptr()->mFlags &= ~NODE_IS_VISIBLE;
}
}
}
void PatchChrAnmResult(ChrAnmResult *) const;
void CalcChrAnmResult(ChrAnmResult *) const;
};
} // namespace g3d
} // namespace nw4r
#endif
-110
View File
@@ -1,110 +0,0 @@
#ifndef NW4R_G3D_RESSHP_H
#define NW4R_G3D_RESSHP_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/g3d_resvtx.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
struct ResTagDLData {
u32 mBufSize; // at 0x0
u32 mCmdSize; // at 0x4
u32 mOffset; // at 0x8
};
struct ResPrePrimDL {
char UNK_0x0[0xA];
detail::CPCmd CP_CMD_0xA;
detail::CPCmd CP_CMD_0x10;
char UNK_0x16[0xA];
detail::CPCmd CP_CMD_0x20;
detail::CPCmd CP_CMD_0x26;
detail::CPCmd CP_CMD_0x2C;
detail::CPCmd CP_CMD_PAIRS_0x32[GX_POS_MTX_ARRAY - GX_VA_POS][2];
char UNK_0xC2[0x1E];
};
struct ResShpData {
char UNK_0x0[0x4];
u32 mParentOffset; // at 0x4
char UNK_0x8[0x10];
ResTagDLData mPrePrimDLTag; // at 0x18
ResTagDLData mPrimDLTag; // at 0x24
char UNK_0x30[0x18];
s16 mVtxPosIndex; // at 0x48
s16 mVtxNrmIndex; // at 0x4a
s16 mVtxClrIndices[GX_VA_TEX0 - GX_VA_CLR0]; // at 0x4c
s16 mVtxTexCoordIndices[GX_POS_MTX_ARRAY - GX_VA_TEX0]; // at 0x50
};
struct ResTagDL {
ResCommon<ResTagDLData> mData;
inline ResTagDL(void *vptr) : mData(vptr) {}
inline u8 *GetDL() const {
return const_cast<u8 *>(mData.ofs_to_ptr<u8>(mData.ref().mOffset));
}
inline u32 GetBufSize() const {
return mData.ref().mBufSize;
}
inline u32 GetCmdSize() const {
return mData.ref().mCmdSize;
}
};
struct ResShpPrePrim {
ResCommon<ResPrePrimDL> mDL;
inline ResShpPrePrim(void *vptr) : mDL(vptr) {}
inline ResPrePrimDL &ref() const {
return mDL.ref();
}
};
struct ResShp {
ResCommon<ResShpData> mShp;
inline ResShp() : mShp((void *)nullptr) {}
inline ResShp(void *vptr) : mShp(vptr) {}
bool IsValid() const {
return mShp.IsValid();
}
inline ResShpData &ref() const {
return mShp.ref();
}
inline ResShpPrePrim GetResShpPrePrim() const {
return ResTagDL(&ref().mPrePrimDLTag).GetDL();
}
bool GXGetVtxDescv(GXVtxDescList *) const;
bool GXGetVtxAttrFmtv(GXVtxAttrFmtList *) const;
ResMdl GetParent() const; // inlined
ResVtxPos GetResVtxPos() const;
ResVtxNrm GetResVtxNrm() const;
ResVtxClr GetResVtxClr(u32) const;
ResVtxTexCoord GetResVtxTexCoord(u32) const; // inlined
void GXSetArray(GXAttr, const void *, u8); // inlined
void Init();
void DisableSetArray(GXAttr); // inlined
void Terminate();
void CallPrePrimitiveDisplayList(bool, bool) const;
void CallPrimitiveDisplayList(bool) const;
};
} // namespace g3d
} // namespace nw4r
#endif
-56
View File
@@ -1,56 +0,0 @@
#ifndef NW4R_G3D_RESTEV_H
#define NW4R_G3D_RESTEV_H
#include "GXTev.h"
#include "GXTexture.h"
#include "nw4r/g3d/g3d_cpu.h"
#include "nw4r/g3d/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResTevData {
u32 SIZE_0x0;
u32 INT_0x4;
char UNK_0x8[0x4];
u8 BYTE_0xC;
char UNK_0xD[0x13];
detail::BPCmd mSwapSelCmds[GX_MAX_TEVSWAP][4];
char UNK_0x70[0x10];
struct {
detail::BPCmd BP_CMD_0x0;
detail::BPCmd BP_CMD_0x5;
detail::BPCmd BP_CMD_0xA;
detail::BPCmd BP_CMD_PAIR_0xF[2];
char UNK_0x19[0x17];
} mStageCmds[]; //[GX_TEV_STAGE_COUNT];
};
struct ResTev {
ResCommon<ResTevData> mTev;
inline ResTev(void *vptr) : mTev(vptr) {}
inline ResTevData &ref() const {
return mTev.ref();
}
bool
GXGetTevSwapModeTable(GXTevSwapSel, GXTevColorChan *, GXTevColorChan *, GXTevColorChan *, GXTevColorChan *) const;
void GXSetTevSwapModeTable(GXTevSwapSel, GXTevColorChan, GXTevColorChan, GXTevColorChan, GXTevColorChan);
bool GXGetTevOrder(GXTevStageID, GXTexCoordID *, GXTexMapID *, GXChannelID *) const;
void GXSetTevColorIn(GXTevStageID, GXTevColorArg, GXTevColorArg, GXTevColorArg, GXTevColorArg);
void CallDisplayList(bool) const;
void *CopyTo(void *);
UNKTYPE DCStore(bool);
};
} // namespace g3d
} // namespace nw4r
#endif
-76
View File
@@ -1,76 +0,0 @@
#ifndef NW4R_G3D_RESTEX_H
#define NW4R_G3D_RESTEX_H
#include "common.h"
#include "nw4r/g3d/g3d_rescommon.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
struct ResTexData {
char mMagic[4]; // "TEX0"; at 0x0
u32 mLength; // at 0x4
u32 mRevision; // at 0x8
s16 SHORT_0xC;
u16 SHORT_0xE;
u32 INT_0x10;
UNKWORD WORD_0x14;
u32 mFlags; // at 0x18
u16 SHORT_0x1C;
u16 SHORT_0x1E;
union // at 0x20
{
GXTexFmt mFormat;
GXCITexFmt mCiFormat;
};
u32 WORD_0x24;
f32 FLOAT_0x28;
f32 FLOAT_0x2C;
};
struct ResPlttData {
char mMagic[4]; // "PLT0"; at 0x0
u32 mLength; // at 0x4
u32 mRevision; // at 0x8
};
struct ResTex {
enum {
REVISION = 1
};
ResCommon<ResTexData> mTex; // at 0x0
inline ResTex(void *vptr) : mTex(vptr) {}
inline bool CheckRevision() const {
return mTex.ref().mRevision == REVISION;
}
bool GetTexObjParam(void **, u16 *, u16 *, GXTexFmt *, f32 *, f32 *, u8 *) const;
bool GetTexObjCIParam(void **, u16 *, u16 *, GXCITexFmt *, f32 *, f32 *, u8 *) const;
void Init();
bool IsValid() const {
return mTex.IsValid();
}
};
struct ResPltt {
enum {
REVISION = 1
};
ResCommon<ResPlttData> mPltt; // at 0x0
inline ResPltt(void *vptr) : mPltt(vptr) {}
inline bool CheckRevision() const {
return mPltt.ref().mRevision == REVISION;
}
void DCStore(bool);
};
} // namespace g3d
} // namespace nw4r
#endif
-136
View File
@@ -1,136 +0,0 @@
#ifndef NW4R_G3D_RESVTX_H
#define NW4R_G3D_RESVTX_H
#include "nw4r/g3d/g3d_rescommon.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
struct ResVtxPosData {
u32 SIZE_0x0;
char UNK_0x4[0x4];
u32 mDataOffset; // at 0x8
char UNK_0xC[0x11];
u8 BYTE_0x1D;
};
struct ResVtxNrmData {
u32 SIZE_0x0;
char UNK_0x4[0x4];
u32 mDataOffset; // at 0x8
char UNK_0xC[0x11];
u8 BYTE_0x1D;
};
struct ResVtxClrData {
u32 SIZE_0x0;
char UNK_0x4[0x4];
u32 mDataOffset; // at 0x8
char UNK_0xC[0x10];
u8 BYTE_0x1C;
};
struct ResVtxTexCoordData {
u32 SIZE_0x0;
char UNK_0x4[0x4];
u32 mDataOffset; // at 0x8
char UNK_0xC[0x11];
u8 BYTE_0x1D;
};
struct ResVtxPos {
ResCommon<ResVtxPosData> mPos;
inline ResVtxPos(void *vptr) : mPos(vptr) {}
inline ResVtxPosData &ref() const {
return mPos.ref();
}
inline const void *GetData() const {
return mPos.ofs_to_ptr<void>(ref().mDataOffset);
}
inline UNKTYPE Init() {
DCStore(false);
}
void SetArray();
void GetArray(const void **, u8 *) const;
UNKTYPE CopyTo(void *) const;
UNKTYPE DCStore(bool);
};
struct ResVtxNrm {
ResCommon<ResVtxNrmData> mNrm;
inline ResVtxNrm(void *vptr) : mNrm(vptr) {}
inline ResVtxNrmData &ref() const {
return mNrm.ref();
}
inline const void *GetData() const {
return mNrm.ofs_to_ptr<void>(ref().mDataOffset);
}
inline UNKTYPE Init() {
DCStore(false);
}
void SetArray();
void GetArray(const void **, u8 *) const;
UNKTYPE CopyTo(void *) const;
UNKTYPE DCStore(bool);
};
struct ResVtxClr {
ResCommon<ResVtxClrData> mClr;
inline ResVtxClr(void *vptr) : mClr(vptr) {}
inline ResVtxClrData &ref() const {
return mClr.ref();
}
inline const void *GetData() const {
return mClr.ofs_to_ptr<void>(ref().mDataOffset);
}
inline UNKTYPE Init() {
DCStore(false);
}
void SetArray(GXAttr);
void GetArray(const void **, u8 *) const;
UNKTYPE CopyTo(void *) const;
UNKTYPE DCStore(bool);
};
struct ResVtxTexCoord {
ResCommon<ResVtxTexCoordData> mTexCoord;
inline ResVtxTexCoord(void *vptr) : mTexCoord(vptr) {}
inline ResVtxTexCoordData &ref() const {
return mTexCoord.ref();
}
inline const void *GetData() const {
return mTexCoord.ofs_to_ptr<void>(ref().mDataOffset);
}
inline UNKTYPE Init() {
DCStore(false);
}
void GetArray(const void **, u8 *) const;
UNKTYPE DCStore(bool);
};
} // namespace g3d
} // namespace nw4r
#endif
+56
View File
@@ -0,0 +1,56 @@
#ifndef NW4R_G3D_RTTI_H
#define NW4R_G3D_RTTI_H
/**
* (Internal) Declare TypeObj for an object class.
*/
#define __NW4R_G3D_TYPEOBJ_DECL(T) static const nw4r::g3d::G3dObj::ResNameDataT<sizeof(#T)> TYPE_NAME;
/**
* (Internal) Declare data and methods common between base and derived types.
*/
#define __NW4R_G3D_RTTI_DECL(T) \
public: \
virtual const TypeObj GetTypeObj() const { \
return nw4r::g3d::G3dObj::TypeObj(TYPE_NAME); \
} /* at 0x14 */ \
\
static const G3dObj::TypeObj GetTypeObjStatic() { \
return nw4r::g3d::G3dObj::TypeObj(TYPE_NAME); \
} \
\
virtual const char *GetTypeName() const { \
return GetTypeObj().GetTypeName(); \
} /* at 0x18 */ \
\
private: \
__NW4R_G3D_TYPEOBJ_DECL(T);
/**
* Declare data and methods common between base and derived types.
*/
#define NW4R_G3D_RTTI_DEF(T) const nw4r::g3d::G3dObj::ResNameDataT<sizeof(#T)> T::TYPE_NAME = {sizeof(#T), #T}
/**
* Define type RTTI (base type).
*/
#define NW4R_G3D_RTTI_DECL_BASE(T) \
__NW4R_G3D_RTTI_DECL(T); \
\
public: \
virtual bool IsDerivedFrom(nw4r::g3d::G3dObj::TypeObj other) const { \
return other == GetTypeObjStatic(); \
} /* at 0x8 */
/**
* Define type RTTI (derived type).
*/
#define NW4R_G3D_RTTI_DECL_DERIVED(T, BASE) \
__NW4R_G3D_RTTI_DECL(T); \
\
public: \
virtual bool IsDerivedFrom(nw4r::g3d::G3dObj::TypeObj other) const { \
return other == GetTypeObjStatic() ? true : BASE::IsDerivedFrom(other); \
} /* at 0x8 */
#endif
+131 -23
View File
@@ -1,54 +1,162 @@
#ifndef NW4R_G3D_SCN_MDL_H
#define NW4R_G3D_SCN_MDL_H
#include "common.h"
#include "nw4r/g3d/g3d_draw.h"
#include "nw4r/g3d/g3d_resmat.h"
#include "nw4r/g3d/g3d_scnmdlsmpl.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_draw.h>
#include <nw4r/g3d/g3d_scnmdlsmpl.h>
#include <nw4r/g3d/res/g3d_resmat.h>
namespace nw4r {
namespace g3d {
// Forward declarations
class AnmObjShp;
class ScnMdl : public ScnMdlSimple {
public:
class CopiedMatAccess {
public:
CopiedMatAccess(ScnMdl *, u32);
ResTexSrt GetResTexSrtEx(bool);
ResMatPix GetResMatPix(bool);
ResMatTevColor GetResMatTevColor(bool);
ResGenMode GetResGenMode(bool);
CopiedMatAccess(ScnMdl *pScnMdl, u32 id);
ResTexObj GetResTexObj(bool markDirty);
ResTexSrt GetResTexSrt(bool markDirty);
ResMatChan GetResMatChan(bool markDirty);
ResGenMode GetResGenMode(bool markDirty);
ResMatPix GetResMatPix(bool markDirty);
ResMatTevColor GetResMatTevColor(bool markDirty);
ResTev GetResTev(bool markDirty);
ResTexSrt GetResTexSrtEx();
private:
char UNK_0x0[0x34];
ScnMdl *mpScnMdl; // at 0x0
u32 mMatID; // at 0x4
ResTexObj mTexObj; // at 0x8
ResTlutObj mTlutObj; // at 0xC
ResTexSrt mTexSrt; // at 0x10
ResMatChan mChan; // at 0x14
ResGenMode mGenMode; // at 0x18
ResMatMisc mMatMisc; // at 0x1C
ResMatPix mPix; // at 0x20
ResMatTevColor mTevColor; // at 0x24
ResMatIndMtxAndScale mIndMtxAndScale; // at 0x28
ResMatTexCoordGen mTexCoordGen; // at 0x2C
ResTev mTev; // at 0x30
};
class CopiedVisAccess {
public:
CopiedVisAccess(ScnMdl *, u32);
void SetVisibility(bool);
CopiedVisAccess(ScnMdl *pScnMdl, u32 id);
bool IsVisible() const;
bool SetVisibility(bool visible);
bool SetVisibilityEx(bool visible);
private:
// TODO
char UNK_0x0[0x10];
ScnMdl *mpScnMdl; // at 0x0
u32 mNodeID; // at 0x4
u8 *mpVis; // at 0x8
};
#define OPT(KEY, VALUE) OPTION_##KEY = (0x30000 | (VALUE))
enum ScnMdlOption {
OPT(NONE, 0),
OPT(VISBUFFER_REFRESH_NEEDED, 1),
};
#undef OPT
public:
virtual bool SetAnmObj(AnmObj *p, AnmObjType type) override;
static ScnMdl *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, u32 bufferOption, int numView);
static ScnMdl *Construct(MEMAllocator *, unsigned long *, nw4r::g3d::ResMdl, u32 bufferOption, int);
ScnMdl(
MEMAllocator *pAllocator, ResMdl mdl, math::MTX34 *pWorldMtxArray, u32 *pWorldMtxAttribArray,
math::MTX34 *pViewPosMtxArray, math::MTX33 *pViewNrmMtxArray, math::MTX34 *pViewTexMtxArray, int numView,
int numViewMtx, DrawResMdlReplacement *pReplacement, u32 *pMatBufferDirtyFlag
);
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~ScnMdl(); // at 0x10
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 AnmObj *GetAnmObj(AnmObjType type); // at 0x40
virtual const AnmObj *GetAnmObj(AnmObjType type) const; // at 0x44
void InitBuffer();
void CleanMatBuffer(u32 idx, u32 option);
void CleanVisBuffer();
AnmObjShp *GetAnmObjShp() {
return mpAnmObjShp;
}
DrawResMdlReplacement *GetDrawResMdlReplacement() {
return &mDrawMdlReplace;
DrawResMdlReplacement &GetDrawResMdlReplacement() {
return mReplacement;
}
protected:
void ScnMdl_G3DPROC_CALC_WORLD(u32 param, const math::MTX34 *pParent);
void ScnMdl_G3DPROC_CALC_MAT(u32 param, void *pInfo);
void ScnMdl_G3DPROC_CALC_VTX(u32 param, void *pInfo);
void ScnMdl_G3DPROC_DRAW_OPA(u32 param, void *pInfo);
void ScnMdl_G3DPROC_DRAW_XLU(u32 param, void *pInfo);
private:
enum VisBufferFlag {
VISBUFFER_DIRTY = (1 << 0),
VISBUFFER_NOT_REFRESH_NEEDED = (1 << 1),
};
enum MatBufferOption {
BUFOPTION_TEXOBJ = (1 << 0),
BUFOPTION_TLUTOBJ = (1 << 1),
BUFOPTION_TEXSRT = (1 << 2),
BUFOPTION_MATCHAN = (1 << 3),
BUFOPTION_GENMODE = (1 << 4),
BUFOPTION_MATMISC = (1 << 5),
BUFOPTION_VIS = (1 << 6),
BUFOPTION_MATPIX = (1 << 7),
BUFOPTION_MATTEVCOLOR = (1 << 8),
BUFOPTION_MATINDMTXSCALE = (1 << 9),
BUFOPTION_MATTEXCOORDGEN = (1 << 10),
BUFOPTION_TEV = (1 << 11),
BUFOPTION_VTXPOS = (1 << 12),
BUFOPTION_VTXNRM = (1 << 13),
BUFOPTION_VTXCLR = (1 << 14),
};
private:
bool IsVisBufferDirty() const {
return mFlagVisBuffer & VISBUFFER_DIRTY;
}
bool IsVisBufferRefreshNeeded() const {
return !(mFlagVisBuffer & VISBUFFER_NOT_REFRESH_NEEDED);
}
void VisBufferDirty() {
mFlagVisBuffer |= VISBUFFER_DIRTY;
}
bool IsMatBufferDirty(u32 idx, u32 option) const {
return option & mpMatBufferDirtyFlag[idx];
}
void MatBufferDirty(u32 idx, u32 option) {
mpMatBufferDirtyFlag[idx] |= option;
}
private:
char UNK_0x120[0x144 - 0x120];
DrawResMdlReplacement mDrawMdlReplace; // at 0x144
AnmObjShp *mpAnmObjShp; // at 0x138
u32 mFlagVisBuffer; // at 0x13C
u32 *mpMatBufferDirtyFlag; // at 0x140
DrawResMdlReplacement mReplacement; // at 0x144
NW4R_G3D_TYPE_OBJ_DECL(ScnMdl);
NW4R_G3D_RTTI_DECL_DERIVED(ScnMdl, ScnMdlSimple);
};
} // namespace g3d
} // namespace nw4r
+10 -11
View File
@@ -1,18 +1,16 @@
#ifndef NW4R_G3D_SCN_MDL1_MAT1_SHP_H
#define NW4R_G3D_SCN_MDL1_MAT1_SHP_H
#include "common.h"
#include "nw4r/g3d/g3d_resmat.h"
#include "nw4r/g3d/g3d_resshp.h"
#include "nw4r/g3d/g3d_scnobj.h"
#ifndef NW4R_G3D_SCN_MDL_1MAT_1SHP_H
#define NW4R_G3D_SCN_MDL_1MAT_1SHP_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resshp.h>
namespace nw4r {
namespace g3d {
class ScnMdl1Mat1Shp : public ScnLeaf {
public:
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
ResMat GetResMat() {
return mResMat;
}
@@ -24,8 +22,9 @@ private:
ResMat mResMat; // at 0xE8
ResShp mResShp; // at 0xEC
NW4R_G3D_TYPE_OBJ_DECL(ScnMdl1Mat1Shp);
NW4R_G3D_RTTI_DECL_DERIVED(ScnMdl1Mat1Shp, ScnLeaf);
};
} // namespace g3d
} // namespace nw4r
+175 -67
View File
@@ -1,15 +1,39 @@
#ifndef NW4R_G3D_SCN_MDL_SIMPLE_H
#define NW4R_G3D_SCN_MDL_SIMPLE_H
#include "common.h"
#include "nw4r/g3d/g3d_calcworld.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/math/math_types.h"
#ifndef NW4R_G3D_SCN_MDL_SMPL_H
#define NW4R_G3D_SCN_MDL_SMPL_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_calcview.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
// Forward declarations
class AnmObj;
class AnmObjChr;
class AnmObjVis;
class AnmObjMatClr;
class AnmObjTexPat;
class AnmObjTexSrt;
class ICalcWorldCallback;
class ScnMdlSimple : public ScnLeaf {
public:
enum AnmObjType {
ANMOBJTYPE_CHR,
ANMOBJTYPE_VIS,
ANMOBJTYPE_MATCLR,
ANMOBJTYPE_TEXPAT,
ANMOBJTYPE_TEXSRT,
ANMOBJTYPE_SHP,
ANMOBJTYPE_NOT_SPECIFIED,
ANMOBJTYPE_VTX = ANMOBJTYPE_SHP
};
enum ByteCodeType {
BYTE_CODE_CALC,
BYTE_CODE_MIX,
@@ -17,93 +41,177 @@ public:
BYTE_CODE_DRAW_XLU,
};
enum AnmObjType {
ANMOBJTYPE_CHR = 0,
ANMOBJTYPE_VIS = 1,
ANMOBJTYPE_MATCLR = 2,
ANMOBJTYPE_TEXPAT = 3,
ANMOBJTYPE_TEXSRT = 4,
ANMOBJTYPE_SHP = 5,
ANMOBJTYPE_NOT_SPECIFIED = 6,
ANMOBJTYPE_VTX = 5,
#define OPT(KEY, VALUE) OPTION_##KEY = (0x20000 | (VALUE))
enum ScnMdlSimpleOption {
OPT(NONE, 0),
OPT(IGNORE_ANMCHR_TRANS, 1),
};
#undef OPT
public:
ScnMdlSimple(MEMAllocator *, ResMdl, math::MTX34 *, u32 *, math::MTX34 *, math::MTX33 *, math::MTX34 *, int, int);
static ScnMdlSimple *Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numView);
static ScnMdlSimple *Construct(MEMAllocator *, unsigned long *, nw4r::g3d::ResMdl, int);
ScnMdlSimple(
MEMAllocator *pAllocator, ResMdl mdl, math::MTX34 *pWorldMtxArray, u32 *pWorldMtxAttribArray,
math::MTX34 *pViewPosMtxArray, math::MTX33 *pViewNrmMtxArray, math::MTX34 *pViewTexMtxArray, int numView,
int numViewMtx
);
bool GetScnMtxPos(math::MTX34 *pOut, ScnObjMtxType tp, u32 nodeID) const;
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~ScnMdlSimple(); // at 0x10
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : ScnLeaf::IsDerivedFrom(other);
}
static const TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~ScnMdlSimple(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual bool SetScnObjOption(u32 option, u32 value); // at 0x20
virtual bool GetScnObjOption(u32 option, u32 *pValue) const; // at 0x24
virtual bool SetAnmObj(AnmObj *p, AnmObjType type);
virtual bool RemoveAnmObj(AnmObj *p);
virtual bool RemoveAnmObj(AnmObjType type);
virtual AnmObj *GetAnmObj(AnmObjType type);
virtual AnmObj *GetAnmObj(AnmObjType type) const;
virtual bool SetAnmObj(AnmObj *pObj, AnmObjType type); // 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
const u8 *GetByteCode(ByteCodeType) const;
void EnableScnMdlCallbackTiming(Timing);
bool GetScnMtxPos(math::MTX34 *pMtx, ScnObjMtxType type, u32 idx) const;
const ResMdl GetResMdl() const {
void UpdateFrame();
void EnableScnMdlCallbackTiming(Timing timing);
void DisableScnMdlCallbackTiming(Timing timing);
math::MTX34 *GetViewPosMtxArray();
const math::MTX34 *GetViewPosMtxArray() const;
math::MTX33 *GetViewNrmMtxArray();
const math::MTX33 *GetViewNrmMtxArray() const;
math::MTX34 *GetViewTexMtxArray();
const math::MTX34 *GetViewTexMtxArray() const;
const u8 *GetByteCode(ByteCodeType type) const;
ResMdl GetResMdl() {
return mResMdl;
}
ResMdl GetResMdl() {
const ResMdl GetResMdl() const {
return mResMdl;
}
math::MTX34 *GetWldMtxArray() {
return mWldMatrixArray;
return mpWorldMtxArray;
}
u32 *GetWldMtxAttribArray() {
return mWldMtxAttribArray;
return mpWorldMtxAttribArray;
}
u16 GetNumViewMtx() const {
u32 GetNumViewMtx() const {
return mNumViewMtx;
}
void SetCalcWorldCallback(ICalcWorldCallback *cb) {
mpCalcWorldCallback = cb;
const u8 *GetByteCodeCalc() {
return mpByteCodeCalc;
}
const u8 *GetByteCodeMix() {
return mpByteCodeMix;
}
const u8 *GetByteCodeDrawOpa() {
return mpByteCodeDrawOpa;
}
const u8 *GetByteCodeDrawXlu() {
return mpByteCodeDrawXlu;
}
ResMdlDrawMode GetDrawMode() const {
return mDrawMode;
}
void SetScnMdlCallback(ICalcWorldCallback *pCallback) {
mpCalcWorldCallback = pCallback;
}
ICalcWorldCallback *GetScnMdlCallback() {
return mpCalcWorldCallback;
}
u8 GetScnMdlCallbackTiming() const {
return mCwcbTiming;
}
void SetScnMdlCallbackNodeID(u32 id) {
mCwcbNodeID = id;
}
u32 GetScnMdlCallbackNodeID() const {
return mCwcbNodeID;
}
AnmObjChr *GetAnmObjChr() {
return mpAnmObjChr;
}
AnmObjVis *GetAnmObjVis() {
return mpAnmObjVis;
}
AnmObjMatClr *GetAnmObjMatClr() {
return mpAnmObjMatClr;
}
AnmObjTexPat *GetAnmObjTexPat() {
return mpAnmObjTexPat;
}
AnmObjTexSrt *GetAnmObjTexSrt() {
return mpAnmObjTexSrt;
}
protected:
enum ScnMdlSmplFlag {
SCNMDLSMPLFLAG_LC_DMA = (1 << 0),
};
static const int VIEW_MAX = 16;
static const int MTX_CACHE_MIN = 8;
static const int MTX_CACHE_MAX = sizeof(detail::MtxCacheMap) / sizeof(math::MTX34) + 1;
protected:
void ScnMdlSmpl_CalcPosture(u32 param, const math::MTX34 *pParent);
void ScnMdlSmpl_G3DPROC_GATHER_SCNOBJ(u32 param, IScnObjGather *pCollection);
void ScnMdlSmpl_G3DPROC_CALC_WORLD(u32 param, const math::MTX34 *pParent);
void ScnMdlSmpl_G3DPROC_CALC_MAT(u32 param, void *pInfo);
void ScnMdlSmpl_G3DPROC_CALC_VIEW(u32 param, const math::MTX34 *pCamera);
void ScnMdlSmpl_G3DPROC_DRAW_OPA(u32 param, void *pInfo);
void ScnMdlSmpl_G3DPROC_DRAW_XLU(u32 param, void *pInfo);
void ScnMdlSmpl_G3DPROC_UPDATEFRAME(u32 /* param */, void * /* pInfo */) {
UpdateFrame();
}
private:
ResMdl mResMdl; // at 0xE8
math::MTX34 *mWldMatrixArray; // at 0xEC
u32 *mWldMtxAttribArray; // at 0xF0
math::MTX34 *PTR_0xF4;
math::MTX33 *PTR_0xF8;
math::MTX34 *PTR_0xFC;
u8 BYTE_0x100;
u8 BYTE_0x101;
u16 mNumViewMtx; // at 0x102
UNKWORD WORD_0x104;
void *mByteCodeCalc; // at 0x108
void *mByteCodeMix; // at 0x10C
void *mByteCodeDrawOpa; // at 0x110
void *mByteCodeDrawXlu; // at 0x114
UNKWORD WORD_0x118;
ICalcWorldCallback *mpCalcWorldCallback; // at 0x11C
ResMdl mResMdl; // at 0xE8
math::MTX34 *mpWorldMtxArray; // at 0xEC
u32 *mpWorldMtxAttribArray; // at 0xF0
math::MTX34 *mpViewPosMtxArray; // at 0xF4
math::MTX33 *mpViewNrmMtxArray; // at 0xF8
math::MTX34 *mpViewTexMtxArray; // at 0xFC
u8 mNumView; // at 0x100
u8 mCurView; // at 0x101
u16 mNumViewMtx; // at 0x102
u32 mFlagScnMdlSimple; // at 0x104
NW4R_G3D_TYPE_OBJ_DECL(ScnMdlSimple);
const u8 *mpByteCodeCalc; // at 0x108
const u8 *mpByteCodeMix; // at 0x10C
const u8 *mpByteCodeDrawOpa; // at 0x110
const u8 *mpByteCodeDrawXlu; // at 0x114
ResMdlDrawMode mDrawMode; // at 0x118
ICalcWorldCallback *mpCalcWorldCallback; // at 0x11C
u8 mCwcbTiming; // at 0x120
u8 mCwcbDeleteOption; // at 0x121
u16 mCwcbNodeID; // at 0x122
AnmObjChr *mpAnmObjChr; // at 0x124
AnmObjVis *mpAnmObjVis; // at 0x128
AnmObjMatClr *mpAnmObjMatClr; // at 0x12C
AnmObjTexPat *mpAnmObjTexPat; // at 0x130
AnmObjTexSrt *mpAnmObjTexSrt; // at 0x134
NW4R_G3D_RTTI_DECL_DERIVED(ScnMdlSimple, ScnLeaf);
};
} // namespace g3d
} // namespace nw4r
+351 -212
View File
@@ -1,215 +1,346 @@
#ifndef NW4R_G3D_SCNOBJ_H
#define NW4R_G3D_SCNOBJ_H
#include "common.h"
#include "nw4r/g3d/g3d_obj.h"
#include "nw4r/math/math_geometry.h"
#include "nw4r/math/math_types.h"
#ifndef NW4R_G3D_SCN_OBJ_H
#define NW4R_G3D_SCN_OBJ_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_obj.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
namespace {
static inline u32 align4(u32 x) {
return x + 3 & ~3;
}
} // namespace
struct IScnObjGather {
virtual ~IScnObjGather();
virtual UNKWORD Add(ScnObj *, bool, bool) = 0;
extern const math::FRUSTUM *gpCullingFrustum;
enum ResMdlDrawMode {
RESMDL_DRAWMODE_SORT_OPA_NONE = 0,
RESMDL_DRAWMODE_SORT_OPA_Z = (1 << 0),
RESMDL_DRAWMODE_SORT_XLU_NONE = 0,
RESMDL_DRAWMODE_SORT_XLU_Z = (1 << 1),
RESMDL_DRAWMODE_IGNORE_MATERIAL = (1 << 2),
RESMDL_DRAWMODE_FORCE_LIGHTOFF = (1 << 3),
RESMDL_DRAWMODE_NOPPCSYNC = (1 << 4),
RESMDL_DRAWMODE_DEFAULT = RESMDL_DRAWMODE_SORT_XLU_Z,
REDMDL_DRAWMODE_SORT_NONE = 0,
RESMDL_DRAWMODE_SORT_Z = RESMDL_DRAWMODE_SORT_OPA_Z | RESMDL_DRAWMODE_SORT_XLU_Z,
};
/******************************************************************************
*
* ScnObj
*
******************************************************************************/
// Forward declarations
class IScnObjCallback;
class ScnObj : public G3dObj {
public:
enum ForEachResult { FOREACH_RESULT_0, FOREACH_RESULT_1 };
enum ScnObjFlag {
SCNOBJFLAG_DISABLE_CALC_WORLD = 1,
SCNOBJFLAG_DISABLE_CALC_MAT = 2,
SCNOBJFLAG_DISABLE_CALC_VTX = 4,
SCNOBJFLAG_DISABLE_CALC_VIEW = 8,
SCNOBJFLAG_DISABLE_GATHER_SCNOBJ = 16,
SCNOBJFLAG_DISABLE_DRAW_OPA = 32,
SCNOBJFLAG_DISABLE_DRAW_XLU = 64,
SCNOBJFLAG_DISABLE_UPDATEFRAME = 128,
SCNOBJFLAG_IGNORE_ANMCHR_TRANS = 256,
SCNOBJFLAG_ENABLE_CULLING = 268435456,
SCNOBJFLAG_NOT_GATHER_DRAW_OPA = 536870912,
SCNOBJFLAG_NOT_GATHER_DRAW_XLU = 1073741824,
SCNOBJFLAG_MTX_LOCAL_IDENTITY = -2147483648,
SCNOBJFLAG_DISABLE_DRAW = 96,
enum ForEachResult {
FOREACHRESULT_OK,
FOREACHRESULT_CONTINUE,
FOREACHRESULT_RETURN,
FOREACHRESULT_GOBACK
};
enum ScnObjMtxType { MTX_TYPE_LOCAL, MTX_TYPE_WORLD, MTX_TYPE_VIEW, MTX_TYPE_MAX };
typedef ForEachResult (*ForEachFunc)(ScnObj *pParent, void *pInfo);
enum Timing { TIMING_1 = 0x1, TIMING_2 = 0x2, TIMING_4 = 0x4, TIMING_ALL = 0x7 };
enum ScnObjMtxType {
MTX_LOCAL,
MTX_WORLD,
MTX_VIEW,
MTX_TYPE_MAX
};
enum ExecOp { EXEC_OP_1 = 0x1, EXEC_OP_2 = 0x2, EXEC_OP_4 = 0x4 };
enum ScnObjBoundingVolumeType {
BOUNDINGVOLUME_AABB_LOCAL,
BOUNDINGVOLUME_AABB_WORLD,
BOUNDINGVOLUME_MAX
};
enum ScnObjBoundingVolumeType { BOUNDING_0, BOUNDING_1, BOUNDING_MAX };
#define OPT(KEY, VALUE) OPTION_##KEY = (0x00000 | (VALUE))
enum ScnObjOption {
OPT(NONE, 0),
OPT(DISABLE_GATHER_SCNOBJ, 1),
OPT(DISABLE_CALC_WORLD, 2),
OPT(DISABLE_CALC_MAT, 3),
OPT(DISABLE_CALC_VTX, 4),
OPT(DISABLE_CALC_VIEW, 5),
OPT(DISABLE_DRAW_OPA, 6),
OPT(DISABLE_DRAW_XLU, 7),
OPT(DISABLE_UPDATEFRAME, 8),
OPT(ENABLE_CULLING, 9),
};
#undef OPT
enum ScnObjOption { OPTION_VISIBLE = (1 << 0) };
enum Timing {
CALLBACK_TIMING_A = (1 << 0),
CALLBACK_TIMING_B = (1 << 1),
CALLBACK_TIMING_C = (1 << 2)
};
typedef ForEachResult (*ForEachAction)(ScnObj *, void *);
enum ExecOp {
EXECOP_CALC_WORLD = (1 << 0),
EXECOP_CALC_MAT = (1 << 1),
EXECOP_CALC_VIEW = (1 << 2),
EXECOP_DRAW_OPA = (1 << 4),
EXECOP_DRAW_XLU = (1 << 5)
};
public:
ScnObj(MEMAllocator *);
explicit ScnObj(MEMAllocator *pAllocator);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : G3dObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *) = 0; // at 0xC
virtual ~ScnObj(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual ForEachResult ForEach(ForEachAction, void *, bool) = 0; // at 0x1C
virtual bool SetScnObjOption(u32, u32); // at 0x20
virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24
virtual f32 GetValueForSortOpa() const; // at 0x28
virtual f32 GetValueForSortXlu() const; // at 0x2C
virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~ScnObj(); // at 0x10
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual ForEachResult ForEach(ForEachFunc pFunc, void *pInfo,
bool postOrder) = 0; // at 0x1C
virtual bool SetScnObjOption(u32 option, u32 value); // at 0x20
virtual bool GetScnObjOption(u32 option, u32 *pValue) const; // at 0x24
virtual f32 GetValueForSortOpa() const; // at 0x28
virtual f32 GetValueForSortXlu() const; // at 0x2C
virtual void CalcWorldMtx(const math::MTX34 *pParent,
u32 *pParam); // at 0x30
void CalcViewMtx(const math::MTX34 *pCamera);
bool SetMtx(ScnObjMtxType type, const math::MTX34 *pMtx);
bool GetMtx(ScnObjMtxType type, math::MTX34 *pMtx) const;
const math::MTX34 *GetMtxPtr(ScnObjMtxType type) const {
return &mMtxArray[type];
}
void SetPriorityDrawOpa(int prio);
int GetPriorityDrawOpa() const {
return mPriorityDrawOpa;
}
void SetPriorityDrawXlu(int prio);
int GetPriorityDrawXlu() const {
return mPriorityDrawXlu;
}
void EnableScnObjCallbackTiming(Timing timing);
void EnableScnObjCallbackExecOp(ExecOp op);
bool SetBoundingVolume(ScnObjBoundingVolumeType type, const math::AABB *pAABB);
bool GetBoundingVolume(ScnObjBoundingVolumeType type, math::AABB *pAABB) const;
bool SetBoundingVolume(const math::AABB *pAABB) {
return SetBoundingVolume(BOUNDINGVOLUME_AABB_LOCAL, pAABB);
}
void CalcViewMtx(const math::MTX34 *);
bool SetMtx(ScnObjMtxType, const math::MTX34 *);
bool GetMtx(ScnObjMtxType, math::MTX34 *) const;
void SetPriorityDrawOpa(int);
void SetPriorityDrawXlu(int);
void EnableScnObjCallbackTiming(Timing);
void EnableScnObjCallbackExecOp(ExecOp);
bool SetBoundingVolume(ScnObjBoundingVolumeType, const math::AABB *);
bool GetBoundingVolume(ScnObjBoundingVolumeType, math::AABB *) const;
void SetCallback(IScnObjCallback *cb) {
mCallback = cb;
mpFuncObjExec = cb;
}
IScnObjCallback *GetScnObjCallback() {
return mCallback;
}
const math::MTX34 *GetMtxPtr(ScnObjMtxType type) const {
return &mMatrices[type];
}
void SetScnObjFlag(ScnObjFlag f, u32 set) {
if (set) {
mFlags |= f;
} else {
mFlags &= ~f;
}
}
bool TestScnObjFlag(ScnObjFlag f) const {
return mFlags & f;
}
inline void CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6);
inline void CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6);
inline void CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6);
bool IsG3dProcDisabled(u32 task) const {
if ((task < 9) && (1 << (task - 1) & mFlags)) {
return true;
}
return false;
return mpFuncObjExec;
}
protected:
math::MTX34 mMatrices[MTX_TYPE_MAX]; // at 0xC
math::AABB mBounds[BOUNDING_MAX]; // at 0x9C
enum ScnObjFlag {
SCNOBJFLAG_DISABLE_CALC_WORLD = (1 << 0),
SCNOBJFLAG_DISABLE_CALC_MAT = (1 << 1),
SCNOBJFLAG_DISABLE_CALC_VTX = (1 << 2),
SCNOBJFLAG_DISABLE_CALC_VIEW = (1 << 3),
SCNOBJFLAG_DISABLE_GATHER_SCNOBJ = (1 << 4),
SCNOBJFLAG_DISABLE_DRAW_OPA = (1 << 5),
SCNOBJFLAG_DISABLE_DRAW_XLU = (1 << 6),
SCNOBJFLAG_DISABLE_UPDATEFRAME = (1 << 7),
SCNOBJFLAG_IGNORE_ANMCHR_TRANS = (1 << 8),
u32 mFlags; // at 0xCC
u8 mPriorityDrawOpa; // at 0xD0
u8 mPriorityDrawXlu; // at 0xD1
u8 BYTE_0xD2;
u8 BYTE_0xD3;
IScnObjCallback *mCallback; // at 0xD4
u8 mTiming; // at 0xD8
u8 BYTE_0xD9;
u16 mExecOp; // at 0xDA
SCNOBJFLAG_ENABLE_CULLING = (1 << 28),
SCNOBJFLAG_NOT_GATHER_DRAW_OPA = (1 << 29),
SCNOBJFLAG_NOT_GATHER_DRAW_XLU = (1 << 30),
SCNOBJFLAG_MTX_LOCAL_IDENTITY = (1 << 31),
NW4R_G3D_TYPE_OBJ_DECL(ScnObj);
SCNOBJFLAG_DISABLE_DRAW = SCNOBJFLAG_DISABLE_DRAW_OPA | SCNOBJFLAG_DISABLE_DRAW_XLU
};
protected:
void SetScnObjFlag(ScnObjFlag flag, u32 on) {
if (on) {
mScnObjFlags |= flag;
} else {
mScnObjFlags &= ~flag;
}
}
u32 TestScnObjFlag(ScnObjFlag flag) const {
return (mScnObjFlags & flag) != 0;
}
bool IsG3dProcDisabled(u32 task) const {
if (task < __G3DPROC_OPTIONAL_END && ((1 << task - 1) & mScnObjFlags)) {
return true;
}
return false;
}
/**
* Defined elsewhere to resolve circular dependency with IScnObjCallback
*/
inline void CheckCallback_CALC_VIEW(Timing timing, u32 param, void *pInfo);
inline void CheckCallback_CALC_MAT(Timing timing, u32 param, void *pInfo);
inline void CheckCallback_CALC_WORLD(Timing timing, u32 param, void *pInfo);
inline void CheckCallback_DRAW_OPA(Timing timing, u32 param, void *pInfo);
inline void CheckCallback_DRAW_XLU(Timing timing, u32 param, void *pInfo);
protected:
math::MTX34 mMtxArray[MTX_TYPE_MAX]; // at 0xC
math::AABB mAABB[BOUNDINGVOLUME_MAX]; // at 0x9C
private:
u32 mScnObjFlags; // at 0xCC
u8 mPriorityDrawOpa; // at 0xD0
u8 mPriorityDrawXlu; // at 0xD1
u8 PADDING_0xD2; // at 0xD2
u8 PADDING_0xD3; // at 0xD3
IScnObjCallback *mpFuncObjExec; // at 0xD4
u8 mCallbackTiming; // at 0xD8
u8 mCallbackDeleteOption; // at 0xD9
u16 mCallbackExecOpMask; // at 0xDA
NW4R_G3D_RTTI_DECL_DERIVED(ScnObj, G3dObj);
};
struct IScnObjCallback {
virtual ~IScnObjCallback() {} // at 0x8
virtual void ExecCallback_CALC_WORLD(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0xC
virtual void ExecCallback_CALC_MAT(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x10
virtual void ExecCallback_CALC_VIEW(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x14
virtual void ExecCallback_DRAW_OPA(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x18
virtual void ExecCallback_DRAW_XLU(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x1C
};
// Is there a better way of resolving this dependency?
void ScnObj::CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6) {
if (mCallback != NULL) {
if ((mExecOp & EXEC_OP_4) && (mTiming & timing)) {
mCallback->ExecCallback_CALC_VIEW(timing, this, r5, r6);
}
}
}
void ScnObj::CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6) {
if (mCallback != NULL) {
if ((mExecOp & EXEC_OP_2) && (mTiming & timing)) {
mCallback->ExecCallback_CALC_MAT(timing, this, r5, r6);
}
}
}
void ScnObj::CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6) {
if (mCallback != NULL) {
if ((mExecOp & EXEC_OP_1) && (mTiming & timing)) {
mCallback->ExecCallback_CALC_WORLD(timing, this, r5, r6);
}
}
}
class ScnLeaf : public ScnObj {
/******************************************************************************
*
* IScnObjGather
*
******************************************************************************/
class IScnObjGather {
public:
// Unofficial name, however GetScaleProperty needs to return an enum to match
enum ScaleProperty {
SCALE_PROPERTY_0,
SCALE_PROPERTY_1,
SCALE_PROPERTY_2,
typedef bool (*LessThanFunc)(const ScnObj *pLhs, const ScnObj *pRhs);
enum CullingStatus {
CULLINGSTATUS_INTERSECT,
CULLINGSTATUS_INSIDE,
CULLINGSTATUS_OUTSIDE,
CULLINGSTATUS_NOTEST
};
public:
ScnLeaf(MEMAllocator *allocator) : ScnObj(allocator), mScale(1.0f, 1.0f, 1.0f) {}
virtual ~IScnObjGather() {} // at 0x8
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : ScnObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *) = 0; // at 0xC
virtual ~ScnLeaf() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C
virtual bool SetScnObjOption(u32, u32); // at 0x20
virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24
virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30
virtual CullingStatus Add(ScnObj *pObj, bool opa, bool xlu) = 0; // at 0xC
virtual void Clear() = 0; // at 0x10
virtual void ZSort() = 0; // at 0x14
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual void Sort() = 0; // at 0x18
virtual void Sort(LessThanFunc pOpaFunc,
LessThanFunc pXluFunc) = 0; // at 0x1C
virtual void DrawOpa(ResMdlDrawMode *pForceMode) = 0; // at 0x20
virtual void DrawXlu(ResMdlDrawMode *pForceMode) = 0; // at 0x24
};
/******************************************************************************
*
* IScnObjCallback
*
******************************************************************************/
class IScnObjCallback {
public:
virtual ~IScnObjCallback() {} // at 0x8
virtual void
ExecCallback_CALC_WORLD(ScnObj::Timing /* timing */, ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */) {
} // at 0xC
virtual void
ExecCallback_CALC_MAT(ScnObj::Timing /* timing */, ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */) {
} // at 0x10
virtual void
ExecCallback_CALC_VIEW(ScnObj::Timing /* timing */, ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */) {
} // at 0x14
virtual void
ExecCallback_DRAW_OPA(ScnObj::Timing /* timing */, ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */) {
} // at 0x18
virtual void
ExecCallback_DRAW_XLU(ScnObj::Timing /* timing */, ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */) {
} // at 0x1C
};
/******************************************************************************
*
* ScnObj implementation
*
******************************************************************************/
void ScnObj::CheckCallback_CALC_VIEW(Timing timing, u32 param, void *pInfo) {
if (mpFuncObjExec != NULL && (mCallbackExecOpMask & EXECOP_CALC_VIEW) && (mCallbackTiming & timing)) {
mpFuncObjExec->ExecCallback_CALC_VIEW(timing, this, param, pInfo);
}
}
void ScnObj::CheckCallback_CALC_MAT(Timing timing, u32 param, void *pInfo) {
if (mpFuncObjExec != NULL && (mCallbackExecOpMask & EXECOP_CALC_MAT) && (mCallbackTiming & timing)) {
mpFuncObjExec->ExecCallback_CALC_MAT(timing, this, param, pInfo);
}
}
void ScnObj::CheckCallback_CALC_WORLD(Timing timing, u32 param, void *pInfo) {
if (mpFuncObjExec != NULL && (mCallbackExecOpMask & EXECOP_CALC_WORLD) && (mCallbackTiming & timing)) {
mpFuncObjExec->ExecCallback_CALC_WORLD(timing, this, param, pInfo);
}
}
void ScnObj::CheckCallback_DRAW_OPA(Timing timing, u32 param, void *pInfo) {
if (mpFuncObjExec != NULL && (mCallbackExecOpMask & EXECOP_DRAW_OPA) && (mCallbackTiming & timing)) {
mpFuncObjExec->ExecCallback_DRAW_OPA(timing, this, param, pInfo);
}
}
void ScnObj::CheckCallback_DRAW_XLU(Timing timing, u32 param, void *pInfo) {
if (mpFuncObjExec != NULL && (mCallbackExecOpMask & EXECOP_DRAW_XLU) && (mCallbackTiming & timing)) {
mpFuncObjExec->ExecCallback_DRAW_XLU(timing, this, param, pInfo);
}
}
/******************************************************************************
*
* ScnLeaf
*
******************************************************************************/
class ScnLeaf : public ScnObj {
public:
enum ScaleProperty {
NOT_SCALED,
UNIFORM_SCALED,
NONUNIFORM_SCALED,
};
#define OPT(KEY, VALUE) OPTION_##KEY = (0x10000 | (VALUE))
enum ScnLeafOption {
OPT(NONE, 0),
OPT(DISABLE_DRAW_ALL, 1),
};
#undef OPT
public:
explicit ScnLeaf(MEMAllocator *pAllocator) : ScnObj(pAllocator), mScale(1.0f, 1.0f, 1.0f) {}
virtual void G3dProc(u32 task, u32 param, void *pInfo) = 0; // at 0xC
virtual ~ScnLeaf() {} // at 0x10
virtual ForEachResult ForEach(ForEachFunc pFunc, void *pInfo,
bool postOrder); // at 0x1C
virtual bool SetScnObjOption(u32 option, u32 value); // at 0x20
virtual bool GetScnObjOption(u32 option, u32 *pValue) const; // at 0x24
virtual void CalcWorldMtx(const math::MTX34 *pParent,
u32 *pParam); // at 0x30
ScaleProperty GetScaleProperty() const;
void DefG3dProcScnLeaf(u32, u32, void *);
inline void SetScale(f32 x, f32 y, f32 z) {
mScale.x = x;
@@ -227,51 +358,55 @@ public:
}
}
private:
math::VEC3 mScale;
protected:
void DefG3dProcScnLeaf(u32 task, u32 param, void *pInfo);
NW4R_G3D_TYPE_OBJ_DECL(ScnLeaf);
private:
math::VEC3 mScale; // at 0xDC
NW4R_G3D_RTTI_DECL_DERIVED(ScnLeaf, ScnObj);
};
/******************************************************************************
*
* ScnGroup
*
******************************************************************************/
class ScnGroup : public ScnObj {
public:
ScnGroup(MEMAllocator *, ScnObj **, u32);
ScnGroup(MEMAllocator *pAllocator, ScnObj **ppObj, u32 capacity);
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic()) ? true : ScnObj::IsDerivedFrom(other);
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~ScnGroup(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C
virtual bool Insert(u32, ScnObj *); // at 0x34
virtual ScnObj *Remove(u32); // at 0x38
virtual bool Remove(ScnObj *); // at 0x3C
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~ScnGroup(); // at 0x10
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
virtual ForEachResult ForEach(ForEachFunc pFunc, void *pInfo,
bool postOrder); // at 0x1C
virtual bool Insert(u32 idx, ScnObj *pObj); // at 0x34
virtual ScnObj *Remove(u32 idx); // at 0x38
virtual bool Remove(ScnObj *pObj); // at 0x3C
ScnObj **Begin() {
return mpScnObjArray;
}
ScnObj **End() {
return mpScnObjArray + mNumScnObj;
}
bool PushBack(ScnObj *obj) {
return Insert(Size(), obj);
}
bool Empty() const {
return mSize == 0;
ScnObj *operator[](u32 idx) {
return mpScnObjArray[idx];
}
u32 Size() const {
return mSize;
return mNumScnObj;
}
bool Empty() const {
return mNumScnObj == 0;
}
bool PushBack(ScnObj *pObj) {
return Insert(mNumScnObj, pObj);
}
ScnObj *PopBack() {
if (!Empty()) {
return Remove(Size() - 1);
@@ -286,19 +421,23 @@ public:
}
}
void ScnGroup_G3DPROC_GATHER_SCNOBJ(u32, IScnObjGather *);
void ScnGroup_G3DPROC_CALC_WORLD(u32, const math::MTX34 *);
void ScnGroup_G3DPROC_CALC_MAT(u32, void *);
void ScnGroup_G3DPROC_CALC_VIEW(u32, const math::MTX34 *);
void DefG3dProcScnGroup(u32, u32, void *);
ScnObj **mObjects; // at 0xDC
u32 mCapacity; // at 0xE0
u32 mSize; // at 0xE4
protected:
void DefG3dProcScnGroup(u32 task, u32 param, void *pInfo);
private:
NW4R_G3D_TYPE_OBJ_DECL(ScnGroup);
void ScnGroup_G3DPROC_GATHER_SCNOBJ(u32 param, IScnObjGather *pCollection);
void ScnGroup_G3DPROC_CALC_WORLD(u32 param, const math::MTX34 *pParent);
void ScnGroup_G3DPROC_CALC_MAT(u32 param, void *pInfo);
void ScnGroup_G3DPROC_CALC_VIEW(u32 param, const math::MTX34 *pCamera);
private:
ScnObj **mpScnObjArray; // at 0xDC
u32 mSizeScnObj; // at 0xE0
u32 mNumScnObj; // at 0xE4
NW4R_G3D_RTTI_DECL_DERIVED(ScnGroup, ScnObj);
};
} // namespace g3d
} // namespace nw4r
+47 -52
View File
@@ -1,75 +1,70 @@
#ifndef NW4R_G3D_SCNPROC_H
#define NW4R_G3D_SCNPROC_H
#include "common.h"
#include "nw4r/g3d/g3d_scnobj.h"
#ifndef NW4R_G3D_SCN_PROC_H
#define NW4R_G3D_SCN_PROC_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
namespace nw4r {
namespace g3d {
class ScnProc : public ScnLeaf {
public:
typedef void (*DrawProc)(ScnProc *, bool opa);
typedef void (*DrawProc)(ScnProc *pProc, bool opa);
ScnProc(MEMAllocator *allocator, DrawProc proc, void *userdata, bool set1, bool set2)
: ScnLeaf(allocator), mFlags(0), mDrawProc(proc), mUserData(userdata) {
if (set1) {
mFlags |= 0x1;
public:
static ScnProc *Construct(MEMAllocator *pAllocator, u32 *pSize, DrawProc pProc, bool opa, bool xlu, u32 userData);
ScnProc(MEMAllocator *pAllocator, DrawProc pProc, void *pUserData, bool opa, bool xlu)
: ScnLeaf(pAllocator), mFlag(0), mpDrawProc(pProc), mpUserData(pUserData) {
if (opa) {
mFlag |= SCNPROCFLAG_DRAW_OPA;
}
if (set2) {
mFlags |= 0x2;
if (xlu) {
mFlag |= SCNPROCFLAG_DRAW_XLU;
}
}
static ScnProc *Construct(MEMAllocator *, u32 *, DrawProc, bool, bool, u32);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~ScnProc() {} // at 0x10
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return other == GetTypeObjStatic() ? true : ScnLeaf::IsDerivedFrom(other);
};
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~ScnProc() {} // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
void SetDrawProc(DrawProc pProc, bool opa, bool xlu) {
mpDrawProc = pProc;
if (opa) {
mFlag |= SCNPROCFLAG_DRAW_OPA;
} else {
mFlag &= ~SCNPROCFLAG_DRAW_OPA;
}
if (xlu) {
mFlag |= SCNPROCFLAG_DRAW_XLU;
} else {
mFlag &= ~SCNPROCFLAG_DRAW_XLU;
}
}
static const G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
void SetUserData(void *pData) {
mpUserData = pData;
}
void *GetUserData() {
return mUserData;
}
void SetUserData(void *data) {
mUserData = data;
}
void SetDrawProc(DrawProc proc, bool r5, bool r6) {
mDrawProc = proc;
if (r5) {
mFlags |= 0x1;
} else {
mFlags &= ~0x1;
}
if (r6) {
mFlags |= 0x2;
} else {
mFlags &= ~0x2;
}
return mpUserData;
}
private:
u32 mFlags; // at 0xE8
DrawProc mDrawProc; // at 0xEC
void *mUserData; // at 0xF0
enum ScnProcFlag {
SCNPROCFLAG_DRAW_OPA = (1 << 0),
SCNPROCFLAG_DRAW_XLU = (1 << 1)
};
NW4R_G3D_TYPE_OBJ_DECL(ScnProc);
private:
u32 mFlag; // at 0xE8
DrawProc mpDrawProc; // at 0xEC
void *mpUserData; // at 0xF0
NW4R_G3D_RTTI_DECL_DERIVED(ScnProc, ScnLeaf);
};
} // namespace g3d
} // namespace nw4r
+43 -44
View File
@@ -1,52 +1,51 @@
#ifndef NW4R_G3D_SCNRFL_H
#define NW4R_G3D_SCNRFL_H
#include "RFL/RFL_MiddleDatabase.h"
#include "RFL/RFL_Model.h"
#include "common.h"
#include "nw4r/g3d/g3d_scnobj.h"
// #ifndef NW4R_G3D_SCNRFL_H
// #define NW4R_G3D_SCNRFL_H
// #include "RFL/RFL_MiddleDatabase.h"
// #include "RFL/RFL_Model.h"
// #include "common.h"
// #include "nw4r/g3d/g3d_scnobj.h"
// namespace nw4r {
// namespace g3d {
// class ScnRfl : public ScnLeaf {
// public:
// struct RflData {
// bool SetupCharModel(RFLDataSource, u16, RFLMiddleDB *);
// };
namespace nw4r {
namespace g3d {
class ScnRfl : public ScnLeaf {
public:
struct RflData {
bool SetupCharModel(RFLDataSource, u16, RFLMiddleDB *);
};
// public:
// static ScnRfl *Construct(MEMAllocator *, u32 *, RFLResolution, u32, u32);
// ScnRfl(MEMAllocator *, ScnRfl *, RflData *, void *, u32);
public:
static ScnRfl *Construct(MEMAllocator *, u32 *, RFLResolution, u32, u32);
ScnRfl(MEMAllocator *, ScnRfl *, RflData *, void *, u32);
// virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
// {
// return (other == GetTypeObjStatic());
// }
// virtual void G3dProc(u32, u32, void *); // at 0xC
// virtual ~ScnRfl(); // at 0x10
// virtual const TypeObj GetTypeObj() const // at 0x14
// {
// return TypeObj(TYPE_NAME);
// }
// virtual const char *GetTypeName() const // at 0x18
// {
// return GetTypeObj().GetTypeName();
// }
virtual bool IsDerivedFrom(TypeObj other) const // at 0x8
{
return (other == GetTypeObjStatic());
}
virtual void G3dProc(u32, u32, void *); // at 0xC
virtual ~ScnRfl(); // at 0x10
virtual const TypeObj GetTypeObj() const // at 0x14
{
return TypeObj(TYPE_NAME);
}
virtual const char *GetTypeName() const // at 0x18
{
return GetTypeObj().GetTypeName();
}
// bool GetExpression(RFLExpression *);
// bool SetExpression(RFLExpression);
bool GetExpression(RFLExpression *);
bool SetExpression(RFLExpression);
// void SetFogIdx(int);
// void SetLightSetIdx(int);
void SetFogIdx(int);
void SetLightSetIdx(int);
// static const nw4r::g3d::G3dObj::TypeObj GetTypeObjStatic() {
// return TypeObj(TYPE_NAME);
// }
static const nw4r::g3d::G3dObj::TypeObj GetTypeObjStatic() {
return TypeObj(TYPE_NAME);
}
// private:
// NW4R_G3D_TYPE_OBJ_DECL(ScnRfl);
// };
// } // namespace g3d
// } // namespace nw4r
private:
NW4R_G3D_TYPE_OBJ_DECL(ScnRfl);
};
} // namespace g3d
} // namespace nw4r
#endif
// #endif
+109 -23
View File
@@ -1,49 +1,135 @@
#ifndef NW4R_G3D_SCNROOT_H
#define NW4R_G3D_SCNROOT_H
#include "common.h"
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/g3d_light.h"
#include "nw4r/g3d/g3d_scnobj.h"
#ifndef NW4R_G3D_SCN_ROOT_H
#define NW4R_G3D_SCN_ROOT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/g3d_state.h>
namespace nw4r {
namespace g3d {
// Forward declarations
class AnmScn;
/******************************************************************************
*
* ScnRoot
*
******************************************************************************/
class ScnRoot : public ScnGroup {
public:
Camera GetCamera(int);
Camera GetCurrentCamera();
void SetCurrentCamera(int);
Fog GetFog(int);
enum ScnRootFlag {
SCNROOTFLAG_FORCE_RESMDLDRAWMODE = (1 << 0)
};
static ScnRoot *Construct(MEMAllocator *pHeap, u32 *pSize, u32 maxNumChildren, u32 maxNumScnObj, u32 numLightObj,
u32 numLightSet);
public:
static ScnRoot *
Construct(MEMAllocator *pAllocator, u32 *pSize, u32 maxChildren, u32 maxScnObj, u32 numLightObj, u32 numLightSet);
static ScnRoot *Construct(MEMAllocator *pAllocator, u32 *pSize, u32 maxChildren, u32 maxScnObj) {
return Construct(pAllocator, pSize, maxChildren, maxScnObj, G3DState::NUM_LIGHT, G3DState::NUM_LIGHT_SET);
}
ScnRoot(
MEMAllocator *pAllocator, IScnObjGather *pGather, ScnObj **ppChildrenBuf, u32 maxChildren, u32 numLight,
u32 numLightSet, LightObj *pLightObjBuf, AmbLightObj *pAmbObjBuf, LightSetData *pLightSetBuf
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
virtual ~ScnRoot(); // at 0x10
Camera GetCamera(int idx);
Camera GetCurrentCamera();
void SetCurrentCamera(int idx);
Fog GetFog(int idx);
LightSet GetLightSet(int idx);
void UpdateFrame();
void SetGlbSettings();
void CalcAnmScn();
void CalcWorld();
void CalcMaterial();
void CalcVtx();
void CalcView();
void GatherDrawScnObj();
void ZSort();
void DrawOpa();
void DrawXlu();
u8 GetCurrentCameraID() const {
return mCameraId;
u32 TestScnRootFlag(ScnRootFlag flag) const {
return (mScnRootFlags & flag) != 0;
}
void SetScnRootFlag(ScnRootFlag flag, u32 on) {
if (on) {
mScnRootFlags |= flag;
} else {
mScnRootFlags &= ~flag;
}
}
inline LightSetting *getLightSetting() {
return &mLightSetting;
int GetCurrentCameraID() const {
return mCurrentCameraID;
}
LightSetting &GetLightSetting() {
return mLightSetting;
}
private:
UNKWORD WORD_0xE8;
UNKWORD WORD_0xEC;
UNKWORD WORD_0xF0;
/* 0x00F4 */ u8 mCameraId;
u8 unk1[0x2878 - 0x00F8];
/* 0x2878 */ LightSetting mLightSetting;
IScnObjGather *mpCollection; // at 0xE8
ResMdlDrawMode mDrawMode; // at 0xEC
u32 mScnRootFlags; // at 0xF0
u8 mCurrentCameraID; // at 0xF4
u8 PADDING_0xF5; // at 0xF5
u8 PADDING_0xF6; // at 0xF6
u8 PADDING_0xF7; // at 0xF7
CameraData mCamera[G3DState::NUM_CAMERA]; // at 0xF8
FogData mFog[G3DState::NUM_FOG]; // at 0x2278
LightSetting mLightSetting; // at 0x2878
AnmScn *mpAnmScn; // at 0x2888
NW4R_G3D_RTTI_DECL_DERIVED(ScnRoot, ScnGroup);
};
/******************************************************************************
*
* ScnObjGather
*
******************************************************************************/
class ScnObjGather : public IScnObjGather {
public:
ScnObjGather(ScnObj **ppBufOpa, ScnObj **ppBufXlu, u32 capacity);
virtual ~ScnObjGather() {} // at 0x8
virtual CullingStatus Add(ScnObj *pObj, bool opa, bool xlu); // at 0xC
virtual void Clear() {
mNumScnObjOpa = mNumScnObjXlu = 0;
} // at 0x10
virtual void ZSort(); // at 0x14
virtual void Sort(); // at 0x18
virtual void Sort(LessThanFunc pOpaFunc,
LessThanFunc pXluFunc); // at 0x1C
virtual void DrawOpa(ResMdlDrawMode *pForceMode); // at 0x20
virtual void DrawXlu(ResMdlDrawMode *pForceMode); // at 0x24
protected:
ScnObj **mpArrayOpa; // at 0x4
ScnObj **mpArrayXlu; // at 0x8
u32 mSizeScnObj; // at 0xC
u32 mNumScnObjOpa; // at 0x10
u32 mNumScnObjXlu; // at 0x14
};
} // namespace g3d
} // namespace nw4r
+184 -11
View File
@@ -1,24 +1,197 @@
#ifndef NW4R_G3D_STATE_H
#define NW4R_G3D_STATE_H
#include "common.h"
#include "nw4r/math.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/math.h>
#include <rvl/GX.h>
namespace nw4r {
namespace g3d {
namespace detail {
/******************************************************************************
*
* ScnDependentMtxFunc
*
******************************************************************************/
namespace ScnDependentMtxFunc {
void EnvironmentMapping(math::MTX34 *pMtx, s8 camRef, s8 lightRef);
void ProjectionMapping(math::MTX34 *pMtx, s8 camRef, s8 lightRef);
void EnvironmentSpecularMapping(math::MTX34 *pMtx, s8 camRef, s8 lightRef);
void DefaultMapping(math::MTX34 *pMtx, s8 camRef, s8 lightRef);
} // namespace ScnDependentMtxFunc
} // namespace detail
/******************************************************************************
*
* G3DState
*
******************************************************************************/
namespace G3DState {
struct IndMtxOp {};
void SetViewPosNrmMtxArray(const math::MTX34 *, const math::MTX33 *, const math::MTX34 *);
static const int NUM_LIGHT = 128;
static const int NUM_LIGHT_SET = 128;
void SetRenderModeObj(const GXRenderModeObj &);
GXRenderModeObj &GetRenderModeObj();
void LoadLightSet(
int idx_lightset, u32 *mask_diff_color /* r1+0xC */, u32 *mask_diff_alpha, u32 *mask_spec_color,
u32 *mask_spec_alpha, AmbLightObj *amb
static const int NUM_LIGHT_IN_LIGHT_SET = 8;
static const int NUM_CAMERA = 32;
static const int NUM_FOG = 32;
static const int NUM_SCNDEPENDENT_TEXMTX_FUNCTYPE = 256;
enum InvalidateFlag {
INVALIDATE_TEX = (1 << 0),
INVALIDATE_TLUT = (1 << 1),
INVALIDATE_TEV = (1 << 2),
INVALIDATE_GENMODE = (1 << 3),
INVALIDATE_SHP = (1 << 4),
INVALIDATE_CURRMTX = (1 << 5),
INVALIDATE_TEXMTX = (1 << 6),
INVALIDATE_MISC = (1 << 7),
INVALIDATE_FOG = (1 << 8),
INVALIDATE_LIGHT = (1 << 9),
INVALIDATE_POSMTX = (1 << 10),
INVALIDATE_ALL = INVALIDATE_TEX | INVALIDATE_TLUT | INVALIDATE_TEV | INVALIDATE_GENMODE | INVALIDATE_SHP |
INVALIDATE_CURRMTX | INVALIDATE_TEXMTX | INVALIDATE_MISC | INVALIDATE_FOG | INVALIDATE_LIGHT |
INVALIDATE_POSMTX
};
enum ScnDependentTexMtxFuncType {
SCNDEPENDENT_TEXMTX_FUNCTYPE_SRC_TEXCOORD,
SCNDEPENDENT_TEXMTX_FUNCTYPE_SRC_NRM,
SCNDEPENDENT_TEXMTX_FUNCTYPE_SRC_POS,
SCNDEPENDENT_TEXMTX_FUNCTYPE_SRC_COLOR,
MAX_SCNDEPENDENT_TEXMTX_FUNCTYPE,
SCNDEPENDENT_TEXMTX_FUNCTYPE_TEXMTX_NOT_EXIST = SCNDEPENDENT_TEXMTX_FUNCTYPE_SRC_TEXCOORD,
};
typedef void (*ScnDependentTexMtxFuncPtr)(math::MTX34 *pMtx, s8 camRef, s8 lightRef);
/******************************************************************************
*
* IndTexMtxInfo
*
******************************************************************************/
struct IndTexMtxInfo {
u32 flag; // at 0x0
math::MTX34 offset_mtx[GX_ITM_2 - GX_ITM_0 + 1]; // at 0x4
IndTexMtxInfo() : flag(0) {}
explicit IndTexMtxInfo(const ResMatIndMtxAndScale ind);
void FifoSend() const;
void SetMtx(GXIndTexMtxID id, const math::MTX34 &rMtx);
};
/******************************************************************************
*
* IndMtxOp
*
******************************************************************************/
class IndMtxOp {
public:
virtual void operator()(IndTexMtxInfo *pInfo) = 0; // at 0x8
virtual ~IndMtxOp() {} // at 0xC
virtual void Reset() = 0; // at 0x10
virtual void SetNrmMapMtx(
GXIndTexMtxID id, const math::VEC3 *pLightVec, const math::MTX34 *pNrmMtx,
ResMatMiscData::IndirectMethod method
) = 0; // at 0x14
};
/******************************************************************************
*
* IndMtxOpStd
*
******************************************************************************/
class IndMtxOpStd : public IndMtxOp {
public:
IndMtxOpStd();
virtual void operator()(IndTexMtxInfo *pInfo); // at 0x8
virtual ~IndMtxOpStd() {} // at 0xC
virtual void Reset(); // at 0x10
virtual void SetNrmMapMtx(
GXIndTexMtxID id, const math::VEC3 *pLightVec, const math::MTX34 *pNrmMtx,
ResMatMiscData::IndirectMethod method
); // at 0x14
private:
bool mIsValidMtx[GX_ITM_2 - GX_ITM_0 + 1]; // at 0x4
u8 PADDING_0x7; // at 0x7
math::MTX34 mIndMtx[GX_ITM_2 - GX_ITM_0 + 1]; // at 0x8
};
/******************************************************************************
*
* Functions
*
******************************************************************************/
void LoadResMatMisc(const ResMatMisc misc);
void LoadResTexObj(const ResTexObj texObj);
void LoadResTlutObj(const ResTlutObj tlutObj);
void LoadResGenMode(const ResGenMode mode);
void LoadResTev(const ResTev tev);
void LoadResMatPix(const ResMatPix pix);
void LoadResMatTevColor(const ResMatTevColor color);
void LoadResMatIndMtxAndScale(const ResMatIndMtxAndScale ind);
void LoadResMatIndMtxAndScale(const ResMatIndMtxAndScale ind, IndMtxOp &rOp);
void LoadResMatChan(
const ResMatChan chan, u32 maskDiffColor, u32 maskDiffAlpha, u32 maskSpecColor, u32 maskSpecAlpha, GXColor amb,
bool lightOff
);
void LoadResMatTexCoordGen(const ResMatTexCoordGen gen);
void LoadResTexSrt(const ResTexSrt srt);
void LoadResShpPrePrimitive(const ResShp shp);
void LoadResShpPrimitive(const ResShp shp, const math::MTX34 *pViewPos, const math::MTX34 *pViewNrm);
void SetViewPosNrmMtxArray(
const math::MTX34 *pViewPosMtxArray, const math::MTX33 *pViewNrmMtxArray, const math::MTX34 *pViewEnvTexMtxArray
);
const math::MTX33 *GetViewNrmMtxPtr(u32 id);
void SetScnDependentTexMtxFunc(u32 id, ScnDependentTexMtxFuncPtr func, ScnDependentTexMtxFuncType type);
bool GetScnDependentTexMtxFunc(u32 id, ScnDependentTexMtxFuncPtr *pFunc, ScnDependentTexMtxFuncType *pType);
IndMtxOp *GetIndMtxOp();
void SetFog(const Fog fog, int id);
void LoadFog(int id);
void SetLightSetting(const LightSetting &rSetting);
const LightObj *GetLightObj(int id);
void LoadLightSet(
int id, u32 *pDiffColorMask, u32 *pDiffAlphaMask, u32 *pSpecColorMask, u32 *pSpecAlphaMask, AmbLightObj *pAmb
);
void LoadLightSet(int id, u32 *pDiffMask, u32 *pSpecMask, AmbLightObj *pAmb);
void SetCameraProjMtx(const Camera &rCam, int id, bool view);
const math::MTX34 *GetCameraMtxPtr();
const math::MTX34 *GetInvCameraMtxPtr();
const math::MTX34 *GetCameraMtxPtr(int id);
const math::MTX34 *GetProjectionTexMtxPtr();
const math::MTX34 *GetProjectionTexMtxPtr(int id);
const math::MTX34 *GetEnvironmentTexMtxPtr();
void SetRenderModeObj(const GXRenderModeObj &rObj);
const GXRenderModeObj *GetRenderModeObj();
void Invalidate(u32 flag = INVALIDATE_ALL);
void Invalidate(u32);
} // namespace G3DState
} // namespace g3d
} // namespace nw4r
-15
View File
@@ -1,15 +0,0 @@
#ifndef NW4R_G3D_TMEM_H
#define NW4R_G3D_TMEM_H
#include "common.h"
namespace nw4r {
namespace g3d {
namespace tmem {
enum TMemLayout { TMEM_LAYOUT_0, TMEM_LAYOUT_1 };
void SetTMemLayout(TMemLayout);
} // namespace tmem
} // namespace g3d
} // namespace nw4r
#endif
+58 -10
View File
@@ -1,19 +1,67 @@
#ifndef NW4R_G3D_WORKMEM_H
#define NW4R_G3D_WORKMEM_H
#include "common.h"
#ifndef NW4R_G3D_WORK_MEM_H
#define NW4R_G3D_WORK_MEM_H
#include <nw4r/types_nw4r.h>
#define G3D_WORKMEM_SIZE 0x18000
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include <nw4r/math.h>
namespace nw4r {
namespace g3d {
namespace detail {
namespace workmem {
void *GetScaleTemporary();
void *GetMtxIDTemporary();
void *GetMdlZTemporary();
void *GetSkinningMtxTemporary();
void *GetBillboardMtxTemporary();
void *GetShpAnmResultBufTemporary();
/******************************************************************************
*
* MdlZ
*
******************************************************************************/
struct MdlZ {
f32 Z; // at 0x0
u16 priority; // at 0x4
u16 nodeID; // at 0x6
u16 matID; // at 0x8
u16 shpID; // at 0xA
};
/******************************************************************************
*
* ShpAnmResultBuf
*
******************************************************************************/
struct ShpAnmResultBuf {
ShpAnmResult resultBuf; // at 0x0
const ShpAnmResult *pResult; // at 0x218
f32 weight; // at 0x21C
};
/******************************************************************************
*
* Work memory size constants
*
******************************************************************************/
static const int WORKMEM_SIZE = 0x18000;
static const int WORKMEM_NUMTMPSCALE = 2048;
static const int WORKMEM_NUMMTXID = 2048;
static const int WORKMEM_NUMBYTECODE = WORKMEM_SIZE;
static const int WORKMEM_NUMMDLZ = 2048;
static const int WORKMEM_NUMSKINNINGMTX = 2048;
static const int WORKMEM_NUMBBMTX = 2048;
static const int WORKMEM_NUMSHPANMRESULT = WORKMEM_SIZE / sizeof(ShpAnmResultBuf);
/******************************************************************************
*
* Work memory accessor functions
*
******************************************************************************/
math::VEC3 *GetScaleTemporary();
u32 *GetMtxIDTemporary();
MdlZ *GetMdlZTemporary();
math::MTX34 *GetSkinningMtxTemporary();
math::MTX34 *GetBillboardMtxTemporary();
ShpAnmResultBuf *GetShpAnmResultBufTemporary();
} // namespace workmem
} // namespace detail
} // namespace g3d
+12 -5
View File
@@ -1,15 +1,22 @@
#ifndef NW4R_G3D_XSI_H
#define NW4R_G3D_XSI_H
#include "common.h"
#include "nw4r/math.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
namespace nw4r {
namespace g3d {
namespace detail {
namespace dcc {
bool CalcTexMtx_Xsi(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag);
}
bool CalcTexMtx_Xsi(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag);
u32 CalcWorldMtx_Xsi(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const g3d::ChrAnmResult *pResult
);
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
+22
View File
@@ -0,0 +1,22 @@
#ifndef NW4R_G3D_PLATFORM_ALLOCATOR_H
#define NW4R_G3D_PLATFORM_ALLOCATOR_H
#include <nw4r/types_nw4r.h>
#include <rvl/MEM.h>
namespace nw4r {
namespace g3d {
namespace detail {
inline void *AllocFromAllocator(MEMAllocator *pAllocator, u32 size) {
return MEMAllocFromAllocator(pAllocator, size);
}
inline void FreeToAllocator(MEMAllocator *pAllocator, void *pBlock) {
return MEMFreeToAllocator(pAllocator, pBlock);
}
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
+169
View File
@@ -0,0 +1,169 @@
#ifndef NW4R_G3D_PLATFORM_CPU_H
#define NW4R_G3D_PLATFORM_CPU_H
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
namespace nw4r {
namespace g3d {
/******************************************************************************
*
* Fastcast
*
******************************************************************************/
namespace fastcast {
/******************************************************************************
*
* Convert from U8
*
******************************************************************************/
inline f32 U8_0ToF32(const u8 *pPtr) {
f32 x;
OSu8tof32(const_cast<u8 *>(pPtr), &x);
return x;
}
/******************************************************************************
*
* Convert from U16
*
******************************************************************************/
inline f32 U16_0ToF32(const u16 *pPtr) {
f32 x;
OSu16tof32(const_cast<u16 *>(pPtr), &x);
return x;
}
/******************************************************************************
*
* Convert from S16
*
******************************************************************************/
inline f32 S7_8ToF32(register const s16 *pPtr) {
register f32 f;
// clang-format off
asm {
psq_l f, 0(pPtr), 1, 7
}
// clang-format on
return f;
}
inline f32 S10_5ToF32(register const s16 *pPtr) {
register f32 f;
// clang-format off
asm {
psq_l f, 0(pPtr), 1, 6
}
// clang-format on
return f;
}
/******************************************************************************
*
* Convert from F32
*
******************************************************************************/
inline u8 F32ToU8_0(f32 f) {
u8 x;
OSf32tou8(&f, &x);
return x;
}
inline s16 F32ToS10_5(register f32 f) {
s16 x;
register s16 *pPtr = &x;
// clang-format off
asm {
psq_st f, 0(pPtr), 1, 6
}
// clang-format on
return x;
}
/******************************************************************************
*
* GQR
*
******************************************************************************/
inline void SetGQR6_S10_5() {
OSSetGQR6(OS_GQR_TYPE_S16, 5);
}
inline void SetGQR7_S7_8() {
OSSetGQR7(OS_GQR_TYPE_S16, 8);
}
/******************************************************************************
*
* Initialization
*
******************************************************************************/
namespace detail {
inline void Init() {
OSInitFastCast();
SetGQR6_S10_5();
SetGQR7_S7_8();
}
} // namespace detail
} // namespace fastcast
/******************************************************************************
*
* Cache
*
******************************************************************************/
namespace DC {
inline void StoreRange(void *pBase, u32 size) {
DCStoreRange(pBase, size);
}
inline void StoreRangeNoSync(void *pBase, u32 size) {
DCStoreRangeNoSync(pBase, size);
}
inline void FlushRangeNoSync(void *pBase, u32 size) {
DCFlushRangeNoSync(pBase, size);
}
inline void InvalidateRange(void *pBase, u32 size) {
DCInvalidateRange(pBase, size);
}
} // namespace DC
/******************************************************************************
*
* Memory
*
******************************************************************************/
namespace detail {
void Copy32ByteBlocks(void *pDst, const void *pSrc, u32 size);
void ZeroMemory32ByteBlocks(void *pDst, u32 size);
} // namespace detail
/******************************************************************************
*
* Initialize fastcast
*
******************************************************************************/
inline void InitFastCast() {
fastcast::detail::Init();
}
} // namespace g3d
} // namespace nw4r
#endif
+109
View File
@@ -0,0 +1,109 @@
#ifndef NW4R_G3D_PLATFORM_GPU_H
#define NW4R_G3D_PLATFORM_GPU_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/math.h>
#include <rvl/GX.h>
namespace nw4r {
namespace g3d {
namespace fifo {
// Swap bits to get hardware representation
static const u8 cm2hw[] = {0b0000, 0b0010, 0b0001, 0b0011};
inline void LoadBPCmd(u32 reg) {
GXCmd1u8(GX_FIFO_CMD_LOAD_BP_REG);
GXCmd1u32(reg);
}
inline void LoadCPCmd(u8 addr, u32 value) {
GXCmd1u8(GX_FIFO_CMD_LOAD_CP_REG);
GXCmd1u8(addr);
GXCmd1u32(value);
}
inline void LoadXFCmd(u16 addr, u32 value) {
GXCmd1u8(GX_FIFO_CMD_LOAD_XF_REG);
GXCmd1u16(0); // No size (single write)
GXCmd1u16(addr);
GXCmd1u32(value);
}
inline void LoadXFCmdHdr(u16 addr, u8 len) {
GXCmd1u8(GX_FIFO_CMD_LOAD_XF_REG);
GXCmd1u16(len - 1);
GXCmd1u16(addr);
}
void GDSetGenMode2(u8 numTexGens, u8 numChans, u8 numTevs, u8 numInds, GXCullMode cullMode);
inline void GDSetGenMode2Ex_BP(u8 numTexGens, u8 numChans, u8 numTevs, u8 numInds, GXCullMode cullMode) {
// clang-format off
// @note NUMCOLORS is actually three bits
LoadBPCmd(GX_BP_REG_SSMASK << GX_BP_OPCODE_SHIFT |
GX_BP_GENMODE_NUMTEX_MASK |
0b11 << GX_BP_GENMODE_NUMCOLORS_SHIFT |
GX_BP_GENMODE_NUMTEVSTAGES_MASK |
GX_BP_GENMODE_CULLMODE_MASK |
GX_BP_GENMODE_NUMINDSTAGES_MASK);
// clang-format on
// clang-format off
LoadBPCmd(
numTexGens << GX_BP_GENMODE_NUMTEX_SHIFT |
numChans << GX_BP_GENMODE_NUMCOLORS_SHIFT |
numTevs - 1 << GX_BP_GENMODE_NUMTEVSTAGES_SHIFT |
cm2hw[cullMode] << GX_BP_GENMODE_CULLMODE_SHIFT |
numInds << GX_BP_GENMODE_NUMINDSTAGES_SHIFT |
GX_BP_REG_GENMODE << GX_BP_OPCODE_SHIFT);
// clang-format on
}
void GDSetCullMode(GXCullMode cullMode);
void GDSetTexCoordScale2(
GXTexCoordID coord, u16 scaleS, GXBool biasS, GXBool wrapS, u16 scaleT, GXBool biasT, GXBool wrapT
);
void GDSetIndTexMtx(u32 id, const math::MTX34 &rMtx);
void GDResetCurrentMtx();
void GDSetCurrentMtx(const u32 *pIdArray);
void GDLoadTexMtxImm3x3(const math::MTX33 &rMtx, u32 id);
inline void GDSetChanCtrl(GXChannelID chan, u32 param, u32 lightMask) {
param &= ~(GX_XF_COLOR0CNTRL_LMASKLO_MASK | GX_XF_COLOR0CNTRL_LMASKHI_MASK);
param |= (lightMask & 0b1111) << GX_XF_COLOR0CNTRL_LMASKLO_SHIFT | ((lightMask >> 4) & 0b1111)
<< GX_XF_COLOR0CNTRL_LMASKHI_SHIFT;
LoadXFCmd(GX_XF_REG_COLOR0CNTRL + (chan & 3), param);
}
inline void GDSetChanCtrlLightOff(GXChannelID chan, u32 param, u32 lightMask) {
param &= ~(GX_XF_COLOR0CNTRL_LMASKLO_MASK | GX_XF_COLOR0CNTRL_LMASKHI_MASK | GX_XF_COLOR0CNTRL_LIGHT_MASK);
param |= (lightMask & 0b1111) << GX_XF_COLOR0CNTRL_LMASKLO_SHIFT | ((lightMask >> 4) & 0b1111)
<< GX_XF_COLOR0CNTRL_LMASKHI_SHIFT;
LoadXFCmd(GX_XF_REG_COLOR0CNTRL + (chan & 3), param);
}
inline void GDSetChanAmbColor(GXChannelID chan, GXColor color) {
LoadXFCmd(GX_XF_REG_AMBIENT0 + chan, *reinterpret_cast<u32 *>(&color));
}
inline void GDSetChanMatColor(GXChannelID chan, GXColor color) {
LoadXFCmd(GX_XF_REG_MATERIAL0 + chan, *reinterpret_cast<u32 *>(&color));
}
} // namespace fifo
} // namespace g3d
} // namespace nw4r
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef NW4R_G3D_PLATFORM_TMEM_H
#define NW4R_G3D_PLATFORM_TMEM_H
#include <nw4r/types_nw4r.h>
namespace nw4r {
namespace g3d {
namespace tmem {
// TODO: Naming
enum TMemLayout {
TMEM_LAYOUT_NONE,
TMEM_LAYOUT_1,
TMEM_LAYOUT_2,
TMEM_LAYOUT_3
};
void SetTMemLayout(TMemLayout layout);
} // namespace tmem
} // namespace g3d
} // namespace nw4r
#endif

Some files were not shown because too many files have changed in this diff Show More