20#ifndef HEADER_MATERIAL_HPP 
   21#define HEADER_MATERIAL_HPP 
   23#include "utils/no_copy.hpp" 
   24#include "utils/random_generator.hpp" 
   35    namespace video { 
class ITexture; 
class IImage; 
class SMaterial; }
 
   36    namespace scene { 
class ISceneNode; 
class IMeshBuffer; }
 
   50    enum ParticleConditions
 
   58    enum CollisionReaction
 
   71    std::array<video::ITexture*, 4> m_vk_textures;
 
   76    std::string      m_full_path;
 
  125    bool  m_complain_if_not_found;
 
  204    std::string      m_colorization_mask;
 
  207    void  install (std::function<
void(video::IImage*)> image_mani = 
nullptr,
 
  208                   video::SMaterial* m = NULL);
 
  210    void  initParticlesEffect(
const XMLNode *node);
 
  213    std::string      m_shader_name;
 
  214    std::string      m_uv_two_tex;
 
  216    std::array<std::string, 6> m_sampler_path;
 
  217    std::string      m_container_id;
 
  218    void loadContainerId();
 
  223                   bool is_full_path=
false,
 
  224                   bool complain_if_not_found=
true,
 
  225                   bool load_texture = 
true,
 
  226                   const std::string& shader_name = 
"solid");
 
  229    void unloadTexture();
 
  235    video::ITexture *
getTexture(
bool srgb = 
true, 
bool premul_alpha = 
false);
 
  237    bool  isIgnore           ()
 const { 
return m_ignore;             }
 
  278          getTexFname        ()
 const { 
return m_texname;            }
 
  281          getTexFullPath     ()
 const { 
return m_full_path;          }
 
  284    bool  isTransparent      ()
 const 
  286        return m_shader_name == 
"additive" || m_shader_name == 
"alphablend" ||
 
  287               m_shader_name == 
"displace";
 
  291    bool  useAlphaChannel    ()
 const 
  293        return isTransparent() || m_shader_name == 
"alphatest" ||
 
  294               m_shader_name == 
"unlit" || m_shader_name == 
"grass";
 
  326        return m_particles_effects[cond]; 
 
  344                             float *zipper_duration,
 
  345                             float *zipper_speed_gain,
 
  346                             float *zipper_fade_out_time,
 
  347                             float *zipper_engine_force)
 const 
  364    const std::string& getAlphaMask()
 const                 { 
return m_mask; }
 
  366    const std::string& getColorizationMask()
 const 
  367                                               { 
return m_colorization_mask; }
 
  369    void setShaderName(
const std::string& name)      { m_shader_name = name; }
 
  371    const std::string& getShaderName()
 const         { 
return m_shader_name; }
 
  374    const std::string& getUVTwoTexture()
 const 
  375                                                      { 
return m_uv_two_tex; }
 
  377    bool use2UV()
 const                      { 
return !m_uv_two_tex.empty(); }
 
  379    const std::string& getSamplerPath(
unsigned layer)
 const 
  382        return m_sampler_path[layer];
 
  388    const std::string& getContainerId()
 const 
  390        static std::string empty;
 
  393        return m_container_id;
 
  396    std::function<void(irr::video::IImage*)> getMaskImageMani() 
const;
 
Definition: material.hpp:48
 
float getZipperMinSpeed() const
Returns the minimum speed of a kart on this material.
Definition: material.hpp:359
 
video::ITexture * getTexture(bool srgb=true, bool premul_alpha=false)
Returns the ITexture associated with this material.
Definition: material.cpp:402
 
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.
Definition: material.hpp:343
 
float m_sfx_pitch_per_speed
(max_pitch-min_pitch) / (max_speed - min_speed).
Definition: material.hpp:184
 
float getMaxSpeedFraction() const
Returns the fraction of maximum speed on this material.
Definition: material.hpp:299
 
CollisionReaction getCollisionReaction() const
Returns if this material should trigger a rescue if a kart crashes against it.
Definition: material.hpp:269
 
bool hasGravity() const
Returns true if this texture adjusts the gravity vector of the kart to be parallel to the normal of t...
Definition: material.hpp:340
 
float m_zipper_duration
Time a zipper stays activated.
Definition: material.hpp:191
 
char m_mirror_axis_when_reverse
Either ' ' (no mirroring), 'U' or 'V' if a texture needs to be mirrored when driving in reverse.
Definition: material.hpp:85
 
void init()
Inits all material data with the default settings.
Definition: material.cpp:502
 
float m_zipper_fade_out_time
Time it takes for the zipper advantage to fade out.
Definition: material.hpp:198
 
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.
Definition: material.hpp:111
 
float m_zipper_max_speed_increase
Additional speed allowed on top of the kart-specific maximum kart speed if a zipper is used.
Definition: material.hpp:188
 
float m_zipper_engine_force
Additional engine force.
Definition: material.hpp:200
 
std::string m_texname
Name of the texture.
Definition: material.hpp:74
 
bool m_high_tire_adhesion
True if the material shouldn't be "slippy" at an angle.
Definition: material.hpp:123
 
float m_sfx_min_pitch
The minimum pitch to be used (at minimum speed).
Definition: material.hpp:178
 
bool m_ignore
If the property should be ignored in the physics.
Definition: material.hpp:120
 
bool isDriveReset() const
Returns if this material should trigger a rescue if a kart is driving on it.
Definition: material.hpp:244
 
float getColorizationFactor() const
Returns the minimum resulting saturation when colorized.
Definition: material.hpp:252
 
bool m_falling_effect
If a kart is falling over a material with this flag set, it will trigger the special camera fall effe...
Definition: material.hpp:95
 
const ParticleKind * getParticlesWhen(ParticleConditions cond) const
Get the kind of particles that are to be used on this material, in the given conditions.
Definition: material.hpp:324
 
float m_zipper_speed_gain
A one time additional speed gain - the kart will instantly add this amount of speed to its current sp...
Definition: material.hpp:195
 
CollisionReaction m_collision_reaction
If a kart is rescued when crashing into this surface.
Definition: material.hpp:141
 
void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer *mb)
Sets the appropriate flags in an irrlicht SMaterial.
Definition: material.cpp:816
 
float m_sfx_max_pitch
The maximum pitch to be used (at maximum speed).
Definition: material.hpp:180
 
std::map< void *, bool > m_mirrorred_mesh_buffers
Associated with m_mirror_axis_when_reverse, to avoid mirroring the same material twice (setAllMateria...
Definition: material.hpp:150
 
float m_sfx_max_speed
The speed at which the maximum pitch is used.
Definition: material.hpp:176
 
void initCustomSFX(const XMLNode *sfx)
Initialise the data structures for a custom sfx to be played when a kart is driving on that particula...
Definition: material.cpp:650
 
std::vector< float > m_hue_settings
List of hue pre-defined for colorization (from 0 to 1)
Definition: material.hpp:158
 
void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const
Adjusts the pitch of the given sfx depending on the given speed.
Definition: material.cpp:776
 
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.
Definition: material.hpp:80
 
bool isBelowSurface() const
Returns true if this material is under some other mesh and therefore requires another raycast to find...
Definition: material.hpp:310
 
const std::string & getSFXName() const
Returns the name of a special sfx to play while a kart is on this terrain.
Definition: material.hpp:319
 
float m_colorization_factor
Minimum resulting saturation when colorized (from 0 to 1)
Definition: material.hpp:138
 
bool m_tex_compression
True if this material should use texture compression.
Definition: material.hpp:135
 
float m_sfx_min_speed
The minimum speed at which a special sfx is started to be played.
Definition: material.hpp:174
 
float getRandomHue()
Returns a random hue when colorized.
Definition: material.hpp:258
 
float m_max_speed_fraction
Maximum speed at which no more slow down occurs.
Definition: material.hpp:167
 
char getMirrorAxisInReverse() const
True if this texture should have the U coordinates mirrored.
Definition: material.hpp:362
 
float m_zipper_min_speed
Minimum speed on this terrain.
Definition: material.hpp:172
 
bool m_zipper
If the material is a zipper, i.e.
Definition: material.hpp:104
 
unsigned int m_clamp_tex
Texture clamp bitmask.
Definition: material.hpp:155
 
bool hasFallingEffect() const
Returns true if a kart falling over this kind of material triggers the special falling camera.
Definition: material.hpp:331
 
int m_slowdown_ticks
How much the top speed is reduced per second.
Definition: material.hpp:164
 
RandomGenerator m_random_hue
Random generator for getting pre-defined hue.
Definition: material.hpp:161
 
bool isZipper() const
Returns true if this material is a zipper.
Definition: material.hpp:240
 
bool isColorizable() const
Returns if this material can be colorized.
Definition: material.hpp:248
 
bool m_drive_reset
If a kart is rescued when driving on this surface.
Definition: material.hpp:107
 
bool isJumpTexture() const
Returns if being in the air after this texture should start the jump animation.
Definition: material.hpp:335
 
bool m_colorizable
True if this material can be colorized (like red/blue in team game).
Definition: material.hpp:132
 
bool isSurface() const
Returns true if this material is a surface, i.e.
Definition: material.hpp:315
 
bool m_surface
A material that is a surface only, i.e.
Definition: material.hpp:101
 
bool m_has_gravity
True if driving on this texture should adjust the gravity of the kart to be along the normal of the t...
Definition: material.hpp:116
 
video::ITexture * m_texture
Pointer to the texture.
Definition: material.hpp:69
 
int getSlowDownTicks() const
Returns how long it will take for a slowdown to take effect.
Definition: material.hpp:304
 
bool m_below_surface
Set if being on this surface means being under some other mesh.
Definition: material.hpp:91
 
std::string m_collision_particles
Particles to show on touch.
Definition: material.hpp:144
 
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
 
type of particles
Definition: particle_kind.hpp:42
 
A random number generator.
Definition: random_generator.hpp:34
 
int get(int n)
Returns a pseudo random number between 0 and n-1 inclusive.
Definition: random_generator.hpp:45
 
The base class for sound effects.
Definition: sfx_base.hpp:43
 
utility class used to parse XML files
Definition: xml_node.hpp:48