Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
J3DShape.h
Go to the documentation of this file.
1#ifndef J3DSHAPE_H
2#define J3DSHAPE_H
3
5#include "JSystem/J3DAssert.h"
7#include <dolphin/mtx.h>
8
9class J3DShapeMtx;
10
20
26public:
28 mMtxIdxRegA = 0x3cf3cf00;
29 mMtxIdxRegB = 0x00f3cf3c;
30 }
31
35 return *this;
36 }
37
38 u32 getMtxIdxRegA() const { return mMtxIdxRegA; }
39 u32 getMtxIdxRegB() const { return mMtxIdxRegB; }
40
41 void load() const {
42 J3DFifoLoadCPCmd(CP_REG_MTXIDXA_ID, mMtxIdxRegA);
43 J3DFifoLoadCPCmd(CP_REG_MTXIDXB_ID, mMtxIdxRegB);
44 J3DFifoLoadXFCmdHdr(GX_XF_REG_MATRIXINDEX0, 2);
45 GXCmd1u32(mMtxIdxRegA);
46 GXCmd1u32(mMtxIdxRegB);
47 }
48
49 void setCurrentTexMtx(u8 param_1, u8 param_2, u8 param_3, u8 param_4,
50 u8 param_5, u8 param_6, u8 param_7, u8 param_8) {
51 mMtxIdxRegA = (param_1 << 6) | (param_2 << 0xc) | (param_3 << 0x12) | (param_4 << 0x18);
52 mMtxIdxRegB = (param_5) | param_6 << 6 | param_7 << 0xc | param_8 << 0x12;
53 }
54};
55
56typedef void (J3DShapeMtx::*J3DShapeMtx_LoadFunc)(int, u16) const;
57
63public:
64 J3DShapeMtx(u16 useMtxIndex)
65 : mUseMtxIndex(useMtxIndex)
66 {}
67
68 void loadMtxIndx_PNGP(int, u16) const;
69 void loadMtxIndx_PCPU(int, u16) const;
70 void loadMtxIndx_NCPU(int, u16) const;
71 void loadMtxIndx_PNCPU(int, u16) const;
72
73 virtual ~J3DShapeMtx() {}
74 virtual u32 getType() const { return 'SMTX'; }
75 virtual u16 getUseMtxNum() const { return 1; }
76 virtual u16 getUseMtxIndex(u16) const { return mUseMtxIndex; }
77 virtual void load() const;
78 virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
79
81 static u16 sMtxLoadCache[10];
84 static bool sNBTFlag;
85 static bool sLODFlag;
87
88 static void setCurrentPipeline(u32 pipeline) {
89 J3D_ASSERT_RANGE(91, pipeline < 4);
90 sCurrentPipeline = pipeline;
91 }
92
93 static void setLODFlag(bool flag) { sLODFlag = flag; }
94 static u32 getLODFlag() { return sLODFlag; }
95 static void resetMtxLoadCache();
96
97protected:
98 /* 0x04 */ u16 mUseMtxIndex;
99};
100
101class J3DMaterial;
102class J3DVertexData;
103class J3DDrawMtxData;
104
113
118class J3DShape {
119public:
121 initialize();
122 }
123
124 static const int kVcdVatDLSize = 0xC0;
125
126 void initialize();
129 void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
130 u16 countBumpMtxNum() const;
131 void loadVtxArray() const;
133 void makeVtxArrayCmd();
134 void makeVcdVatCmd();
135 void loadPreDrawSetting() const;
136 void setArrayAndBindPipeline() const;
137
138 virtual void draw() const;
139 virtual void drawFast() const;
140 virtual void simpleDraw() const;
141 virtual void simpleDrawCache() const;
142
143 void loadCurrentMtx() const;
144
145 void onFlag(u32 flag) { mFlags |= flag; }
146 void offFlag(u32 flag) { mFlags &= ~flag; }
147 bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; }
148
149 void setMaterial(J3DMaterial* pMaterial) {
150 J3D_ASSERT_NULLPTR(509, pMaterial != NULL);
151 mMaterial = pMaterial;
152 }
153
155 J3D_ASSERT_NULLPTR(554, pMtxData != NULL);
156 mDrawMtxData = pMtxData;
157 }
158
160 J3D_ASSERT_NULLPTR(657, pVtxData != NULL);
161 mVertexData = pVtxData;
162 }
163
164 void* getVcdVatCmd() { return mVcdVatCmd; }
165 void setVcdVatCmd(void* pVatCmd) { mVcdVatCmd = (u8*)pVatCmd; }
168
169 void setCurrentViewNoPtr(u32* pViewNoPtr) {
170 J3D_ASSERT_NULLPTR(584, pViewNoPtr != NULL);
171 mCurrentViewNo = pViewNoPtr;
172 }
173
175
176 void setScaleFlagArray(u8* pScaleFlagArray) {
177 J3D_ASSERT_NULLPTR(595, pScaleFlagArray != NULL);
178 mScaleFlagArray = pScaleFlagArray;
179 }
180
181 void setDrawMtx(Mtx** pDrawMtx) { mDrawMtx = pDrawMtx; }
182 void setNrmMtx(Mtx33** pNrmMtx) { mNrmMtx = pNrmMtx; }
183 void setTexMtxLoadType(u32 type) { mFlags = (mFlags & 0xFFFF0FFF) | type; }
184 bool getNBTFlag() const { return mHasNBT; }
186 void setBumpMtxOffset(u32 offset) { mBumpMtxOffset = offset; }
188
189 J3DMaterial* getMaterial() const { return mMaterial; }
190 u16 getIndex() const { return mIndex; }
191 u32 getTexMtxLoadType() const { return mFlags & 0xF000; }
192 u32 getMtxGroupNum() const { return mMtxGroupNum; }
194 J3DShapeMtx* getShapeMtx(u16 idx) { return mShapeMtx[idx]; }
195 Vec* getMin() { return &mMin; }
196 Vec* getMax() { return &mMax; }
197
198 static void resetVcdVatCache() { sOldVcdVatCmd = NULL; }
199
200 static void* sOldVcdVatCmd;
201 static bool sEnvelopeFlag;
202
203private:
204 friend struct J3DShapeFactory;
205 friend class J3DJointTree;
206
208 /* 0x08 */ u16 mIndex;
209 /* 0x0A */ u16 mMtxGroupNum;
210 /* 0x0C */ u32 mFlags;
211 /* 0x10 */ f32 mRadius;
212 /* 0x14 */ Vec mMin;
213 /* 0x20 */ Vec mMax;
214 /* 0x2C */ u8* mVcdVatCmd;
216 /* 0x34 */ bool mHasNBT;
217 /* 0x38 */ J3DShapeMtx** mShapeMtx;
220 /* 0x48 */ bool mHasPNMTXIdx;
223 /* 0x54 */ u8* mScaleFlagArray;
224 /* 0x58 */ Mtx** mDrawMtx;
225 /* 0x5C */ Mtx33** mNrmMtx;
226 /* 0x60 */ u32* mCurrentViewNo;
227 /* 0x64 */ u32 mBumpMtxOffset;
228};
229
230#endif /* J3DSHAPE_H */
static BOOL flag
Definition DEMOAVX.c:20
void J3DFifoLoadXFCmdHdr(u16 addr, u8 len)
Definition J3DFifo.h:42
void J3DFifoLoadCPCmd(u8 reg, u32 value)
Definition J3DFifo.h:30
void(J3DShapeMtx::* J3DShapeMtx_LoadFunc)(int, u16) const
Definition J3DShape.h:56
J3DShpFlag
Definition J3DShape.h:105
@ J3DShpFlag_SkinNrmCpu
Definition J3DShape.h:108
@ J3DShpFlag_NoMtx
Definition J3DShape.h:111
@ J3DShpFlag_Visible
Definition J3DShape.h:106
@ J3DShpFlag_EnableLod
Definition J3DShape.h:110
@ J3DShpFlag_Hidden
Definition J3DShape.h:109
@ J3DShpFlag_SkinPosCpu
Definition J3DShape.h:107
static Mtx mtx[10]
Definition c_lib.cpp:486
Definition J3DShape.h:15
u32 mMtxIdxRegA
Definition J3DShape.h:17
u32 mMtxIdxRegB
Definition J3DShape.h:18
Definition J3DShape.h:25
u32 getMtxIdxRegB() const
Definition J3DShape.h:39
J3DCurrentMtx & operator=(J3DCurrentMtxInfo const &info)
Definition J3DShape.h:32
void load() const
Definition J3DShape.h:41
void setCurrentTexMtx(u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5, u8 param_6, u8 param_7, u8 param_8)
Definition J3DShape.h:49
u32 getMtxIdxRegA() const
Definition J3DShape.h:38
J3DCurrentMtx()
Definition J3DShape.h:27
Definition J3DJointTree.h:39
Definition J3DMaterial.h:16
Definition J3DShapeDraw.h:10
Definition J3DShape.h:62
static u32 sCurrentPipeline
Definition J3DShape.h:82
static u8 * sCurrentScaleFlag
Definition J3DShape.h:83
void loadMtxIndx_PCPU(int, u16) const
Definition J3DShapeMtx.cpp:30
static bool sNBTFlag
Definition J3DShape.h:84
void loadMtxIndx_PNCPU(int, u16) const
Definition J3DShapeMtx.cpp:40
static u16 sMtxLoadCache[10]
Definition J3DShape.h:81
u16 mUseMtxIndex
Definition J3DShape.h:98
static void resetMtxLoadCache()
Definition J3DShapeMtx.cpp:11
virtual void load() const
Definition J3DShapeMtx.cpp:345
static void setLODFlag(bool flag)
Definition J3DShape.h:93
virtual u16 getUseMtxIndex(u16) const
Definition J3DShape.h:76
static void setCurrentPipeline(u32 pipeline)
Definition J3DShape.h:88
void loadMtxIndx_NCPU(int, u16) const
Definition J3DShapeMtx.cpp:35
J3DShapeMtx(u16 useMtxIndex)
Definition J3DShape.h:64
static bool sLODFlag
Definition J3DShape.h:85
virtual void calcNBTScale(Vec const &, f32(*)[3][3], f32(*)[3][3])
Definition J3DShapeMtx.cpp:350
static u32 getLODFlag()
Definition J3DShape.h:94
static J3DShapeMtx_LoadFunc sMtxLoadPipeline[4]
Definition J3DShape.h:45
static u32 sTexMtxLoadType
Definition J3DShape.h:86
virtual u16 getUseMtxNum() const
Definition J3DShape.h:75
void loadMtxIndx_PNGP(int, u16) const
Definition J3DShapeMtx.cpp:24
virtual ~J3DShapeMtx()
Definition J3DShape.h:73
virtual u32 getType() const
Definition J3DShape.h:74
Definition J3DShape.h:118
Vec mMin
Definition J3DShape.h:212
void show()
Definition J3DShape.h:166
void makeVcdVatCmd()
Definition J3DShape.cpp:230
J3DCurrentMtx mCurrentMtx
Definition J3DShape.h:219
virtual void drawFast() const
Definition J3DShape.cpp:275
u32 getTexMtxLoadType() const
Definition J3DShape.h:191
J3DShapeDraw * getShapeDraw(u16 idx)
Definition J3DShape.h:193
void setBumpMtxOffset(u32 offset)
Definition J3DShape.h:186
Mtx33 ** mNrmMtx
Definition J3DShape.h:225
u8 * mVcdVatCmd
Definition J3DShape.h:214
static const int kVcdVatDLSize
Definition J3DShape.h:124
Vec mMax
Definition J3DShape.h:213
void setScaleFlagArray(u8 *pScaleFlagArray)
Definition J3DShape.h:176
void onFlag(u32 flag)
Definition J3DShape.h:145
J3DShapeMtx ** mShapeMtx
Definition J3DShape.h:217
void setDrawMtxDataPointer(J3DDrawMtxData *pMtxData)
Definition J3DShape.h:154
void setVertexDataPointer(J3DVertexData *pVtxData)
Definition J3DShape.h:159
void makeVtxArrayCmd()
Definition J3DShape.cpp:153
void setVcdVatCmd(void *pVatCmd)
Definition J3DShape.h:165
virtual void simpleDrawCache() const
Definition J3DShape.cpp:322
u32 getBumpMtxOffset() const
Definition J3DShape.h:185
void setMaterial(J3DMaterial *pMaterial)
Definition J3DShape.h:149
void addTexMtxIndexInVcd(_GXAttr)
Definition J3DShape.cpp:65
u8 * mScaleFlagArray
Definition J3DShape.h:223
Vec * getMin()
Definition J3DShape.h:195
void setTexMtxLoadType(u32 type)
Definition J3DShape.h:183
bool mHasPNMTXIdx
Definition J3DShape.h:220
void calcNBTScale(Vec const &, f32(*)[3][3], f32(*)[3][3])
Definition J3DShape.cpp:109
u16 mMtxGroupNum
Definition J3DShape.h:209
Mtx ** mDrawMtx
Definition J3DShape.h:224
void offFlag(u32 flag)
Definition J3DShape.h:146
static void * sOldVcdVatCmd
Definition J3DShape.h:200
GXVtxDescList * getVtxDesc()
Definition J3DShape.h:187
u16 countBumpMtxNum() const
Definition J3DShape.cpp:114
J3DShapeMtx * getShapeMtx(u16 idx)
Definition J3DShape.h:194
u32 mFlags
Definition J3DShape.h:210
void setArrayAndBindPipeline() const
Definition J3DShape.cpp:264
bool checkFlag(u32 flag) const
Definition J3DShape.h:147
bool isSameVcdVatCmd(J3DShape *)
Definition J3DShape.cpp:143
void loadCurrentMtx() const
Definition J3DShape.cpp:249
static bool sEnvelopeFlag
Definition J3DShape.h:201
J3DShapeDraw ** mShapeDraw
Definition J3DShape.h:218
virtual void draw() const
Definition J3DShape.cpp:304
void setCurrentMtx(J3DCurrentMtx &mtx)
Definition J3DShape.h:174
Vec * getMax()
Definition J3DShape.h:196
void setNrmMtx(Mtx33 **pNrmMtx)
Definition J3DShape.h:182
u16 mIndex
Definition J3DShape.h:208
void * getVcdVatCmd()
Definition J3DShape.h:164
J3DMaterial * getMaterial() const
Definition J3DShape.h:189
bool mHasNBT
Definition J3DShape.h:216
f32 mRadius
Definition J3DShape.h:211
virtual void simpleDraw() const
Definition J3DShape.cpp:310
void loadVtxArray() const
Definition J3DShape.cpp:133
void setCurrentViewNoPtr(u32 *pViewNoPtr)
Definition J3DShape.h:169
GXVtxDescList * mVtxDesc
Definition J3DShape.h:215
u16 getIndex() const
Definition J3DShape.h:190
void hide()
Definition J3DShape.h:167
bool getNBTFlag() const
Definition J3DShape.h:184
void initialize()
Definition J3DShape.cpp:13
u32 * mCurrentViewNo
Definition J3DShape.h:226
static void resetVcdVatCache()
Definition J3DShape.h:198
J3DMaterial * mMaterial
Definition J3DShape.h:207
J3DDrawMtxData * mDrawMtxData
Definition J3DShape.h:222
void loadPreDrawSetting() const
Definition J3DShape.cpp:253
void addTexMtxIndexInDL(_GXAttr, u32)
Definition J3DShape.cpp:38
u32 mBumpMtxOffset
Definition J3DShape.h:227
u32 getMtxGroupNum() const
Definition J3DShape.h:192
J3DShape()
Definition J3DShape.h:120
void setDrawMtx(Mtx **pDrawMtx)
Definition J3DShape.h:181
J3DVertexData * mVertexData
Definition J3DShape.h:221
Definition J3DVertex.h:29
_GXAttr
Definition GXEnum.h:87
f32 Mtx33[3][3]
Definition mtx.h:35
f32 Mtx[3][4]
Definition mtx.h:25
unsigned long u32
Definition types.h:12
float f32
Definition types.h:25
unsigned short int u16
Definition types.h:10
unsigned char u8
Definition types.h:8
Definition J3DJointTree.h:23
Definition J3DShapeFactory.h:50
Definition mtx.h:13
Definition GXStruct.h:62