1 /* Copyright (C) 2011 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
18 #ifndef INCLUDED_PARTICLEEMITTERTYPE
19 #define INCLUDED_PARTICLEEMITTERTYPE
21 #include "graphics/Texture.h"
23 #include "lib/file/vfs/vfs_path.h"
24 #include "maths/BoundingBoxAligned.h"
27 class CParticleEmitter
;
28 class CParticleManager
;
30 class IParticleEffector
;
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.
36 * The data is initialised from XML files.
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,
43 class CParticleEmitterType
45 NONCOPYABLE(CParticleEmitterType
); // reference member
47 CParticleEmitterType(const VfsPath
& path
, CParticleManager
& manager
);
50 friend class CModelParticleEmitter
;
51 friend class CParticleEmitter
;
52 friend class CParticleVarConstant
;
53 friend class CParticleVarUniform
;
54 friend class CParticleVarCopy
;
55 friend class ParticleRenderer
;
77 int GetVariableID(const std::string
& name
);
79 bool LoadXML(const VfsPath
& path
);
82 * Update the state of an emitter's particles, by a potentially long time @p dt.
84 void UpdateEmitter(CParticleEmitter
& emitter
, float dt
);
87 * Update the state of an emitter's particles, by a short time @p dt that can
88 * be computed in a single step.
90 void UpdateEmitterStep(CParticleEmitter
& emitter
, float dt
);
92 CBoundingBoxAligned
CalculateBounds(CVector3D emitterPos
, CBoundingBoxAligned emittedBounds
);
94 CTexturePtr m_Texture
;
96 GLenum m_BlendEquation
;
97 GLenum m_BlendFuncSrc
;
98 GLenum m_BlendFuncDst
;
100 bool m_UseRelativeVelocity
;
103 size_t m_MaxParticles
;
104 CBoundingBoxAligned m_MaxBounds
;
106 typedef shared_ptr
<IParticleVar
> IParticleVarPtr
;
107 std::vector
<IParticleVarPtr
> m_Variables
;
109 typedef shared_ptr
<IParticleEffector
> IParticleEffectorPtr
;
110 std::vector
<IParticleEffectorPtr
> m_Effectors
;
112 CParticleManager
& m_Manager
;
115 typedef shared_ptr
<CParticleEmitterType
> CParticleEmitterTypePtr
;
117 #endif // INCLUDED_PARTICLEEMITTERTYPE