Make water speed customizable
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10791 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
1032f9654d
commit
6dcc313611
@ -75,28 +75,34 @@ public:
|
||||
class WaterShaderProvider : public video::IShaderConstantSetCallBack
|
||||
{
|
||||
float m_dx_1, m_dy_1, m_dx_2, m_dy_2;
|
||||
float m_water_shader_speed_1;
|
||||
float m_water_shader_speed_2;
|
||||
|
||||
public:
|
||||
LEAK_CHECK()
|
||||
|
||||
|
||||
WaterShaderProvider()
|
||||
WaterShaderProvider(float water_shader_speed_1,
|
||||
float water_shader_speed_2)
|
||||
{
|
||||
m_dx_1 = 0.0f;
|
||||
m_dy_1 = 0.0f;
|
||||
m_dx_2 = 0.0f;
|
||||
m_dy_2 = 0.0f;
|
||||
|
||||
m_water_shader_speed_1 = water_shader_speed_1/100.0f;
|
||||
m_water_shader_speed_2 = water_shader_speed_2/100.0f;
|
||||
}
|
||||
|
||||
virtual void OnSetConstants(
|
||||
irr::video::IMaterialRendererServices *services,
|
||||
s32 userData)
|
||||
{
|
||||
m_dx_1 += GUIEngine::getLatestDt()/15.0f;
|
||||
m_dy_1 += GUIEngine::getLatestDt()/15.0f;
|
||||
m_dx_1 += GUIEngine::getLatestDt()*m_water_shader_speed_1;
|
||||
m_dy_1 += GUIEngine::getLatestDt()*m_water_shader_speed_1;
|
||||
|
||||
m_dx_2 += GUIEngine::getLatestDt()/25.0f;
|
||||
m_dy_2 -= GUIEngine::getLatestDt()/25.0f;
|
||||
m_dx_2 += GUIEngine::getLatestDt()*m_water_shader_speed_2;
|
||||
m_dy_2 -= GUIEngine::getLatestDt()*m_water_shader_speed_2;
|
||||
|
||||
if (m_dx_1 > 1.0f) m_dx_1 -= 1.0f;
|
||||
if (m_dy_1 > 1.0f) m_dy_1 -= 1.0f;
|
||||
@ -429,6 +435,11 @@ Material::Material(const XMLNode *node, int index)
|
||||
}
|
||||
|
||||
node->get("water-shader", &m_water_shader);
|
||||
if (m_water_shader)
|
||||
{
|
||||
node->get("water-shader-speed-1", &m_water_shader_speed_1);
|
||||
node->get("water-shader-speed-2", &m_water_shader_speed_2);
|
||||
}
|
||||
|
||||
// Terrain-specifc sound effect
|
||||
const unsigned int children_count = node->getNumNodes();
|
||||
@ -505,6 +516,8 @@ void Material::init(unsigned int index)
|
||||
m_add = false;
|
||||
m_disable_z_write = false;
|
||||
m_water_shader = false;
|
||||
m_water_shader_speed_1 = 6.6667f;
|
||||
m_water_shader_speed_2 = 4.0f;
|
||||
m_fog = true;
|
||||
m_max_speed_fraction = 1.0f;
|
||||
m_slowdown_time = 1.0f;
|
||||
@ -987,7 +1000,8 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
{
|
||||
if (m_shaders[WATER_SHADER] == NULL)
|
||||
{
|
||||
m_shaders[WATER_SHADER] = new WaterShaderProvider();
|
||||
m_shaders[WATER_SHADER] = new WaterShaderProvider(m_water_shader_speed_1,
|
||||
m_water_shader_speed_2);
|
||||
}
|
||||
|
||||
m->setTexture(1, irr_driver->getTexture(file_manager->getTextureFile("waternormals.jpg")));
|
||||
|
@ -107,7 +107,18 @@ private:
|
||||
bool m_zipper;
|
||||
/** If a kart is rescued when driving on this surface. */
|
||||
bool m_drive_reset;
|
||||
|
||||
/** If the water shader (simulating wave effects and reflexions) is enabled */
|
||||
bool m_water_shader;
|
||||
|
||||
/** Speed of the 'main' wave in the water shader. Only used if
|
||||
m_water_shader is true */
|
||||
float m_water_shader_speed_1;
|
||||
|
||||
/** Speed of the 'secondary' waves in the water shader. Only used if
|
||||
m_water_shader is true */
|
||||
float m_water_shader_speed_2;
|
||||
|
||||
/** If a kart is rescued when crashing into this surface. */
|
||||
CollisionReaction m_collision_reaction;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user