A whole system of particles. More...
Public Member Functions | |
System () | |
Constructor of System. | |
void | enableAABBComputing (bool AABB) |
Enables or disables the computation of the axis aligned Vector for this System. | |
size_t | getNbParticles () const |
Gets the number of active particles in this system. | |
size_t | computeNbParticles () |
Computes the number of active particles in this System and returns it. | |
size_t | getNbGroups () const |
Gets the number of groups in the System. | |
const std::vector< Group * > & | getGroups () const |
Gets the vector of the groups (pointers) in this System. | |
Group * | getGroup (size_t index) |
Gets the Group at index. | |
bool | isAABBComputingEnabled () const |
Tells whether the computation of the axis aligned bouding box is enabled. | |
const Vector3D & | getAABBMin () const |
Gets a Vector3D holding the minimum coordinates of the AABB of this System. | |
const Vector3D & | getAABBMax () const |
Gets a Vector3D holding the maximum coordinates of the AABB of this System. | |
void | addGroup (Group *group) |
Adds a Group to the System. | |
void | removeGroup (Group *group) |
Removes a Group from the System. | |
virtual bool | update (float deltaTime) |
Updates the System of the current time step. | |
virtual void | render () const |
Renders particles in the System. | |
void | grow (float time, float step) |
Makes this System grow to the given time. | |
void | empty () |
Empties the System. | |
void | sortParticles () |
Sorts the particles in all the group of this System where the sorting is enabled. | |
void | computeDistances () |
Computes the distances between each Particle in each Group of this System. | |
void | computeAABB () |
Computes the bounding box of this System and of all groups in the System. | |
virtual Registerable * | findByName (const std::string &name) |
Finds a registerable with its name recursively from this registerable. | |
Static Public Member Functions | |
static System * | create () |
Creates and registers a new System. | |
static void | setCameraPosition (const Vector3D &cameraPosition) |
Sets the camera position. | |
static void | setClampStep (bool useClampStep, float clamp=1.0f) |
Enables or not the clamping on the deltaTime when updating systems. | |
static void | useConstantStep (float constantStep) |
Uses a constant step to update the systems. | |
static void | useAdaptiveStep (float minStep, float maxStep) |
Uses an adaptive step to update the systems. | |
static void | useRealStep () |
Uses the real step to update the systems. | |
static const Vector3D & | getCameraPosition () |
Gets the camera position. | |
static StepMode | getStepMode () |
Gets the current step mode. | |
Protected Member Functions | |
virtual void | registerChildren (bool registerAll) |
Registers the children of this Registerable. | |
virtual void | destroyChildren (bool createBase) |
Destroys the children of this Registerable. | |
virtual void | propagateUpdateTransform () |
Propagates the update of the transform to transformable children of this transformable. |
A whole system of particles.
This class defines a whole system of particles. It contains particle groups.
It offers a way to handle a system very easily.
Basically a particle system is updated by calling update(unsigned int) and renderered with render() at each frame.
Note that a System is only a helper class to manage many Groups. However it can be omitted and groups can be updated and rendered alone.
A System is transformable. If the system is transformed, all its sub emitters will be transformed as well. However, its modifiers will not (modifiers can be described in the world coordinates already). If you wish to transform some of its modifiers as well, you will have to do it aside.
Definition at line 63 of file SPK_System.h.
void addGroup | ( | Group * | group | ) |
void computeAABB | ( | ) |
Computes the bounding box of this System and of all groups in the System.
The bounding box of the System is only computed if the System has its bounding box computing enabled.
In the same way, the bounding box of a Group within the System is only computed if the Group has its bounding box computing enabled.
Note that the computation of bounding boxes is also performed during the update.
This method is therefore only useful when the bounding boxes have to be recomputed between 2 updates.
This methods calls the Group::computeAABB() of each Group in this System.
void computeDistances | ( | ) |
Computes the distances between each Particle in each Group of this System.
Note that the distances computation is also performed during the update.
This method is therefore only useful when the camera position changes several times between 2 updates.
This methods calls the Group::computeDistances() of each Group in this System.
size_t computeNbParticles | ( | ) |
Computes the number of active particles in this System and returns it.
Unlike getNbParticles() which returns the last number of particles computed (after a call to update(float) or empty()), this method recomputes the current number of active particles by parsing all the groups of this System.
In that way, this method must not be used as an accessor but call once when necesseray between 2 updates.
Note that this method updates the inner number of particles of this System, which means a call to getNbParticles() will then return the computed number.
System * create | ( | ) | [static] |
Creates and registers a new System.
Definition at line 409 of file SPK_System.h.
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.
void empty | ( | ) |
void enableAABBComputing | ( | bool | AABB | ) |
Enables or disables the computation of the axis aligned Vector for this System.
Enabling the computation of the AABB for the System only takes the AABB of all AABB of the Groups within the System where AABB computation is enabled.
see Group::enableAABBComputing(bool) for more details.
AABB | : true to enable the computing of the AABB of this System, false to disable it |
Definition at line 416 of file SPK_System.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.
const Vector3D & getAABBMax | ( | ) | const |
Gets a Vector3D holding the maximum coordinates of the AABB of this System.
Note that this method is only useful when the AABB computation is enabled (see enableAABBComputing(bool)).
Definition at line 451 of file SPK_System.h.
const Vector3D & getAABBMin | ( | ) | const |
Gets a Vector3D holding the minimum coordinates of the AABB of this System.
Note that this method is only useful when the AABB computation is enabled (see enableAABBComputing(bool)).
Definition at line 446 of file SPK_System.h.
static const Vector3D& getCameraPosition | ( | ) | [static] |
Gets the camera position.
Note that the camera position vector is only read by SPARK. Only the user modifies it.
Group * getGroup | ( | size_t | index | ) |
Gets the Group at index.
Note that no bound check is performed.
index | : the index of the Group to get |
Definition at line 436 of file SPK_System.h.
const std::vector< Group * > & getGroups | ( | ) | const |
Gets the vector of the groups (pointers) in this System.
This method allows to modify Group parameters within the System.
Note that for addition and removal, methods addGroup(Group*) and removeGroup(Group*) must exist.
Definition at line 431 of file SPK_System.h.
size_t getNbGroups | ( | ) | const |
Gets the number of groups in the System.
Definition at line 426 of file SPK_System.h.
size_t getNbParticles | ( | ) | const |
Gets the number of active particles in this system.
The number of active particles in the system is the addition of the number of active particles in each group of the system.
Note that the number of active particle of the system is updated after each update of the system.
This means if the user changes manually the number of particles in a group and call this method before an update, the number returned will not be up to date.
To compute and get the real number of active particles in the System, see computeNbParticles().
Definition at line 421 of file SPK_System.h.
static StepMode getStepMode | ( | ) | [static] |
Gets the current step mode.
void grow | ( | float | time, | |
float | step | |||
) |
Makes this System grow to the given time.
This method is useful to get a newwly created System to a mature state.
This method only calls update(float) with the step until the total update time reaches the time.
time | : the total time of which to update this System | |
step | : the time the System is updated at each call to update(float) |
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).
Definition at line 441 of file SPK_System.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.
Reimplemented from Transformable.
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.
void removeGroup | ( | Group * | group | ) |
virtual void render | ( | ) | const [virtual] |
Renders particles in the System.
Note that this method renders all groups in the System from first to last.
Reimplemented in IRRSystem, and SFMLSystem.
static void setCameraPosition | ( | const Vector3D & | cameraPosition | ) | [static] |
Sets the camera position.
Note that the camera position is only useful if a group has to be sorted.
In that case this vector will be used as the camera position to derive the distance between the particle and the camera position.
The camera position has to be updated before an update of the sorted group.
cameraPosition | the camera position |
static void setClampStep | ( | bool | useClampStep, | |
float | clamp = 1.0f | |||
) | [static] |
Enables or not the clamping on the deltaTime when updating systems.
This allows to limit too big deltaTime which may spoil your particle systems.
Basically if the deltaTime is higher than the clamp value, the clamp calue is used as the deltaTime.
It allows in real step mode to avoid having too big deltaTimes and in the other 2 modes to avoid having too many updates that may slow down the application.
Note that setting the clamp value too low may slow down your systems
useClampStep | : true to use a clamp value on the step, false not to | |
clamp | : the clamp value |
void sortParticles | ( | ) |
Sorts the particles in all the group of this System where the sorting is enabled.
Note that the sorting is also performed during the update.
This method is therefore only useful when the camera position changes several times between 2 updates.
This methods calls the Group::sortParticles() of each Group in this System.
virtual bool update | ( | float | deltaTime | ) | [virtual] |
Updates the System of the current time step.
Note that this method updates all groups in the System from first to last.
deltaTime | : the time step |
Reimplemented in IRRSystem, and SFMLSystem.
static void useAdaptiveStep | ( | float | minStep, | |
float | maxStep | |||
) | [static] |
Uses an adaptive step to update the systems.
This tells the system to be updated with a time between min and max.
If the deltaTime passed is higher than maxStep or lower than minStep then this mode operates like the constant step mode with either constant time being maxStep or minStep (respectivally).
If the deltaTime lies between minStep and maxStep then this mode performs like the real step mode.
This mode is a good alternative between the other two.
Combined with the clamp step, it allows to correctly handle the step time without being to much frame rate dependant.
minStep | : the minimal time step | |
maxStep | : the maximal time step |
static void useConstantStep | ( | float | constantStep | ) | [static] |
Uses a constant step to update the systems.
This tells the system to be updated with a constant time.
Depending on the deltaTime passed for the update, 0 to many updates can occur.
For example if the delta time is 1.0 and the constant step is 0.1 then 10 updates of time 0.1 will occur.
This mode is useful when the update must be constant (accurate collisions...) but be aware it can be very computationnaly intensive.
constantStep | : the value of the step |
static void useRealStep | ( | ) | [static] |
Uses the real step to update the systems.
This is the basic mode (and the mode per default) to update the systems.
One call to update means one update of time deltaTime.
This mode is the simpler and the one that allows best performance on low end systems.
However the update may be inaccurate (due to too big deltaTime) and it performs badly with frame rate variation.