A model of particles for particles' generation and evolution. More...
Public Member Functions | |
Model (int enableFlag=FLAG_RED|FLAG_GREEN|FLAG_BLUE, int mutableFlag=FLAG_NONE, int randomFlag=FLAG_NONE, int interpolatedFlag=FLAG_NONE) | |
The constructor for Model. | |
Model (const Model &model) | |
The copy constructor for Model. | |
~Model () | |
The destructor for Model. | |
void | setLifeTime (float lifeTimeMin, float lifeTimeMax) |
Sets the life time. | |
void | setImmortal (bool immortal) |
Defines whether to generate immortal particles or not. | |
bool | setParam (ModelParam type, float startMin, float startMax, float endMin, float endMax) |
Sets a given parameter with 4 values. | |
bool | setParam (ModelParam type, float value0, float value1) |
Sets a given parameter with 2 values. | |
bool | setParam (ModelParam type, float value) |
Sets a given parameter with 1 value. | |
float | getLifeTimeMin () const |
Gets the minimum life time. | |
float | getLifeTimeMax () const |
Gets the maximum life time. | |
bool | isImmortal () const |
Returns whether immortility is set or not. | |
int | isEnabled (ModelParam type) const |
Checks whether a parameter is enabled or not. | |
int | isMutable (ModelParam type) const |
Checks whether a parameter is mutable or not. | |
int | isRandom (ModelParam type) const |
Checks whether a parameter is random or not. | |
int | isInterpolated (ModelParam type) const |
Checks whether a parameter is interpolated or not. | |
float | getParamValue (ModelParam type, size_t index) const |
Gets a parameter value. | |
unsigned int | getNbValues (ModelParam type) const |
Gets the number of values for a parameter. | |
size_t | getNbEnabled () const |
Gets the number of enabled parameters. | |
size_t | getNbMutable () const |
Gets the number of mutable parameters. | |
size_t | getNRandom () const |
Gets the number of random parameters. | |
Interpolator * | getInterpolator (ModelParam param) |
Gets the interpolator for the given parameter. | |
size_t | getNbInterpolated () const |
Gets the number of interpolated parameters. | |
size_t | getSizeOfParticleCurrentArray () const |
Gets the number of float values in the particle current array. | |
size_t | getSizeOfParticleExtendedArray () const |
Gets the number of float values in the particle extended array. | |
size_t | getSizeOfModelArray () const |
Gets the number of float values in the model array. | |
size_t | getParameterOffset (ModelParam param) const |
Gets the offset of the given parameter in the current array. | |
Static Public Member Functions | |
static Model * | create (int enableFlag=FLAG_RED|FLAG_GREEN|FLAG_BLUE, int mutableFlag=FLAG_NONE, int randomFlag=FLAG_NONE, int interpolatedFlag=FLAG_NONE) |
Creates and registers a new Model. | |
static float | getDefaultValue (ModelParam param) |
Gets the default value of the parameter. |
A model of particles for particles' generation and evolution.
This class defines a behavior for particles generation and evolution over time.
A Particle is generated under a Model that cannot be changed during its life time. A Particle Model can however be changed but it will reinitialize the Particle parameters and life.
A Model defines which parameters to use/update for a Particle. To do that an Model holds 4 flags that are :
The flags are processed when building up a model so that they are consistent :
The life time of a particle and immortality is also defined by the Model.
The default values for the parameters are the following :
Definition at line 95 of file SPK_Model.h.
Model | ( | int | enableFlag = FLAG_RED|FLAG_GREEN|FLAG_BLUE , |
|
int | mutableFlag = FLAG_NONE , |
|||
int | randomFlag = FLAG_NONE , |
|||
int | interpolatedFlag = FLAG_NONE | |||
) |
The constructor for Model.
The user have to pass the Model flags that cannot be changed afterwards.
To set up flags enumerators from ModelParamFlag can be used in a OR way.
For instance, Model(FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA,FLAG_NONE,FLAG_NONE,FLAG_NONE) constructs a Model that will generate Particles with a defined color that will not change over time.
Since 1.03.00, PARAM_RED, PARAM_GREEN and PARAM_BLUE are enabled by default. This is needed to pass the values to the GPU in an optimized way.
Note that even the enable flag passed by the user does not containt those params, they will be enabled anyway.
enableFlag | : the enable flag | |
mutableFlag | : the mutable flag | |
randomFlag | : the random flag | |
interpolatedFlag | : the interpolated flag |
Model * create | ( | int | enableFlag = FLAG_RED | FLAG_GREEN | FLAG_BLUE , |
|
int | mutableFlag = FLAG_NONE , |
|||
int | randomFlag = FLAG_NONE , |
|||
int | interpolatedFlag = FLAG_NONE | |||
) | [static] |
Creates and registers a new Model.
enableFlag | : the enable flag | |
mutableFlag | : the mutable flag | |
randomFlag | : the random flag | |
interpolatedFlag | : the interpolated flag |
Definition at line 471 of file SPK_Model.h.
static float getDefaultValue | ( | ModelParam | param | ) | [static] |
Gets the default value of the parameter.
param | : the parameter to get the default value from |
Interpolator * getInterpolator | ( | ModelParam | param | ) |
Gets the interpolator for the given parameter.
param | : the parameter whose intepolator must be retrieved |
Definition at line 539 of file SPK_Model.h.
float getLifeTimeMax | ( | ) | const |
Gets the maximum life time.
Definition at line 494 of file SPK_Model.h.
float getLifeTimeMin | ( | ) | const |
Gets the minimum life time.
Definition at line 489 of file SPK_Model.h.
size_t getNbEnabled | ( | ) | const |
Gets the number of enabled parameters.
Definition at line 524 of file SPK_Model.h.
size_t getNbInterpolated | ( | ) | const |
Gets the number of interpolated parameters.
Definition at line 544 of file SPK_Model.h.
size_t getNbMutable | ( | ) | const |
Gets the number of mutable parameters.
Definition at line 529 of file SPK_Model.h.
unsigned int getNbValues | ( | ModelParam | type | ) | const |
Gets the number of values for a parameter.
The number of values depends on the Model flags :
type | : the parameter |
size_t getNRandom | ( | ) | const |
Gets the number of random parameters.
Definition at line 534 of file SPK_Model.h.
size_t getParameterOffset | ( | ModelParam | param | ) | const |
Gets the offset of the given parameter in the current array.
This methods is used internally by the engine
param | : the parameter |
Definition at line 564 of file SPK_Model.h.
float getParamValue | ( | ModelParam | type, | |
size_t | index | |||
) | const |
Gets a parameter value.
If index is superior or equal to the number of values for the parameter, the default value of the parameter is returned.
Otherwise the value returned depending on the index is :
Note that in case of an interpolated parameter, the default value is always returned.
The user has to use the interpolator object associated to the parameter to get its values.
type | : the parameter | |
index | : the index of the value to get |
size_t getSizeOfModelArray | ( | ) | const |
Gets the number of float values in the model array.
This is used internally and should not be needed by the user.
Definition at line 559 of file SPK_Model.h.
size_t getSizeOfParticleCurrentArray | ( | ) | const |
Gets the number of float values in the particle current array.
The particle current array holds the current values of enabled parameters for a particle.
This is used internally and should not be needed by the user.
Definition at line 549 of file SPK_Model.h.
size_t getSizeOfParticleExtendedArray | ( | ) | const |
Gets the number of float values in the particle extended array.
The particle extended array holds the extended values needed for parameters interpolation for a particle.
This is used internally and should not be needed by the user.
Definition at line 554 of file SPK_Model.h.
int isEnabled | ( | ModelParam | type | ) | const |
Checks whether a parameter is enabled or not.
type | : the parameter |
Definition at line 504 of file SPK_Model.h.
bool isImmortal | ( | ) | const |
Returns whether immortility is set or not.
Definition at line 499 of file SPK_Model.h.
int isInterpolated | ( | ModelParam | type | ) | const |
Checks whether a parameter is interpolated or not.
type | : the parameter |
Definition at line 519 of file SPK_Model.h.
int isMutable | ( | ModelParam | type | ) | const |
Checks whether a parameter is mutable or not.
type | : the parameter |
Definition at line 509 of file SPK_Model.h.
int isRandom | ( | ModelParam | type | ) | const |
Checks whether a parameter is random or not.
type | : the parameter |
Definition at line 514 of file SPK_Model.h.
void setImmortal | ( | bool | immortal | ) |
Defines whether to generate immortal particles or not.
Immortal particles will still be given a life time. However the age of immortal particles will not increase so that they cannot die. An immortal Particle whose Model immortality is unset will grow older again.
The immortality is therefore dynamic and can be granted or removed by impacting all particles generated under this Model.
immortal | : whether the Model will generate immortal particles or not |
Definition at line 484 of file SPK_Model.h.
void setLifeTime | ( | float | lifeTimeMin, | |
float | lifeTimeMax | |||
) |
Sets the life time.
All particles generated under this Model will be given a life time randomly generated within [lifeTimeMin,lifeTimeMax[.
To generate particles with a non random life time, simply use setLifeTime(a,a).
lifeTimeMin | : the minimum life time | |
lifeTimeMax | : the maximum life time |
Definition at line 478 of file SPK_Model.h.
bool setParam | ( | ModelParam | type, | |
float | value | |||
) |
Sets a given parameter with 1 value.
This method will only set parameters that are enabled and neither mutable or random.
If not nothing will happen and the method will return false.
Note that to set the value of an interpolated parameter cannot be set with this function, you must used the interpolator object associated to the parameter to control its value.
type | : the parameter to set | |
value | : the value of the parameter |
bool setParam | ( | ModelParam | type, | |
float | value0, | |||
float | value1 | |||
) |
Sets a given parameter with 2 values.
This method will only set parameters that are enabled and either mutable or random.
If not nothing will happen and the method will return false.
In case of a mutable parameter : value0 defines the birth value and value0 defines the death value.
In case of a random parameter : value0 defines the minimum value and value1 defines the maximum value.
type | : the parameter to set | |
value0 | : the first value (the meaning depends on the flag) | |
value1 | : the second value (the meaning depends on the flag) |
bool setParam | ( | ModelParam | type, | |
float | startMin, | |||
float | startMax, | |||
float | endMin, | |||
float | endMax | |||
) |
Sets a given parameter with 4 values.
This method will only set parameters that are enabled, mutable and random.
If not nothing will happen and the method will return false.
type | : the parameter to set | |
startMin | : the minimum value at the Particle birth | |
startMax | : the maximum value at the Particle birth | |
endMin | : the minimum value at the Particle death | |
endMax | : the maximum value at the Particle death |