NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
g3d_resanmchr.h
1#ifndef NW4R_G3D_RES_RES_ANM_CHR_H
2#define NW4R_G3D_RES_RES_ANM_CHR_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/g3d/res/g3d_resanm.h>
6#include <nw4r/g3d/res/g3d_rescommon.h>
7#include <nw4r/g3d/res/g3d_resmdl.h>
8
9#include <nw4r/math.h>
10
11namespace nw4r {
12namespace g3d {
13
14/******************************************************************************
15 *
16 * ChrAnmResult
17 *
18 ******************************************************************************/
20 enum Flag {
21 FLAG_ANM_EXISTS = (1 << 0),
22 FLAG_MTX_IDENT = (1 << 1),
23 FLAG_ROT_TRANS_ZERO = (1 << 2),
24 FLAG_SCALE_ONE = (1 << 3),
25 FLAG_SCALE_UNIFORM = (1 << 4),
26 FLAG_ROT_ZERO = (1 << 5),
27 FLAG_TRANS_ZERO = (1 << 6),
28 FLAG_PATCH_SCALE = (1 << 7),
29 FLAG_PATCH_ROT = (1 << 8),
30 FLAG_PATCH_TRANS = (1 << 9),
31
32 // Maya Scale Compensation
33 FLAG_SSC_APPLY = (1 << 10),
34 FLAG_SSC_PARENT = (1 << 11),
35
36 // Softimage Hierarchical Scaling
37 FLAG_XSI_SCALING = (1 << 12),
38
39 FLAG_ROT_RAW_FMT = (1 << 31)
40 };
41
42 ulong flags; // at 0x0
43 math::VEC3 s; // at 0x4
44 math::VEC3 rawR; // at 0x10
45 math::MTX34 rt; // at 0x1C
46
47 void GetScale(math::VEC3* pScale) const;
48 bool GetRotateDeg(math::VEC3* pRotate) const;
49 void GetTranslate(math::VEC3* pTrans) const;
50 void GetRotTrans(math::MTX34* pRotTrans) const;
51
52 void SetScale(const math::VEC3* pScale);
53 void SetRotTrans(const math::MTX34* pRotTrans);
54};
55
56/******************************************************************************
57 *
58 * Frame values (FVS) animation data
59 *
60 ******************************************************************************/
62 union {
63 ulong fvsulong; // at 0x0
64
65 struct {
66 u8 frame; // at 0x0
67 u8 vs[3]; // at 0x1
68 } fvs;
69 };
70};
72 f32 scale; // at 0x0
73 f32 offset; // at 0x4
74 ResAnmChrFrm32Data frameValues[1]; // at 0x8
75};
76
78 s16 frame; // at 0x0
79 u16 value; // at 0x2
80 s16 slope; // at 0x4
81};
83 f32 scale; // at 0x0
84 f32 offset; // at 0x4
85 ResAnmChrFrm48Data frameValues[1]; // at 0x8
86};
87
89 f32 frame; // at 0x0
90 f32 value; // at 0x4
91 f32 slope; // at 0x8
92};
94 ResAnmChrFrm96Data frameValues[1]; // at 0x0
95};
96
98 u16 numFrameValues; // at 0x0
99 u8 PADDING_0x2[0x4 - 0x2]; // at 0x2
100 f32 invKeyFrameRange; // at 0x4
101
102 union {
103 ResAnmChrFVS32Data fvs32; // at 0x8
104 ResAnmChrFVS48Data fvs48; // at 0x8
105 ResAnmChrFVS96Data fvs96; // at 0x8
106 };
107};
108
109/******************************************************************************
110 *
111 * Const value (CV) animation data
112 *
113 ******************************************************************************/
115 f32 scale; // at 0x0
116 f32 offset; // at 0x4
117 u8 values[1]; // at 0x8
118};
120 f32 scale; // at 0x0
121 f32 offset; // at 0x4
122 u16 values[1]; // at 0x8
123};
125 f32 values[1]; // at 0x0
126};
127
129 union {
130 ResAnmChrCV8Data cv8; // at 0x0
131 ResAnmChrCV16Data cv16; // at 0x0
132 ResAnmChrCV32Data cv32; // at 0x0
133 };
134};
135
136/******************************************************************************
137 *
138 * ResAnmChr
139 *
140 ******************************************************************************/
142 union {
143 ResAnmChrFVSData fvs; // at 0x0
144 ResAnmChrCVData cv; // at 0x0
145 };
146};
147
149 enum Flag {
150 FLAG_ANM_EXISTS = (1 << 0),
151 FLAG_MTX_IDENT = (1 << 1),
152 FLAG_ROT_TRANS_ZERO = (1 << 2),
153 FLAG_SCALE_ONE = (1 << 3),
154 FLAG_SCALE_UNIFORM = (1 << 4),
155 FLAG_ROT_ZERO = (1 << 5),
156 FLAG_TRANS_ZERO = (1 << 6),
157 FLAG_PATCH_SCALE = (1 << 7),
158 FLAG_PATCH_ROT = (1 << 8),
159 FLAG_PATCH_TRANS = (1 << 9),
160
161 // Maya Scale Compensation
162 FLAG_SSC_APPLY = (1 << 10),
163 FLAG_SSC_PARENT = (1 << 11),
164
165 // Softimage Hierarchical Scaling
166 FLAG_XSI_SCALING = (1 << 12),
167
168 FLAG_SCALE_X_CONST = (1 << 13),
169 FLAG_SCALE_Y_CONST = (1 << 14),
170 FLAG_SCALE_Z_CONST = (1 << 15),
171
172 FLAG_ROT_X_CONST = (1 << 16),
173 FLAG_ROT_Y_CONST = (1 << 17),
174 FLAG_ROT_Z_CONST = (1 << 18),
175
176 FLAG_TRANS_X_CONST = (1 << 19),
177 FLAG_TRANS_Y_CONST = (1 << 20),
178 FLAG_TRANS_Z_CONST = (1 << 21),
179
180 FLAG_HAS_SCALE = (1 << 22),
181 FLAG_HAS_ROT = (1 << 23),
182 FLAG_HAS_TRANS = (1 << 24),
183
184 FLAG_SCALE_FVS32_FMT = (1 << 25),
185 FLAG_SCALE_FVS48_FMT = (1 << 26),
186 FLAG_SCALE_FVS96_FMT = FLAG_SCALE_FVS32_FMT | FLAG_SCALE_FVS48_FMT,
187
188 FLAG_ROT_FVS32_FMT = (1 << 27),
189 FLAG_ROT_FVS48_FMT = (1 << 28),
190 FLAG_ROT_FVS96_FMT = FLAG_ROT_FVS32_FMT | FLAG_ROT_FVS48_FMT,
191
192 FLAG_ROT_CV8_FMT = (1 << 29),
193 FLAG_ROT_CV16_FMT = (1 << 27) | (1 << 29),
194 FLAG_ROT_CV32_FMT = (1 << 28) | (1 << 29),
195
196 FLAG_TRANS_FVS32_FMT = (1 << 30),
197 FLAG_TRANS_FVS48_FMT = (1 << 31),
198 FLAG_TRANS_FVS96_FMT = FLAG_TRANS_FVS32_FMT | FLAG_TRANS_FVS48_FMT,
199
200 FLAG_HAS_SRT_MASK = FLAG_HAS_SCALE | FLAG_HAS_ROT | FLAG_HAS_TRANS,
201
202 FLAG_SCALE_FMT_MASK =
203 FLAG_SCALE_FVS32_FMT | FLAG_SCALE_FVS48_FMT | FLAG_SCALE_FVS96_FMT,
204
205 FLAG_ROT_FMT_MASK = FLAG_ROT_FVS32_FMT | FLAG_ROT_FVS48_FMT |
206 FLAG_ROT_FVS96_FMT | FLAG_ROT_CV8_FMT |
207 FLAG_ROT_CV16_FMT | FLAG_ROT_CV32_FMT,
208
209 FLAG_TRANS_FMT_MASK =
210 FLAG_TRANS_FVS32_FMT | FLAG_TRANS_FVS48_FMT | FLAG_TRANS_FVS96_FMT
211 };
212
213 union AnmData {
214 s32 toResAnmChrAnmData; // at 0x0
215 f32 constValue; // at 0x0
216 };
217
218 s32 name; // at 0x0
219 ulong flags; // at 0x4
220 AnmData anms[1]; // at 0x8
221};
222
224 u16 numFrame; // at 0x0
225 u16 numNode; // at 0x2
226 AnmPolicy policy; // at 0x4
227 ScalingRule scalingRule; // at 0x8
228};
229
231 ResBlockHeaderData header; // at 0x0
232 ulong revision; // at 0x8
233 s32 toResFileData; // at 0xC
234 s32 toChrDataDic; // at 0x10
235 s32 toResUserData; // at 0x14
236 s32 name; // at 0x18
237 s32 original_path; // at 0x1C
238 ResAnmChrInfoData info; // at 0x20
239};
240
241class ResAnmChr : public ResCommon<ResAnmChrData> {
242public:
243 static const ulong SIGNATURE = 'CHR0';
244 static const int REVISION = 4;
245
246public:
247 NW4R_G3D_RESOURCE_FUNC_DEF(ResAnmChr);
248
249 ulong GetRevision() const {
250 return ref().revision;
251 }
252
253 bool CheckRevision() const {
254 return GetRevision() == REVISION;
255 }
256
257 void GetAnmResult(ChrAnmResult* pResult, ulong idx, f32 frame) const;
258
259 const ResAnmChrNodeData* GetNodeAnm(int idx) const {
260 return static_cast<ResAnmChrNodeData*>(
261 ofs_to_obj<ResDic>(ref().toChrDataDic)[idx]);
262 }
263 const ResAnmChrNodeData* GetNodeAnm(ulong idx) const {
264 return static_cast<ResAnmChrNodeData*>(
265 ofs_to_obj<ResDic>(ref().toChrDataDic)[idx]);
266 }
267
268 s32 GetNodeAnmIndex(const ResName name) const {
269 return ofs_to_obj<ResDic>(ref().toChrDataDic).GetIndex(name);
270 }
271
272 int GetNumFrame() const {
273 return ref().info.numFrame;
274 }
275
276 int GetNumNode() const {
277 return ref().info.numNode;
278 }
279
280 AnmPolicy GetAnmPolicy() const {
281 return ref().info.policy;
282 }
283};
284
285} // namespace g3d
286} // namespace nw4r
287
288#endif
3D graphics drawing library.
Definition g3d_3dsmax.h:10