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
6#include "dolphin/gx.h"
7
17
18static inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) {
20 GXWGFifo.u8 = cmd;
21 GXWGFifo.u32 = param;
22}
23
24static inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) {
26 GXWGFifo.u16 = (len - 1);
27 GXWGFifo.u16 = cmd;
28}
29
35public:
37 mMtxIdxRegA = 0x3cf3cf00;
38 mMtxIdxRegB = 0x00f3cf3c;
39 }
40
44 return *this;
45 }
46
47 u32 getMtxIdxRegA() const { return mMtxIdxRegA; }
48 u32 getMtxIdxRegB() const { return mMtxIdxRegB; }
49
50 inline void load() const {
51 J3DFifoWriteCPCmd(0x30, getMtxIdxRegA()); // CP_MATINDEX_A
52 J3DFifoWriteCPCmd(0x40, getMtxIdxRegB()); // CP_MATINDEX_B
53 J3DFifoWriteXFCmd(0x1018, 2);
54 GXWGFifo.u32 = getMtxIdxRegA();
55 GXWGFifo.u32 = getMtxIdxRegB();
56 }
57
58 void setCurrentTexMtx(u8 param_1, u8 param_2, u8 param_3, u8 param_4,
60 mMtxIdxRegA = (param_1 << 6) | (param_2 << 0xc) | (param_3 << 0x12) | (param_4 << 0x18);
61 mMtxIdxRegB = (param_5) | param_6 << 6 | param_7 << 0xc | param_8 << 0x12;
62 }
63};
64
65class J3DMaterial;
66class J3DVertexData;
67class J3DDrawMtxData;
68
77
82class J3DShape {
83public:
85 initialize();
86 }
87
88 enum {
90 };
91
92 /* 80314B48 */ void initialize();
93 /* 80314BB8 */ void addTexMtxIndexInDL(_GXAttr, u32);
94 /* 80314CBC */ void addTexMtxIndexInVcd(_GXAttr);
95 /* 80314DA8 */ void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
96 /* 80314E28 */ u32 countBumpMtxNum() const;
97 /* 80314EEC */ void loadVtxArray() const;
98 /* 80314F5C */ bool isSameVcdVatCmd(J3DShape*);
99 /* 80314F98 */ void makeVtxArrayCmd();
100 /* 80315260 */ void makeVcdVatCmd();
101 /* 80315300 */ void loadPreDrawSetting() const;
102 /* 80315398 */ void setArrayAndBindPipeline() const;
103
104 /* 803155E0 */ virtual void draw() const;
105 /* 8031544C */ virtual void drawFast() const;
106 /* 80315628 */ virtual void simpleDraw() const;
107 /* 803156AC */ virtual void simpleDrawCache() const;
108
109 void onFlag(u32 flag) { mFlags |= flag; }
111 bool checkFlag(u32 flag) const { return !!(mFlags & flag); }
114 void* getVcdVatCmd() const { return mVcdVatCmd; }
123 void setTexMtxLoadType(u32 type) { mFlags = (mFlags & 0xFFFF0FFF) | type; }
124 bool getNBTFlag() const { return mHasNBT; }
126 void setBumpMtxOffset(u32 offset) { mBumpMtxOffset = offset; }
127 GXVtxDescList* getVtxDesc() const { return mVtxDesc; }
128
129 J3DMaterial* getMaterial() const { return mMaterial; }
130 u32 getIndex() const { return mIndex; }
131 u32 getPipeline() const { return (mFlags >> 2) & 0x07; }
132 u32 getTexMtxLoadType() const { return mFlags & 0xF000; }
133 u32 getMtxGroupNum() const { return mMtxGroupNum; }
134 J3DShapeDraw* getShapeDraw(u32 idx) const { return mShapeDraw[idx]; }
135 J3DShapeMtx* getShapeMtx(u32 idx) const { return mShapeMtx[idx]; }
136 Vec* getMin() { return &mMin; }
137 Vec* getMax() { return &mMax; }
138
140
141 static void* sOldVcdVatCmd;
142
143private:
144 friend struct J3DShapeFactory;
145 friend class J3DJointTree;
146
148 /* 0x08 */ u16 mIndex;
149 /* 0x0A */ u16 mMtxGroupNum;
150 /* 0x0C */ u32 mFlags;
151 /* 0x10 */ f32 mRadius;
152 /* 0x14 */ Vec mMin;
153 /* 0x20 */ Vec mMax;
154 /* 0x2C */ u8* mVcdVatCmd;
156 /* 0x34 */ bool mHasNBT;
157 /* 0x38 */ J3DShapeMtx** mShapeMtx;
160 /* 0x48 */ bool mHasPNMTXIdx;
163 /* 0x54 */ u8* mScaleFlagArray;
164 /* 0x58 */ Mtx** mDrawMtx;
165 /* 0x5C */ Mtx33** mNrmMtx;
166 /* 0x60 */ u32* mCurrentViewNo;
167 /* 0x64 */ u32 mBumpMtxOffset;
168};
169
170#endif /* J3DSHAPE_H */
_GXAttr
Definition GXEnum.h:197
@ GX_CMD_LOAD_CP_REG
Definition GXEnum.h:797
@ GX_CMD_LOAD_XF_REG
Definition GXEnum.h:798
static void J3DFifoWriteCPCmd(u8 cmd, u32 param)
Definition J3DShape.h:18
static void J3DFifoWriteXFCmd(u16 cmd, u16 len)
Definition J3DShape.h:24
J3DShpFlag
Definition J3DShape.h:69
@ J3DShpFlag_SkinNrmCpu
Definition J3DShape.h:72
@ J3DShpFlag_NoMtx
Definition J3DShape.h:75
@ J3DShpFlag_Visible
Definition J3DShape.h:70
@ J3DShpFlag_EnableLod
Definition J3DShape.h:74
@ J3DShpFlag_Hidden
Definition J3DShape.h:73
@ J3DShpFlag_SkinPosCpu
Definition J3DShape.h:71
static Mtx mtx[10]
Definition c_lib.cpp:347
T cLib_calcTimer(T *value)
Definition c_lib.h:74
Definition J3DShape.h:12
u32 mMtxIdxRegA
Definition J3DShape.h:14
u32 mMtxIdxRegB
Definition J3DShape.h:15
Definition J3DShape.h:34
u32 getMtxIdxRegB() const
Definition J3DShape.h:48
J3DCurrentMtx & operator=(J3DCurrentMtxInfo const &info)
Definition J3DShape.h:41
void load() const
Definition J3DShape.h:50
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:58
u32 getMtxIdxRegA() const
Definition J3DShape.h:47
J3DCurrentMtx()
Definition J3DShape.h:36
Definition J3DJointTree.h:39
Definition J3DShapeDraw.h:10
Definition J3DShapeMtx.h:49
Definition J3DShape.h:82
Vec mMin
Definition J3DShape.h:152
void show()
Definition J3DShape.h:116
void makeVcdVatCmd()
Definition J3DShape.cpp:237
J3DCurrentMtx mCurrentMtx
Definition J3DShape.h:159
virtual void drawFast() const
Definition J3DShape.cpp:290
u32 getTexMtxLoadType() const
Definition J3DShape.h:132
void setBumpMtxOffset(u32 offset)
Definition J3DShape.h:126
Mtx33 ** mNrmMtx
Definition J3DShape.h:165
u8 * mVcdVatCmd
Definition J3DShape.h:154
Vec mMax
Definition J3DShape.h:153
void setScaleFlagArray(u8 *pScaleFlagArray)
Definition J3DShape.h:120
void onFlag(u32 flag)
Definition J3DShape.h:109
J3DShapeMtx ** mShapeMtx
Definition J3DShape.h:157
void setDrawMtxDataPointer(J3DDrawMtxData *pMtxData)
Definition J3DShape.h:112
void setVertexDataPointer(J3DVertexData *pVtxData)
Definition J3DShape.h:113
void * getVcdVatCmd() const
Definition J3DShape.h:114
void makeVtxArrayCmd()
Definition J3DShape.cpp:153
void setVcdVatCmd(void *pVatCmd)
Definition J3DShape.h:115
virtual void simpleDrawCache() const
Definition J3DShape.cpp:341
@ kVcdVatDLSize
Definition J3DShape.h:89
u32 getBumpMtxOffset() const
Definition J3DShape.h:125
void addTexMtxIndexInVcd(_GXAttr)
Definition J3DShape.cpp:70
u8 * mScaleFlagArray
Definition J3DShape.h:163
Vec * getMin()
Definition J3DShape.h:136
void setTexMtxLoadType(u32 type)
Definition J3DShape.h:123
GXVtxDescList * getVtxDesc() const
Definition J3DShape.h:127
J3DShapeMtx * getShapeMtx(u32 idx) const
Definition J3DShape.h:135
bool mHasPNMTXIdx
Definition J3DShape.h:160
u32 countBumpMtxNum() const
Definition J3DShape.cpp:113
void calcNBTScale(Vec const &, f32(*)[3][3], f32(*)[3][3])
Definition J3DShape.cpp:107
u16 mMtxGroupNum
Definition J3DShape.h:149
Mtx ** mDrawMtx
Definition J3DShape.h:164
void offFlag(u32 flag)
Definition J3DShape.h:110
static void * sOldVcdVatCmd
Definition J3DShape.h:141
u32 getIndex() const
Definition J3DShape.h:130
u32 getPipeline() const
Definition J3DShape.h:131
u32 mFlags
Definition J3DShape.h:150
void setArrayAndBindPipeline() const
Definition J3DShape.cpp:276
bool checkFlag(u32 flag) const
Definition J3DShape.h:111
J3DShapeDraw * getShapeDraw(u32 idx) const
Definition J3DShape.h:134
bool isSameVcdVatCmd(J3DShape *)
Definition J3DShape.cpp:143
J3DShapeDraw ** mShapeDraw
Definition J3DShape.h:158
virtual void draw() const
Definition J3DShape.cpp:321
void setCurrentMtx(J3DCurrentMtx &mtx)
Definition J3DShape.h:119
Vec * getMax()
Definition J3DShape.h:137
void setNrmMtx(Mtx33 **pNrmMtx)
Definition J3DShape.h:122
u16 mIndex
Definition J3DShape.h:148
J3DMaterial * getMaterial() const
Definition J3DShape.h:129
bool mHasNBT
Definition J3DShape.h:156
f32 mRadius
Definition J3DShape.h:151
virtual void simpleDraw() const
Definition J3DShape.cpp:328
void loadVtxArray() const
Definition J3DShape.cpp:134
void setCurrentViewNoPtr(u32 *pViewNoPtr)
Definition J3DShape.h:118
GXVtxDescList * mVtxDesc
Definition J3DShape.h:155
void hide()
Definition J3DShape.h:117
bool getNBTFlag() const
Definition J3DShape.h:124
void initialize()
Definition J3DShape.cpp:16
u32 * mCurrentViewNo
Definition J3DShape.h:166
static void resetVcdVatCache()
Definition J3DShape.h:139
J3DMaterial * mMaterial
Definition J3DShape.h:147
J3DDrawMtxData * mDrawMtxData
Definition J3DShape.h:162
void loadPreDrawSetting() const
Definition J3DShape.cpp:262
void addTexMtxIndexInDL(_GXAttr, u32)
Definition J3DShape.cpp:42
u32 mBumpMtxOffset
Definition J3DShape.h:167
u32 getMtxGroupNum() const
Definition J3DShape.h:133
J3DShape()
Definition J3DShape.h:84
void setDrawMtx(Mtx **pDrawMtx)
Definition J3DShape.h:121
J3DVertexData * mVertexData
Definition J3DShape.h:161
Definition J3DVertex.h:29
static volatile BOOL flag
Definition dspproc.cpp:20
f32 Mtx33[3][3]
Definition mtx.h:16
f32 Mtx[3][4]
Definition mtx.h:15
Definition J3DJointTree.h:23
Definition d_a_hozelda.cpp:93
Definition J3DShapeFactory.h:50
Definition d_a_hozelda.cpp:18
Definition GXAttr.h:10
unsigned long u32
Definition types.h:10
float f32
Definition types.h:22
unsigned short u16
Definition types.h:9
unsigned char u8
Definition types.h:8