SuperTuxKart
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
KartGFX Class Reference

Public Types

enum  KartGFXType {
  KGFX_NITRO1 =0, KGFX_NITRO2, KGFX_NITROSMOKE1, KGFX_NITROSMOKE2,
  KGFX_ZIPPER, KGFX_TERRAIN, KGFX_SKIDL, KGFX_SKIDR,
  KGFX_SKID1L = KGFX_SKIDL, KGFX_SKID1R = KGFX_SKIDR, KGFX_SKID2L, KGFX_SKID2R,
  KGFX_SKID0L, KGFX_SKID0R, KGFX_EXHAUST1, KGFX_EXHAUST2,
  KGFX_COUNT
}
 All particle effects supported by this object. More...
 

Public Member Functions

 KartGFX (const AbstractKart *kart, bool is_day)
 
 ~KartGFX ()
 Destructor. More...
 
void reset ()
 Resets all particle emitters. More...
 
void setSkidLevel (const unsigned int level)
 Selects the correct skidding particle type depending on skid bonus level. More...
 
void setParticleKind (const KartGFXType type, const ParticleKind *pk)
 Sets a new particle type to be used. More...
 
void setXYZ (const KartGFXType type, const Vec3 &xyz)
 Defines the new position of the specified emitter. More...
 
void setCreationRateAbsolute (const KartGFXType type, float f)
 Sets the absolute creation rate for the specified particle type. More...
 
void setCreationRateRelative (const KartGFXType type, float f)
 Sets the creation rate for the specified particle type relative to the given minimum and maximum particle rate. More...
 
void updateTerrain (const ParticleKind *pk)
 If necessary defines a new particle type for the terrain emitter. More...
 
void update (float dt)
 Updates all gfx. More...
 
void updateNitroGraphics (float f)
 Updates nitro dependent particle effects. More...
 
void updateSkidLight (unsigned int level)
 Updates the skiddng light (including disabling it). More...
 
void getGFXStatus (int *nitro, bool *zipper, int *skidding, bool *red_skidding) const
 
void setGFXFromReplay (int nitro, bool zipper, int skidding, bool red_skidding)
 
void setGFXInvisible ()
 

Private Member Functions

void addEffect (KartGFXType type, const std::string &file_name, const Vec3 &position, bool important)
 Creates a new particle node with the specified particle kind read from the given file. More...
 
void resizeBox (const KartGFXType type, float new_size)
 Resize the area from which the particles are emitted: the emitter box should spread from last frame's position to the current position if we want the particles to be emitted in a smooth, continuous flame and not in blobs. More...
 

Private Attributes

const ParticleKindm_skid_kind0
 The particle kind for skidding bonus level 0. More...
 
const ParticleKindm_skid_kind1
 The particle kind for skidding bonus level 1. More...
 
const ParticleKindm_skid_kind2
 The particle kind for skidding bonus level 2. More...
 
std::vector< ParticleEmitter * > m_all_emitters
 Vector of all particle emitters. More...
 
const AbstractKartm_kart
 Pointer to the owner of this kart. More...
 
int m_wheel_toggle
 Used to alternate particle effects from the rear wheels. More...
 
int m_skid_level
 A skid level that is currently in use.
 
irr::scene::ISceneNode * m_nitro_light
 A light that's shown when the kart uses nitro. More...
 
irr::scene::ISceneNode * m_skidding_light_1
 Light that is shown when the kart is skidding. More...
 
irr::scene::ISceneNode * m_skidding_light_2
 A light that's shown on the second skid-level with another color. More...
 

Member Enumeration Documentation

◆ KartGFXType

All particle effects supported by this object.

Nitro, zipper, terrain, and skidding effects. Three different skid types are supported, but only one emitter node will be created. So KGFX_SKID1/2/3 store the two types, and KGFX_SKID = KGFX_SKID1 stores the actual emitter node. KGFX_COUNT is the number of entries and must therefore be last.

Constructor & Destructor Documentation

◆ ~KartGFX()

KartGFX::~KartGFX ( )

Destructor.

Frees all particle effects and kinds.

Member Function Documentation

◆ addEffect()

void KartGFX::addEffect ( KartGFXType  type,
const std::string &  file_name,
const Vec3 position,
bool  important 
)
private

Creates a new particle node with the specified particle kind read from the given file.

Parameters
typeThe KGFX_ type of this type.
file_nameThe file name of the particle specification.
positionWhere on the kart the particles should be emitted.

◆ reset()

void KartGFX::reset ( )

Resets all particle emitters.

Used at the (re)start of a race.

◆ resizeBox()

void KartGFX::resizeBox ( const KartGFXType  type,
float  new_size 
)
private

Resize the area from which the particles are emitted: the emitter box should spread from last frame's position to the current position if we want the particles to be emitted in a smooth, continuous flame and not in blobs.

Parameters
typeThe particle effect for which to resize the emitting box.
new_sizeNew size of the box, typically speed*dt.

◆ setCreationRateAbsolute()

void KartGFX::setCreationRateAbsolute ( const KartGFXType  type,
float  f 
)

Sets the absolute creation rate for the specified particle type.

Parameters
typeThe particle effect for which to set the creation rate (in particles per seconds).
fThe new creation rate.

◆ setCreationRateRelative()

void KartGFX::setCreationRateRelative ( const KartGFXType  type,
float  f 
)

Sets the creation rate for the specified particle type relative to the given minimum and maximum particle rate.

If a negative value is specified, the creation rate will be set to 0 (absolute).

Parameters
typeThe particle effect for which to set the creation rate (<0 means no more particles).
fThe new relative creation rate.

◆ setParticleKind()

void KartGFX::setParticleKind ( const KartGFXType  type,
const ParticleKind pk 
)

Sets a new particle type to be used.

Note that the memory of this kind must be managed by the caller.

Parameters
typeThe emitter type for which to set the new particle type.
pkThe particle kind to use.

◆ setSkidLevel()

void KartGFX::setSkidLevel ( const unsigned int  level)

Selects the correct skidding particle type depending on skid bonus level.

Parameters
levelMust be 0 (no bonus, showing tiny sparks), 1 (accumulated enough for level 1 bonus), or 2 (accumulated enough for level 2 bonus).

◆ setXYZ()

void KartGFX::setXYZ ( const KartGFXType  type,
const Vec3 xyz 
)

Defines the new position of the specified emitter.

Parameters
typeThe emitter to set a new position for.
xyzThe new position of the emitter.

◆ update()

void KartGFX::update ( float  dt)

Updates all gfx.

Parameters
dtTime step size.

◆ updateNitroGraphics()

void KartGFX::updateNitroGraphics ( float  nitro_frac)

Updates nitro dependent particle effects.

Parameters
nitro_fracNitro fraction/

◆ updateSkidLight()

void KartGFX::updateSkidLight ( unsigned int  level)

Updates the skiddng light (including disabling it).

Parameters
levelWhich level of light to display: 0 no light at all, 1: level 1, 2 level 2.

◆ updateTerrain()

void KartGFX::updateTerrain ( const ParticleKind pk)

If necessary defines a new particle type for the terrain emitter.

Then adjusts the location of the terrain emitter to be in synch with the current wheel position, and defines the emission rate depending on speed, steering, and skidding.

Parameters
pkParticle type to use.

Member Data Documentation

◆ m_all_emitters

std::vector<ParticleEmitter*> KartGFX::m_all_emitters
private

Vector of all particle emitters.

◆ m_kart

const AbstractKart* KartGFX::m_kart
private

Pointer to the owner of this kart.

◆ m_nitro_light

irr::scene::ISceneNode* KartGFX::m_nitro_light
private

A light that's shown when the kart uses nitro.

◆ m_skid_kind0

const ParticleKind* KartGFX::m_skid_kind0
private

The particle kind for skidding bonus level 0.

◆ m_skid_kind1

const ParticleKind* KartGFX::m_skid_kind1
private

The particle kind for skidding bonus level 1.

◆ m_skid_kind2

const ParticleKind* KartGFX::m_skid_kind2
private

The particle kind for skidding bonus level 2.

◆ m_skidding_light_1

irr::scene::ISceneNode* KartGFX::m_skidding_light_1
private

Light that is shown when the kart is skidding.

◆ m_skidding_light_2

irr::scene::ISceneNode* KartGFX::m_skidding_light_2
private

A light that's shown on the second skid-level with another color.

◆ m_wheel_toggle

int KartGFX::m_wheel_toggle
private

Used to alternate particle effects from the rear wheels.


The documentation for this class was generated from the following files: