Model Class Reference

A model of particles for particles' generation and evolution. More...

Inheritance diagram for Model:
Registerable

List of all members.

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.
InterpolatorgetInterpolator (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 Modelcreate (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.

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
enableFlag : the enable flag
mutableFlag : the mutable flag
randomFlag : the random flag
interpolatedFlag : the interpolated flag
Model ( const Model model  ) 

The copy constructor for Model.

Parameters:
model : The Model to construct the new Model from
~Model (  ) 

The destructor for Model.


Member Function Documentation

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.

Parameters:
enableFlag : the enable flag
mutableFlag : the mutable flag
randomFlag : the random flag
interpolatedFlag : the interpolated flag
Returns:
A new registered Model
Since:
1.04.00

Definition at line 471 of file SPK_Model.h.

static float getDefaultValue ( ModelParam  param  )  [static]

Gets the default value of the parameter.

Parameters:
param : the parameter to get the default value from
Returns:
the default value of the parameter
Since:
1.05.00
Interpolator * getInterpolator ( ModelParam  param  ) 

Gets the interpolator for the given parameter.

Parameters:
param : the parameter whose intepolator must be retrieved
Returns:
a pointer to the interpolator of the given parameter or NULL if the parameter is not interpolated
Since:
1.05.00

Definition at line 539 of file SPK_Model.h.

float getLifeTimeMax (  )  const

Gets the maximum life time.

Returns:
the minimum life time

Definition at line 494 of file SPK_Model.h.

float getLifeTimeMin (  )  const

Gets the minimum life time.

Returns:
the minimum life time

Definition at line 489 of file SPK_Model.h.

size_t getNbEnabled (  )  const

Gets the number of enabled parameters.

Returns:
the number of enabled parameters in the model
Since:
1.05.00

Definition at line 524 of file SPK_Model.h.

size_t getNbInterpolated (  )  const

Gets the number of interpolated parameters.

Returns:
the number of interpolated parameters in the model
Since:
1.05.00

Definition at line 544 of file SPK_Model.h.

size_t getNbMutable (  )  const

Gets the number of mutable parameters.

Returns:
the number of mutable parameters in the model
Since:
1.05.00

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 :

  • Enabled parameter : 1
  • Mutable or random parameter : 2
  • Mutable and random parameter : 4
  • Interpolated parameter : 0
  • Not Enabled : 0
Parameters:
type : the parameter
Returns:
the number of values stored in the Model for the parameter
size_t getNRandom (  )  const

Gets the number of random parameters.

Returns:
the number of random parameters in the model
Since:
1.05.00

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

Parameters:
param : the parameter
Returns:
the offset of the given parameter in the current array
Since:
1.03.00

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 :

  • Enabled parameters :
    • 0 : the value of the parameter
  • Mutable parameters :
    • 0 : the birth value of the parameter
    • 1 : the death value of the parameter
  • Random parameters :
    • 0 : the minimum value of the parameter
    • 1 : the maximum value of the parameter
  • Mutable and random parameters :
    • 0 : the minimum birth value of the parameter
    • 1 : the maximum birth value of the parameter
    • 2 : the minimum death value of the parameter
    • 3 : the maximum death value of the parameter

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.

Parameters:
type : the parameter
index : the index of the value to get
Returns:
the value
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.

Returns:
the number of float values in the model array
Since:
1.02.00

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.

Returns:
the number of float values in the particle current array
Since:
1.02.00

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.

Returns:
the number of float values in the particle extended array
Since:
1.03.00

Definition at line 554 of file SPK_Model.h.

int isEnabled ( ModelParam  type  )  const

Checks whether a parameter is enabled or not.

Parameters:
type : the parameter
Returns:
0 is the parameter is not enabled, a flag with the parameter bit set otherwise

Definition at line 504 of file SPK_Model.h.

bool isImmortal (  )  const

Returns whether immortility is set or not.

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.

Parameters:
type : the parameter
Returns:
0 is the parameter is not interpolated, a flag with the parameter bit set otherwise
Since:
1.05.00

Definition at line 519 of file SPK_Model.h.

int isMutable ( ModelParam  type  )  const

Checks whether a parameter is mutable or not.

Parameters:
type : the parameter
Returns:
0 is the parameter is not mutable, a flag with the parameter bit set otherwise

Definition at line 509 of file SPK_Model.h.

int isRandom ( ModelParam  type  )  const

Checks whether a parameter is random or not.

Parameters:
type : the parameter
Returns:
0 is the parameter is not random, a flag with the parameter bit set otherwise

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.

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

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

Parameters:
type : the parameter to set
value : the value of the parameter
Returns:
true if the parameter can be set (right flags), false otherwise
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.

Parameters:
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)
Returns:
true if the parameter can be set (right flags), false otherwise
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.

Parameters:
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
Returns:
true if the parameter can be set (right flags), false otherwise

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