My Project
|
The particle class keeps a list of all of its instances.A particle system instance is always associated with a owner pointer, which is now the current scene object, such as a missile or a biped. More...
#include <particle.h>
Public Member Functions | |
void | update (SceneState *pSceneState, float dt) |
void | ClearAllInstances () |
clear all particle instances. More... | |
DeviceTexturePtr_type | GetDeviceTexture () |
get associated texture | |
TextureEntity * | GetTexture () |
bool | AnimateExistingParticles (float dt, const Vector3 &vOffset, ParticleList *instancePS) |
only update existing particles More... | |
ParticleList * | GetCurrentInstance (SceneState *pSceneState, bool bForceCreate=true) |
get the current particle system instance according to the current scene object. More... | |
bool | DeleteInstance (void *owner) |
delete instances for a given scene object | |
void | setup (SceneState *pSceneState, int anim, int time) |
set the current animation ID and animation time, this function is usually called by its parent model to make them synchronized. More... | |
void | draw (SceneState *pSceneState) |
draw the current instance, if it is a non-absolute particle system instance. More... | |
void | drawInstance (ParticleList *instancePS) |
draw a specified instance. More... | |
void | drawAllAbsInstances () |
draw all absolute instances.This is called for batch-rendering global(absolute) particle instances. More... | |
CParaXModel * | GetParent () |
get the parent model. More... | |
void | DrawInstanceSub (ParticleList *instancePS) |
void | SetTextureRowsCols (int nRows, int nCols) |
set how many rows and cols that the texture associated with this particle system is evenly divided into. | |
Public Attributes | |
Animated< float > | speed |
initial speed, the initial speed magnitude of a particle is V(0) = speed + variation * rand(-1,1). | |
Animated< float > | variation |
initial speed variation, the initial speed magnitude of a particle is V(0) = speed + variation * rand(-1,1). | |
Animated< float > | gravity |
particle acceleration magnitude along their current directions, shared by all existing particles at a given time , this is usually a positive constant like 9.8 | |
Animated< float > | lifespan |
maxlife of a newly born particle in seconds | |
Animated< float > | rate |
how many particles to spawn per second. | |
Animated< float > | areal |
the half length of the emitter plane | |
Animated< float > | areaw |
the half width of the emitter plane | |
Animated< float > | spread |
RESERVED: this parameter is reserved for other emitter types. | |
Animated< float > | lat |
RESERVED: this parameter is reserved for other emitter types. | |
Animated< float > | grav2 |
RESERVED: this parameter is reserved for other emitter types. | |
float | slowdown |
it controls how fast the speed magnitude of a particle dwindles as its life is approaching the end. More... | |
float | rotation |
float | mid |
the color[0] and sizes[0] is the color and size of a particle at its birth the color[1] and sizes[1] is the color and size of a particle at when it is age is mid, assuming a lifespan in [0,1] the color[2] and sizes[2] is the color and size of a particle at its death for particle at any age [0,1], it will interpolate between these values linearly. More... | |
Vector4 | colors [3] |
float | sizes [3] |
Vector3 | pos |
all particles are offset by this value at its birth. this is usually V(0,0,0). | |
int | blend |
how the texture blending is applied to each particle. More... | |
int | order |
the triangle winding order of the quad: whether it is CCW(-1) or CW(0). It does not matter if particle is transparent. | |
int | type |
this is 0,1,2. More... | |
bool | billboard |
whether using billboard when during the particles. In most cases, this is true, because particles are usually drawn with triangle quads facing the camera. | |
int | rows |
int | cols |
std::vector< TexCoordSet > | tiles |
int32 | m_texture_index |
Bone * | parent |
ParticleEmitter * | emitter |
CParaXModel * | model |
float | tofs |
this is just a rand seed for this particle system. | |
map< void *, ParticleList * > | m_instances |
instances of the particle systems. More... | |
bool | rotate2SpeedDirection |
Friends | |
class | PlaneParticleEmitter |
class | SphereParticleEmitter |
The particle class keeps a list of all of its instances.A particle system instance is always associated with a owner pointer, which is now the current scene object, such as a missile or a biped.
The instance may be global or local. Global particles remain in the scene even after its owner object is released and is rendered as global object. The scene manager keeps a reference to all active particle systems and their instances. It will automatically delete instances that is no longer active in the current frame. It will also animate and render global PS instances whose owner has been destroyed. Particles in global particle systems should have a short(finite) life time, in order to clean themselves quickly after its owner is released.
bool ParticleSystem::AnimateExistingParticles | ( | float | dt, |
const Vector3 & | vOffset, | ||
ParticleList * | instancePS | ||
) |
only update existing particles
dt | time delta |
vOffset | all position and origin will be offset by this value during animation. this is usually the render origin offset between two consecutive calls. |
instancePS | particle system instance. |
void ParaEngine::ParticleSystem::ClearAllInstances | ( | ) |
clear all particle instances.
delete all particle system instances
void ParticleSystem::draw | ( | SceneState * | pSceneState | ) |
draw the current instance, if it is a non-absolute particle system instance.
get the particle system instance for the current scene object.
void ParticleSystem::drawAllAbsInstances | ( | ) |
draw all absolute instances.This is called for batch-rendering global(absolute) particle instances.
void ParticleSystem::drawInstance | ( | ParticleList * | instancePS | ) |
draw a specified instance.
draw the particle system instance.
void ParticleSystem::DrawInstanceSub | ( | ParticleList * | instancePS | ) |
each particle is rendered as a quad, which require 2 triangles or 6 vertices.
ParticleList * ParticleSystem::GetCurrentInstance | ( | SceneState * | pSceneState, |
bool | bForceCreate = true |
||
) |
get the current particle system instance according to the current scene object.
bForceCreate | if this is true, the instance will be created if not found. |
get the particle system instance for the current scene object.
|
inline |
get the parent model.
void ParticleSystem::setup | ( | SceneState * | pSceneState, |
int | anim, | ||
int | time | ||
) |
set the current animation ID and animation time, this function is usually called by its parent model to make them synchronized.
void ParticleSystem::update | ( | SceneState * | pSceneState, |
float | dt | ||
) |
get the particle system instance for the current scene object.
add this particle system to the scene state. so that the scene state will automatically maintain the life of this particle system instance.
mark as updated instance
animate existing particles.
spawn new particles Tricky: 2010.3.10: we will not spawn new particle at very low frame rate, such as 10FPS
int ParaEngine::ParticleSystem::blend |
how the texture blending is applied to each particle.
In most cases, it is 2 ALPHA_BLEND or 4 ADDITIVE ALPHA. 0 for OPAQUE; 1 ADDITIVE BLEND; 2 ALPHA_BLEND(using alpha); 3 TRANSPARENT(using alpha testing); 4 ADDITIVE ALPHA;
map<void*, ParticleList*> ParaEngine::ParticleSystem::m_instances |
instances of the particle systems.
mapping from the owner object,typically this is a scene object, to the particle list of that owner
float ParaEngine::ParticleSystem::mid |
the color[0] and sizes[0] is the color and size of a particle at its birth the color[1] and sizes[1] is the color and size of a particle at when it is age is mid, assuming a lifespan in [0,1] the color[2] and sizes[2] is the color and size of a particle at its death for particle at any age [0,1], it will interpolate between these values linearly.
Age is defined as particle_time/life_span; In most cases, mid is 0.5, color[0] and color[2] are transparent;or sizes[0] and size[2] are zero, either of which will let particle fade in and out gracefully.
float ParaEngine::ParticleSystem::slowdown |
it controls how fast the speed magnitude of a particle dwindles as its life is approaching the end.
in formula, it is V*expf(-1.0f * slowdown * p.life), where p.life is the current life of a particle in seconds. if slowdown is infinitely small, there will be no slowed down; if it is big(such as 1), the particle will has no speed after just a few seconds from birth.
int ParaEngine::ParticleSystem::type |
this is 0,1,2.
usually means how the particles are rendered.