NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
g3d_resanm.h
1#ifndef NW4R_G3D_RES_RES_ANM_H
2#define NW4R_G3D_RES_RES_ANM_H
3#include <nw4r/types_nw4r.h>
4
5namespace nw4r {
6namespace g3d {
7
8/******************************************************************************
9 *
10 * ResKeyFrame
11 *
12 ******************************************************************************/
14 f32 frame; // at 0x0
15 f32 value; // at 0x4
16 f32 slope; // at 0x8
17};
18
20 u16 numKeyFrame; // at 0x0
21 u8 PADDING_0x2[0x4 - 0x2]; // at 0x2
22 f32 invKeyFrameRange; // at 0x4
23 ResKeyFrameData keyFrames[1]; // at 0x8
24};
25
26namespace detail {
27
28f32 GetResKeyFrameAnmResult(const ResKeyFrameAnmData* pData, f32 frame);
29
30} // namespace detail
31
32/******************************************************************************
33 *
34 * ResAnm
35 *
36 ******************************************************************************/
37enum AnmPolicy { ANM_POLICY_ONETIME, ANM_POLICY_LOOP, ANM_POLICY_MAX };
38
40 f32 constValue; // at 0x0
41 s32 toResKeyFrameAnmData; // at 0x0
42};
43
44namespace detail {
45
46inline f32 GetResAnmResult(const ResAnmData* pData, f32 frame, bool constant) {
47 if (constant) {
48 return pData->constValue;
49 }
50
51 const ResKeyFrameAnmData* pFrameData =
52 reinterpret_cast<const ResKeyFrameAnmData*>(
53 reinterpret_cast<const char*>(pData) + pData->toResKeyFrameAnmData);
54
55 return GetResKeyFrameAnmResult(pFrameData, frame);
56}
57
58template <typename T> inline f32 ClipFrame(const T& rInfo, f32 frame) {
59 if (frame <= 0.0f) {
60 return 0.0f;
61 }
62
63 if (rInfo.numFrame <= frame) {
64 return rInfo.numFrame;
65 }
66
67 return frame;
68}
69
70} // namespace detail
71
72/******************************************************************************
73 *
74 * ResColorAnm
75 *
76 ******************************************************************************/
78 ulong constValue; // at 0x0
79 s32 toResColorAnmFramesData; // at 0x0
80};
82 ulong frameColors[1]; // at 0x0
83};
84
85namespace detail {
86
87ulong GetResColorAnmResult(const ResColorAnmFramesData* pData, f32 frame);
88
89inline ulong GetResColorAnmResult(const ResColorAnmData* pData, f32 frame,
90 bool constant) {
91 if (constant) {
92 return pData->constValue;
93 }
94
95 const ResColorAnmFramesData* pFrameData =
96 reinterpret_cast<const ResColorAnmFramesData*>(
97 reinterpret_cast<const char*>(pData) +
98 pData->toResColorAnmFramesData);
99
100 return GetResColorAnmResult(pFrameData, frame);
101}
102
103} // namespace detail
104
105/******************************************************************************
106 *
107 * ResBoolAnm
108 *
109 ******************************************************************************/
111 s32 toResBoolAnmFramesData; // at 0x0
112};
114 ulong boolBits[1]; // at 0x0
115};
116
117namespace detail {
118
119inline bool GetResBoolAnmFramesResult(const ResBoolAnmFramesData* pData,
120 int frame) {
121 const ulong* pBits = pData->boolBits;
122 ulong index = static_cast<ulong>(frame);
123
124 ulong wordIdx = index / 32;
125 ulong bitIdx = index % 32;
126
127 ulong targetBit = (1U << 31) >> bitIdx;
128 ulong bitWord = pBits[wordIdx];
129
130 return bitWord & targetBit;
131}
132
133inline bool GetResBoolAnmResult(const ResBoolAnmData* pData, int frame) {
134 const ResBoolAnmFramesData* pFrameData =
135 reinterpret_cast<const ResBoolAnmFramesData*>(
136 reinterpret_cast<const char*>(pData) +
137 pData->toResBoolAnmFramesData);
138
139 return GetResBoolAnmFramesResult(pFrameData, frame);
140}
141
142} // namespace detail
143
144} // namespace g3d
145} // namespace nw4r
146
147#endif
3D graphics drawing library.
Definition g3d_3dsmax.h:10