NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_a_obj_fruit_tree.cpp
1#include <game/bases/d_a_obj_fruit_tree.hpp>
2#include <game/mLib/m_allocator_dummy_heap.hpp>
4#include <game/bases/d_s_stage.hpp>
5
6ACTOR_PROFILE(OBJ_FRUITTREE, daObjFruitTree_c, 0);
7
9 u32 param = mParam;
10
11 nw4r::g3d::ResMdl model;
12 nw4r::g3d::ResAnmChr anim;
13 nw4r::g3d::ResFile res;
14 mHeapAllocator.createFrmHeap(-1, mHeap::g_gameHeaps[0], nullptr, 0x20);
15
16 int style = ACTOR_PARAM_LOCAL(param, Style);
17 if (style == STYLE_REGULAR) {
18 res = dResMng_c::m_instance->getRes("fruits_kusa", "g3d/fruits_kusa.brres");
19 } else {
20 res = dResMng_c::m_instance->getRes("fruits_kusa_gake", "g3d/fruits_kusa_gake.brres");
21 }
22
23 mResFile = res;
24 if (style == STYLE_REGULAR) {
25 switch (ACTOR_PARAM_LOCAL(param, Size)) {
26 case SIZE_SMALL:
27 model = mResFile.GetResMdl("fruits_kusa_S");
28 break;
29
30 case SIZE_MEDIUM:
31 model = mResFile.GetResMdl("fruits_kusa_M");
32 break;
33
34 case SIZE_LARGE:
35 model = mResFile.GetResMdl("fruits_kusa_L");
36 break;
37
38 case SIZE_EXTRA_LARGE:
39 model = mResFile.GetResMdl("fruits_kusa_LL");
40 break;
41 }
42 } else {
43 switch (ACTOR_PARAM_LOCAL(param, Size)) {
44 case SIZE_SMALL:
45 model = mResFile.GetResMdl("fruits_kusa_gake_S");
46 break;
47
48 case SIZE_MEDIUM:
49 model = mResFile.GetResMdl("fruits_kusa_gake_M");
50 break;
51
52 case SIZE_LARGE:
53 model = mResFile.GetResMdl("fruits_kusa_gake_L");
54 break;
55
56 case SIZE_EXTRA_LARGE:
57 model = mResFile.GetResMdl("fruits_kusa_gake_LL");
58 break;
59 }
60 }
61
62 // [Bug: the actor's bounding box is not updated based on the bush size]
63 mBushModel.create(model, &mHeapAllocator, 0x20, 1);
65
66 if (style == STYLE_REGULAR) {
67 switch (ACTOR_PARAM_LOCAL(param, Size)) {
68 case SIZE_SMALL:
69 anim = mResFile.GetResAnmChr("fruits_kusa_S");
70 break;
71
72 case SIZE_MEDIUM:
73 anim = mResFile.GetResAnmChr("fruits_kusa_M");
74 break;
75
76 case SIZE_LARGE:
77 anim = mResFile.GetResAnmChr("fruits_kusa_L");
78 break;
79
80 case SIZE_EXTRA_LARGE:
81 anim = mResFile.GetResAnmChr("fruits_kusa_LL");
82 break;
83 }
84 } else {
85 switch (ACTOR_PARAM_LOCAL(param, Size)) {
86 case SIZE_SMALL:
87 anim = mResFile.GetResAnmChr("fruits_kusa_gake_S");
88 break;
89
90 case SIZE_MEDIUM:
91 anim = mResFile.GetResAnmChr("fruits_kusa_gake_M");
92 break;
93
94 case SIZE_LARGE:
95 anim = mResFile.GetResAnmChr("fruits_kusa_gake_L");
96 break;
97
98 case SIZE_EXTRA_LARGE:
99 anim = mResFile.GetResAnmChr("fruits_kusa_gake_LL");
100 break;
101 }
102 }
103
104 createBushAnim(model, anim);
106 mBushModel.setAnm(mBushAnim, 1.0f);
107 mBushAnim.setFrame(dScStage_c::m_exeFrame % (u32)mBushAnim.mFrameMax);
108 mHeapAllocator.adjustFrmHeap();
109 execute();
110
111 return SUCCEEDED;
112}
113
115 mBushModel.play();
116 return SUCCEEDED;
117}
118
120 mVec3_c pos = mPos;
121 mAng3_c rot = mAngle;
122 changePosAngle(&pos, &rot, 1);
123
124 if (mLayer == LAYER_1) {
125 pos.z = -200.0f;
126 } else {
127 pos.z = -3700.0f;
128 }
129
130 mMatrix.trans(pos.x, pos.y, pos.z);
131 mMatrix.YrotM(rot.y);
132 mMatrix.XrotM(rot.x);
133 mMatrix.ZrotM(rot.z);
134
135 mBushModel.setLocalMtx(&mMatrix);
136 mBushModel.setScale(mScale);
137 mBushModel.calc(false);
138 mBushModel.entry();
139
140 return SUCCEEDED;
141}
142
144 if (mHeapAllocator.mpHeap != mAllocatorDummyHeap_c::getInstance()) {
145 mBushModel.remove();
146 }
147
148 return SUCCEEDED;
149}
static void setSoftLight_MapObj(m3d::bmdl_c &mdl)
Sets the soft light effect for map objects.
Definition d_actor.cpp:333
static void changePosAngle(mVec3_c *pos, mAng3_c *ang, int param3)
Adjusts the actor's position to account for looping stages.
Definition d_actor.cpp:297
u8 mLayer
The actor's layer.
Definition d_actor.hpp:377
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).
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:61
A decorative leafy bush used for Yoshi fruits.
nw4r::g3d::ResFile mResFile
The resource file.
virtual int create()
do method for the create operation.
m3d::anmChr_c mBushAnim
The bush model animation.
@ STYLE_REGULAR
The regular bush style.
virtual int doDelete()
do method for the delete operation.
virtual int draw()
do method for the draw operation.
m3d::mdl_c mBushModel
The bush model.
dHeapAllocator_c mHeapAllocator
The allocator.
virtual int execute()
do method for the execute operation.
u32 mParam
A bitfield that configures the base's behaviour. Its usage varies from profile to profile.
Definition f_base.hpp:61
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:45
A three-dimensional short angle vector.
Definition m_angle.hpp:59
mAng y
The rotation on the Y axis.
Definition m_angle.hpp:109
mAng z
The rotation on the Z axis.
Definition m_angle.hpp:110
mAng x
The rotation on the X axis.
Definition m_angle.hpp:108
A three-dimensional floating point vector.
Definition m_vec.hpp:107
#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
@ FORWARD_LOOP
Play the animation forward in a loop.
Definition banm.hpp:8