NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_a_wm_cloud.cpp
1#include <game/bases/d_cs_seq_manager.hpp>
3#include <game/bases/d_w_camera.hpp>
4#include <game/bases/d_wm_lib.hpp>
5#include <game/bases/d_a_wm_cloud.hpp>
6#include <game/sLib/s_GlobalData.hpp>
7
8const char *daWmCloud_c::sGroupNodeNames[] = {
9 "group01",
10 "group02",
11 "group03",
12 "group04",
13 "group05",
14 "group06",
15 "group07",
16 "group08",
17 // [group09 is missing]
18 "group10",
19 "group11",
20 "group12",
21 "group13",
22 "group14",
23 "group15",
24 "group16",
25 nullptr,
26 nullptr,
27 nullptr,
28 nullptr,
29 nullptr
30};
31
32void DUMMY_UNUSED() {
33 static const float UNUSED[] = { 200.0f, 0.0f };
34}
35
36template <>
38 0.0f,
39 {
40 300.0f,
41 300.0f,
42 500.0f,
43 300.0f,
44 350.0f,
45 420.0f,
46 500.0f,
47 800.0f,
48 600.0f,
49 300.0f,
50 350.0f,
51 550.0f,
52 600.0f,
53 600.0f,
54 200.0f,
55 100.0f,
56 100.0f,
57 100.0f,
58 100.0f,
59 100.0f
60 },
61 { 8, 0 }
62};
63
64ACTOR_PROFILE(WM_CLOUD, daWmCloud_c, 0);
65
67
69 if (mpBgmSync != nullptr) {
70 delete mpBgmSync;
71 }
72}
73
75 dWmBgmSync_c *bgmSync = new dWmBgmSync_c();
76 mpBgmSync = bgmSync;
77 bgmSync->m_18 = GLOBAL_DATA.mBgmValue;
78 bgmSync->m_04 = 7;
79 bgmSync->m_08 = 0;
80
82 mClipSphere.set(mPos, 2500.0f);
83
84 calcModel();
86 initState();
87 return SUCCEEDED;
88}
89
91 mpBgmSync->execute();
92 if (mpBgmSync->m_0c) {
93 float rate = mpBgmSync->getAnmRate(mChrAnim->mFrameMax);
94 mChrAnim->setRate(rate);
95 }
96
97 static const ProcFunc Proc_tbl[PROC_COUNT] = {
99 };
100
101 dCsSeqMng_c *csSeqMng = dCsSeqMng_c::ms_instance;
102 if (csSeqMng->FUN_80915600()) {
103 processCutsceneCommand(csSeqMng->GetCutName(), csSeqMng->m_164);
104 } else {
105 (this->*Proc_tbl[mCurrProc])();
106 }
107
108 calcCulling();
109 mModel.play();
110 calcModel();
111
112 return SUCCEEDED;
113}
114
116 mModel.entry();
117 return SUCCEEDED;
118}
119
121 return SUCCEEDED;
122}
123
125 mAllocator.createFrmHeap(-1, mHeap::g_gameHeaps[mHeap::GAME_HEAP_DEFAULT], nullptr, 0x20);
126 mResFile = dResMng_c::m_instance->getRes("CS_W7", "g3d/model.brres");
127
128 nw4r::g3d::ResMdl resMdl = mResFile.GetResMdl("CS_W7_Cloud");
129 mModel.create(resMdl, &mAllocator, nw4r::g3d::ScnMdl::BUFFER_RESMATMISC, 1);
130
131 static const char *resAnmNames[ANIM_COUNT] = {
132 "CS_W7_Cloud"
133 };
134
135 static const m3d::playMode_e playModes[ANIM_COUNT] = {
137 };
138
139 for (int i = 0; i < ANIM_COUNT; i++) {
140 nw4r::g3d::ResAnmChr resAnmChr = mResFile.GetResAnmChr(resAnmNames[i]);
141 mChrAnim[i].create(resMdl, resAnmChr, &mAllocator, nullptr);
142 mChrAnim[i].mPlayMode = playModes[i];
143 mChrAnim[i].setRate(0.0f);
144 mChrAnim[i].setFrame(0.0f);
145 mModel.setAnm(mChrAnim[i]);
146 }
147
149 mAllocator.adjustFrmHeap();
150}
151
153 mVec3_c pos = mPos;
154 mAng3_c angle = mAngle;
155 mMatrix.trans(pos);
156 mMatrix.ZXYrotM(angle);
157 mModel.setLocalMtx(&mMatrix);
158 mModel.setScale(mScale);
159 mModel.calc(false);
160}
161
164
165 mChrAnim[CS_W7_Cloud].setRate(1.0f);
166 mChrAnim[CS_W7_Cloud].setFrame(0.0f);
167 mModel.setPriorityDraw(0, 0);
168
169 init_exec();
170}
171
173 mCurrProc = PROC_TYPE_EXEC;
174}
175
177
178void daWmCloud_c::processCutsceneCommand(int cutsceneCommandId, bool isFirstFrame) {
179 if (cutsceneCommandId != dCsSeqMng_c::CUTSCENE_CMD_NONE && !isStaff()) {
180 mIsCutEnd = true;
181 }
182}
183
185 for (int i = 0; i < NODE_COUNT; i++) {
186 if (sGroupNodeNames[i] == nullptr) {
187 mGroupNodeIds[i] = -1;
188 } else {
189 mGroupNodeIds[i] = m3d::getNodeID(mModel.getResMdl(), sGroupNodeNames[i]);
190 }
191 }
192}
193
195 dWCamera_c *worldCamera = dWCamera_c::m_instance;
196 for (int i = 0; i < NODE_COUNT; i++) {
197 if (mGroupNodeIds[i] < 0) {
198 return;
199 }
200
201 mVec3_c nodePos;
202 nodePos = dWmLib::GetModelNodePos(&mModel, mGroupNodeIds[i]);
203 mCurrNodeClipSphere.set(nodePos, GLOBAL_DATA.mGroupNodeRadii[i]);
204
205 nw4r::g3d::ResMdl resMdl = mModel.getResMdl();
206 nw4r::g3d::ResNode resNode = resMdl.GetResNode(mGroupNodeIds[i]);
207 bool onScreen = worldCamera->mViewClip.CheckClipSphere(&mCurrNodeClipSphere);
208
209 if (!onScreen) {
210 hideNode(resNode);
211 } else {
212 showNode(resNode);
213 }
214 }
215}
mMtx_c mMatrix
The actor's partial transformation matrix. See makeMtx() for details.
mVec3_c mScale
The actor's scale (defaults to 1).
mVec3_c mPos
The actor's position.
mAng3_c mAngle
The actor's rotation (for 2D actors).
bool FUN_80915600()
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:61
static dWCamera_c * m_instance
The instance of the camera.
dWmViewClip_c mViewClip
The camera's view clip.
static void setSoftLight_Map(m3d::bmdl_c &mdl)
Sets the soft light effect for map actors.
mSphere_c mClipSphere
A sphere representing the actor's visible area.
The actor for the decorative clouds used in the World 7 map.
nw4r::g3d::ResFile mResFile
The resource file.
void createModel()
Initializes the resources for the actor.
static const char * sGroupNodeNames[NODE_COUNT]
The bone names used for the culling mechanism.
virtual int doDelete()
do method for the delete operation.
virtual int execute()
do method for the execute operation.
virtual int draw()
do method for the draw operation.
m3d::anmChr_c mChrAnim[ANIM_COUNT]
The model animations.
dWmBgmSync_c * mpBgmSync
The background music synchronization helper.
virtual int create()
do method for the create operation.
mSphere_c mCurrNodeClipSphere
The sphere currently in use during per-node culling checks.
void calcModel()
Updates the model's transformation matrix.
daWmCloud_c()
Constructs a new object.
void initState()
Sets up the actor's initial state.
void calcCulling()
Performs per-node culling based on the camera frustum.
void mode_exec()
Process function for the exec process type.
dHeapAllocator_c mAllocator
The allocator.
int mGroupNodeIds[NODE_COUNT]
The bone indices, resolved from sGroupNodeNames.
PROC_TYPE_e mCurrProc
The current process type. See dWmObjActor_c::PROC_TYPE_e.
void init_exec()
Process initialization function for the exec process type.
virtual void processCutsceneCommand(int cutsceneCommandId, bool isFirstFrame)
Contains the actor-specific logic for processing the current world map cutscene.
void initGroupNodeIds()
Initializes the bone index values from the model bone names.
~daWmCloud_c()
Destroys the object.
m3d::smdl_c mModel
The model.
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:46
A three-dimensional short angle vector.
Definition m_angle.hpp:59
A three-dimensional floating point vector.
Definition m_vec.hpp:112
static mVec3_c Zero
The null vector.
Definition m_vec.hpp:220
static const T::GlobalData_t mData
#define ACTOR_PROFILE(profName, className, properties)
Creates an actor profile, using the profile number as the execute and draw order value.
Definition f_profile.hpp:29
playMode_e
Definition banm.hpp:7
@ FORWARD_LOOP
Play the animation forward in a loop.
Definition banm.hpp:8
@ GAME_HEAP_DEFAULT
The default game heap (alias of MEM1 or MEM2).
Definition m_heap.hpp:38
EGG::ExpHeap * g_gameHeaps[GAME_HEAP_COUNT]
The game heaps.
Definition m_heap.cpp:13
The global configuration for the actor.