NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ef_emitter.h
1#ifndef NW4R_EF_EMITTER_H
2#define NW4R_EF_EMITTER_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ef/ef_activitylist.h>
6#include <nw4r/ef/ef_animcurve.h>
7#include <nw4r/ef/ef_emitter.h>
8#include <nw4r/ef/ef_random.h>
9#include <nw4r/ef/ef_referencedobject.h>
10#include <nw4r/ef/ef_types.h>
11
12#include <nw4r/math.h>
13#include <nw4r/ut.h>
14
15namespace nw4r {
16namespace ef {
17
18// Forward declarations
19class ParticleManager;
20struct EmitterResource;
21class Effect;
22class EmitterForm;
23class Emitter;
24class Particle;
25
27 enum Flag {
28 FLAG_FOLLOW_EMIT = (1 << 0),
29 FLAG_INHERIT_ROT = (1 << 1),
30 };
31
32 s16 speed; // at 0x0
33 u8 scale; // at 0x2
34 u8 alpha; // at 0x3
35 u8 color; // at 0x4
36 u8 weight; // at 0x5
37 u8 type; // at 0x6
38 u8 flag; // at 0x7
39};
40
42public:
43 enum InheritFlag {
44 INHERIT_FLAG_SCALE = (1 << 0),
45 INHERIT_FLAG_ROT = (1 << 1)
46 };
47
48public:
49 ulong mComFlags; // at 0x0
50 ulong mEmitFlags; // at 0x4
51 f32 mEmitRatio; // at 0x8
52 f32 mEmitRandom; // at 0xC
53 u16 mEmitInterval; // at 0x10
54 u16 mEmitEmitDiv; // at 0x12
55 f32 mEmitIntervalRandom; // at 0x14
56 f32 mEmitCount; // at 0x18
57 u16 mEmitSpan; // at 0x1C
58 f32 mLODNear; // at 0x20
59 f32 mLODFar; // at 0x24
60 f32 mLODMinEmit; // at 0x28
61 f32 mParams[NUM_PARAMS]; // at 0x2C
62 u8 mInherit; // at 0x44
63 s8 mInheritTranslate; // at 0x45
64 s8 mVelInitVelocityRandom; // at 0x46
65 s8 mVelMomentumRandom; // at 0x47
66 f32 mVelPowerRadiationDir; // at 0x48
67 f32 mVelPowerYAxis; // at 0x4C
68 f32 mVelPowerRandomDir; // at 0x50
69 f32 mVelPowerNormalDir; // at 0x54
70 f32 mVelDiffusionEmitterNormal; // at 0x58
71 f32 mVelPowerSpecDir; // at 0x5C
72 f32 mVelDiffusionSpecDir; // at 0x60
73 math::VEC3 mVelSpecDir; // at 0x64
74 math::VEC3 mTranslate; // at 0x70
75 math::VEC3 mScale; // at 0x7C
76 math::VEC3 mRotate; // at 0x88
77};
78
79class Emitter : public ReferencedObject {
80 friend class Effect;
81
82public:
83 EmitterParameter mParameter; // at 0x20
84 EvaluateStatus mEvalStatus; // at 0xB4
85 EmitterResource* mResource; // at 0xB8
86 Effect* mManagerEF; // at 0xBC
87 ActivityList mActivityList; // at 0xC0
88 bool mIsFirstEmission; // at 0xDC
89 u16 mWaitTime; // at 0xDE
90 u16 mEmitIntervalWait; // at 0xE0
91 ulong mTick; // at 0xE4
92 u16 mCalcRemain; // at 0xE8
93 u16 mRandSeed; // at 0xEA
94 Random mRandom; // at 0xEC
95 EmitterForm* mForm; // at 0xF0
96 Emitter* mParent; // at 0xF4
97 Particle* mpReferenceParticle; // at 0xF8
98 EmitterInheritSetting mInheritSetting; // at 0xFC
99
100protected:
101 bool mMtxDirty; // at 0x104
102
103public:
104 math::MTX34 mMtx; // at 0x108
105
106public:
107 Emitter();
108 ~Emitter();
109
110 virtual void SendClosing(); // at 0x8
111 virtual void DestroyFunc(); // at 0xC
112
113 virtual bool Initialize(Effect* pParent, EmitterResource* pResource,
114 u8 drawWeight); // at 0x10
115
116 virtual Emitter* CreateEmitter(EmitterResource* pResource,
117 EmitterInheritSetting* pSetting,
118 Particle* pParticle,
119 u16 calcRemain); // at 0x14
120
121 virtual void CalcEmitter(); // at 0x18
122 virtual void CalcParticle(); // at 0x1C
123 virtual void CalcEmission(); // at 0x20
124 virtual void CalcBillboard(); // at 0x24
125
126 bool Closing(ParticleManager* pManager);
127
128 ulong RetireParticleAll();
129 ulong RetireParticleManager(ParticleManager* pManager);
130 ulong RetireParticleManagerAll();
131
132 void UpdateDatas(EmitterResource* pResource);
133 bool InitializeDatas(EmitterResource* pResource, Effect* pEffect);
134
135 void CreateEmitterTmp(EmitterResource* pResource,
136 EmitterInheritSetting* pSetting, Particle* pParticle,
137 u16 calcRemain);
138
139 ParticleManager* FindParticleManager(EmitterResource* pResource,
140 bool inheritS, bool inheritR,
141 s8 inheritT, u8 weight);
142
143 void Emission(ParticleManager* pManager, const math::MTX34* pSpace);
144
145 math::MTX34* CalcGlobalMtx(math::MTX34* pResult);
146 void SetMtxDirty();
147
148 u16 GetNumParticleManager() const;
149 ParticleManager* GetParticleManager(u16 idx);
150
151 ulong ForeachEmitter(ForEachFunc pFunc, ForEachParam param,
152 bool ignoreLifeStatus);
153 ulong ForeachParticleManager(ForEachFunc pFunc, ForEachParam param,
154 bool ignoreLifeStatus, bool propogate);
155
156 static math::MTX34* RestructMatrix(math::MTX34* pResult, math::MTX34* pOrig,
157 bool inheritS, bool inheritR,
158 s8 inheritT);
159
160 bool GetFlagDisableCalc() const {
161 return mParameter.mComFlags & EmitterDesc::CMN_FLAG_DISABLE_CALC;
162 }
163
164 void SetTranslate(const math::VEC3& rTrans) {
165 mParameter.mTranslate = rTrans;
166 }
167 void SetScale(const math::VEC3& rScale) {
168 mParameter.mScale = rScale;
169 }
170};
171
172} // namespace ef
173} // namespace nw4r
174
175#endif