Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticleEmitterType.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_PARTICLEEMITTERTYPE
19 #define INCLUDED_PARTICLEEMITTERTYPE
20 
21 #include "graphics/Texture.h"
22 #include "lib/ogl.h"
23 #include "lib/file/vfs/vfs_path.h"
25 
26 class CVector3D;
27 class CParticleEmitter;
28 class CParticleManager;
29 class IParticleVar;
30 class IParticleEffector;
31 
32 /**
33  * Particle emitter type - stores the common state data for all emitters of that
34  * type, and uses that data to update the emitter states.
35  *
36  * The data is initialised from XML files.
37  *
38  * Most of the emitter type data is represented as subclasses of IParticleVar,
39  * which will typically return a constant value or a random value each time it's
40  * evaluated. New subclasses can be added to support different random distributions,
41  * etc.
42  */
44 {
45  NONCOPYABLE(CParticleEmitterType); // reference member
46 public:
47  CParticleEmitterType(const VfsPath& path, CParticleManager& manager);
48 
49 private:
50  friend class CModelParticleEmitter;
51  friend class CParticleEmitter;
52  friend class CParticleVarConstant;
53  friend class CParticleVarUniform;
54  friend class CParticleVarCopy;
55  friend class ParticleRenderer;
56 
57  enum
58  {
74  };
75 
76  int GetVariableID(const std::string& name);
77 
78  bool LoadXML(const VfsPath& path);
79 
80  /**
81  * Update the state of an emitter's particles, by a potentially long time @p dt.
82  */
83  void UpdateEmitter(CParticleEmitter& emitter, float dt);
84 
85  /**
86  * Update the state of an emitter's particles, by a short time @p dt that can
87  * be computed in a single step.
88  */
89  void UpdateEmitterStep(CParticleEmitter& emitter, float dt);
90 
92 
94 
99 
103 
104  typedef shared_ptr<IParticleVar> IParticleVarPtr;
105  std::vector<IParticleVarPtr> m_Variables;
106 
107  typedef shared_ptr<IParticleEffector> IParticleEffectorPtr;
108  std::vector<IParticleEffectorPtr> m_Effectors;
109 
111 };
112 
113 typedef shared_ptr<CParticleEmitterType> CParticleEmitterTypePtr;
114 
115 #endif // INCLUDED_PARTICLEEMITTERTYPE
shared_ptr< IParticleEffector > IParticleEffectorPtr
Particle variable that returns a constant value.
Particle emitter.
Particle emitter type - stores the common state data for all emitters of that type, and uses that data to update the emitter states.
shared_ptr< CParticleEmitterType > CParticleEmitterTypePtr
Particle variable that returns a uniformly-distributed random value.
void UpdateEmitterStep(CParticleEmitter &emitter, float dt)
Update the state of an emitter&#39;s particles, by a short time dt that can be computed in a single step...
Interface for particle effectors, which get evaluated every frame to update particles.
Render particles.
shared_ptr< IParticleVar > IParticleVarPtr
CBoundingBoxAligned CalculateBounds(CVector3D emitterPos, CBoundingBoxAligned emittedBounds)
void UpdateEmitter(CParticleEmitter &emitter, float dt)
Update the state of an emitter&#39;s particles, by a potentially long time dt.
Definition: path.h:75
Interface for particle state variables, which get evaluated for each newly constructed particle...
NONCOPYABLE(CParticleEmitterType)
CParticleManager & m_Manager
CBoundingBoxAligned m_MaxBounds
Particle variable that returns the same value as some other variable (assuming that variable was eval...
CParticleEmitterType(const VfsPath &path, CParticleManager &manager)
std::vector< IParticleEffectorPtr > m_Effectors
Particle emitter model, for attaching emitters as props on other models.
std::vector< IParticleVarPtr > m_Variables
int GetVariableID(const std::string &name)
bool LoadXML(const VfsPath &path)
shared_ptr< CTexture > CTexturePtr
Definition: Texture.h:22