NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_a_wm_cloud.hpp
1#pragma once
2
3#include <game/bases/d_heap_allocator.hpp>
4#include <game/mLib/m_3d/anm_chr.hpp>
5#include <game/mLib/m_3d/smdl.hpp>
6#include <game/bases/d_wm_obj_actor.hpp>
7#include <game/bases/d_wm_bgm_sync.hpp>
9/**
10* @brief The actor for the decorative clouds used in the World 7 map.
11* @details The actor represents an animated cloud model composed of multiple bones.
12*
13* Each bone listed in #sGroupNodeNames is treated as an independent visual group, and is
14* culled individually every frame. This allows the model to be partially rendered, improving performance.
15*
16* The bone indices are resolved during initialization via #initGroupNodeIds. Then on every frame the actor:
17* - Computes each bone’s world position.
18* - Builds a bounding sphere, using the radius from GlobalData_t::mGroupNodeRadii.
19* - Tests the sphere against the camera frustum.
20* - Toggles visibility of the bone depending on the test result.
21*
22* Animation playback is synchronized with background music using #mpBgmSync, which adjusts animation rate dynamically.
23* @ingroup bases
24*/
25class daWmCloud_c : public dWmObjActor_c {
26public:
27 static const int NODE_COUNT = 20;
28
29 /// @brief The global configuration for the actor.
30 struct GlobalData_t {
31 float mUnk; ///< @unused
32 float mGroupNodeRadii[NODE_COUNT]; ///< The culling radius for each bone.
33 s16 mBgmValue[2];
34 };
35
36 /// @brief The available animations for this actor.
37 enum ANIM_e {
38 CS_W7_Cloud,
39 ANIM_COUNT
40 };
41
42 typedef void (daWmCloud_c::*ProcFunc)();
43
44 daWmCloud_c(); ///< @copydoc dWmObjActor_c::dWmObjActor_c
45 ~daWmCloud_c(); ///< @copydoc dWmObjActor_c::~dWmObjActor_c
46
47 virtual int create();
48 virtual int execute();
49 virtual int draw();
50 virtual int doDelete();
51
52 virtual void processCutsceneCommand(int cutsceneCommandId, bool isFirstFrame);
53
54 void createModel(); ///< Initializes the resources for the actor.
55 void initState(); ///< Sets up the actor's initial state.
56 void initGroupNodeIds(); ///< Initializes the @ref mGroupNodeIds "bone index values" from the @ref sGroupNodeNames "model bone names".
57
58 void calcModel(); ///< Updates the model's transformation matrix.
59 void calcCulling(); ///< Performs per-node culling based on the camera frustum.
60
61 void init_exec(); ///< Process initialization function for the @ref dWmObjActor_c::PROC_TYPE_EXEC "exec" process type.
62 void mode_exec(); ///< Process function for the @ref dWmObjActor_c::PROC_TYPE_EXEC "exec" process type.
63
64 static void hideNode(nw4r::g3d::ResNode node) {
65 if (node.IsValid()) {
66 node.SetVisibility(false);
67 }
68 }
69
70 static void showNode(nw4r::g3d::ResNode node) {
71 if (node.IsValid()) {
72 node.SetVisibility(true);
73 }
74 }
75
76 u32 mUnk188; ///< @unused
77 dHeapAllocator_c mAllocator; ///< The allocator.
78 nw4r::g3d::ResFile mResFile; ///< The resource file.
79 m3d::smdl_c mModel; ///< The model.
80 m3d::anmChr_c mChrAnim[ANIM_COUNT]; ///< The model animations.
81 u32 mUnk250; ///< @unused
82 PROC_TYPE_e mCurrProc; ///< The current process type. See dWmObjActor_c::PROC_TYPE_e.
83
84 /// @brief The bone indices, resolved from #sGroupNodeNames.
85 /// @details A value of @p -1 indicates an unused or missing node.
86 int mGroupNodeIds[NODE_COUNT];
87 mSphere_c mCurrNodeClipSphere; ///< The sphere currently in use during per-node culling checks.
88 dWmBgmSync_c *mpBgmSync; ///< The background music synchronization helper.
89
90 /// @brief The bone names used for the culling mechanism.
91 /// @details Entries may be null, indicating unused slots.
92 /// @hideinitializer
93 static const char *sGroupNodeNames[NODE_COUNT];
94};
dWmObjActor_c()
Constructs a new object.
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.
ANIM_e
The available animations for this actor.
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.
The global configuration for the actor.
float mGroupNodeRadii[NODE_COUNT]
The culling radius for each bone.