![]() |
SAGE
A Simple Academic Game Engine
|
A particle. More...
#include <SageParticle.h>


Public Member Functions | |
| CParticle (const CParticleDesc< VEC, SD > &, float) | |
| Constructor. | |
| void | move (float) |
| Move and rotate. | |
| void | rescale (float) |
| Rescale. | |
| void | fade (float) |
| Fade. | |
| void | translate (const VEC &) |
| Translate by an amount. | |
| void | translateto (const VEC &) |
| Translate to a destination. | |
Public Attributes | |
| float | m_fBirthTime = 0.0f |
| Time of creation. | |
Public Attributes inherited from Sage::CParticleDesc< VEC, SD > | |
| VEC | m_vVel = VEC::Zero |
| Velocity. | |
| VEC | m_vAccel = VEC::Zero |
| Acceleration. | |
| float | m_fFriction = 0.0f |
| Coefficient of friction. | |
| float | m_fRSpeed = 0.0f |
| Rotational speed. | |
| float | m_fLifeSpan = FLT_MAX |
| Time it will live for. | |
| float | m_fMaxScale = 1.0f |
| Maximum scale. | |
| float | m_fScaleInFrac = 0.0f |
| Fraction of life growing in. | |
| float | m_fScaleOutFrac = 0.0f |
| Fraction of life shrinking out. | |
| float | m_fFadeInFrac = 0.0f |
| Fraction of life fading in. | |
| float | m_fFadeOutFrac = 0.0f |
| Fraction of life fading out. | |
Protected Member Functions | |
| float | Frac (float, float, float, float) |
| Compute fraction. | |
A particle is a sprite that exists for a brief time. It can grow in and shrink out, and also fade in and fade out using an alpha channel. It's templated so we can define a 2D and a 3D version with a minimum of fuss.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| CParticle::CParticle | ( | const CParticleDesc< VEC, SD > & | d, |
| float | t ) |
Create a particle given a particle descriptor and a creation time.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| d | Particle descriptor. |
| t | Birth time. |
| void CParticle::fade | ( | float | f | ) |
Make the particle's alpha channel fade in or fade out over time.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| f | Fraction of lifespan lived, from 0.0f to 1.0f inclusive. |
|
protected |
Compute fraction.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| fCurFrac | Current fraction. |
| fInFrac | In fraction. |
| fOutFrac | Out fraction. |
| fMaxFrac | Maximum fraction (which is the default). |
| void CParticle::move | ( | float | t | ) |
Translate, apply acceleration, apply friction, and rotate.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| t | Time step. |
| void CParticle::rescale | ( | float | f | ) |
Rescale the particle. It grows to m_fMaxScale for the first m_fScaleInFrac fraction of its life, and shrink to zero for the last m_fScaleOutFrac of its life.
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| f | Fraction of lifespan lived, from 0.0f to 1.0f inclusive. |
| void CParticle::translate | ( | const VEC & | delta | ) |
Move particle by a given distance and direction.
| delta | Vector amount to add to current position. |
| VEC | A vector class. |
| SD | A sprite descriptor class. |
| void CParticle::translateto | ( | const VEC & | v | ) |
Move particle by a given distance and direction.
| v | Destination. |
| VEC | A vector class. |
| SD | A sprite descriptor class. |