SuperTuxKart
Loading...
Searching...
No Matches
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.
 
void reset ()
 Resets all particle emitters.
 
void setSkidLevel (const unsigned int level)
 Selects the correct skidding particle type depending on skid bonus level.
 
void setParticleKind (const KartGFXType type, const ParticleKind *pk)
 Sets a new particle type to be used.
 
void setXYZ (const KartGFXType type, const Vec3 &xyz)
 Defines the new position of the specified emitter.
 
void setCreationRateAbsolute (const KartGFXType type, float f)
 Sets the absolute creation rate for the specified particle type.
 
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.
 
void updateTerrain (const ParticleKind *pk)
 If necessary defines a new particle type for the terrain emitter.
 
void update (float dt)
 Updates all gfx.
 
void updateNitroGraphics (float f)
 Updates nitro dependent particle effects.
 
void updateSkidLight (unsigned int level)
 Updates the skiddng light (including disabling it).
 
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.
 
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.
 

Private Attributes

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

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.

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