SuperTuxKart
Loading...
Searching...
No Matches
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.
 
 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.
 
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.
 
void setMaterialProperties (video::SMaterial *m, scene::IMeshBuffer *mb)
 Sets the appropriate flags in an irrlicht SMaterial.
 
video::ITexture * getTexture (bool srgb=true, bool premul_alpha=false)
 Returns the ITexture associated with this material.
 
bool isIgnore () const
 
bool isZipper () const
 Returns true if this material is a zipper.
 
bool isDriveReset () const
 Returns if this material should trigger a rescue if a kart is driving on it.
 
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.
 
std::string getCrashResetParticles () const
 
bool highTireAdhesion () const
 
const std::string & getTexFname () const
 
const std::string & getTexFullPath () const
 
bool isTransparent () const
 
bool useAlphaChannel () const
 
float getMaxSpeedFraction () const
 Returns the fraction of maximum speed on this material.
 
int getSlowDownTicks () const
 Returns how long it will take for a slowdown to take effect.
 
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.
 
bool isSurface () const
 Returns true if this material is a surface, i.e.
 
const std::string & getSFXName () const
 Returns the name of a special sfx to play while a kart is on this terrain.
 
const ParticleKindgetParticlesWhen (ParticleConditions cond) const
 Get the kind of particles that are to be used on this material, in the given conditions.
 
bool hasFallingEffect () const
 Returns true if a kart falling over this kind of material triggers the special falling camera.
 
bool isJumpTexture () const
 Returns if being in the air after this texture should start the jump animation.
 
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.
 
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.
 
float getZipperMinSpeed () const
 Returns the minimum speed of a kart on this material.
 
char getMirrorAxisInReverse () const
 True if this texture should have the U coordinates mirrored.
 
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
 
std::function< void(irr::video::IImage *)> getMaskImageMani () const
 

Private Member Functions

void init ()
 Inits all material data with the default settings.
 
void install (std::function< void(video::IImage *)> image_mani=nullptr, video::SMaterial *m=NULL)
 
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.
 
void initParticlesEffect (const XMLNode *node)
 
void loadContainerId ()
 

Private Attributes

video::ITexture * m_texture
 Pointer to the texture.
 
std::array< video::ITexture *, 4 > m_vk_textures
 
std::string m_texname
 Name of the texture.
 
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.
 
char m_mirror_axis_when_reverse
 Either ' ' (no mirroring), 'U' or 'V' if a texture needs to be mirrored when driving in reverse.
 
bool m_below_surface
 Set if being on this surface means being under some other mesh.
 
bool m_falling_effect
 If a kart is falling over a material with this flag set, it will trigger the special camera fall effect.
 
bool m_surface
 A material that is a surface only, i.e.
 
bool m_zipper
 If the material is a zipper, i.e.
 
bool m_drive_reset
 If a kart is rescued when driving on this surface.
 
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.
 
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.
 
bool m_ignore
 If the property should be ignored in the physics.
 
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).
 
bool m_tex_compression
 True if this material should use texture compression.
 
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.
 
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.
 
float m_max_speed_fraction
 Maximum speed at which no more slow down occurs.
 
float m_zipper_min_speed
 Minimum speed on this terrain.
 
float m_sfx_min_speed
 The minimum speed at which a special sfx is started to be played.
 
float m_sfx_max_speed
 The speed at which the maximum pitch is used.
 
float m_sfx_min_pitch
 The minimum pitch to be used (at minimum speed).
 
float m_sfx_max_pitch
 The maximum pitch to be used (at maximum speed).
 
float m_sfx_pitch_per_speed
 (max_pitch-min_pitch) / (max_speed - min_speed).
 
float m_zipper_max_speed_increase
 Additional speed allowed on top of the kart-specific maximum kart speed if a zipper is used.
 
float m_zipper_duration
 Time a zipper stays activated.
 
float m_zipper_speed_gain
 A one time additional speed gain - the kart will instantly add this amount of speed to its current speed.
 
float m_zipper_fade_out_time
 Time it takes for the zipper advantage to fade out.
 
float m_zipper_engine_force
 Additional engine force.
 
std::string m_mask
 
std::string m_colorization_mask
 
std::string m_shader_name
 
std::string m_uv_two_tex
 
std::array< std::string, 6 > m_sampler_path
 
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

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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_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_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_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_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_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_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: