Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZBaseParticleSystem< particleType > Class Template Reference

#include <ZE_ZBaseParticleSystem.h>

Inherited by ZE::ZSimpleParticleSystem< particleType >.

List of all members.


Detailed Description

template<class particleType>
class ZE::ZBaseParticleSystem< particleType >

Virtual class providing outline of basic particle system, designed so that a working particle system can be derived with minimal waste. Uses templated system to allow particle systems to work with their own types of particles, the particleType template parameter must be a type that has the members of ZBaseParticle. (Note: If you need a very specific particle system it's probably best to write your own fit to your needs.)


Public Member Functions

 ZBaseParticleSystem ()
 Basic constructor for ZBaseParticleSystem.

virtual ~ZBaseParticleSystem ()
 Virtual destructor for ZBaseParticleSystem.

virtual void Render ()=0
 Pure virtual function, renders the particles.

void Emit (int numParticles)
 Emit a given number of particles.

virtual void Update ()
 Updates status of particle system.

void Clear ()
 Empties particle system of all particles.

void Pause ()
 Pauses particle system.

void Unpause ()
 Unpauses particle system.

void Stop ()
 Clears system and pauses it.

bool Paused ()
 Detect if particle system is currently paused.

void SetMaxParticles (unsigned int max)
 Sets max particles allowed in system.

void SetRate (unsigned int rate)
 Sets release rate of particles.


Protected Member Functions

void AddParticle ()
 Adds a new particle.

virtual particleType NewParticle ()=0
 Pure virtual function to initialize and return a new particle.

virtual void UpdateParticle (int index, float elapsedTime)=0
 Pure virtual function to update a particle.


Protected Attributes

ZEnginerEngine
 Pointer to ZEngine singleton.

particleType * rParticles
 Pointer to array of particles.

unsigned int rMaxParticles
 Maximum number of particles, and size of rParticles array.

unsigned int rCurParticles
 Current number of particles.

unsigned int rNumParticlesPerSec
 Number of particles to release per second.

Uint32 rLastUpdate
 Millisecond format time of last update.

bool rPaused
 Boolean value indicating if system is paused.


Constructor & Destructor Documentation

template<class particleType>
ZE::ZBaseParticleSystem< particleType >::ZBaseParticleSystem  ) 
 

Basic constructor for ZBaseParticle system, initializes all values to 0.

template<class particleType>
ZE::ZBaseParticleSystem< particleType >::~ZBaseParticleSystem  )  [virtual]
 

Virtual destructor for ZBaseParticleSystem, destroys all particles, virtual to make class inheritance-safe.


Member Function Documentation

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::AddParticle  )  [protected]
 

Finds room in array with dead particle, and adds new particle using NewParticle, called by Emit.

template<class particleType>
virtual particleType ZE::ZBaseParticleSystem< particleType >::NewParticle  )  [protected, pure virtual]
 

Pure virtual function, overload should set up a new particle with desired traits, called by AddParticle.

Implemented in ZE::ZSimpleParticleSystem< particleType >.

template<class particleType>
virtual void ZE::ZBaseParticleSystem< particleType >::UpdateParticle int  index,
float  elapsedTime
[protected, pure virtual]
 

Pure virtual function, overload should update the particle `rParticles[index]`, called by Update.

Parameters:
index Index of particle in rParticles array to update.
elapsedTime Decimal portion of a second since last call.

Implemented in ZE::ZSimpleParticleSystem< particleType >.

template<class particleType>
virtual void ZE::ZBaseParticleSystem< particleType >::Render  )  [pure virtual]
 

Pure virtual so that each particle system can render it's member particles in it's own way.

Implemented in ZE::ZSimpleParticleSystem< particleType >.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Emit int  numParticles  ) 
 

Emits a given number of particles, will not emit particles if system is full.

Parameters:
numParticles Number of particles to emit.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Update  )  [virtual]
 

Updates entire particle system, calling update on every particle, emitting necessary new particles, removing particles which have an energy <= 0 or are off the screen. Virtual for special cases, but generally should not be overridden.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Clear  ) 
 

Empties particle system of all particles, does not alter paused state.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Pause  ) 
 

Pauses particle system, particles may still be drawn but particles are not updated.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Unpause  ) 
 

Returns particle system to active state, system starts unpaused.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::Stop  ) 
 

Same as calling Clear() and then Pause(), use unpause to restart system.

template<class particleType>
bool ZE::ZBaseParticleSystem< particleType >::Paused  ) 
 

Returns bool indicating if the particle system is currently paused.

Returns:
true if paused, false if active

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::SetMaxParticles unsigned int  max  ) 
 

Set maximum number of particles allowed in system, particles are not emitted when system is full. When this resizes the array contents are moved to the new array, if it shrinks the array particles may be lost.

Parameters:
max Maximum number of particles for system.

template<class particleType>
void ZE::ZBaseParticleSystem< particleType >::SetRate unsigned int  rate  ) 
 

Set number of particles to release per second.

Parameters:
rate Number of particles to release over the duration of one second.


The documentation for this class was generated from the following file:
Generated on Sun Oct 5 19:34:46 2003 for ZEngine by doxygen1.3