22#define J3DSHAPE_H
33
44#include " JSystem/J3DGraphBase/J3DShapeDraw.h"
5- #include " JSystem/J3DGraphBase/J3DShapeMtx .h"
5+ #include " JSystem/JUtility/JUTAssert .h"
66#include " dolphin/gx.h"
7+ #include " mtx.h"
8+
9+ class J3DShapeMtx ;
710
811/* *
912 * @ingroup jsystem-j3d
@@ -48,11 +51,11 @@ class J3DCurrentMtx : public J3DCurrentMtxInfo {
4851 u32 getMtxIdxRegB () const { return mMtxIdxRegB ; }
4952
5053 inline void load () const {
51- J3DFifoWriteCPCmd (0x30 , getMtxIdxRegA () ); // CP_MATINDEX_A
52- J3DFifoWriteCPCmd (0x40 , getMtxIdxRegB () ); // CP_MATINDEX_B
54+ J3DFifoWriteCPCmd (0x30 , mMtxIdxRegA ); // CP_MATINDEX_A
55+ J3DFifoWriteCPCmd (0x40 , mMtxIdxRegB ); // CP_MATINDEX_B
5356 J3DFifoWriteXFCmd (0x1018 , 2 );
54- GXWGFifo. u32 = getMtxIdxRegA ( );
55- GXWGFifo. u32 = getMtxIdxRegB ( );
57+ GXCmd1u32 ( mMtxIdxRegA );
58+ GXCmd1u32 ( mMtxIdxRegB );
5659 }
5760
5861 void setCurrentTexMtx (u8 param_1, u8 param_2, u8 param_3, u8 param_4,
@@ -111,7 +114,7 @@ class J3DShape {
111114 bool checkFlag (u32 flag) const { return !!(mFlags & flag); }
112115 void setDrawMtxDataPointer (J3DDrawMtxData* pMtxData) { mDrawMtxData = pMtxData; }
113116 void setVertexDataPointer (J3DVertexData* pVtxData) { mVertexData = pVtxData; }
114- void * getVcdVatCmd () const { return mVcdVatCmd ; }
117+ void * getVcdVatCmd () { return mVcdVatCmd ; }
115118 void setVcdVatCmd (void * pVatCmd) { mVcdVatCmd = (u8 *)pVatCmd; }
116119 void show () { offFlag (J3DShpFlag_Visible); }
117120 void hide () { onFlag (J3DShpFlag_Visible); }
@@ -124,15 +127,14 @@ class J3DShape {
124127 bool getNBTFlag () const { return mHasNBT ; }
125128 u32 getBumpMtxOffset () const { return mBumpMtxOffset ; }
126129 void setBumpMtxOffset (u32 offset) { mBumpMtxOffset = offset; }
127- GXVtxDescList* getVtxDesc () const { return mVtxDesc ; }
130+ GXVtxDescList* getVtxDesc () { return mVtxDesc ; }
128131
129132 J3DMaterial* getMaterial () const { return mMaterial ; }
130133 u16 getIndex () const { return mIndex ; }
131- u32 getPipeline () const { return (mFlags >> 2 ) & 0x07 ; }
132134 u32 getTexMtxLoadType () const { return mFlags & 0xF000 ; }
133135 u32 getMtxGroupNum () const { return mMtxGroupNum ; }
134- J3DShapeDraw* getShapeDraw (u32 idx) const { return mShapeDraw [idx]; }
135- J3DShapeMtx* getShapeMtx (u32 idx) const { return mShapeMtx [idx]; }
136+ J3DShapeDraw* getShapeDraw (u16 idx) { return mShapeDraw [idx]; }
137+ J3DShapeMtx* getShapeMtx (u16 idx) { return mShapeMtx [idx]; }
136138 Vec* getMin () { return &mMin ; }
137139 Vec* getMax () { return &mMax ; }
138140
@@ -167,4 +169,48 @@ class J3DShape {
167169 /* 0x64 */ u32 mBumpMtxOffset ;
168170};
169171
172+ typedef void (J3DShapeMtx::*J3DShapeMtx_LoadFunc)(int , u16 ) const ;
173+
174+ /* *
175+ * @ingroup jsystem-j3d
176+ *
177+ */
178+ class J3DShapeMtx {
179+ public:
180+ J3DShapeMtx (u16 useMtxIndex)
181+ : mUseMtxIndex (useMtxIndex)
182+ {}
183+
184+ /* 803130E4 */ void loadMtxIndx_PNGP (int , u16 ) const ;
185+ /* 80313128 */ void loadMtxIndx_PCPU (int , u16 ) const ;
186+ /* 80313188 */ void loadMtxIndx_NCPU (int , u16 ) const ;
187+ /* 803131D4 */ void loadMtxIndx_PNCPU (int , u16 ) const ;
188+
189+ /* 80314798 */ virtual ~J3DShapeMtx () {}
190+ /* 803147E0 */ virtual u32 getType () const { return ' SMTX' ; }
191+ /* 80273E08 */ virtual u32 getUseMtxNum () const { return 1 ; }
192+ /* 8031459C */ virtual u32 getUseMtxIndex (u16 ) const { return mUseMtxIndex ; }
193+ /* 80313B94 */ virtual void load () const ;
194+ /* 80313BF0 */ virtual void calcNBTScale (Vec const &, f32 (*)[3][3], f32 (*)[3][3]);
195+
196+ static J3DShapeMtx_LoadFunc sMtxLoadPipeline [4 ];
197+ static u16 sMtxLoadCache [10 ];
198+ static u32 sCurrentPipeline ;
199+ static u8 * sCurrentScaleFlag ;
200+ static u8 sNBTFlag ;
201+ static u8 sLODFlag ;
202+ static u32 sTexMtxLoadType ;
203+
204+ static void setCurrentPipeline (u32 pipeline) {
205+ J3D_ASSERT (91 , pipeline < 4 , " Error : range over." );
206+ sCurrentPipeline = pipeline;
207+ }
208+ static void setLODFlag (u8 flag) { sLODFlag = flag; }
209+ static u32 getLODFlag () { return sLODFlag ; }
210+ static void resetMtxLoadCache ();
211+
212+ protected:
213+ /* 0x04 */ u16 mUseMtxIndex ;
214+ };
215+
170216#endif /* J3DSHAPE_H */
0 commit comments