18 #include "precompiled.h"
31 m_Type(type), m_Active(true), m_NextParticleIdx(0), m_EmissionRoundingError(0.f),
32 m_LastUpdateTime(type->m_Manager.GetCurrentTime()),
33 m_IndexArray(GL_DYNAMIC_DRAW),
34 m_VertexArray(GL_DYNAMIC_DRAW)
70 for (
size_t i = 0; i <
m_Type->m_MaxParticles; ++i)
149 if (
m_Type->m_BlendFuncDst == GL_ONE_MINUS_SRC_COLOR)
151 color.
R = (color.
R * color.
A) / 255;
152 color.
G = (color.
G * color.
A) / 255;
153 color.
B = (color.
B * color.
A) / 255;
156 *attrColor++ = color;
157 *attrColor++ = color;
158 *attrColor++ = color;
159 *attrColor++ = color;
174 shader->Uniform(str_sunColor, lightEnv.
m_SunColor);
175 shader->Uniform(str_fogColor, lightEnv.
m_FogColor);
178 shader->BindTexture(str_baseTex,
m_Type->m_Texture);
179 pglBlendEquationEXT(
m_Type->m_BlendEquation);
180 glBlendFunc(
m_Type->m_BlendFuncSrc,
m_Type->m_BlendFuncDst);
204 shader->AssertPointersBound();
205 glDrawElements(GL_TRIANGLES, (GLsizei)(
m_Particles.size() * 6), GL_UNSIGNED_SHORT, indexBase);
214 m_Type->m_Manager.AddUnattachedEmitter(
self);
247 m_Emitter->SetEntityVariable(name, value);
void Unattach(const CParticleEmitterPtr &self)
Stop this emitter emitting new particles, and pass responsibility for rendering to the CParticleManag...
virtual void SetTransform(const CMatrix3D &transform)
CParticleEmitterPtr m_Emitter
bool m_Active
Whether this emitter is still emitting new particles.
void UpdateArrayData()
Update particle and vertex array data.
VertexArrayIterator< u16 > GetIterator() const
Gets the iterator over the (only) attribute in this array, i.e. a u16.
shared_ptr< CParticleEmitterType > CParticleEmitterTypePtr
CModelParticleEmitter(const CParticleEmitterTypePtr &type)
GLuint GetTextureSmooth()
void AddParticle(const SParticle &particle)
Push a new particle onto the ring buffer.
virtual CModelAbstract * Clone() const
void AddAttribute(Attribute *attr)
std::vector< SParticle > m_Particles
void RenderArray(const CShaderProgramPtr &shader)
Draw the vertex array.
shared_ptr< CParticleEmitter > CParticleEmitterPtr
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
CBoundingBoxAligned m_WorldBounds
World-space bounds of this object.
virtual void InvalidatePosition()
Mark this model's position and bone matrices, and all props' positions as invalid.
void Bind(const CShaderProgramPtr &shader)
Bind rendering state (textures and blend modes).
VertexArray m_VertexArray
VertexArray::Attribute m_AttributeAxis
VertexArray::Attribute m_AttributeUV
VertexArray::Attribute m_AttributeColor
void SetNumVertices(size_t num)
virtual void SetEntityVariable(const std::string &name, float value)
Called when the entity tries to set some variable to affect the display of this model and/or its chil...
VertexArrayIterator< T > GetIterator() const
VertexIndexArray m_IndexArray
virtual void ValidatePosition()
Ensure that both the transformation and the bone matrices are correct for this model and all its prop...
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
virtual void InvalidateBounds()
Marks the bounds as invalid.
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap...
CBoundingBoxAligned m_ParticleBounds
Bounding box of the current particle center points.
std::map< std::string, float > m_EntityVariables
const CMatrix3D & GetTextureMatrix()
Returns a matrix to map (x,y,z) world coordinates onto (u,v) LOS texture coordinates, in the form expected by glLoadMatrixf.
virtual void CalcBounds()
(Re)calculates and stores any bounds or bound-dependent data for this object.
CVector3D GetTranslation() const
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
shared_ptr< CShaderProgram > CShaderProgramPtr
VertexArray::Attribute m_AttributePos
Simulation state for a single particle.
CParticleEmitter(const CParticleEmitterTypePtr &type)
CParticleEmitterTypePtr m_Type
CParticleEmitterTypePtr m_Type
void SetEntityVariable(const std::string &name, float value)