An abstract layer for a ParticleProducer. More...
#include <ParticleLayer.h>
Public Member Functions | |
ParticleLayer (const char *type, int particleSize) | |
Creates a new ParticleLayer. | |
virtual | ~ParticleLayer () |
Deletes this ParticleLayer. | |
ParticleProducer * | getOwner () |
Returns the ParticleProducer to which this ParticleLayer belongs. | |
bool | isEnabled () |
Returns true if this layer is enabled. | |
void | setIsEnabled (bool enable) |
Enables or disables this ParticleLayer. | |
virtual int | getParticleSize () |
Returns the size in bytes of the layer specific data that must be stored for each particle. | |
void * | getParticleData (ParticleStorage::Particle *p) |
Returns a pointer to the layer specific data of the given particle. | |
ParticleStorage::Particle * | getParticle (void *p) |
Returns a pointer to the Particle corresponding to the given layer specific data. | |
virtual void | getReferencedProducers (vector< ptr< TileProducer > > &producers) const |
Returns the tile producers used by this ParticleLayer. | |
virtual void | moveParticles (double dt) |
Moves the existing particles. | |
virtual void | removeOldParticles () |
Removes old particles. | |
virtual void | addNewParticles () |
Adds new particles. | |
Protected Member Functions | |
void | init (int particleSize) |
Initializes this ParticleLayer. | |
virtual void | initialize () |
Initializes this ParticleLayer. | |
virtual void | initParticle (ParticleStorage::Particle *p) |
Initializes the data that is specific to this layer in the given particle. | |
Private Attributes | |
ParticleProducer * | owner |
The ParticleProducer to which this ParticleLayer belongs. | |
int | size |
The size in bytes of the layer specific data that must be stored for each particle. | |
int | offset |
The offset of the data that is specific to this layer in the global particle data. | |
bool | enabled |
True if this layer is enabled. |
An abstract layer for a ParticleProducer.
proland::ParticleLayer::ParticleLayer | ( | const char * | type, | |
int | particleSize | |||
) |
Creates a new ParticleLayer.
type | the layer's type. | |
particleSize | the size in bytes of the layer specific data that must be stored for each particle. |
virtual proland::ParticleLayer::~ParticleLayer | ( | ) | [virtual] |
Deletes this ParticleLayer.
virtual void proland::ParticleLayer::addNewParticles | ( | ) | [virtual] |
Adds new particles.
The default implementation of this method does nothing.
Reimplemented in proland::RandomParticleLayer, and proland::ScreenParticleLayer.
ParticleProducer* proland::ParticleLayer::getOwner | ( | ) |
Returns the ParticleProducer to which this ParticleLayer belongs.
ParticleStorage::Particle* proland::ParticleLayer::getParticle | ( | void * | p | ) | [inline] |
Returns a pointer to the Particle corresponding to the given layer specific data.
p | a pointer to the data that is specific to this layer for a given particle. |
void* proland::ParticleLayer::getParticleData | ( | ParticleStorage::Particle * | p | ) | [inline] |
Returns a pointer to the layer specific data of the given particle.
p | a particle. |
virtual int proland::ParticleLayer::getParticleSize | ( | ) | [virtual] |
Returns the size in bytes of the layer specific data that must be stored for each particle.
virtual void proland::ParticleLayer::getReferencedProducers | ( | vector< ptr< TileProducer > > & | producers | ) | const [inline, virtual] |
Returns the tile producers used by this ParticleLayer.
[out] | producers | the tile producers used by this ParticleLayer. |
Reimplemented in proland::TerrainParticleLayer.
void proland::ParticleLayer::init | ( | int | particleSize | ) | [protected] |
Initializes this ParticleLayer.
virtual void proland::ParticleLayer::initialize | ( | ) | [protected, virtual] |
Initializes this ParticleLayer.
If this layer needs reference to other layers it can initialize them in this method (using the template method ParticleProducer::getLayer()). The default implementation of this method does nothing.
Reimplemented in proland::ScreenParticleLayer, and proland::TerrainParticleLayer.
virtual void proland::ParticleLayer::initParticle | ( | ParticleStorage::Particle * | p | ) | [protected, virtual] |
Initializes the data that is specific to this layer in the given particle.
The default implementation of this method does nothing.
Reimplemented in proland::LifeCycleParticleLayer, proland::RandomParticleLayer, proland::ScreenParticleLayer, proland::TerrainParticleLayer, and proland::WorldParticleLayer.
bool proland::ParticleLayer::isEnabled | ( | ) |
Returns true if this layer is enabled.
If it is not the case, its moveParticles, removeOldParticles and addNewParticles will not be called by the ParticleProducer.
virtual void proland::ParticleLayer::moveParticles | ( | double | dt | ) | [virtual] |
Moves the existing particles.
The default implementation of this method does nothing.
dt | the elapsed time since the last call to this method, in microseconds. |
Reimplemented in proland::LifeCycleParticleLayer, proland::ScreenParticleLayer, proland::TerrainParticleLayer, and proland::WorldParticleLayer.
virtual void proland::ParticleLayer::removeOldParticles | ( | ) | [virtual] |
Removes old particles.
The default implementation of this method does nothing.
Reimplemented in proland::LifeCycleParticleLayer, and proland::ScreenParticleLayer.
void proland::ParticleLayer::setIsEnabled | ( | bool | enable | ) |
Enables or disables this ParticleLayer.
The moveParticles, removeOldParticles and addNewParticles methods are called only on enabled layers.
enable | true to enable this layer, false otherwise. |
bool proland::ParticleLayer::enabled [private] |
True if this layer is enabled.
int proland::ParticleLayer::offset [private] |
The offset of the data that is specific to this layer in the global particle data.
ParticleProducer* proland::ParticleLayer::owner [private] |
The ParticleProducer to which this ParticleLayer belongs.
int proland::ParticleLayer::size [private] |
The size in bytes of the layer specific data that must be stored for each particle.