SuperTuxKart
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Material Class Reference
Inheritance diagram for Material:
Inheritance graph
[legend]

Public Types

enum  ParticleConditions { EMIT_ON_DRIVE = 0, EMIT_ON_SKID, EMIT_KINDS_COUNT }
 
enum  CollisionReaction { NORMAL, RESCUE, PUSH_BACK, PUSH_SOCCER_BALL }
 

Public Member Functions

 Material (const XMLNode *node, bool deprecated)
 Create a new material using the parameters specified in the xml file. More...
 
 Material (const std::string &fname, bool is_full_path=false, bool complain_if_not_found=true, bool load_texture=true, const std::string &shader_name="solid")
 Create a standard material using the default settings for materials. More...
 
void unloadTexture ()
 
void setSFXSpeed (SFXBase *sfx, float speed, bool should_be_paused) const
 Adjusts the pitch of the given sfx depending on the given speed. More...
 
void setMaterialProperties (video::SMaterial *m, scene::IMeshBuffer *mb)
 Sets the appropriate flags in an irrlicht SMaterial. More...
 
video::ITexture * getTexture (bool srgb=true, bool premul_alpha=false)
 Returns the ITexture associated with this material. More...
 
bool isIgnore () const
 
bool isZipper () const
 Returns true if this material is a zipper. More...
 
bool isDriveReset () const
 Returns if this material should trigger a rescue if a kart is driving on it. More...
 
bool isColorizable () const
 Returns if this material can be colorized.
 
float getColorizationFactor () const
 Returns the minimum resulting saturation when colorized.
 
bool hasRandomHue () const
 
float getRandomHue ()
 Returns a random hue when colorized.
 
CollisionReaction getCollisionReaction () const
 Returns if this material should trigger a rescue if a kart crashes against it. More...
 
std::string getCrashResetParticles () const
 
bool highTireAdhesion () const
 
const std::string & getTexFname () const
 
const std::string & getTexFullPath () const
 
bool isTransparent () const
 
float getMaxSpeedFraction () const
 Returns the fraction of maximum speed on this material. More...
 
int getSlowDownTicks () const
 Returns how long it will take for a slowdown to take effect. More...
 
bool isBelowSurface () const
 Returns true if this material is under some other mesh and therefore requires another raycast to find the surface it is under (used for gfx, e.g. More...
 
bool isSurface () const
 Returns true if this material is a surface, i.e. More...
 
const std::string & getSFXName () const
 Returns the name of a special sfx to play while a kart is on this terrain. More...
 
const ParticleKindgetParticlesWhen (ParticleConditions cond) const
 Get the kind of particles that are to be used on this material, in the given conditions. More...
 
bool hasFallingEffect () const
 Returns true if a kart falling over this kind of material triggers the special falling camera. More...
 
bool isJumpTexture () const
 Returns if being in the air after this texture should start the jump animation. More...
 
bool hasGravity () const
 Returns true if this texture adjusts the gravity vector of the kart to be parallel to the normal of the triangle - which allows karts to e.g. More...
 
void getZipperParameter (float *zipper_max_speed_increase, float *zipper_duration, float *zipper_speed_gain, float *zipper_fade_out_time, float *zipper_engine_force) const
 Returns the zipper parametersfor the current material. More...
 
float getZipperMinSpeed () const
 Returns the minimum speed of a kart on this material. More...
 
char getMirrorAxisInReverse () const
 True if this texture should have the U coordinates mirrored. More...
 
const std::string & getAlphaMask () const
 
const std::string & getColorizationMask () const
 
void setShaderName (const std::string &name)
 
const std::string & getShaderName () const
 
const std::string & getUVTwoTexture () const
 
bool use2UV () const
 
const std::string & getSamplerPath (unsigned layer) const
 
const std::string & getContainerId () const
 

Private Member Functions

void init ()
 Inits all material data with the default settings.
 
void install (bool srgb=false, bool premul_alpha=false)
 
void initCustomSFX (const XMLNode *sfx)
 Initialise the data structures for a custom sfx to be played when a kart is driving on that particular material. More...
 
void initParticlesEffect (const XMLNode *node)
 
void loadContainerId ()
 

Private Attributes

video::ITexture * m_texture
 Pointer to the texture. More...
 
std::string m_texname
 Name of the texture. More...
 
std::string m_full_path
 
std::string m_sfx_name
 Name of a special sfx to play when a kart is on this terrain, or "" if no special sfx exists. More...
 
char m_mirror_axis_when_reverse
 Either ' ' (no mirroring), 'U' or 'V' if a texture needs to be mirrored when driving in reverse. More...
 
bool m_below_surface
 Set if being on this surface means being under some other mesh. More...
 
bool m_falling_effect
 If a kart is falling over a material with this flag set, it will trigger the special camera fall effect. More...
 
bool m_surface
 A material that is a surface only, i.e. More...
 
bool m_zipper
 If the material is a zipper, i.e. More...
 
bool m_drive_reset
 If a kart is rescued when driving on this surface. More...
 
bool m_is_jump_texture
 True if this is a texture that will start the jump animation when leaving it and being in the air. More...
 
bool m_has_gravity
 True if driving on this texture should adjust the gravity of the kart to be along the normal of the triangle. More...
 
bool m_ignore
 If the property should be ignored in the physics. More...
 
bool m_high_tire_adhesion
 True if the material shouldn't be "slippy" at an angle.
 
bool m_complain_if_not_found
 
bool m_deprecated
 
bool m_installed
 
bool m_colorizable
 True if this material can be colorized (like red/blue in team game). More...
 
bool m_tex_compression
 True if this material should use texture compression. More...
 
float m_colorization_factor
 Minimum resulting saturation when colorized (from 0 to 1)
 
CollisionReaction m_collision_reaction
 If a kart is rescued when crashing into this surface. More...
 
std::string m_collision_particles
 Particles to show on touch.
 
std::map< void *, bool > m_mirrorred_mesh_buffers
 Associated with m_mirror_axis_when_reverse, to avoid mirroring the same material twice (setAllMaterialFlags can be called multiple times on the same mesh buffer)
 
ParticleKindm_particles_effects [EMIT_KINDS_COUNT]
 
unsigned int m_clamp_tex
 Texture clamp bitmask.
 
std::vector< float > m_hue_settings
 List of hue pre-defined for colorization (from 0 to 1)
 
RandomGenerator m_random_hue
 Random generator for getting pre-defined hue.
 
int m_slowdown_ticks
 How much the top speed is reduced per second. More...
 
float m_max_speed_fraction
 Maximum speed at which no more slow down occurs. More...
 
float m_zipper_min_speed
 Minimum speed on this terrain. More...
 
float m_sfx_min_speed
 The minimum speed at which a special sfx is started to be played. More...
 
float m_sfx_max_speed
 The speed at which the maximum pitch is used. More...
 
float m_sfx_min_pitch
 The minimum pitch to be used (at minimum speed). More...
 
float m_sfx_max_pitch
 The maximum pitch to be used (at maximum speed). More...
 
float m_sfx_pitch_per_speed
 (max_pitch-min_pitch) / (max_speed - min_speed). More...
 
float m_zipper_max_speed_increase
 Additional speed allowed on top of the kart-specific maximum kart speed if a zipper is used. More...
 
float m_zipper_duration
 Time a zipper stays activated. More...
 
float m_zipper_speed_gain
 A one time additional speed gain - the kart will instantly add this amount of speed to its current speed. More...
 
float m_zipper_fade_out_time
 Time it takes for the zipper advantage to fade out. More...
 
float m_zipper_engine_force
 Additional engine force. More...
 
std::string m_mask
 
std::string m_colorization_mask
 
std::string m_shader_name
 
std::string m_uv_two_tex
 
std::string m_sampler_path [6]
 
std::string m_container_id
 

Constructor & Destructor Documentation

◆ Material() [1/2]

Material::Material ( const XMLNode node,
bool  deprecated 
)

Create a new material using the parameters specified in the xml file.

Parameters
nodeNode containing the parameters for this material.

◆ Material() [2/2]

Material::Material ( const std::string &  fname,
bool  is_full_path = false,
bool  complain_if_not_found = true,
bool  load_texture = true,
const std::string &  shader_name = "solid" 
)

Create a standard material using the default settings for materials.

Parameters
fnameName of the texture file.
is_full_pathIf the fname contains the full path.

Member Function Documentation

◆ getCollisionReaction()

CollisionReaction Material::getCollisionReaction ( ) const
inline

Returns if this material should trigger a rescue if a kart crashes against it.

◆ getMaxSpeedFraction()

float Material::getMaxSpeedFraction ( ) const
inline

Returns the fraction of maximum speed on this material.

◆ getMirrorAxisInReverse()

char Material::getMirrorAxisInReverse ( ) const
inline

True if this texture should have the U coordinates mirrored.

◆ getParticlesWhen()

const ParticleKind* Material::getParticlesWhen ( ParticleConditions  cond) const
inline

Get the kind of particles that are to be used on this material, in the given conditions.

Returns
The particles to use, or NULL if none.

◆ getSFXName()

const std::string& Material::getSFXName ( ) const
inline

Returns the name of a special sfx to play while a kart is on this terrain.

The string will be "" if no special sfx exists.

◆ getSlowDownTicks()

int Material::getSlowDownTicks ( ) const
inline

Returns how long it will take for a slowdown to take effect.

It is the time it takes till the full slowdown applies to karts. So a short time will slowdown a kart much faster.

◆ getTexture()

video::ITexture * Material::getTexture ( bool  srgb = true,
bool  premul_alpha = false 
)

Returns the ITexture associated with this material.

◆ getZipperMinSpeed()

float Material::getZipperMinSpeed ( ) const
inline

Returns the minimum speed of a kart on this material.

This is used for zippers on a ramp to guarantee the right jump distance even on lower speeds. A negative value indicates no minimum speed.

◆ getZipperParameter()

void Material::getZipperParameter ( float *  zipper_max_speed_increase,
float *  zipper_duration,
float *  zipper_speed_gain,
float *  zipper_fade_out_time,
float *  zipper_engine_force 
) const
inline

Returns the zipper parametersfor the current material.

◆ hasFallingEffect()

bool Material::hasFallingEffect ( ) const
inline

Returns true if a kart falling over this kind of material triggers the special falling camera.

◆ hasGravity()

bool Material::hasGravity ( ) const
inline

Returns true if this texture adjusts the gravity vector of the kart to be parallel to the normal of the triangle - which allows karts to e.g.

drive upside down.

◆ initCustomSFX()

void Material::initCustomSFX ( const XMLNode sfx)
private

Initialise the data structures for a custom sfx to be played when a kart is driving on that particular material.

Parameters
sfxThe xml node containing the information for this sfx.

◆ isBelowSurface()

bool Material::isBelowSurface ( ) const
inline

Returns true if this material is under some other mesh and therefore requires another raycast to find the surface it is under (used for gfx, e.g.

driving under water to find where the water splash should be shown at.

◆ isDriveReset()

bool Material::isDriveReset ( ) const
inline

Returns if this material should trigger a rescue if a kart is driving on it.

◆ isJumpTexture()

bool Material::isJumpTexture ( ) const
inline

Returns if being in the air after this texture should start the jump animation.

◆ isSurface()

bool Material::isSurface ( ) const
inline

Returns true if this material is a surface, i.e.

it is going to be ignored for the physics, but the information is needed e.g. for gfx. See m_below_surface for more details.

◆ isZipper()

bool Material::isZipper ( ) const
inline

Returns true if this material is a zipper.

◆ setMaterialProperties()

void Material::setMaterialProperties ( video::SMaterial *  m,
scene::IMeshBuffer *  mb 
)

Sets the appropriate flags in an irrlicht SMaterial.

Parameters
materialThe irrlicht SMaterial which gets the flags set.

! Texture is clamped to the last pixel ETC_CLAMP, ! Texture is clamped to the edge pixel ETC_CLAMP_TO_EDGE, ! Texture is clamped to the border pixel (if exists) ETC_CLAMP_TO_BORDER,

◆ setSFXSpeed()

void Material::setSFXSpeed ( SFXBase sfx,
float  speed,
bool  should_be_paused 
) const

Adjusts the pitch of the given sfx depending on the given speed.

Parameters
sfxThe sound effect to adjust.
speedThe speed of the kart.
should_be_pausedPause for other reasons, i.e. kart is rescued.

Member Data Documentation

◆ m_below_surface

bool Material::m_below_surface
private

Set if being on this surface means being under some other mesh.

This is used to simulate that a kart is in water: the ground under the water is marked as 'm_below_surface', which will then trigger a raycast up to find the position of the actual water surface.

◆ m_collision_reaction

CollisionReaction Material::m_collision_reaction
private

If a kart is rescued when crashing into this surface.

◆ m_colorizable

bool Material::m_colorizable
private

True if this material can be colorized (like red/blue in team game).

◆ m_drive_reset

bool Material::m_drive_reset
private

If a kart is rescued when driving on this surface.

◆ m_falling_effect

bool Material::m_falling_effect
private

If a kart is falling over a material with this flag set, it will trigger the special camera fall effect.

◆ m_has_gravity

bool Material::m_has_gravity
private

True if driving on this texture should adjust the gravity of the kart to be along the normal of the triangle.

This allows karts to drive e.g upside down.

◆ m_ignore

bool Material::m_ignore
private

If the property should be ignored in the physics.

Example would be plants that a kart can just drive through.

◆ m_is_jump_texture

bool Material::m_is_jump_texture
private

True if this is a texture that will start the jump animation when leaving it and being in the air.

◆ m_max_speed_fraction

float Material::m_max_speed_fraction
private

Maximum speed at which no more slow down occurs.

◆ m_mirror_axis_when_reverse

char Material::m_mirror_axis_when_reverse
private

Either ' ' (no mirroring), 'U' or 'V' if a texture needs to be mirrored when driving in reverse.

Typically used for arrows indicating the direction.

◆ m_sfx_max_pitch

float Material::m_sfx_max_pitch
private

The maximum pitch to be used (at maximum speed).

◆ m_sfx_max_speed

float Material::m_sfx_max_speed
private

The speed at which the maximum pitch is used.

◆ m_sfx_min_pitch

float Material::m_sfx_min_pitch
private

The minimum pitch to be used (at minimum speed).

◆ m_sfx_min_speed

float Material::m_sfx_min_speed
private

The minimum speed at which a special sfx is started to be played.

◆ m_sfx_name

std::string Material::m_sfx_name
private

Name of a special sfx to play when a kart is on this terrain, or "" if no special sfx exists.

◆ m_sfx_pitch_per_speed

float Material::m_sfx_pitch_per_speed
private

(max_pitch-min_pitch) / (max_speed - min_speed).

Used to adjust the pitch of a sfx depending on speed of the kart.

◆ m_slowdown_ticks

int Material::m_slowdown_ticks
private

How much the top speed is reduced per second.

◆ m_surface

bool Material::m_surface
private

A material that is a surface only, i.e.

the karts can fall through but the information is still needed (for GFX mostly). An example is a water surface: karts can drive while partly in water (so the water surface is not a physical object), but the location of the water effect is on the surface.

◆ m_tex_compression

bool Material::m_tex_compression
private

True if this material should use texture compression.

◆ m_texname

std::string Material::m_texname
private

Name of the texture.

◆ m_texture

video::ITexture* Material::m_texture
private

Pointer to the texture.

◆ m_zipper

bool Material::m_zipper
private

If the material is a zipper, i.e.

gives a speed boost.

◆ m_zipper_duration

float Material::m_zipper_duration
private

Time a zipper stays activated.

If this value is <0 the kart specific value will be used.

◆ m_zipper_engine_force

float Material::m_zipper_engine_force
private

Additional engine force.

◆ m_zipper_fade_out_time

float Material::m_zipper_fade_out_time
private

Time it takes for the zipper advantage to fade out.

If this value is <0 the kart specific value will be used.

◆ m_zipper_max_speed_increase

float Material::m_zipper_max_speed_increase
private

Additional speed allowed on top of the kart-specific maximum kart speed if a zipper is used.

If this value is <0 the kart specific value will be used.

◆ m_zipper_min_speed

float Material::m_zipper_min_speed
private

Minimum speed on this terrain.

This is used for zippers on a ramp to guarantee the right jump distance. A negative value indicates no minimum speed.

◆ m_zipper_speed_gain

float Material::m_zipper_speed_gain
private

A one time additional speed gain - the kart will instantly add this amount of speed to its current speed.

If this value is <0 the kart specific value will be used.


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