Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
CParticleEmitter Class Reference

Particle emitter. More...

#include <ParticleEmitter.h>

Public Member Functions

 CParticleEmitter (const CParticleEmitterTypePtr &type)
 
void SetPosition (const CVector3D &pos)
 Set the position to be used for emission of new particles. More...
 
CVector3D GetPosition () const
 
CBoundingBoxAligned GetParticleBounds ()
 Get the bounding box of the center points of particles at their current positions. More...
 
void AddParticle (const SParticle &particle)
 Push a new particle onto the ring buffer. More...
 
void UpdateArrayData ()
 Update particle and vertex array data. More...
 
void Bind (const CShaderProgramPtr &shader)
 Bind rendering state (textures and blend modes). More...
 
void RenderArray (const CShaderProgramPtr &shader)
 Draw the vertex array. More...
 
void Unattach (const CParticleEmitterPtr &self)
 Stop this emitter emitting new particles, and pass responsibility for rendering to the CParticleManager. More...
 
void SetEntityVariable (const std::string &name, float value)
 

Public Attributes

CParticleEmitterTypePtr m_Type
 
bool m_Active
 Whether this emitter is still emitting new particles. More...
 
CVector3D m_Pos
 
std::map< std::string, float > m_EntityVariables
 
std::vector< SParticlem_Particles
 
size_t m_NextParticleIdx
 
float m_LastUpdateTime
 
float m_EmissionRoundingError
 

Private Attributes

CBoundingBoxAligned m_ParticleBounds
 Bounding box of the current particle center points. More...
 
VertexIndexArray m_IndexArray
 
VertexArray m_VertexArray
 
VertexArray::Attribute m_AttributePos
 
VertexArray::Attribute m_AttributeAxis
 
VertexArray::Attribute m_AttributeUV
 
VertexArray::Attribute m_AttributeColor
 

Detailed Description

Particle emitter.

Emitters store particle data in two forms:

The number of particles is a constant for the entire life of the emitter, to simplify the updating and rendering. m_Particles acts like a ring buffer, so we don't have to worry about dynamically allocating particles. If particles have variable lifetimes, they'll exist in the array with alpha=0 until they're overwritten by a new particle after the maximum lifetime.

(It's quite likely this could be made more efficient, if the overhead of any added complexity is not high.)

Definition at line 65 of file ParticleEmitter.h.

Constructor & Destructor Documentation

CParticleEmitter::CParticleEmitter ( const CParticleEmitterTypePtr type)

Definition at line 30 of file ParticleEmitter.cpp.

Member Function Documentation

void CParticleEmitter::AddParticle ( const SParticle particle)

Push a new particle onto the ring buffer.

(May overwrite an old particle.)

Definition at line 217 of file ParticleEmitter.cpp.

void CParticleEmitter::Bind ( const CShaderProgramPtr shader)

Bind rendering state (textures and blend modes).

Definition at line 167 of file ParticleEmitter.cpp.

CBoundingBoxAligned CParticleEmitter::GetParticleBounds ( )
inline

Get the bounding box of the center points of particles at their current positions.

Definition at line 86 of file ParticleEmitter.h.

CVector3D CParticleEmitter::GetPosition ( ) const
inline

Definition at line 78 of file ParticleEmitter.h.

void CParticleEmitter::RenderArray ( const CShaderProgramPtr shader)

Draw the vertex array.

Definition at line 183 of file ParticleEmitter.cpp.

void CParticleEmitter::SetEntityVariable ( const std::string &  name,
float  value 
)

Definition at line 227 of file ParticleEmitter.cpp.

void CParticleEmitter::SetPosition ( const CVector3D pos)
inline

Set the position to be used for emission of new particles.

Definition at line 73 of file ParticleEmitter.h.

void CParticleEmitter::Unattach ( const CParticleEmitterPtr self)

Stop this emitter emitting new particles, and pass responsibility for rendering to the CParticleManager.

This should be called before dropping the last shared_ptr to this object so that it will carry on rendering (until all particles have dissipated) even when it's no longer attached to a model.

Parameters
selfthe shared_ptr you're about to drop

Definition at line 211 of file ParticleEmitter.cpp.

void CParticleEmitter::UpdateArrayData ( )

Update particle and vertex array data.

Must be called before RenderArray.

Definition at line 83 of file ParticleEmitter.cpp.

Member Data Documentation

bool CParticleEmitter::m_Active

Whether this emitter is still emitting new particles.

Definition at line 122 of file ParticleEmitter.h.

VertexArray::Attribute CParticleEmitter::m_AttributeAxis
private

Definition at line 142 of file ParticleEmitter.h.

VertexArray::Attribute CParticleEmitter::m_AttributeColor
private

Definition at line 144 of file ParticleEmitter.h.

VertexArray::Attribute CParticleEmitter::m_AttributePos
private

Definition at line 141 of file ParticleEmitter.h.

VertexArray::Attribute CParticleEmitter::m_AttributeUV
private

Definition at line 143 of file ParticleEmitter.h.

float CParticleEmitter::m_EmissionRoundingError

Definition at line 132 of file ParticleEmitter.h.

std::map<std::string, float> CParticleEmitter::m_EntityVariables

Definition at line 126 of file ParticleEmitter.h.

VertexIndexArray CParticleEmitter::m_IndexArray
private

Definition at line 138 of file ParticleEmitter.h.

float CParticleEmitter::m_LastUpdateTime

Definition at line 131 of file ParticleEmitter.h.

size_t CParticleEmitter::m_NextParticleIdx

Definition at line 129 of file ParticleEmitter.h.

CBoundingBoxAligned CParticleEmitter::m_ParticleBounds
private

Bounding box of the current particle center points.

Definition at line 136 of file ParticleEmitter.h.

std::vector<SParticle> CParticleEmitter::m_Particles

Definition at line 128 of file ParticleEmitter.h.

CVector3D CParticleEmitter::m_Pos

Definition at line 124 of file ParticleEmitter.h.

CParticleEmitterTypePtr CParticleEmitter::m_Type

Definition at line 119 of file ParticleEmitter.h.

VertexArray CParticleEmitter::m_VertexArray
private

Definition at line 140 of file ParticleEmitter.h.


The documentation for this class was generated from the following files: