hoa_video::ParticleEffect Class Reference

particle effect, basically one coherent "effect" like an explosion, or snow falling from the sky. Consists of one or more ParticleSystems. An example of using multiple systems to create one effect would be a campfire where you have fire + smoke + glowing embers. More...

#include <particle_effect.h>

Collaboration diagram for hoa_video::ParticleEffect:

Collaboration graph
[legend]
List of all members.

Public Member Functions

float GetAge () const
 return the age of the system, i.e. how many seconds it has been since it was created
int32 GetNumParticles () const
 return the number of active particles in this effect
void GetPosition (float &x, float &y) const
 return the position of the effect into x and y
bool IsAlive ()
 returns true if the system is alive, i.e. the number of active particles is more than zero. This is used by the particle manager so it knows when to destroy an effect.
void Move (float x, float y)
 moves the effect to the specified position on the screen, This can be used if you want to move a particle system around on some flight path, or if you want to attach the system to an object. (e.g. smoke to a jet)
void MoveRelative (float dx, float dy)
 moves the effect dx and dy units relative to its current position
 ParticleEffect ()
 Constructor.
void SetAttractorPoint (float x, float y)
 set the position of an "attractor point". Any particle systems which use radial acceleration and have user-defined attractor points enabled will have particles move towards this point
void SetOrientation (float angle)
 set the orientation of the effect (including all systems contained within the effect). This is essentially added to the emitter orientation for each system. For example, if you want to create a particle system for smoke coming out of a jet, set the emitter orientation to zero degrees (right) when you create the effect. Then, at runtime just call SetOrientation() every frame with the angle the jet is facing.
void Stop (bool kill_immediate=false)
 stops this effect

Private Member Functions

void _Destroy ()
 destroys the effect. This is private so that only the ParticleManager class can destroy effects.
bool _Draw ()
 draws the effect. This is private so that only the ParticleManager class can draw effects.
bool _Update (float frame_time)
 updates the effect. This is private so that only the ParticleManager class can update effects.

Private Attributes

float _age
 age of the effect (seconds since it was created)
bool _alive
 is the effect is alive or not
float _attractor_x
 position of attractor point
float _attractor_y
const ParticleEffectDef_effect_def
 pointer to the effect definition
int32 _num_particles
 number of active particles (this is updated on each call to Update())
float _orientation
 orientation of the effect (angle in radians)
std::list< ParticleSystem * > _systems
float _x
 position of the effect
float _y

Friends

class private_video::ParticleManager

Detailed Description

particle effect, basically one coherent "effect" like an explosion, or snow falling from the sky. Consists of one or more ParticleSystems. An example of using multiple systems to create one effect would be a campfire where you have fire + smoke + glowing embers.

***************************************************************************

Definition at line 68 of file particle_effect.h.


Constructor & Destructor Documentation

hoa_video::ParticleEffect::ParticleEffect (  ) 

Constructor.

Definition at line 27 of file particle_effect.cpp.

References _age, _alive, _attractor_x, _attractor_y, _effect_def, _orientation, _x, and _y.


Member Function Documentation

void hoa_video::ParticleEffect::_Destroy (  )  [private]

destroys the effect. This is private so that only the ParticleManager class can destroy effects.

Definition at line 132 of file particle_effect.cpp.

References _systems.

bool hoa_video::ParticleEffect::_Draw (  )  [private]

draws the effect. This is private so that only the ParticleManager class can draw effects.

Returns:
success/failure

Definition at line 42 of file particle_effect.cpp.

References _systems, _x, _y, hoa_video::GameVideo::Move(), hoa_video::GameVideo::PopMatrix(), hoa_video::GameVideo::PushMatrix(), hoa_video::VIDEO_DEBUG, and hoa_video::VideoManager.

Here is the call graph for this function:

bool hoa_video::ParticleEffect::_Update ( float  frame_time  )  [private]

updates the effect. This is private so that only the ParticleManager class can update effects.

Parameters:
the new frame time
Returns:
success/failure

Definition at line 79 of file particle_effect.cpp.

References _age, _alive, _attractor_x, _attractor_y, _num_particles, _orientation, _systems, _x, _y, hoa_video::private_video::EffectParameters::attractor_x, hoa_video::private_video::EffectParameters::attractor_y, hoa_video::private_video::EffectParameters::orientation, and hoa_video::VIDEO_DEBUG.

float hoa_video::ParticleEffect::GetAge (  )  const

return the age of the system, i.e. how many seconds it has been since it was created

Returns:
age of the system

Definition at line 258 of file particle_effect.cpp.

References _age.

int32 hoa_video::ParticleEffect::GetNumParticles (  )  const

return the number of active particles in this effect

Returns:
number of particles in the system

Definition at line 236 of file particle_effect.cpp.

References _num_particles.

void hoa_video::ParticleEffect::GetPosition ( float &  x,
float &  y 
) const

return the position of the effect into x and y

Parameters:
x parameter to store x value of system in
y parameter to store y value of system in

Definition at line 246 of file particle_effect.cpp.

References _x, and _y.

bool hoa_video::ParticleEffect::IsAlive (  ) 

returns true if the system is alive, i.e. the number of active particles is more than zero. This is used by the particle manager so it knows when to destroy an effect.

Returns:
true if system is alive, false if dead

Definition at line 197 of file particle_effect.cpp.

References _alive.

void hoa_video::ParticleEffect::Move ( float  x,
float  y 
)

moves the effect to the specified position on the screen, This can be used if you want to move a particle system around on some flight path, or if you want to attach the system to an object. (e.g. smoke to a jet)

Parameters:
x movement of system in x direction
y movement of system in y direction

Definition at line 149 of file particle_effect.cpp.

References _x, and _y.

Referenced by hoa_video::private_video::ParticleManager::AddEffect().

void hoa_video::ParticleEffect::MoveRelative ( float  dx,
float  dy 
)

moves the effect dx and dy units relative to its current position

Parameters:
dx x offset to move to from current x position
dy y offset to move to from current y position

Definition at line 161 of file particle_effect.cpp.

References _x, and _y.

void hoa_video::ParticleEffect::SetAttractorPoint ( float  x,
float  y 
)

set the position of an "attractor point". Any particle systems which use radial acceleration and have user-defined attractor points enabled will have particles move towards this point

Note:
a positive radial acceleration will move a particle away from the attractor, and negative will move it towards it.
Parameters:
x x coordiante of gravitation point
y y coordiante of gravitation point

Definition at line 185 of file particle_effect.cpp.

References _attractor_x, and _attractor_y.

void hoa_video::ParticleEffect::SetOrientation ( float  angle  ) 

set the orientation of the effect (including all systems contained within the effect). This is essentially added to the emitter orientation for each system. For example, if you want to create a particle system for smoke coming out of a jet, set the emitter orientation to zero degrees (right) when you create the effect. Then, at runtime just call SetOrientation() every frame with the angle the jet is facing.

Parameters:
angle rotation of particle system

Definition at line 173 of file particle_effect.cpp.

References _orientation.

void hoa_video::ParticleEffect::Stop ( bool  kill_immediate = false  ) 

stops this effect

Parameters:
kill_immediate If this is true, the effect is immediately killed. If it isn't true, then we stop the effect from emitting new particles, and allow it to live until all the active particles fizzle out.

Definition at line 209 of file particle_effect.cpp.

References _alive, and _systems.


Friends And Related Function Documentation

friend class private_video::ParticleManager [friend]

Definition at line 215 of file particle_effect.h.


Member Data Documentation

float hoa_video::ParticleEffect::_age [private]

age of the effect (seconds since it was created)

Definition at line 210 of file particle_effect.h.

Referenced by hoa_video::private_video::ParticleManager::_CreateEffect(), _Update(), GetAge(), and ParticleEffect().

bool hoa_video::ParticleEffect::_alive [private]

is the effect is alive or not

Definition at line 207 of file particle_effect.h.

Referenced by hoa_video::private_video::ParticleManager::_CreateEffect(), _Update(), IsAlive(), ParticleEffect(), and Stop().

float hoa_video::ParticleEffect::_attractor_x [private]

position of attractor point

Definition at line 201 of file particle_effect.h.

Referenced by _Update(), ParticleEffect(), and SetAttractorPoint().

float hoa_video::ParticleEffect::_attractor_y [private]

Definition at line 201 of file particle_effect.h.

Referenced by _Update(), ParticleEffect(), and SetAttractorPoint().

const ParticleEffectDef* hoa_video::ParticleEffect::_effect_def [private]

pointer to the effect definition

Definition at line 191 of file particle_effect.h.

Referenced by hoa_video::private_video::ParticleManager::_CreateEffect(), and ParticleEffect().

int32 hoa_video::ParticleEffect::_num_particles [private]

number of active particles (this is updated on each call to Update())

Definition at line 213 of file particle_effect.h.

Referenced by _Update(), and GetNumParticles().

float hoa_video::ParticleEffect::_orientation [private]

orientation of the effect (angle in radians)

Definition at line 204 of file particle_effect.h.

Referenced by _Update(), ParticleEffect(), and SetOrientation().

std::list<ParticleSystem *> hoa_video::ParticleEffect::_systems [private]

list of subsystems that make up the effect. (for example, a fire effect might consist of a flame + smoke + embers)

Definition at line 195 of file particle_effect.h.

Referenced by hoa_video::private_video::ParticleManager::_CreateEffect(), _Destroy(), _Draw(), _Update(), and Stop().

float hoa_video::ParticleEffect::_x [private]

position of the effect

Definition at line 198 of file particle_effect.h.

Referenced by _Draw(), _Update(), GetPosition(), Move(), MoveRelative(), and ParticleEffect().

float hoa_video::ParticleEffect::_y [private]

Definition at line 198 of file particle_effect.h.

Referenced by _Draw(), _Update(), GetPosition(), Move(), MoveRelative(), and ParticleEffect().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:16:38 2007 for Hero of Allacrost by  doxygen 1.5.1