Emitter Class Reference

An abstract class that defines an emitter of particles. More...

Inheritance diagram for Emitter:
Registerable Transformable NormalEmitter RandomEmitter SphericEmitter StaticEmitter StraightEmitter

List of all members.

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.
ZonegetZone () 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 RegisterablefindByName (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.

Detailed Description

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.


Constructor & Destructor Documentation

Emitter (  ) 

Constructor of Emitter.

virtual ~Emitter (  )  [virtual]

Destructor of Emitter.

Definition at line 71 of file SPK_Emitter.h.


Member Function Documentation

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

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

Parameters:
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.

Parameters:
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.

Parameters:
particle : the Particle to emit from this Emitter

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.

Parameters:
name : the name of the registerable to find
Returns:
: the first registerable with that name within this registerable or NULL if none is found
Since:
1.05.00

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.

Parameters:
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.

Returns:
the flow of this Emitter

Definition at line 317 of file SPK_Emitter.h.

float getForceMax (  )  const

Gets the maximum force of this Emitter.

Returns:
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.

Returns:
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.

Returns:
the number of particles in this Emitters's tanl

Definition at line 312 of file SPK_Emitter.h.

Zone * getZone (  )  const

Gets the Zone of this Emitter.

Returns:
the Zone of this Emitter

Definition at line 332 of file SPK_Emitter.h.

bool isActive (  )  const

Tells whether this Emitter is active or not.

Returns:
true if this Emitter is active, false if is is inactive
Since:
1.05.00

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.

Returns:
true if this EMitter emits in the whole Zone, false if it is 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.

Returns:
true if this Emitter is sleeping, false if it is active
Since:
1.03.00

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.

Since:
1.05.00

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.

Parameters:
registerAll : true to register unregistered children, false to only increment ref counts of already registered children
Since:
1.04.00

Reimplemented from Registerable.

Reimplemented in NormalEmitter.

void setActive ( bool  active  ) 

Sets this Emitter active or not.

An inactive Emitter will not emit in its parent Group during update.
However it can still be used manually by the user.

Parameters:
active : true to activate this Emitter, false to deactivate it
Since:
1.05.00

Definition at line 286 of file SPK_Emitter.h.

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.

Parameters:
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.

Parameters:
min : the minimum force of the Emitter
max : the maximum force of the Emitter

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.

Parameters:
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 
)

Sets the Zone of this Emitter.

If the Zone is NULL, the default Zone will be used (A Point centered at the origin)

Parameters:
zone : the Zone of this Emitter
full : true to generate particles in the whole Zone, false to generate particles only at the Zone borders.

Generated on Wed Apr 27 21:09:25 2011 for SPARK Particle Engine by  doxygen 1.6.1