Classes | Functions | Variables
Particles

Contains a particle system based on textures. The module also provides several affector and emitter classes. More...

Classes

class  thor::ForceAffector
 Applies a translational acceleration to particles over time. More...
class  thor::TorqueAffector
 Applies a rotational acceleration to particles over time. More...
class  thor::ScaleAffector
 Scales particles over time. More...
class  thor::AnimationAffector
 Affector that animates particles using a function. More...
class  thor::EmissionInterface
 Class that connects emitters with their corresponding particle system. More...
class  thor::UniversalEmitter
 Class that emits particles with customizable initial conditions. More...
class  thor::Particle
 Particle class More...
class  thor::ParticleSystem
 Class for particle systems. More...

Functions

sf::Time thor::getElapsedLifetime (const Particle &particle)
 Returns the time passed since the particle has been emitted.
sf::Time thor::getTotalLifetime (const Particle &particle)
 Returns the total time the particle is alive.
sf::Time thor::getRemainingLifetime (const Particle &particle)
 Returns the time left until the particle dies.
float thor::getElapsedRatio (const Particle &particle)
 Returns elapsed lifetime / total lifetime.
float thor::getRemainingRatio (const Particle &particle)
 Returns remaining lifetime / total lifetime.
void thor::abandonParticle (Particle &particle)
 Marks a particle for removal.

Variables

std::function< void(Particle
&, sf::Time)> 
thor::refAffector (Affector &referenced)
 Creates a functor that references an affector.
std::function< void(EmissionInterface
&, sf::Time)> 
thor::refEmitter (Emitter &referenced)
 Creates a functor that references an emitter.

Detailed Description

Contains a particle system based on textures. The module also provides several affector and emitter classes.


Function Documentation

void abandonParticle ( Particle particle) [related]

Marks a particle for removal.

This function can be used when the lifetime of particles is not bound to time, but another condition. For example, in a physics simulation, particles may disappear as soon as they hit an object. Calling this function will set the particle's elapsed time to the total lifetime, and the next update of the particle system will remove it.


Variable Documentation

std::function<void(Particle&, sf::Time)> thor::refAffector(Affector &referenced)

Creates a functor that references an affector.

Parameters:
referencedAffector functor to reference.

Use this function if you do not want to copy the affector, but reference it, when you pass it to thor::ParticleSystem. This allows you to modify the original object after it has been added, and effects are still visible. However, you are responsible to ensure the lifetime of the referenced object. Example:

 // Create affector and particle system
 thor::ForceAffector affector(acceleration);
 thor::ParticleSystem system(...);

 // Add affector to particle system
 system.addAffector(thor::refAffector(affector));

 // Change affector properties later
 affector = ForceAffector(newAcceleration);
std::function<void(EmissionInterface&, sf::Time)> thor::refEmitter(Emitter &referenced)

Creates a functor that references an emitter.

Parameters:
referencedEmitter functor to reference.

Use this function if you do not want to copy the emitter, but reference it, when you pass it to thor::ParticleSystem. This allows you to modify the original object after it has been added, and effects are still visible. However, you are responsible to ensure the lifetime of the referenced object. Example:

 // Create emitter and particle system
 thor::UniversalEmitter emitter;
 thor::ParticleSystem system(...);

 // Add emitter to particle system
 system.addEmitter(thor::refEmitter(emitter));

 // Change emitter properties later
 emitter.setEmissionRate(20);