Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base > Class Template Reference

Inheritance diagram for ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
class ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >

manages emission, initialization and processing of particles

The emitter holds a pool of MAX_P particles of type PartT. A varying number of these are considered active, the rest is considered dead and will not be processed until the active count is increased.
This template accepts a number of policies that control particle and emitter behavior and allow easy creation of a wide range of different particle systems with little or no overhead. These policies enrich the interface, i.e. they may be used to add functions to the emitter class that may be called from the outside.
Many of the policies will make assumptions about the used particle type. See those policies' documentation for details. If the intended particle class does not meet the requirements it must either be extended in an appropriate way or a custom policy must be created.

Parameters:
Heir the inheriting class
MAX_P the maximum number of particles this emitter can handle at the same time. Note that this many particles are always pooled, regardless of the number of active particles.
PartT the handled particle type. This may be any appropriate type including ParticleEmitter s. The particle class must at least provide a getTTL function that returns the time to the particle's death. This should usually be the remaining life time in seconds, however, this class only assumes that particles with a TTL less or equal to zero are dead.
EmissionPolicy controls the number of particles emitted each time process is called. The policy must provide a getEmissionCount function that accepts the time since the last frame (aka deltaT) and returns the number of particles to be emitted during that time.
InitPolicy handles particle initialization. This policy must provide a void init function that accepts a pointer to this emitter and a reference to the particle that will be initialized.
ActionPolicy controls the particle's behavior. The action policy must provide a void process function that accepts a pointer to this emitter, a reference to the particle being processed and the time step. That function is called for each particle every time ParticleEmitter::process is called.
RenderPolicy handles the particle rendering. It must have the following functions:
  • beginRender(Renderer&): called first for stand-alone rendering
  • endRender(Renderer&): called last for stand-alone rendering
  • prepareEmitter(Emitter*,Renderer&): called once before particle loop
  • finishEmitter(Emitter*,Renderer&): called once after particle loop
  • render(Emitter*,Renderer&,Particle&): called for each particle
Base this emitter's base class. This argument may be used to adapt the emitter to different rendering and scene graph infrastructures. The default is SimpleBase.
Author:
Daniel Seibert


Public Types

typedef ActionPolicy< PartT,
Heir
ActionP
typedef EmissionPolicy EmissionP
typedef Heir Heir
typedef InitPolicy< PartT,
Heir
InitP
typedef PartT Particle
typedef util::SmartPointer<
util::Iterator< PartT >,
util::DestructiveCopy
ParticleIt
typedef RenderP::Renderer Renderer
typedef RenderPolicy< PartT,
Heir
RenderP

Public Member Functions

void clear ()
 sets the number of active particles to 0
void emit (unsigned int cnt)
 emits the given number of particles
unsigned int getMaxParticles () const
unsigned int getParticleCount () const
ParticleIt getParticles ()
 accesses the active particles
bool isParticleSortingEnabled () const
 ParticleEmitter ()
void process (const float &deltaT)
 processes all particles
void render (Renderer &, bool standAlone=true)
 renders this emitter's active particles
void setParticleSortingEnabled (bool)
 enables or disables particle sorting

Classes

struct  Comparator


Member Typedef Documentation

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef ActionPolicy<PartT,Heir> ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::ActionP
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef EmissionPolicy ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::EmissionP
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef Heir ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::Heir
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef InitPolicy<PartT,Heir> ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::InitP
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef PartT ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::Particle
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef util::SmartPointer<util::Iterator<PartT>,util::DestructiveCopy> ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::ParticleIt
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef RenderP::Renderer ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::Renderer
 

template<class Heir, unsigned int MAX_P, class PartT, class EmissionPolicy, template< class, class > class InitPolicy, template< class, class > class ActionPolicy, template< class, class > class RenderPolicy, class Base = SimpleBase>
typedef RenderPolicy<PartT,Heir> ONE::fx::ParticleEmitter< Heir, MAX_P, PartT, EmissionPolicy, InitPolicy, ActionPolicy, RenderPolicy, Base >::RenderP
 


Constructor & Destructor Documentation

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::ParticleEmitter  ) 
 


Member Function Documentation

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
void ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::clear  ) 
 

sets the number of active particles to 0

The particles are not destroyed and remain pooled.

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
void ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::emit unsigned int  cnt  ) 
 

emits the given number of particles

The particles are initialized using the initialization policy. cnt must be smaller or equal to the number of available particles, i.e. the maximum number of particles minus the number of active particles.

Parameters:
cnt the number of particles to add

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
unsigned int ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::getMaxParticles  )  const [inline]
 

Returns:
the maximum number of particles

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
unsigned int ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::getParticleCount  )  const [inline]
 

Returns:
the number of active particles

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
util::SmartPointer< util::Iterator< P >, util::DestructiveCopy > ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::getParticles  ) 
 

accesses the active particles

Dead particles will not be traversed by the iterator.

Returns:
an iterator over this emitter's active particles

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
bool ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::isParticleSortingEnabled  )  const [inline]
 

Returns:
if the particles are sorted before rendering

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
void ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::process const float deltaT  ) 
 

processes all particles

This function emits particles according to the emission policy and then processes each one via the action policy.

Parameters:
deltaT the step time in seconds

Reimplemented in ONE::fx::TexturedEmitter< Heir, MAX_P, P, E, I, A, B >, ONE::fx::TexturedEmitter< DustEmitter, MAX_P, DustParticle< DustEmitter >, Emission, Init, Action, Base >, and ONE::fx::TexturedEmitter< SparkEmitter, MAX_P, SparkParticle< SparkEmitter >, Emission, Init, Action, Base >.

template<class H, unsigned int MAX, class P, class E, template< class, class > class I, template< class, class > class A, template< class, class > class R, class B>
void ONE::fx::ParticleEmitter< H, MAX, P, E, I, A, R, B >::render Renderer ,
bool  standAlone = true
 

renders this emitter's active particles

Parameters:
standAlone true for stand-alone render, false for externally managed rendering

template<class H, unsigned int MAX, class P, class EP, template< class, class > class IP, template< class, class > class AP, template< class, class > class RP, class B>
void ONE::fx::ParticleEmitter< H, MAX, P, EP, IP, AP, RP, B >::setParticleSortingEnabled bool   )  [inline]
 

enables or disables particle sorting

If sorting is enabled, particles are sorted before rendering. This can be quite costly but is necessary for certain drawing techniques.


Generated on Wed Sep 7 19:03:13 2005 for ONEngine by  doxygen 1.4.3