NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
g3d_resshp.h
1#ifndef NW4R_G3D_RES_RES_SHP_H
2#define NW4R_G3D_RES_RES_SHP_H
3
4#include <nw4r/types_nw4r.h>
5
6#include <nw4r/g3d/res/g3d_rescommon.h>
7#include <nw4r/g3d/res/g3d_resmdl.h>
8#include <nw4r/g3d/res/g3d_resvtx.h>
9
10#include <revolution/GX.h>
11
12namespace nw4r {
13namespace g3d {
14
15/******************************************************************************
16 *
17 * ResShpPrePrim
18 *
19 ******************************************************************************/
21 static const int SIZE_GXVTXDESCLIST = (GX_VA_TEX7 + 1) + 1;
22 static const int SIZE_GXVTXATTRFMTLIST = (GX_VA_TEX7 - GX_VA_POS + 1) + 1;
23
24 union {
25 struct {
26 u8 cullMode[10]; // at 0x0
27 u8 vtxDescv[21]; // at 0xA
28 u8 PADDING_0x1F; // at 0x1F
29 u8 vtxFmtv[GX_CP_CMD_SZ * 3]; // at 0x20
30 u8 array[GX_POS_MTX_ARRAY - GX_VA_POS][GX_CP_CMD_SZ * 2]; // at 0x32
31 u8 PADDING_0xC2[0xE0 - 0xC2]; // at 0xC2
32 } dl;
33
34 u8 data[0xE0]; // at 0x0
35 };
36};
37
38class ResShpPrePrim : public ResCommon<ResPrePrimDL> {
39public:
40 NW4R_G3D_RESOURCE_FUNC_DEF_EX(ResShpPrePrim, ResPrePrimDL);
41
42 void DCStore(bool sync);
43};
44
45/******************************************************************************
46 *
47 * ResShp
48 *
49 ******************************************************************************/
51 union {
52 ulong data_ulong[0xC / sizeof(ulong)];
53 u8 data[0xC / sizeof(u8)];
54 }; // at 0x0
55
56 void Clear() {
57 data_ulong[0] = data_ulong[1] = data_ulong[2] = 0;
58 }
59
60 bool operator==(const ResCacheVtxDescv& rRhs) const {
61 return data_ulong[0] == rRhs.data_ulong[0] &&
62 data_ulong[1] == rRhs.data_ulong[1] &&
63 data_ulong[2] == rRhs.data_ulong[2];
64 }
65};
66
68 ulong numMtxID; // at 0x0
69 u16 vecMtxID[2]; // at 0x4
70};
71
72struct ResShpData {
73 enum IDFlag {
74 ID_FLAG_ENVELOPE = (1 << 31),
75 };
76
77 enum Flag {
78 FLAG_INVISIBLE = (1 << 1),
79 };
80
81 ulong size; // at 0x0
82 s32 toResMdlData; // at 0x4
83 s32 curMtxIdx; // at 0x8
84 ResCacheVtxDescv cache; // at 0xC
85 ResTagDLData tagPrePrimDL; // at 0x18
86 ResTagDLData tagPrimDL; // at 0x24
87 ulong vcdBitmap; // at 0x30
88 ulong flag; // at 0x34
89 s32 name; // at 0x38
90 ulong id; // at 0x3C
91 ulong numVtx; // at 0x40
92 ulong numPolygon; // at 0x44
93 s16 idVtxPosition; // at 0x48
94 s16 idVtxNormal; // at 0x4A
95 s16 idVtxColor[GX_VA_TEX0 - GX_VA_CLR0]; // at 0x4C
96 s16 idVtxTexCoord[GX_POS_MTX_ARRAY - GX_VA_TEX0]; // at 0x50
97 s32 toMtxSetUsed; // at 0x60
98 ResMtxSetUsed msu; // at 0x64
99};
100
101class ResShp : public ResCommon<ResShpData> {
102public:
103 NW4R_G3D_RESOURCE_FUNC_DEF(ResShp);
104
105 void Init();
106 void Terminate();
107
108 ResMdl GetParent() const;
109
110 bool GXGetVtxDescv(GXVtxDescList* pList) const;
111 bool GXGetVtxAttrFmtv(GXVtxAttrFmtList* pList) const;
112 void GXSetArray(GXAttr attr, const void* pBase, u8 stride);
113 void DisableSetArray(GXAttr attr);
114
115 ResVtxPos GetResVtxPos() const;
116 ResVtxNrm GetResVtxNrm() const;
117 ResVtxClr GetResVtxClr(ulong idx) const;
118 ResVtxTexCoord GetResVtxTexCoord(ulong idx) const;
119
120 void CallPrePrimitiveDisplayList(bool sync, bool cacheIsSame) const;
121 void CallPrimitiveDisplayList(bool sync) const;
122
123 ResTagDL GetPrePrimDLTag() {
124 return ResTagDL(&ref().tagPrePrimDL);
125 }
126 ResTagDL GetPrePrimDLTag() const {
127 return ResTagDL(const_cast<ResTagDLData*>(&ref().tagPrePrimDL));
128 }
129
130 ResTagDL GetPrimDLTag() {
131 return ResTagDL(&ref().tagPrimDL);
132 }
133 ResTagDL GetPrimDLTag() const {
134 return ResTagDL(const_cast<ResTagDLData*>(&ref().tagPrimDL));
135 }
136
137 ResShpPrePrim GetResShpPrePrim() {
138 return ResShpPrePrim(GetPrePrimDLTag().GetDL());
139 }
140 ResShpPrePrim GetResShpPrePrim() const {
141 return ResShpPrePrim(GetPrePrimDLTag().GetDL());
142 }
143
144 bool ExistVtxDesc(GXAttr attr) const {
145 return ref().vcdBitmap & (1 << attr);
146 }
147
148 bool IsVisible() const {
149 return !(ref().flag & ResShpData::FLAG_INVISIBLE);
150 }
151};
152
153} // namespace g3d
154} // namespace nw4r
155
156#endif
3D graphics drawing library.
Definition g3d_3dsmax.h:10