Bromeon
Public Types | Static Public Member Functions | Public Member Functions | Protected Member Functions
thor::DirectionalEmitter Class Reference

Class that emits particles in a given direction. More...

Inheritance diagram for thor::DirectionalEmitter:
Inheritance graph

List of all members.

Public Types

typedef std::tr1::shared_ptr
< DirectionalEmitter
Ptr
 Shared pointer type referring to DirectionalEmitter objects.

Static Public Member Functions

static Ptr Create (float particlesPerSecond, float particleLifetime)
 Creates an emitter that emits particles mainly in one direction.

Public Member Functions

 DirectionalEmitter (float particlesPerSecond, float particleLifetime)
 Constructor.
virtual void Emit (Adder &system, float dt)
 Emits particles into a particle system.
void SetParticleVelocity (sf::Vector2f velocity)
 Sets the initial particle velocity.
sf::Vector2f GetParticleVelocity () const
 Returns the initial particle velocity.
void SetEmissionAngle (float emissionAngle)
 Sets the particle emission angle.
float GetEmissionAngle () const
 Returns the particle emission angle.
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

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

Class that emits particles in a given direction.

This direction is the initial particle velocity.


Constructor & Destructor Documentation

thor::DirectionalEmitter::DirectionalEmitter ( float  particlesPerSecond,
float  particleLifetime 
)

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, inherited]

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.
static Ptr thor::DirectionalEmitter::Create ( float  particlesPerSecond,
float  particleLifetime 
) [static]

Creates an emitter that emits particles mainly in one direction.

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).

Particle thor::Emitter::CreateParticlePrototype ( ) const [protected, inherited]

Creates a prototype of a particle.

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

virtual void thor::DirectionalEmitter::Emit ( Adder system,
float  dt 
) [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.

Implements thor::Emitter.

Returns the particle emission angle.

Returns:
The difference angle of the cone towards which particles are emitted, in degrees. For example, 0 means a straight line and 180 the half space.
float thor::Emitter::GetEmissionRate ( ) const [inherited]

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.
const Zone& thor::Emitter::GetEmissionZone ( ) const [inherited]

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

Returns:
Reference to constant zone.
void thor::DirectionalEmitter::SetEmissionAngle ( float  emissionAngle)

Sets the particle emission angle.

Parameters:
emissionAngleThe difference angle of the cone towards which particles are emitted, in degrees. For example, 0 means a straight line and 180 the half space.
void thor::Emitter::SetEmissionRate ( float  particlesPerSecond) [inherited]

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).
void thor::Emitter::SetEmissionZone ( MovedPtr< Zone zone) [inherited]

Sets the zone inside which particles are created.

Parameters:
zoneMovable smart pointer to concrete zone.
void thor::DirectionalEmitter::SetParticleVelocity ( sf::Vector2f  velocity)

Sets the initial particle velocity.

Note that the emission angle influences the actual direction of particles.


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