Torque3D Documentation / _generateds / afxParticleEmitter.h

afxParticleEmitter.h

Engine/source/afx/ce/afxParticleEmitter.h

More...

Classes:

Public Typedefs

afxParticleEmitterPath_OriginType 

Detailed Description

Public Typedefs

typedef afxParticleEmitterPathData::PathOriginType afxParticleEmitterPath_OriginType 

Public Functions

DefineEnumType(afxParticleEmitterPath_OriginType )

  1
  2
  3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  5// Copyright (C) 2015 Faust Logic, Inc.
  6//
  7// Permission is hereby granted, free of charge, to any person obtaining a copy
  8// of this software and associated documentation files (the "Software"), to
  9// deal in the Software without restriction, including without limitation the
 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 11// sell copies of the Software, and to permit persons to whom the Software is
 12// furnished to do so, subject to the following conditions:
 13//
 14// The above copyright notice and this permission notice shall be included in
 15// all copies or substantial portions of the Software.
 16//
 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 23// IN THE SOFTWARE.
 24//
 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 26
 27#ifndef _AFX_EMITTER_PARTICLE_H_
 28#define _AFX_EMITTER_PARTICLE_H_
 29
 30#include "T3D/fx/particleEmitter.h"
 31
 32class afxPathData;
 33class afxPath3D;
 34
 35class afxParticleEmitterData : public ParticleEmitterData
 36{
 37  typedef ParticleEmitterData Parent;
 38
 39public:
 40  // The afx enhanced particle emitter allows fading
 41  // of particle color, size, velocity, and/or offset.
 42  // Fading is controlled by a common value which is
 43  // set externally using setFadeAmount().
 44  //
 45  bool        fade_velocity;
 46  bool        fade_offset;
 47  Point3F     pe_vector;
 48  // new -- consider vector in world space?
 49  bool        pe_vector_is_world;
 50
 51  // new -- transform paths?
 52  StringTableEntry      tpaths_string;       // 
 53  Vector<afxPathData*>  tPathDataBlocks;     // datablocks for paths
 54  Vector<U32>           tPathDataBlockIds;   // datablock IDs which correspond to the pathDataBlocks
 55
 56public:
 57  /*C*/       afxParticleEmitterData();
 58  /*C*/       afxParticleEmitterData(const afxParticleEmitterData&, bool = false);
 59
 60  void        packData(BitStream* stream);
 61  void        unpackData(BitStream* stream);
 62  bool        onAdd();
 63
 64  bool        preload(bool server, String &errorStr);
 65
 66  virtual bool allowSubstitutions() const { return true; }
 67
 68  static void initPersistFields();
 69
 70  DECLARE_CONOBJECT(afxParticleEmitterData);
 71  DECLARE_CATEGORY("AFX");
 72};
 73
 74//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 75// VECTOR
 76
 77class afxParticleEmitterVectorData : public afxParticleEmitterData
 78{
 79  typedef afxParticleEmitterData Parent;
 80
 81public:
 82  /*C*/       afxParticleEmitterVectorData();
 83  /*C*/       afxParticleEmitterVectorData(const afxParticleEmitterVectorData&, bool = false);
 84
 85  void        packData(BitStream* stream);
 86  void        unpackData(BitStream* stream);
 87  bool        onAdd();
 88
 89  bool        preload(bool server, String &errorStr);
 90
 91  virtual bool allowSubstitutions() const { return true; }
 92
 93  static void initPersistFields();
 94
 95  DECLARE_CONOBJECT(afxParticleEmitterVectorData);
 96  DECLARE_CATEGORY("AFX");
 97};
 98
 99//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
100// CONE
101
102class afxParticleEmitterConeData : public afxParticleEmitterData
103{
104  typedef afxParticleEmitterData Parent;
105
106public:
107  F32         spread_min;
108  F32         spread_max;
109
110public:
111  /*C*/       afxParticleEmitterConeData();
112  /*C*/       afxParticleEmitterConeData(const afxParticleEmitterConeData&, bool = false);
113
114  void        packData(BitStream* stream);
115  void        unpackData(BitStream* stream);
116  bool        onAdd();
117
118  bool        preload(bool server, String &errorStr);
119
120  virtual bool allowSubstitutions() const { return true; }
121
122  static void initPersistFields();
123
124  DECLARE_CONOBJECT(afxParticleEmitterConeData);
125  DECLARE_CATEGORY("AFX");
126};
127
128//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
129// PATH
130
131class afxParticleEmitterPathData : public afxParticleEmitterData
132{
133  typedef afxParticleEmitterData Parent;
134
135public:
136  enum PathOriginType 
137  {
138    PATHEMIT_ORIGIN,
139    PATHEMIT_POINT,
140    PATHEMIT_VECTOR,
141    PATHEMIT_TANGENT
142  };   
143  StringTableEntry      epaths_string;       // 
144  Vector<afxPathData*>  epathDataBlocks;     // datablocks for paths
145  Vector<U32>           epathDataBlockIds;   // datablock IDs which correspond to the pathDataBlocks
146  U32                   path_origin_type;
147
148  bool                  ground_conform;
149  bool                  ground_conform_terrain;
150  bool                  ground_conform_interiors;
151  F32                   ground_conform_height;
152
153public:
154  /*C*/                 afxParticleEmitterPathData();
155  /*C*/                 afxParticleEmitterPathData(const afxParticleEmitterPathData&, bool = false);
156
157  void                  packData(BitStream* stream);
158  void                  unpackData(BitStream* stream);
159  bool                  onAdd();
160
161  bool                  preload(bool server, String &errorStr);
162
163  virtual void          onPerformSubstitutions();
164  virtual bool          allowSubstitutions() const { return true; }
165
166  static void           initPersistFields();
167
168  DECLARE_CONOBJECT(afxParticleEmitterPathData);
169  DECLARE_CATEGORY("AFX");
170};
171
172typedef afxParticleEmitterPathData::PathOriginType afxParticleEmitterPath_OriginType;
173DefineEnumType( afxParticleEmitterPath_OriginType );
174
175//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
176// DISC
177
178class afxParticleEmitterDiscData : public afxParticleEmitterData
179{
180  typedef afxParticleEmitterData Parent;
181
182public:
183  F32                   pe_radius_min;
184  F32                   pe_radius_max;
185
186public:
187  /*C*/                 afxParticleEmitterDiscData();
188  /*C*/                 afxParticleEmitterDiscData(const afxParticleEmitterDiscData&, bool = false);
189
190  void                  packData(BitStream* stream);
191  void                  unpackData(BitStream* stream);
192  bool                  onAdd();
193
194  bool                  preload(bool server, String &errorStr);
195
196  virtual bool          allowSubstitutions() const { return true; }
197
198  static void           initPersistFields();
199
200  DECLARE_CONOBJECT(afxParticleEmitterDiscData);
201  DECLARE_CATEGORY("AFX");
202};
203
204//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
205//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
206
207class afxParticleEmitter : public ParticleEmitter
208{
209  typedef ParticleEmitter Parent;
210
211private:
212  afxParticleEmitterData* mDataBlock;
213
214protected:
215  Point3F       pe_vector, pe_vector_norm;
216
217  // these go with the "pathsTransform" field
218  Vector<afxPath3D*> tpaths;
219  Vector<F32>        tpath_mults;
220  U32                n_tpath_points;
221  Point3F**          tpath_points;
222
223  const SimObject*   afx_owner; 
224
225  void          init_paths();
226  void          cleanup_paths();
227
228  Particle*     alloc_particle();
229  ParticleData* pick_particle_type();
230  void          afx_emitParticles(const Point3F& point, const bool useLastPosition, const Point3F& velocity, const U32 numMilliseconds);
231  void          afx_emitParticles(const Point3F& start, const Point3F& end, const Point3F& velocity, const U32 numMilliseconds);
232  void          preCompute(const MatrixF& mat);
233
234  virtual void  sub_particleUpdate(Particle*);
235  virtual void  sub_preCompute(const MatrixF& mat)=0;
236  virtual void  sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx)=0;
237
238public:
239  /*C*/         afxParticleEmitter();
240  /*D*/         ~afxParticleEmitter();
241
242  virtual void  emitParticlesExt(const MatrixF& xfm, const Point3F& point, const Point3F& velocity, const U32 numMilliseconds);
243
244  afxParticleEmitterData* getDataBlock(){ return mDataBlock; }
245  void          setAFXOwner(const SimObject* owner) { afx_owner = owner; }
246  bool          onNewDataBlock(GameBaseData* dptr, bool reload);
247  bool          onAdd();
248  void          onRemove();
249};
250
251//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
252// VECTOR
253
254class afxParticleEmitterVector : public afxParticleEmitter
255{
256  typedef afxParticleEmitter Parent;
257
258private:
259  afxParticleEmitterVectorData* mDataBlock;
260
261public:
262  /*C*/       afxParticleEmitterVector();
263  /*D*/       ~afxParticleEmitterVector();
264
265  bool        onNewDataBlock(GameBaseData* dptr, bool reload);
266
267protected:
268  void        sub_preCompute(const MatrixF& mat);
269  void        sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offse, S32 part_idxt);
270};
271
272//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
273// CONE
274
275class afxParticleEmitterCone : public afxParticleEmitter
276{
277  typedef afxParticleEmitter Parent;
278
279private:
280  afxParticleEmitterData* mDataBlock;
281  Point3F     cone_v, cone_s0, cone_s1;
282
283public:
284  /*C*/       afxParticleEmitterCone();
285  /*D*/       ~afxParticleEmitterCone();
286
287  bool        onNewDataBlock(GameBaseData* dptr, bool reload);
288
289protected:
290  void        sub_preCompute(const MatrixF& mat);
291  void        sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx);
292};
293
294//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
295// PATH
296
297class afxParticleEmitterPath : public afxParticleEmitter
298{
299  typedef afxParticleEmitter Parent;
300
301private:
302  afxParticleEmitterPathData* mDataBlock;
303
304  Vector<afxPath3D*> epaths;
305  Vector<F32>        epath_mults;
306  U32                n_epath_points;
307  Point3F**          epath_points;
308
309  void               init_paths();
310  void               cleanup_paths();
311
312  void               groundConformPoint(Point3F& point, const MatrixF& mat);
313
314public:
315  /*C*/       afxParticleEmitterPath();
316  /*D*/       ~afxParticleEmitterPath();
317
318  bool        onNewDataBlock(GameBaseData* dptr, bool reload);
319
320protected:
321  bool        onAdd();
322  void        onRemove();
323  void        sub_preCompute(const MatrixF& mat);
324  void        sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx);
325};
326
327//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
328// DISC
329
330class afxParticleEmitterDisc : public afxParticleEmitter
331{
332  typedef afxParticleEmitter Parent;
333
334private:
335  afxParticleEmitterDiscData* mDataBlock;
336  Point3F     disc_v, disc_r;
337
338public:
339  /*C*/       afxParticleEmitterDisc();
340  /*D*/       ~afxParticleEmitterDisc();
341
342  bool        onNewDataBlock(GameBaseData* dptr, bool reload);
343
344protected:
345  void        sub_preCompute(const MatrixF& mat);
346  void        sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx);
347};
348
349//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
350
351#endif // _AFX_EMITTER_PARTICLE_H_
352