forked from zeldaret/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ3DSys.h
More file actions
167 lines (135 loc) · 4.73 KB
/
J3DSys.h
File metadata and controls
167 lines (135 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef J3DSYS_H
#define J3DSYS_H
#include <dolphin/gx.h>
#include <dolphin/mtx.h>
#include "JSystem/JUtility/JUTAssert.h"
// Perhaps move to a new J3DEnum.h?
enum J3DError {
kJ3DError_Success = 0,
kJ3DError_Alloc = 4,
};
enum J3DSysDrawBuffer {
/* 0x0 */ J3DSys_OPA_BUFFER_e,
/* 0x1 */ J3DSys_XLU_BUFFER_e
};
class J3DMtxCalc;
class J3DModel;
class J3DMatPacket;
class J3DShapePacket;
class J3DShape;
class J3DDrawBuffer;
class J3DTexture;
/**
* @ingroup jsystem-j3d
*
*/
struct J3DTexCoordScaleInfo {
/* 0x0 */ u16 field_0x00;
/* 0x2 */ u16 field_0x02;
/* 0x4 */ u16 field_0x04;
/* 0x6 */ u16 field_0x06;
};
enum J3DSysFlag {
J3DSysFlag_SkinPosCpu = 0x00000004,
J3DSysFlag_SkinNrmCpu = 0x00000008,
J3DSysFlag_PostTexMtx = 0x40000000,
};
/**
* @ingroup jsystem-j3d
*
*/
struct J3DSys {
/* 0x000 */ Mtx mViewMtx;
/* 0x030 */ J3DMtxCalc* mCurrentMtxCalc;
/* 0x034 */ u32 mFlags;
/* 0x038 */ J3DModel* mModel;
/* 0x03C */ J3DMatPacket* mMatPacket;
/* 0x040 */ J3DShapePacket* mShapePacket;
/* 0x044 */ J3DShape* mShape;
/* 0x048 */ J3DDrawBuffer* mDrawBuffer[2];
/* 0x050 */ u32 mDrawMode;
/* 0x054 */ u32 mMaterialMode;
/* 0x058 */ J3DTexture* mTexture;
/* 0x05C */ u8 field_0x5c[0x04];
/* 0x060 */ u32 mTexCacheRegionNum;
/* 0x064 */ GXTexRegion mTexCacheRegion[8];
/* 0x0E4 */ u8 field_0xe4[0x20];
/* 0x104 */ Mtx* mModelDrawMtx;
/* 0x108 */ Mtx33* mModelNrmMtx;
/* 0x10C */ void* mVtxPos;
/* 0x110 */ void* mVtxNrm;
/* 0x114 */ _GXColor* mVtxCol;
/* 0x118 */ Vec* mNBTScale;
/* 8030FDE8 */ J3DSys();
/* 8030FEC0 */ void loadPosMtxIndx(int, u16) const;
/* 8030FEE4 */ void loadNrmMtxIndx(int, u16) const;
/* 8030FF0C */ void setTexCacheRegion(_GXTexCacheSize);
/* 803100BC */ void drawInit();
/* 8031073C */ void reinitGX();
/* 8031079C */ void reinitGenMode();
/* 803107E8 */ void reinitLighting();
/* 80310894 */ void reinitTransform();
/* 80310998 */ void reinitTexture();
/* 80310A3C */ void reinitTevStages();
/* 80310D44 */ void reinitIndStages();
/* 80310E3C */ void reinitPixelProc();
enum DrawMode {
/* 0x3 */ OPA_TEX_EDGE = 3,
/* 0x4 */ XLU,
};
MtxP getViewMtx() { return mViewMtx; }
void setDrawModeOpaTexEdge() { mDrawMode = OPA_TEX_EDGE; }
void setDrawModeXlu() { mDrawMode = XLU; }
void* getVtxPos() const { return mVtxPos; }
void setVtxPos(void* pVtxPos) { mVtxPos = pVtxPos; }
void* getVtxNrm() const { return mVtxNrm; }
void setVtxNrm(void* pVtxNrm) { mVtxNrm = pVtxNrm; }
void* getVtxCol() const { return mVtxCol; }
void setVtxCol(_GXColor* pVtxCol) { mVtxCol = pVtxCol; }
void setModel(J3DModel* pModel) { mModel = pModel; }
void setShapePacket(J3DShapePacket* pPacket) { mShapePacket = pPacket; }
void setMatPacket(J3DMatPacket* pPacket) { mMatPacket = pPacket; }
J3DMatPacket* getMatPacket() { return mMatPacket; }
void setMaterialMode(u32 mode) { mMaterialMode = mode; }
void setCurrentMtxCalc(J3DMtxCalc * pCalc) { mCurrentMtxCalc = pCalc; }
J3DMtxCalc * getCurrentMtxCalc() const { return mCurrentMtxCalc; }
void setTexture(J3DTexture* pTex) { mTexture = pTex; }
J3DTexture* getTexture() { return mTexture; }
void setNBTScale(Vec* scale) { mNBTScale = scale; }
Vec* getNBTScale() { return mNBTScale; }
void onFlag(u32 flag) { mFlags |= flag; }
void offFlag(u32 flag) { mFlags &= ~flag; }
bool checkFlag(u32 flag) { return mFlags & flag; }
void setModelDrawMtx(Mtx* pMtxArr) {
mModelDrawMtx = pMtxArr;
GXSetArray(GX_POS_MTX_ARRAY, mModelDrawMtx, sizeof(*mModelDrawMtx));
}
void setModelNrmMtx(Mtx33* pMtxArr) {
mModelNrmMtx = pMtxArr;
GXSetArray(GX_NRM_MTX_ARRAY, mModelNrmMtx, sizeof(*mModelNrmMtx));
}
// Type 0: Opa Buffer
// Type 1: Xlu Buffer
void setDrawBuffer(J3DDrawBuffer* buffer, int type) {
J3D_ASSERT(114, type >= 0 && type < 2, "Error : range over.");
J3D_ASSERT(115, buffer, "Error : null pointer.");
mDrawBuffer[type] = buffer;
}
// Type 0: Opa Buffer
// Type 1: Xlu Buffer
J3DDrawBuffer* getDrawBuffer(int type) {
J3D_ASSERT(121, type >= 0 && type < 2, "Error : range over.");
return mDrawBuffer[type];
}
Mtx& getModelDrawMtx(u16 no) const { return mModelDrawMtx[no]; }
J3DShapePacket* getShapePacket() const { return mShapePacket; }
void setViewMtx(Mtx m) { MTXCopy(m, mViewMtx); }
J3DModel* getModel() { return mModel; }
static Mtx mCurrentMtx;
static Vec mCurrentS;
static Vec mParentS;
static J3DTexCoordScaleInfo sTexCoordScaleTable[8];
};
extern u32 j3dDefaultViewNo;
extern J3DSys j3dSys;
#endif /* J3DSYS_H */