NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
g3d_resmdl.h
1#ifndef NW4R_G3D_RES_RES_MDL_H
2#define NW4R_G3D_RES_RES_MDL_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/g3d/res/g3d_rescommon.h>
6#include <nw4r/g3d/res/g3d_resdict.h>
7#include <nw4r/g3d/res/g3d_resmat.h>
8#include <nw4r/g3d/res/g3d_resnode.h>
9#include <nw4r/g3d/res/g3d_resshp.h>
10#include <nw4r/g3d/res/g3d_resvtx.h>
11
12#include <nw4r/math.h>
13
14namespace nw4r {
15namespace g3d {
16
17/******************************************************************************
18 *
19 * ResMdlInfo
20 *
21 ******************************************************************************/
23 enum TexMatrixMode {
24 TEXMATRIXMODE_MAYA,
25 TEXMATRIXMODE_XSI,
26 TEXMATRIXMODE_3DSMAX
27 };
28
29 enum EnvelopeMatrixMode {
30 EVPMATRIXMODE_NORMAL,
31 EVPMATRIXMODE_APPROX,
32 EVPMATRIXMODE_EXACT
33 };
34};
35
36enum ScalingRule {
37 SCALINGRULE_STANDARD,
38 SCALINGRULE_SOFTIMAGE,
39 SCALINGRULE_MAYA
40};
41
43 ulong numMtxID; // at 0x0
44};
45
47 ulong size; // at 0x0
48 s32 toResMdlData; // at 0x4
49 ScalingRule scaling_rule; // at 0x8
50 TexMatrixMode tex_mtx_mode; // at 0xC
51 s32 vertex_size; // at 0x10
52 s32 triangle_size; // at 0x14
53 s32 original_path; // at 0x18
54 ulong numViewMtx; // at 0x1C
55 bool need_nrm_mtx_array; // at 0x20
56 bool need_tex_mtx_array; // at 0x21
57 bool is_valid_volume; // at 0x22
58 u8 envelope_mtx_mode; // at 0x23
59 s32 toMtxIDToNodeID; // at 0x24
60 math::_VEC3 volume_min; // at 0x28
61 math::_VEC3 volume_max; // at 0x34
62};
63
64class ResMdlInfo : public ResCommon<ResMdlInfoData>,
66public:
67 NW4R_G3D_RESOURCE_FUNC_DEF(ResMdlInfo);
68
69 ScalingRule GetScalingRule() const {
70 return ref().scaling_rule;
71 }
72
73 ulong GetNumViewMtx() const {
74 return ref().numViewMtx;
75 }
76
77 EnvelopeMatrixMode GetEnvelopeMatrixMode() const {
78 return static_cast<EnvelopeMatrixMode>(ref().envelope_mtx_mode);
79 }
80
81 ulong GetNumPosNrmMtx() const {
82 const ResMtxIDToNodeIDData* pData =
83 reinterpret_cast<const ResMtxIDToNodeIDData*>(
84 reinterpret_cast<const u8*>(&ref()) + ref().toMtxIDToNodeID);
85
86 return pData->numMtxID;
87 }
88
89 s32 GetNodeIDFromMtxID(ulong id) const {
90 const s32* pArray = reinterpret_cast<const s32*>(
91 reinterpret_cast<const u8*>(&ref()) + ref().toMtxIDToNodeID +
92 sizeof(ResMtxIDToNodeIDData));
93
94 return pArray[id];
95 }
96};
97
98/******************************************************************************
99 *
100 * ResMdl
101 *
102 ******************************************************************************/
104 ResBlockHeaderData header; // at 0x0
105 ulong revision; // at 0x8
106 s32 toResFileData; // at 0xC
107 s32 toResByteCodeDic; // at 0x10
108 s32 toResNodeDic; // at 0x14
109 s32 toResVtxPosDic; // at 0x18
110 s32 toResVtxNrmDic; // at 0x1C
111 s32 toResVtxClrDic; // at 0x20
112 s32 toResVtxTexCoordDic; // at 0x24
113 s32 toResMatDic; // at 0x28
114 s32 toResTevDic; // at 0x2C
115 s32 toResShpDic; // at 0x30
116 s32 toResTexNameToTexPlttInfoDic; // at 0x34
117 s32 toResPlttNameToTexPlttInfoDic; // at 0x38
118 s32 name; // at 0x3C
119 ResMdlInfoData info; // at 0x40
120};
121
122class ResMdl : public ResCommon<ResMdlData> {
123public:
124 static const ulong SIGNATURE = 'MDL0';
125 static const int REVISION = 9;
126
127public:
128 NW4R_G3D_RESOURCE_FUNC_DEF(ResMdl);
129
130 void Init();
131 void Terminate();
132
133 bool Bind(const ResFile file);
134 void Release();
135
136 ulong GetRevision() const {
137 return ref().revision;
138 }
139
140 bool CheckRevision() const {
141 return GetRevision() == REVISION;
142 }
143
144 const u8* GetResByteCode(const char* pName) const;
145
146 ResNode GetResNode(const char* pName) const;
147 ResNode GetResNode(const ResName name) const;
148 ResNode GetResNode(int idx) const;
149 ResNode GetResNode(ulong idx) const;
150 ulong GetResNodeNumEntries() const;
151
152 ResVtxPos GetResVtxPos(const ResName name) const;
153 ResVtxPos GetResVtxPos(int idx) const;
154 ResVtxPos GetResVtxPos(ulong idx) const;
155 ulong GetResVtxPosNumEntries() const;
156
157 ResVtxNrm GetResVtxNrm(const ResName name) const;
158 ResVtxNrm GetResVtxNrm(int idx) const;
159 ResVtxNrm GetResVtxNrm(ulong idx) const;
160 ulong GetResVtxNrmNumEntries() const;
161
162 ResVtxClr GetResVtxClr(const ResName name) const;
163 ResVtxClr GetResVtxClr(int idx) const;
164 ResVtxClr GetResVtxClr(ulong idx) const;
165 ulong GetResVtxClrNumEntries() const;
166
167 ResVtxTexCoord GetResVtxTexCoord(int idx) const;
168 ulong GetResVtxTexCoordNumEntries() const;
169
170 ResMat GetResMat(const char* pName) const;
171 ResMat GetResMat(const ResName name) const;
172 ResMat GetResMat(int idx) const;
173 ResMat GetResMat(size_t idx) const;
174 ulong GetResMatNumEntries() const;
175
176 ResShp GetResShp(const char* pName) const;
177 ResShp GetResShp(int idx) const;
178 ResShp GetResShp(ulong idx) const;
179 ulong GetResShpNumEntries() const;
180
181 ResTexPlttInfo GetResTexPlttInfoOffsetFromTexName(int idx) const;
182 ulong GetResTexPlttInfoOffsetFromTexNameNumEntries() const;
183
184 ResMdlInfo GetResMdlInfo() {
185 return ResMdlInfo(&ref().info);
186 }
187 ResMdlInfo GetResMdlInfo() const {
188 return ResMdlInfo(const_cast<ResMdlInfoData*>(&ref().info));
189 }
190};
191
192} // namespace g3d
193} // namespace nw4r
194
195#endif
3D graphics drawing library.
Definition g3d_3dsmax.h:10