Bromeon
Classes | Public Types | Public Member Functions | Protected Member Functions
thor::Emitter Class Reference

Abstract base class for particle emitters. More...

Inheritance diagram for thor::Emitter:
Inheritance graph

List of all members.

Classes

struct  Adder
 Class that connects emitters with their corresponding particle system. More...

Public Types

typedef std::tr1::shared_ptr
< Emitter
Ptr
 Shared pointer type referring to derivates of Emitter.

Public Member Functions

virtual ~Emitter ()
 Virtual destructor.
virtual void Emit (Adder &system, float dt)=0
 Emits particles into a particle system.
void SetEmissionZone (MovedPtr< Zone > zone)
 Sets the zone inside which particles are created.
ZoneGetEmissionZone ()
 Returns the zone inside which particles are created.
const ZoneGetEmissionZone () const
 Returns the zone inside which particles are created (const overload).
void SetEmissionRate (float particlesPerSecond)
 Sets the particle emission rate.
float GetEmissionRate () const
 Returns the particle emission rate.
void SetParticleScale (sf::Vector2f scale)
 Sets the initial particle scale.
sf::Vector2f GetParticleScale () const
 Returns the initial particle velocity.
void SetParticleColor (const sf::Color &color)
 Sets the initial particle color.
const sf::Color & GetParticleColor () const
 Returns the initial particle color.
void SetParticleLifetime (float lifetime)
 Sets the lifetime (time between emission and death) of the particle.
float GetParticleLifetime () const
 Returns the lifetime (time between emission and death) of the particle.

Protected Member Functions

 Emitter (float particlesPerSecond, float particleLifetime)
 Constructor.
unsigned int ComputeNbParticles (float dt)
 Helper function for emission: Computes how many particles should be emitted in this frame.
Particle CreateParticlePrototype () const
 Creates a prototype of a particle.

Detailed Description

Abstract base class for particle emitters.

Emitters are classes which create particles (using particular initial conditions) and insert them into a particle system.
Inherit from this class and override Emit() to implement custom emitters.


Constructor & Destructor Documentation

thor::Emitter::Emitter ( float  particlesPerSecond,
float  particleLifetime 
) [protected]

Constructor.

Parameters:
particlesPerSecondHow many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds).
particleLifetimeHow long the particles live until they are removed (in seconds).

Member Function Documentation

unsigned int thor::Emitter::ComputeNbParticles ( float  dt) [protected]

Helper function for emission: Computes how many particles should be emitted in this frame.

Saves the user from calculations, takes care of too short times to emit particles. This function shall be called exactly once each frame.

Parameters:
dtFrame time.
Returns:
Number of particles to emit.

Creates a prototype of a particle.

Applies the initial particle settings (position, rotation, scale, color, lifetime).

virtual void thor::Emitter::Emit ( Adder system,
float  dt 
) [pure virtual]

Emits particles into a particle system.

Override this method in your emitter class to implement your own functionality. If your emitter does only emit the particles in a different area, you should have a look at RandomOffset().

Parameters:
systemIndirection to the particle system that stores the particles.
dtTime interval during which particles are emitted.

Implemented in thor::TargetEmitter, and thor::DirectionalEmitter.

Returns the particle emission rate.

Returns:
How many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds).

Returns the zone inside which particles are created.

Returns:
Reference to modifiable zone, allowing changes of it.

Returns the zone inside which particles are created (const overload).

Returns:
Reference to constant zone.
void thor::Emitter::SetEmissionRate ( float  particlesPerSecond)

Sets the particle emission rate.

Parameters:
particlesPerSecondHow many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds).

Sets the zone inside which particles are created.

Parameters:
zoneMovable smart pointer to concrete zone.

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