NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ef_particlemanager.h
1#ifndef NW4R_EF_PARTICLE_MANAGER_H
2#define NW4R_EF_PARTICLE_MANAGER_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ef/ef_activitylist.h>
6#include <nw4r/ef/ef_referencedobject.h>
7#include <nw4r/ef/ef_res_emitter.h>
8
9#include <nw4r/math.h>
10#include <nw4r/ut.h>
11
12namespace nw4r {
13namespace ef {
14
15// Forward declarations
16class DrawInfo;
17class DrawStrategy;
18class Emitter;
20struct EmitterResource;
21class Particle;
22
23class ParticleManager : public ReferencedObject {
24public:
25 enum Flag {
26 FLAG_MTX_INHERIT_SCALE = (1 << 0),
27 FLAG_MTX_INHERIT_ROT = (1 << 1),
28 };
29
31 enum SimpleLightType {
32 SIMPLELIGHT_OFF,
33 SIMPLELIGHT_AMBIENT,
34 SIMPLELIGHT_DIFFUSE
35 };
36
37 struct SimpleLight {
38 u8 mType; // at 0x0
39 GXColor mAmbient; // at 0x1
40 GXColor mDiffuse; // at 0x5
41 f32 mRadius; // at 0xC
42 math::VEC3 mPosition; // at 0x10
43 };
44
45 math::VEC2 mScale; // at 0x0
46 math::VEC3 mRotate; // at 0x8
47 SimpleLight mLight; // at 0x14
48 };
49
50public:
51 Emitter* mManagerEM; // at 0x20
52 EmitterResource* mResource; // at 0x24
53 ulong mFlag; // at 0x28
54 DrawStrategy* mDrawStrategy; // at 0x2C
55 ut::Link mDrawOrderLink; // at 0x30
56 ActivityList mActivityList; // at 0x38
57 Particle* mLastCalced; // at 0x54
58 ParticleModifier mModifier; // at 0x58
59 s8 mInheritTranslate; // at 0x88
60 u8 mWeight; // at 0x89
61
62protected:
63 bool mMtxDirty; // at 0x8A
64
65public:
66 math::MTX34 mMtx; // at 0x8C
67
68 static math::MTX34 smDrawMtxPMtoEM;
69 static math::MTX34 smMtxInv;
70 static s32 smMtxInvId;
71
72public:
73 ParticleManager();
74 ~ParticleManager();
75
76 virtual void SendClosing(); // at 0x8
77 virtual void DestroyFunc(); // at 0xC
78
79 virtual bool Initialize(Emitter* pParent,
80 EmitterResource* pResource); // at 0x10
81
82 virtual Particle* CreateParticle(u16 life, math::VEC3 pos, math::VEC3 vel,
83 const math::MTX34* pSpace, f32 momentum,
84 const EmitterInheritSetting* pSetting,
85 Particle* pReferencePtcl,
86 u16 calcRemain); // at 0x14
87
88 virtual void Calc(); // at 0x18
89 virtual void Draw(const DrawInfo& rInfo); // at 0x1C
90
91 bool Closing(Particle* pParticle);
92
93 int RetireParticle(Particle* pParticle);
94 int RetireParticleAll();
95
96 math::MTX34* CalcGlobalMtx(math::MTX34* pResult);
97
98 void BeginCalc(bool remainOnly);
99 void EndCalc();
100
101 void BeginDraw();
102 void EndDraw();
103
104 const math::MTX34* Draw_GetMtxPMtoEM() const;
105
106 void Draw_ModifyColor(Particle* pParticle, GXColor* pColorPri,
107 GXColor* pColorSec);
108
109 f32 Draw_ModifyScaleX(Particle* /* pParticle */, f32 sx) {
110 return sx * mModifier.mScale.x;
111 }
112 f32 Draw_ModifyScaleY(Particle* /* pParticle */, f32 sy) {
113 return sy * mModifier.mScale.y;
114 }
115
116 void Draw_ModifyRotate(Particle* /* pParticle */, math::VEC3* pRot) {
117 pRot->x += mModifier.mRotate.x;
118 pRot->y += mModifier.mRotate.y;
119 pRot->z += mModifier.mRotate.z;
120 }
121
122 void Modifier_SetSimpleLightParameter(const EmitterDrawSetting& rSetting) {
123 Modifier_SetSimpleLightParameter(
124 rSetting.mLighting.mType, rSetting.mLighting.mAmbient,
125 rSetting.mLighting.mDiffuse, rSetting.mLighting.mRadius,
126 rSetting.mLighting.mPosition);
127 }
128
129 void Modifier_SetSimpleLightParameter(u8 type, const GXColor& rAmbient,
130 const GXColor& rDiffuse, f32 radius,
131 const math::VEC3& rPos) {
132 mModifier.mLight.mType = type;
133 mModifier.mLight.mAmbient = rAmbient;
134 mModifier.mLight.mDiffuse = rDiffuse;
135 mModifier.mLight.mRadius = radius;
136 mModifier.mLight.mPosition = rPos;
137 }
138
139 ActivityList* GetParticleList() {
140 return &mActivityList;
141 }
142
143 void ParticleToFree(Particle* pParticle) {
144 mActivityList.ToFree(pParticle);
145 }
146
147 void SetMtxDirty() {
148 mMtxDirty = true;
149 }
150
151 static void ModifierTravFunc_SetSimpleLightType(void* pObject,
152 ForEachParam param) {
153
154 static_cast<ParticleManager*>(pObject)->mModifier.mLight.mType =
155 static_cast<u8>(param);
156 }
157
158 static void ModifierTravFunc_SetSimpleLightAmbient(void* pObject,
159 ForEachParam param) {
160
161 static_cast<ParticleManager*>(pObject)->mModifier.mLight.mAmbient =
162 *reinterpret_cast<GXColor*>(param);
163 }
164
165 static void ModifierTravFunc_SetScale(void* pObject, ForEachParam param) {
166 static_cast<ParticleManager*>(pObject)->mModifier.mScale =
167 *reinterpret_cast<math::VEC2*>(param);
168 }
169
170 static void ModifierTravFunc_SetRotate(void* pObject, ForEachParam param) {
171 static_cast<ParticleManager*>(pObject)->mModifier.mRotate =
172 *reinterpret_cast<math::VEC3*>(param);
173 }
174};
175
176} // namespace ef
177} // namespace nw4r
178
179#endif