Group Class Reference

A group of many particles. More...

Inheritance diagram for Group:
Registerable Transformable

List of all members.

Public Member Functions

 Group (Model *model=NULL, size_t capacity=Pool< Particle >::DEFAULT_CAPACITY)
 Constructor for a Group.
 Group (const Group &group)
 Copy Constructor of Group.
 ~Group ()
 The destructor of Group.
void setModel (Model *model)
 change the Model of this Group
void setRenderer (Renderer *renderer)
 Sets the Renderer of this Group.
void setFriction (float friction)
 Sets the friction of this Group.
void setGravity (const Vector3D &gravity)
 Sets the gravity of this Group.
void setCustomUpdate (bool(*fupdate)(Particle &, float))
 Assigns a callback for the custom update.
void setCustomBirth (void(*fbirth)(Particle &))
 Assigns a callback for custom birth.
void setCustomDeath (void(*fdeath)(Particle &))
 Assigns a callback for custom death.
void enableSorting (bool sort)
 Enables or disables the sorting of particles.
void enableDistanceComputation (bool distanceComputation)
 Enables or disables the computation of the distance of a Particle from the camera.
void enableAABBComputing (bool AABB)
 Enables or disables the computation of the axis aligned bouding box of the Group.
const Pool< Particle > & getParticles () const
 Gets the Pool of particles of the Group.
ParticlegetParticle (size_t index)
 Gets a single Particle in the Group by its index.
const ParticlegetParticle (size_t index) const
 Gets a single Particle in the Group by its index.
size_t getNbParticles () const
 Gets the number of particles in the Group.
const std::vector< Emitter * > & getEmitters () const
 Gets the emitters of the Group.
EmittergetEmitter (size_t index) const
 Gets an Emitter of the Group by its index.
size_t getNbEmitters () const
 Gets the number of emitters in this Group.
const std::vector< Modifier * > & getModifiers () const
 Gets the modifiers of the Group.
ModifiergetModifier (size_t index) const
 Gets an Modifier of the Group by its index.
size_t getNbModifiers () const
 Gets the number of modifiers in this Group.
ModelgetModel () const
 Gets the Model of this Group.
RenderergetRenderer () const
 Gets the Renderer of this Group.
float getFriction () const
 Gets the friction coefficient of this Group.
const Vector3DgetGravity () const
 Gets the gravity Vector3D of this Group.
bool isSortingEnabled () const
 Tells whether the sorting of particles from back to front is enabled.
bool isDistanceComputationEnabled () const
 Tells whether the distance computation between particles and camera is enabled.
bool isAABBComputingEnabled () const
 Tells whether the computation of the axis aligned bouding box is enabled.
const Vector3DgetAABBMin () const
 Gets a Vector3D holding the minimum coordinates of the AABB of the Group.
const Vector3DgetAABBMax () const
 Gets a Vector3D holding the maximum coordinates of the AABB of the Group.
const void * getParamAddress (ModelParam param) const
 Gets the start address of the given param.
const void * getPositionAddress () const
 Gets the start address of the position.
size_t getParamStride () const
 Gets the stride for parameters.
size_t getPositionStride () const
 Gets the stride for positions.
void addParticles (unsigned int nb, const Vector3D &position, const Vector3D &velocity)
 Adds some Particles to this Group.
void addParticles (unsigned int nb, const Zone *zone, Emitter *emitter, bool full=true)
 Adds some Particles to this Group.
void addParticles (unsigned int nb, const Zone *zone, const Vector3D &velocity, bool full=true)
 Adds some Particles to this Group.
void addParticles (unsigned int nb, const Vector3D &position, Emitter *emitter)
 Adds some Particles to this Group.
void addParticles (unsigned int nb, Emitter *emitter)
 Adds some Particles to this Group.
void addParticles (const Zone *zone, Emitter *emitter, float deltaTime, bool full=true)
 Adds some Particles to this Group.
void addParticles (const Vector3D &position, Emitter *emitter, float deltaTime)
 Adds some Particles to this Group.
void addParticles (Emitter *emitter, float deltaTime)
 Adds some Particles to this Group.
float addParticles (const Vector3D &start, const Vector3D &end, Emitter *emitter, float step, float offset=0.0f)
 Adds some Particles to this Group.
float addParticles (const Vector3D &start, const Vector3D &end, const Vector3D &velocity, float step, float offset=0.0f)
 Adds some Particles to this Group.
void removeParticle (size_t index)
 Removes a Particle from this Group.
void addEmitter (Emitter *emitter)
 Adds an Emitter in this Group.
void removeEmitter (Emitter *emitter)
 Removes an Emitter from this Group.
void addModifier (Modifier *modifier)
 Adds an Modifier in this Group.
void removeModifier (Modifier *modifier)
 Removes an Modifier from this Group.
bool update (float deltaTime)
 Updates this Group by a step time.
void render ()
 Renders this Group.
void empty ()
 Empties this Group.
void flushAddedParticles ()
 Adds all manually added particles to the Group.
void sortParticles ()
 Sorts the particles within this Group.
void computeDistances ()
 Computes the distance between each Particle within this Group and the camera.
void computeAABB ()
 Computes the bounding box of this Group.
void reallocate (size_t capacity)
 Increases the maximum number of particles this Group can hold.
BuffercreateBuffer (const std::string &ID, const BufferCreator &creator, unsigned int flag=0, bool swapData=true) const
 Creates a new additional buffer attached to the Group.
void destroyBuffer (const std::string &ID) const
 Destroys the buffer with the given ID.
void destroyAllBuffers () const
 Destroys all the buffers held by this Group.
BuffergetBuffer (const std::string &ID, unsigned int flag) const
 Gets the buffer with the given ID and checks its flag.
BuffergetBuffer (const std::string &ID) const
 Gets the buffer with the given ID.
virtual RegisterablefindByName (const std::string &name)
 Finds a registerable with its name recursively from this registerable.

Static Public Member Functions

static Groupcreate (Model *model=NULL, size_t capacity=Pool< Particle >::DEFAULT_CAPACITY)
 Creates and registers a new Group.
static void enableBuffersManagement (bool manage)
 Enables or not Renderer buffers management in a statix way.
static bool isBuffersManagementEnabled ()
 Tells whether renderers buffer management is enabled or not.

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

A group of many particles.

A Group is the structure the user will interact with the most to build up a full Particle System.
More than only storing many particles, a Group also defines and entire environment for Particle generation and Evolution.

This class is the spine of the SPARK engine.

Definition at line 53 of file SPK_Group.h.


Constructor & Destructor Documentation

Group ( Model model = NULL,
size_t  capacity = PoolParticle >::DEFAULT_CAPACITY 
)

Constructor for a Group.

A Group is constructed with a Model (if NULL, the default Model will be used to generate particles). This Model will be used to handle Particle's generation and evolution within the Group.

A Group also needs a maximum capacity which is the maximum number of particles the Group can handle. This is necessary to reserve some memory space. Note that the capacity can be changed by calling reallocate(unsigned int). By default, the capacity is set to Pool::DEFAULT_CAPACITY.

Parameters:
model : the Model of this Group
capacity : The maximum number of particles of this Group
Group ( const Group group  ) 

Copy Constructor of Group.

Parameters:
group : the Group to construct the new Group from
~Group (  ) 

The destructor of Group.


Member Function Documentation

void addEmitter ( Emitter emitter  ) 

Adds an Emitter in this Group.

Note that if the emitter is already in the group, it will not be inserted again.

Parameters:
emitter : the Emitter to add
void addModifier ( Modifier modifier  ) 

Adds an Modifier in this Group.

Parameters:
modifier : the Modifier to add
float addParticles ( const Vector3D start,
const Vector3D end,
const Vector3D velocity,
float  step,
float  offset = 0.0f 
)

Adds some Particles to this Group.

See addParticles(const Vector3D&,const Vector3D&,const Emitter*,float,float) for a complete description.

Parameters:
start : the position of the start of the line
end : the position of the end of the line
velocity : the velocity of the Particles
step : the distance between each generated Particle
offset : the starting distance of the beginning of the line
Returns:
the new offset at the end of the line
float addParticles ( const Vector3D start,
const Vector3D end,
Emitter emitter,
float  step,
float  offset = 0.0f 
)

Adds some Particles to this Group.

This method is slightly different to other addParticles methods as Particles are generated not at a point but on a line defined by start and end.
The step is the distance between each Particle on the line and the offset is the starting distance to compute the first Particle's position.
The offset is useful to generate equidistant particles on several lines. the returned offset has to be used as the passed offset for the next line.

This method is useful to generate equidistant particles on lines no matter the framerate.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for some complementary information.

Parameters:
start : the position of the start of the line
end : the position of the end of the line
emitter : the Emitter that will be used to generate the velocity
step : the distance between each generated Particle
offset : the starting distance of the beginning of the line
Returns:
the new offset at the end of the line
void addParticles ( Emitter emitter,
float  deltaTime 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
emitter : the Emitter that will be used to generate the velocity and whose Zone will be used to generate the position
deltaTime : the step time that will be used to determine how many particles to generate
void addParticles ( const Vector3D position,
Emitter emitter,
float  deltaTime 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
position : the position where the Particles will be added
emitter : the Emitter that will be used to generate the velocity
deltaTime : the step time that will be used to determine how many particles to generate
void addParticles ( const Zone zone,
Emitter emitter,
float  deltaTime,
bool  full = true 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
zone : the Zone that will be used to generate the position
emitter : the Emitter that will be used to generate the velocity
deltaTime : the step time that will be used to determine how many particles to generate
full : true to generate a position within the whole Zonz, false only at its borders
void addParticles ( unsigned int  nb,
Emitter emitter 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
nb : the number of Particles to add
emitter : the Emitter that will be used to generate the velocity and whose Zone will be used to generate the position
void addParticles ( unsigned int  nb,
const Vector3D position,
Emitter emitter 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
nb : the number of Particles to add
position : the position where the Particles will be added
emitter : the Emitter that will be used to generate the velocity

Definition at line 1040 of file SPK_Group.h.

void addParticles ( unsigned int  nb,
const Zone zone,
const Vector3D velocity,
bool  full = true 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
nb : the number of Particles to add
zone : the Zone that will be used to generate the position
velocity : the velocity of the Particles
full : true to generate a position within the whole Zonz, false only at its borders

Definition at line 1035 of file SPK_Group.h.

void addParticles ( unsigned int  nb,
const Zone zone,
Emitter emitter,
bool  full = true 
)

Adds some Particles to this Group.

See addParticles(unsigned int,const Vector3D&,const Vector3D&) for a complete description.

Parameters:
nb : the number of Particles to add
zone : the Zone that will be used to generate the position
emitter : the Emitter that will be used to generate the velocity
full : true to generate a position within the whole Zonz, false only at its borders

Definition at line 1030 of file SPK_Group.h.

void addParticles ( unsigned int  nb,
const Vector3D position,
const Vector3D velocity 
)

Adds some Particles to this Group.

This method and all the methods of type addParticles will add a given number of Particles at the given position with the given velocity.
Note that even if a Zone and an Emitter is passed, the position and the velocity will be the same for all Particles.

In case a Zone is passed, Zone::generatePosition(Particle,bool) is used to generate the position.
In case an Emitter is passed, Emitter::generateVelocity(Particle) with a mass of 1 is used to generate the velocity. The velocity will then be updated with the Particle's mass when the Particle will be generated.
In case a delta time is passed instead of a fixed number, the number will be computed thanks to the flow of the Emitter passed.

Particles will be added to the Group at the next call to update(unsigned int) or flushAddedParticles().
This is why any Emitter and Zone used to generate particles must be valid at the next call of either update(unsigned int) or flushAddedParticles().

On some methods addParticles, the full variable is present. This variable defines where to generate positions in a Zone :

  • true to generate position somewhere within the whole Zone.
  • false to generate position somewhere on the Zone border.
Parameters:
nb : the number of Particles to add
position : the position where the Particles will be added
velocity : the velocity of the Particles

Definition at line 1025 of file SPK_Group.h.

void computeAABB (  ) 

Computes the bounding box of this Group.

The bounding box is computed only if the computation of the bounding box of this Group is enabled. See enableAABBComputing(bool).
Note that update(unsigned int) also computes the bounding box.
This method is therefore only useful when the bounding boxe has to be recomputed between 2 updates.

Since:
1.01.00
void computeDistances (  ) 

Computes the distance between each Particle within this Group and the camera.

The distances are computed only if the computation of distances of this Group is enabled. See enableDistanceComputation(bool).
Note that update(unsigned int) also computes the distances between particles and camera.
This method is therefore only useful when the camera position changes several times between 2 updates.

Since:
1.01.00
Group * create ( Model model = NULL,
size_t  capacity = Pool<Particle>::DEFAULT_CAPACITY 
) [static]

Creates and registers a new Group.

Parameters:
model : the Model of this Group
capacity : The maximum number of particles of this Group
Returns:
A new registered Group
Since:
1.04.00

Definition at line 881 of file SPK_Group.h.

Buffer* createBuffer ( const std::string &  ID,
const BufferCreator creator,
unsigned int  flag = 0,
bool  swapData = true 
) const

Creates a new additional buffer attached to the Group.

Additional buffers are used to attach data to a particles. They are mainly used by renderers to store data to transfer to the GPU but can be used by the user in any other way.

A buffer is defined by a ID which is a std::string.
A buffer also has a flag, which can give information about the way it is configured.

Note that ID starting with SPK_ are reserved by the engine. Note also that creating a buffer with an already existing ID will destroy the previous buffer.
A buffer needs a BufferCreator to allow the group to create it.

Parameters:
ID : the ID of the additinal buffer
creator : the buffer creator object
flag : the flag of the buffer
swapData : true to swap data when particle are swapped, false not to (faster but dont keep right order)
Since:
1.03.00
void destroyAllBuffers (  )  const

Destroys all the buffers held by this Group.

Since:
1.03.00
void destroyBuffer ( const std::string &  ID  )  const

Destroys the buffer with the given ID.

If no buffer with this ID exists, nothing happens.
Note that destroying a buffer must never freeze the engine. Checks must be performed.

Parameters:
ID : the ID of the buffer to destroyed
Since:
1.03.00
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.

void empty (  ) 

Empties this Group.

Not that this method does not release resource of this Group. Particles are only inactivated, not destroyed.

void enableAABBComputing ( bool  AABB  ) 

Enables or disables the computation of the axis aligned bouding box of the Group.

if the computing of the AABB is enabled, after each call to update(unsigned int), 2 Vector3D are updated with the coordinates information of the AABB. Those Vector3D can be gotten with getAABBMin() and getAABBMax() which give respectively the minimum and maximum coordinates of the bounding box in each axis.

Knowing the AABB of a Group of particles can be useful in some case like frustum culling for instance.

Note that the bounding box does not use the size information of the particles which means when computing the bounding box, particles are considered to be points in the space.

Parameters:
AABB : true to enable the computing of the AABB of the Group, false to disable it

Definition at line 925 of file SPK_Group.h.

static void enableBuffersManagement ( bool  manage  )  [static]

Enables or not Renderer buffers management in a statix way.

If the buffer management is enabled, then a call to setRenderer(Renderer*) will destroy the existing buffers of the previous Renderer held by this Group, and create the needed buffer for the new Renderer.

By default, the renderer buffers management is enabled.

Parameters:
manage : true to enable buffers management, false to disable it
Since:
1.03.00
void enableDistanceComputation ( bool  distanceComputation  ) 

Enables or disables the computation of the distance of a Particle from the camera.

The distance computation happens at each call to update(unsigned int).
The distance of a Particle from the camera can be gotten with a call to Particle::getDistanceFromCamera() or Particle::getSqrDistanceFromCamera()

Note that the distance is defined by the difference vector between the Particle and the the camera set with System::setCameraPosition(Vector3D&).

If the distance computation is disabled, then the sorting of particles is disabled as well.

Parameters:
distanceComputation : true to enable the computation of the camera distance, false not to
Since:
1.01.00

Definition at line 919 of file SPK_Group.h.

void enableSorting ( bool  sort  ) 

Enables or disables the sorting of particles.

The sorting is performed from particles further to the camera to particles closer to the camera.
Sorting particles allows to well draw particles with alpha.

If the sorting is enabled/disabled, the distance computation is enabled/disabled as well.

Note that sorting a Group is a computationnaly expensive operation that should be avoided when possible.

Parameters:
sort : true to enable the sorting of particles, false otherwise

Definition at line 913 of file SPK_Group.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.

void flushAddedParticles (  ) 

Adds all manually added particles to the Group.

This method adds all particles added with the addParticles methods immediatly to the Group without waiting the next call to update(unsigned int). The Particles are added in FIFO order until there is no more or the capacity limit of the Group is reached.

const Vector3D & getAABBMax (  )  const

Gets a Vector3D holding the maximum coordinates of the AABB of the Group.

Note that this method is only useful when the AABB computation is enabled (see enableAABBComputing(bool)).

Returns:
a Vector3D holding the maximum coordinates of the AABB of the Group

Definition at line 1020 of file SPK_Group.h.

const Vector3D & getAABBMin (  )  const

Gets a Vector3D holding the minimum coordinates of the AABB of the Group.

Note that this method is only useful when the AABB computation is enabled (see enableAABBComputing(bool)).

Returns:
a Vector3D holding the minimum coordinates of the AABB of the Group

Definition at line 1015 of file SPK_Group.h.

Buffer* getBuffer ( const std::string &  ID  )  const

Gets the buffer with the given ID.

NULL is returned if the buffer does not exist

Parameters:
ID : the ID of the buffer
Returns:
a pointer to the buffer, or NULL if not found
Since:
1.03.02
Buffer* getBuffer ( const std::string &  ID,
unsigned int  flag 
) const

Gets the buffer with the given ID and checks its flag.

The flag is used as a check. the passed flag must be the same as the stored flag.
If not or if no buffer with the given ID exists, NULL is returned.

The method returns a pointer on the buffer.

Parameters:
ID : the ID of the buffer to get
flag : the flag used for the flag check
Returns:
a pointer to the buffer, or NULL if not found or with an incorrect flag
Since:
1.03.00
Emitter * getEmitter ( size_t  index  )  const

Gets an Emitter of the Group by its index.

Parameters:
index : the position in the vector of emitters of the Emitter to get
Returns:
: the Emitter at index

Definition at line 955 of file SPK_Group.h.

const std::vector< Emitter * > & getEmitters (  )  const

Gets the emitters of the Group.

Returns:
the vector of emitters of the Group

Definition at line 950 of file SPK_Group.h.

float getFriction (  )  const

Gets the friction coefficient of this Group.

For a description of the friction see setFriction(float).

Returns:
the friction coefficient of this Group

Definition at line 990 of file SPK_Group.h.

const Vector3D & getGravity (  )  const

Gets the gravity Vector3D of this Group.

For a description of the gravity see setGravity(Vector3D&).

Returns:
the gravity Vector3D of this Group

Definition at line 995 of file SPK_Group.h.

Model * getModel (  )  const

Gets the Model of this Group.

Returns:
the Model of this Group

Definition at line 980 of file SPK_Group.h.

Modifier * getModifier ( size_t  index  )  const

Gets an Modifier of the Group by its index.

Parameters:
index : the position in the vector of modifiers of the Modifier to get
Returns:
: the Modifier at index

Definition at line 970 of file SPK_Group.h.

const std::vector< Modifier * > & getModifiers (  )  const

Gets the modifiers of the Group.

Returns:
the vector of modifiers of the Group

Definition at line 965 of file SPK_Group.h.

size_t getNbEmitters (  )  const

Gets the number of emitters in this Group.

Returns:
the number of emitters in this Group

Definition at line 960 of file SPK_Group.h.

size_t getNbModifiers (  )  const

Gets the number of modifiers in this Group.

Returns:
the number of modifiers in this Group

Definition at line 975 of file SPK_Group.h.

size_t getNbParticles (  )  const

Gets the number of particles in the Group.

Returns:
the number of particles in the Group

Definition at line 945 of file SPK_Group.h.

const void* getParamAddress ( ModelParam  param  )  const

Gets the start address of the given param.

This method is used by a Renderer to define the start position of an array to pass to the GPU.
You will not generally need it unless you re designing your own Renderer.

Note that if the parameter is not enabled, the return value will point to an enabled parameter starting address.

Parameters:
param : the parameter whose start address is gotten
Since:
1.03.00
size_t getParamStride (  )  const

Gets the stride for parameters.

This method is used by a Renderer to know the stride of an array to pass to the GPU.
You will not generally need it unless you re designing your own Renderer.

Since:
1.03.00
const Particle & getParticle ( size_t  index  )  const

Gets a single Particle in the Group by its index.

This is the constant version of getParticle(size_t).

Parameters:
index : the index of the Particle to get
Returns:
the Particle at index
Since:
1.02.00

Definition at line 940 of file SPK_Group.h.

Particle & getParticle ( size_t  index  ) 

Gets a single Particle in the Group by its index.

Note that a given Particle in a Group is not ensured to keep the same index all over its life. Particle index can be changed when inactivating particles.

Parameters:
index : the position in the Group's Pool of the Particle to get
Returns:
: the Particle at index

Definition at line 935 of file SPK_Group.h.

const Pool< Particle > & getParticles (  )  const

Gets the Pool of particles of the Group.

Note that the Pool returned is constant as the user is not allowed to modify the internal structure of particles.

Returns:
the Pool of the Group

Definition at line 930 of file SPK_Group.h.

const void * getPositionAddress (  )  const

Gets the start address of the position.

This method is used by a Renderer to define the start position of an array to pass to the GPU.
You will not generally need it unless you re designing your own Renderer.

Since:
1.03.00

Definition at line 1050 of file SPK_Group.h.

size_t getPositionStride (  )  const

Gets the stride for positions.

This method is used by a Renderer to know the stride of an array to pass to the GPU.
You will not generally need it unless you re designing your own Renderer.

Since:
1.03.00

Definition at line 1055 of file SPK_Group.h.

Renderer * getRenderer (  )  const

Gets the Renderer of this Group.

Returns:
the Renderer of this Group

Definition at line 985 of file SPK_Group.h.

bool isAABBComputingEnabled (  )  const

Tells whether the computation of the axis aligned bouding box is enabled.

For a description of the computation of the AABB, see enableAABBComputing(bool).

Returns:
true if the computation of the AABB is enabled, false if it is disabled

Definition at line 1010 of file SPK_Group.h.

static bool isBuffersManagementEnabled (  )  [static]

Tells whether renderers buffer management is enabled or not.

see enableBuffersManagement(bool) for more information.

Returns:
true if renderers buffer management is enabled, false if it is disable
Since:
1.03.00
bool isDistanceComputationEnabled (  )  const

Tells whether the distance computation between particles and camera is enabled.

Returns:
true is the distance computation is enabled, false if not
Since:
1.01.00

Definition at line 1005 of file SPK_Group.h.

bool isSortingEnabled (  )  const

Tells whether the sorting of particles from back to front is enabled.

For a description of the sorting of particles, see enableSorting(bool).

Returns:
true if the sorting is enabled, false otherwise

Definition at line 1000 of file SPK_Group.h.

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

void reallocate ( size_t  capacity  ) 

Increases the maximum number of particles this Group can hold.

Note that decreasing the capacity will have no effect.
A reallocation of the group capacity will destroy all its current buffers.

Parameters:
capacity The maximum number of particles of this Group
Since:
1.02.00
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.

void removeEmitter ( Emitter emitter  ) 

Removes an Emitter from this Group.

Parameters:
emitter : the Emitter to remove
void removeModifier ( Modifier modifier  ) 

Removes an Modifier from this Group.

Parameters:
modifier : the Modifier to remove
void removeParticle ( size_t  index  ) 

Removes a Particle from this Group.

Note that the Particle object is not destroyed but only inactivated in the Pool.

Parameters:
index : the position of the Particle in this Group

Definition at line 1045 of file SPK_Group.h.

void render (  ) 

Renders this Group.

Note that if no Renderer is attached to the Group, nothing will happen.

void setCustomBirth ( void(*)(Particle &)  fbirth  ) 

Assigns a callback for custom birth.

This method allows to assign a callback function that will be called each time a Particle borns.
The signature of the function must be of the form :
void customUpdate(Particle&)
with Particle& being the Particle which is just born.

Parameters:
fbirth : A pointer to the callback function that will perform custom birth for this Group

Definition at line 903 of file SPK_Group.h.

void setCustomDeath ( void(*)(Particle &)  fdeath  ) 

Assigns a callback for custom death.

This method allows to assign a callback function that will be called each time a Particle dies.
The signature of the function must be of the form :
void customUpdate(Particle&)
with Particle& being the Particle which has just died.

Parameters:
fdeath : A pointer to the callback function that will perform custom death for this Group

Definition at line 908 of file SPK_Group.h.

void setCustomUpdate ( bool(*)(Particle &, float)  fupdate  ) 

Assigns a callback for the custom update.

The user has the possibility to assign a callback function for update that will be called for each Particle right after the standard update.
The signature of the function must be of the form :
bool customUpdate(Particle&,unsigned int)
with :

  • Particle& being the Particle which is currently updated
  • float being the time step
  • the return bool being true if the Particle has to die at the end of the update, false otherwise
Parameters:
fupdate : A pointer to the callback function that will perform custom update for this Group

Definition at line 898 of file SPK_Group.h.

void setFriction ( float  friction  ) 

Sets the friction of this Group.

The friction defines the way particles are accelerated or decelerated in their environment.

  • If the friction is 0.0f, particles in the Group are neither accelerated nor decelerated (it is the default setting).
  • If the friction is positive, particles will be decelerated function of their speed.
  • If the friction is negative, particles will be accelerated function of their speed.

The friction is applied on each Particle as followed :
velocity *= 1 - min(1,friction * deltaTime / weight)

Note that the lighter the Particle, the more effect has the friction on it.

Parameters:
friction the friction of the Group

Definition at line 888 of file SPK_Group.h.

void setGravity ( const Vector3D gravity  ) 

Sets the gravity of this Group.

The gravity is a vector which defines an attractive force that will be applied to each Particle in the Group during the update.
By default the gravity is the null vector (i.e. a Vector3D equal to (0,0,0)) which means no gravity is applied.

The gravity is applied on each Particle as followed :
velocity += gravity * deltaTime

Parameters:
gravity : the Vector3D that will be used as the gravity for this Group

Definition at line 893 of file SPK_Group.h.

void setModel ( Model model  ) 

change the Model of this Group

If the model parameter is set to NULL, the default model will be used. No changes are done if the model parameter is equal to the Model of this Group. Changing the Model of this Group will empty it.

Parameters:
model : the Model of this Group
void setRenderer ( Renderer renderer  ) 

Sets the Renderer of this Group.

If the Renderer is set to NULL, the particles of the Group will not be renderered with a call to render().

Note that if the bufferManagement is on (see enableBuffersManagement(bool)), setting the Renderer will first destroys the buffers needed for the previous Renderer held by this Group and create buffers needed for the new Renderer.

Parameters:
renderer : the Renderer of this Group
void sortParticles (  ) 

Sorts the particles within this Group.

The particles are sorted only if the sorting of this Group is enabled. See enableSorting(bool).
Note that update(unsigned int) also sorts the particles.
This method is therefore only useful when the camera position changes several times between 2 updates.

This method also makes a call to computeDistances().

Since:
1.01.00
bool update ( float  deltaTime  ) 

Updates this Group by a step time.

The update process performs those operations :

  • Updates the mutable parameters of each Particle.
  • Updates the velocity of each Particle function of the friction and the gravity of the Group.
  • Applies each Modifier of the Group to each Particle.
  • Removes all dead particles
  • Adds particles generated by the emitters of the Group.
  • Adds particles added manually by the user (with calls to addParticles).

Those operations are optimized to limit the swaps and shifts of particles in the Pool to its minimum.
This method tells whether the Group still has some Particles, or if some Particles will still be generated by the Emitters at the next updates by returning a boolean.

Parameters:
deltaTime : the time step used to update the Group
Returns:
true if the Group has still some current or future Particles to update, false otherwise

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