NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
lyt_animation.h
1#ifndef NW4R_LYT_ANIMATION_H
2#define NW4R_LYT_ANIMATION_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/lyt/lyt_common.h>
6#include <nw4r/lyt/lyt_resources.h>
7#include <nw4r/lyt/lyt_group.h>
8#include <nw4r/lyt/lyt_types.h>
9
10#include <nw4r/ut.h>
11
12namespace nw4r {
13namespace lyt {
14
15// Forward declarations
16class Pane;
17class Material;
19
20namespace res {
21
22/******************************************************************************
23 *
24 * AnimationBlock
25 *
26 ******************************************************************************/
28 DataBlockHeader blockHeader; // at 0x0
29 u16 frameSize; // at 0x8
30 u8 loop; // at 0xA
31 u8 PADDING_0xB; // at 0xB
32 u16 fileNum; // at 0xC
33 u16 animContNum; // at 0xE
34 ulong animContOffsetsOffset; // at 0x10
35};
36
38 DataBlockHeader blockHeader; // at 0x00
39 u16 tagOrder; // at 0x08
40 u16 groupNum; // at 0x0A
41 ulong nameOffset; // at 0x0C
42 ulong groupsOffset; // at 0x10
43 u16 startFrame; // at 0x14
44 u16 endFrame; // at 0x16
45 u8 flag; // at 0x18
46 u8 padding[3]; // at 0x19
47};
48
50 DataBlockHeader blockHeader; // at 0x00
51 ulong animShareInfoOffset; // at 0x04
52 u16 shareNum; // at 0x0C
53 u8 padding[2]; // at 0x0E
54};
55
56/******************************************************************************
57 *
58 * AnimationInfo
59 *
60 ******************************************************************************/
62 ulong kind; // at 0x0
63 u8 num; // at 0x4
64 u8 PADDING_0x5[0x8 - 0x5]; // at 0x5
65
66 static const ulong SIGNATURE_ANMPANESRT = 'RLPA';
67 static const ulong SIGNATURE_ANMPANEVIS = 'RLVI';
68 static const ulong SIGNATURE_ANMVTXCLR = 'RLVC';
69
70 static const ulong SIGNATURE_ANMMATCLR = 'RLMC';
71 static const ulong SIGNATURE_ANMTEXSRT = 'RLTS';
72 static const ulong SIGNATURE_ANMTEXPAT = 'RLTP';
73 static const ulong SIGNATURE_ANMINDTEXSRT = 'RLIM';
74};
75
76} // namespace res
77
78/******************************************************************************
79 *
80 * AnimTransform
81 *
82 ******************************************************************************/
83class AnimTransform {
84public:
85 AnimTransform();
86 virtual ~AnimTransform(); // at 0x8
87
88 virtual void SetResource(const res::AnimationBlock* pBlock,
89 ResourceAccessor* pAccessor) = 0; // at 0xC
90 virtual void SetResource(
91 const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor,
92 u16 animNum
93 ) = 0; // at 0x10
94
95 virtual void Bind(Pane* pPane, bool recursive) = 0; // at 0x14
96 virtual void Bind(Material* pMaterial) = 0; // at 0x18
97
98 virtual void Animate(ulong idx, Pane* pPane) = 0; // at 0x1C
99 virtual void Animate(ulong idx, Material* pMaterial) = 0; // at 0x20
100
101 u16 GetFrameSize() const;
102
103 bool IsLoopData() const;
104
105 f32 GetFrame() const {
106 return mFrame;
107 }
108 void SetFrame(f32 frame) {
109 mFrame = frame;
110 }
111
112 f32 GetFrameMax() const {
113 return static_cast<f32>(GetFrameSize());
114 }
115
116public:
117 NW4R_UT_LINKLIST_NODE_DECL(); // at 0x4
118
119protected:
120 const res::AnimationBlock* mpRes; // at 0xC
121 f32 mFrame; // at 0x10
122};
123
124NW4R_UT_LINKLIST_TYPEDEF_DECL(AnimTransform);
125
126class AnimResource {
127public:
128 AnimResource();
129 AnimResource(const void *anmResBuf) {
130 Set(anmResBuf);
131 }
132 void Set(const void *anmResBuf);
133 void Init();
134 u16 GetGroupNum() const;
135 const AnimationGroupRef *GetGroupArray() const;
136 bool IsDescendingBind() const;
137 u16 GetAnimationShareInfoNum() const;
138 const AnimationShareInfo *GetAnimationShareInfoArray() const;
139 u16 CalcAnimationNum(Pane *pPane, bool bRecursive) const;
140 u16 CalcAnimationNum(Group *pGroup, bool bRecursive) const;
141 u16 CalcAnimationNum(res::Group *pGroup, bool bRecursive) const;
142
143 const res::AnimationBlock *GetResourceBlock() const {
144 return mpResBlock;
145 }
146 const res::AnimationTagBlock *GetTagBlock() const {
147 return mpTagBlock;
148 }
149 const res::AnimationShareBlock *GetShareBlock() const {
150 return mpShareBlock;
151 }
152
153private:
154 const res::BinaryFileHeader *mpFileHeader; // at 0x00
155 const res::AnimationBlock *mpResBlock; // at 0x04
156 const res::AnimationTagBlock *mpTagBlock; // at 0x08
157 const res::AnimationShareBlock *mpShareBlock; // at 0x0C
158};
159
160/******************************************************************************
161 *
162 * AnimTransformBasic
163 *
164 ******************************************************************************/
165class AnimTransformBasic : public AnimTransform {
166public:
167 AnimTransformBasic();
168 virtual ~AnimTransformBasic(); // at 0x8
169
170 virtual void SetResource(const res::AnimationBlock* pBlock,
171 ResourceAccessor* pAccessor); // at 0xC
172 virtual void SetResource(const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor, u16 animNum); // at 0x10
173
174 virtual void Bind(Pane* pPane, bool recursive); // at 0x14
175 virtual void Bind(Material* pMaterial); // at 0x18
176
177 virtual void Animate(ulong idx, Pane* pPane); // at 0x1C
178 virtual void Animate(ulong idx, Material* pMaterial); // at 0x20
179
180protected:
181 void** mpFileResAry; // at 0x14
182 AnimationLink* mAnimLinkAry; // at 0x18
183 u16 mAnimLinkNum; // at 0x1C
184};
185
186/******************************************************************************
187 *
188 * Functions
189 *
190 ******************************************************************************/
191namespace detail {
192
193AnimationLink* FindAnimationLink(AnimationLinkList* pAnimList,
194 AnimTransform* pAnimTrans);
195
196} // namespace detail
197
198/******************************************************************************
199 *
200 * AnimTargetPane
201 *
202 ******************************************************************************/
203enum AnimTargetPane {
204 ANIMTARGET_PANE_TRANSX,
205 ANIMTARGET_PANE_TRANSY,
206 ANIMTARGET_PANE_TRANSZ,
207
208 ANIMTARGET_PANE_ROTX,
209 ANIMTARGET_PANE_ROTY,
210 ANIMTARGET_PANE_ROTZ,
211
212 ANIMTARGET_PANE_SCALEX,
213 ANIMTARGET_PANE_SCALEY,
214
215 ANIMTARGET_PANE_SIZEX,
216 ANIMTARGET_PANE_SIZEY,
217
218 ANIMTARGET_PANE_MAX,
219
220 ANIMTARGET_PANE_COLOR_ALPHA = 16,
221 ANIMTARGET_PANE_COLOR_MAX,
222};
223
224/******************************************************************************
225 *
226 * AnimTargetVtxColor
227 *
228 ******************************************************************************/
229enum AnimTargetVtxColor {
230 ANIMTARGET_VERTEXCOLOR_LT_RED,
231 ANIMTARGET_VERTEXCOLOR_LT_GREEN,
232 ANIMTARGET_VERTEXCOLOR_LT_BLUE,
233 ANIMTARGET_VERTEXCOLOR_LT_ALPHA,
234
235 ANIMTARGET_VERTEXCOLOR_RT_RED,
236 ANIMTARGET_VERTEXCOLOR_RT_GREEN,
237 ANIMTARGET_VERTEXCOLOR_RT_BLUE,
238 ANIMTARGET_VERTEXCOLOR_RT_ALPHA,
239
240 ANIMTARGET_VERTEXCOLOR_LB_RED,
241 ANIMTARGET_VERTEXCOLOR_LB_GREEN,
242 ANIMTARGET_VERTEXCOLOR_LB_BLUE,
243 ANIMTARGET_VERTEXCOLOR_LB_ALPHA,
244
245 ANIMTARGET_VERTEXCOLOR_RB_RED,
246 ANIMTARGET_VERTEXCOLOR_RB_GREEN,
247 ANIMTARGET_VERTEXCOLOR_RB_BLUE,
248 ANIMTARGET_VERTEXCOLOR_RB_ALPHA,
249
250 ANIMTARGET_VERTEXCOLOR_MAX
251};
252
253/******************************************************************************
254 *
255 * AnimTargetMatColor
256 *
257 ******************************************************************************/
258enum AnimTargetMatColor {
259 ANIMTARGET_MATCOLOR_MATR,
260 ANIMTARGET_MATCOLOR_MATG,
261 ANIMTARGET_MATCOLOR_MATB,
262 ANIMTARGET_MATCOLOR_MATA,
263
264 ANIMTARGET_MATCOLOR_TEV0R,
265 ANIMTARGET_MATCOLOR_TEV0G,
266 ANIMTARGET_MATCOLOR_TEV0B,
267 ANIMTARGET_MATCOLOR_TEV0A,
268
269 ANIMTARGET_MATCOLOR_TEV1R,
270 ANIMTARGET_MATCOLOR_TEV1G,
271 ANIMTARGET_MATCOLOR_TEV1B,
272 ANIMTARGET_MATCOLOR_TEV1A,
273
274 ANIMTARGET_MATCOLOR_TEV2R,
275 ANIMTARGET_MATCOLOR_TEV2G,
276 ANIMTARGET_MATCOLOR_TEV2B,
277 ANIMTARGET_MATCOLOR_TEV2A,
278
279 ANIMTARGET_MATCOLOR_TEVK0R,
280 ANIMTARGET_MATCOLOR_TEVK0G,
281 ANIMTARGET_MATCOLOR_TEVK0B,
282 ANIMTARGET_MATCOLOR_TEVK0A,
283
284 ANIMTARGET_MATCOLOR_TEVK1R,
285 ANIMTARGET_MATCOLOR_TEVK1G,
286 ANIMTARGET_MATCOLOR_TEVK1B,
287 ANIMTARGET_MATCOLOR_TEVK1A,
288
289 ANIMTARGET_MATCOLOR_TEVK2R,
290 ANIMTARGET_MATCOLOR_TEVK2G,
291 ANIMTARGET_MATCOLOR_TEVK2B,
292 ANIMTARGET_MATCOLOR_TEVK2A,
293
294 ANIMTARGET_MATCOLOR_TEVK3R,
295 ANIMTARGET_MATCOLOR_TEVK3G,
296 ANIMTARGET_MATCOLOR_TEVK3B,
297 ANIMTARGET_MATCOLOR_TEVK3A,
298
299 ANIMTARGET_MATCOLOR_MAX
300};
301
302/******************************************************************************
303 *
304 * AnimTargetTexSRT
305 *
306 ******************************************************************************/
307enum AnimTargetTexSRT {
308 ANIMTARGET_TEXSRT_TRANSX,
309 ANIMTARGET_TEXSRT_TRANSY,
310
311 ANIMTARGET_TEXSRT_ROT,
312
313 ANIMTARGET_TEXSRT_SCALEX,
314 ANIMTARGET_TEXSRT_SCALEY,
315
316 ANIMTARGET_TEXSRT_MAX
317};
318
319/******************************************************************************
320 *
321 * AnimTargetTexPat
322 *
323 ******************************************************************************/
324enum AnimTargetTexPat {
325 ANIMTARGET_TEXPATTURN_IMAGE,
326
327 ANIMTARGET_TEXPATTURN_MAX
328};
329
330void BindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive, bool bDisable);
331
332} // namespace lyt
333} // namespace nw4r
334
335#endif
2D graphics drawing library.