An abstract class that defines an emitter of particles. More...
Public Member Functions | |
Emitter () | |
Constructor of Emitter. | |
virtual | ~Emitter () |
Destructor of Emitter. | |
void | setActive (bool active) |
Sets this Emitter active or not. | |
void | setTank (int tank) |
Sets the number of particles in this Emitter's tank. | |
void | changeTank (int deltaTank) |
Changes the number of particles in this Emitters's tank. | |
void | setFlow (float flow) |
Sets the flow of this Emitter. | |
void | changeFlow (float deltaFlow) |
Changes the flow of particles of this Emitter. | |
void | setForce (float min, float max) |
Sets the force of this Emitter. | |
void | setZone (Zone *zone, bool full=true) |
Sets the Zone of this Emitter. | |
bool | isActive () const |
Tells whether this Emitter is active or not. | |
int | getTank () const |
Gets the number of particles in this Emitter's tank. | |
float | getFlow () const |
Gets the flow of this Emitter. | |
float | getForceMin () const |
Gets the minimum force of this Emitter. | |
float | getForceMax () const |
Gets the maximum force of this Emitter. | |
Zone * | getZone () const |
Gets the Zone of this Emitter. | |
bool | isFullZone () const |
Tells whether this Emitter emits in the whole Zone or only at its borders. | |
bool | isSleeping () const |
Tells whether this Emitter is sleeping or not. | |
void | emit (Particle &particle) const |
Emits a Particle from this Emitter. | |
void | generateVelocity (Particle &particle) const |
Generates the velocity of the Particle. | |
virtual Registerable * | findByName (const std::string &name) |
Finds a registerable with its name recursively from this registerable. | |
Protected Member Functions | |
virtual void | registerChildren (bool registerAll) |
Registers the children of this Registerable. | |
virtual void | destroyChildren (bool keepChildren) |
Destroys the children of this Registerable. | |
virtual void | propagateUpdateTransform () |
Propagates the update of the transform to transformable children of this transformable. |
An abstract class that defines an emitter of particles.
An Emitter is an object that will launch particles by giving them a velocity and a position.
the position is derived from the Zone of the Emitter.
the velocity is derived from the Emitter itself.
An Emitter has a flow and a tank of particles. The flow defines the rate at which particles are launched and the tank defines the total number of Particles the Emitter can launched.
Note that the flow and the tank of an Emitter are only used when the Emitter emits automatically from a Group but the user can also emit manually outside a Group.
Definition at line 53 of file SPK_Emitter.h.
virtual ~Emitter | ( | ) | [virtual] |
Destructor of Emitter.
Definition at line 71 of file SPK_Emitter.h.
void changeFlow | ( | float | deltaFlow | ) |
Changes the flow of particles of this Emitter.
The new flow is equal to : flow of the Emitter + deltaFlow.
This method has no effect for Emitters with infinite flow (a negative flow of particles) and an Emitter's flow cannot become infinite with this method (the new flow is clamped to 0).
deltaFlow | : the number to add to the current flow |
void changeTank | ( | int | deltaTank | ) |
Changes the number of particles in this Emitters's tank.
The new number of particles in the tank is equal to : number of particles in the tank + n.
This method has no effect for Emitters with infinite tank (a negative number of particles) and an Emitter cannot become infinite with this method (the new number is clamped to 0).
deltaTank | : the number to add to the current tank |
virtual void destroyChildren | ( | bool | keepChildren | ) | [protected, virtual] |
Destroys the children of this Registerable.
This method has to be implemented in derived classes of Registerable which hold pointers or references of Registerable children.
The destroyChild(Registerable*,bool) has to be called within it for each child to destroy.
The keepChildren parameter of destroyChild is simply the keepChildren parameter of destroyChildren.
keepChildren | : true to keep the children (used when destroying all registered Registerable) |
Reimplemented from Registerable.
Reimplemented in NormalEmitter.
void emit | ( | Particle & | particle | ) | const |
Emits a Particle from this Emitter.
The Particle's velocity is updated with a call to generateVelocity(Particle&).
The Particle's position is updated with a call to Zone::generatePosition(Particle&) of the Emitter's Zone.
Note that this will not decrease the number of particles in the Emitter's tank. To do it, the user has to manually make a call to changeNumber(-1) after this call.
Definition at line 347 of file SPK_Emitter.h.
virtual Registerable* findByName | ( | const std::string & | name | ) | [virtual] |
Finds a registerable with its name recursively from this registerable.
If the name is not found, NULL is returned.
If the several objects with the same name exists, only the first one is returned.
Note that the name of the registerable itself is already tested.
name | : the name of the registerable to find |
Reimplemented from Registerable.
Reimplemented in NormalEmitter.
void generateVelocity | ( | Particle & | particle | ) | const |
Generates the velocity of the Particle.
The velocity of the Particle is updated in function of the Emitter's nature and parameters.
Unlike emit() the position of the Particle remains unchanged.
particle | : the Particle whose velocity has to be updated |
Definition at line 353 of file SPK_Emitter.h.
float getFlow | ( | ) | const |
Gets the flow of this Emitter.
Definition at line 317 of file SPK_Emitter.h.
float getForceMax | ( | ) | const |
Gets the maximum force of this Emitter.
Definition at line 327 of file SPK_Emitter.h.
float getForceMin | ( | ) | const |
Gets the minimum force of this Emitter.
Definition at line 322 of file SPK_Emitter.h.
int getTank | ( | ) | const |
Gets the number of particles in this Emitter's tank.
Definition at line 312 of file SPK_Emitter.h.
Zone * getZone | ( | ) | const |
bool isActive | ( | ) | const |
Tells whether this Emitter is active or not.
Definition at line 307 of file SPK_Emitter.h.
bool isFullZone | ( | ) | const |
Tells whether this Emitter emits in the whole Zone or only at its borders.
Definition at line 337 of file SPK_Emitter.h.
bool isSleeping | ( | ) | const |
Tells whether this Emitter is sleeping or not.
An Emitter is considered as sleeping if his flow or his tank is equal to 0.
Definition at line 342 of file SPK_Emitter.h.
void propagateUpdateTransform | ( | ) | [protected, virtual] |
Propagates the update of the transform to transformable children of this transformable.
This method can be overriden in derived classes of Transformable (By default it does nothing).
It is this method task to call the updateTransform method of transformable children of this transformable.
Reimplemented from Transformable.
Definition at line 358 of file SPK_Emitter.h.
virtual void registerChildren | ( | bool | registerAll | ) | [protected, virtual] |
Registers the children of this Registerable.
This method has to be implemented in derived classes of Registerable which hold pointers or references of Registerable children.
The registerChild(Registerable*,bool) has to be called within it for each child to copy from object.
The registerAll parameter of registerChild is simply the registerAll parameter of registerChildren.
registerAll | : true to register unregistered children, false to only increment ref counts of already registered children |
Reimplemented from Registerable.
Reimplemented in NormalEmitter.
void setActive | ( | bool | active | ) |
void setFlow | ( | float | flow | ) |
Sets the flow of this Emitter.
The flow is in the unit : nb of particle per step. A flow of -1 (or any negative number) indicates an infinite flow which means all particles in the Emitters(s tank are generated instantly.
Note that if both the flow and the tank are infinite, nothing will happen.
flow | : the flow of this Emitter |
Definition at line 296 of file SPK_Emitter.h.
void setForce | ( | float | min, | |
float | max | |||
) |
Sets the force of this Emitter.
The force of the Emitter vary for each launch of a Particle between a minimum and a maximum. To have a fixed force for the Emitter, just have min = max.
the speed at which a Particle will be launched is equal to : force / weight of the Particle.
Definition at line 301 of file SPK_Emitter.h.
void setTank | ( | int | tank | ) |
Sets the number of particles in this Emitter's tank.
Each time the Emitter is updated, the number of particles emitted is deduced from the Emitter tank. When the tank reaches 0, the Emitter will not emit any longer until it is refilled.
A number of -1 (or any negative number) means the Emitter has an infinite tank which will never be empty.
tank | : the number of particles in this Emitters's tank |
Definition at line 291 of file SPK_Emitter.h.
void setZone | ( | Zone * | zone, | |
bool | full = true | |||
) |