diff --git a/data/stk_config.xml b/data/stk_config.xml
index 562de9744..f4316a4f3 100644
--- a/data/stk_config.xml
+++ b/data/stk_config.xml
@@ -487,7 +487,7 @@
-
+
diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp
index 92c7b11cd..867ea5ad0 100644
--- a/src/karts/kart.cpp
+++ b/src/karts/kart.cpp
@@ -2395,7 +2395,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
wheel_up_axis[i] = m_default_suspension_length[i]
- m_vehicle->getWheelInfo(i).m_raycastInfo.m_suspensionLength;
}
- m_kart_model->update(m_wheel_rotation_dt, getSteerPercent(), wheel_up_axis, m_speed);
+ m_kart_model->update(dt, m_wheel_rotation_dt, getSteerPercent(), wheel_up_axis, m_speed);
Vec3 center_shift = m_kart_properties->getGravityCenterShift();
float y = m_vehicle->getWheelInfo(0).m_chassisConnectionPointCS.getY()
diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp
index 67e1434bf..a2462dfed 100644
--- a/src/karts/kart_model.cpp
+++ b/src/karts/kart_model.cpp
@@ -592,7 +592,7 @@ void KartModel::reset()
{
// Reset the wheels
const float suspension[4]={0,0,0,0};
- update(0, 0.0f, suspension, 0.0f);
+ update(0.0f, 0.0f, 0.0f, suspension, 0.0f);
// Stop any animations currently being played.
setAnimation(KartModel::AF_DEFAULT);
@@ -700,12 +700,13 @@ void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node)
// ----------------------------------------------------------------------------
/** Rotates and turns the wheels appropriately, and adjust for suspension
+ updates the speed-weighted objects' animations.
+ * \param dt time since last frame
* \param rotation_dt How far the wheels have rotated since last time.
* \param steer The actual steer settings.
* \param suspension Suspension height for all four wheels.
* \param speed The speed of the kart in meters/sec, used for the speed-weighted objects' animations
*/
-void KartModel::update(float rotation_dt, float steer, const float suspension[4], float speed)
+void KartModel::update(float dt, float rotation_dt, float steer, const float suspension[4], float speed)
{
float clamped_suspension[4];
// Clamp suspension to minimum and maximum suspension length, so that
@@ -783,6 +784,27 @@ void KartModel::update(float rotation_dt, float steer, const float suspension[4]
float anim_speed = speed * speed_factor;
obj.m_node->setAnimationSpeed(anim_speed);
}
+
+ // Texture animation
+ const core::vector2df& tex_speed = m_kart->getKartProperties()->getSpeedWeightedTextureSpeed();
+ if(tex_speed != core::vector2df(0.0f, 0.0f))
+ {
+ obj.m_texture_cur_offset += speed * tex_speed * dt;
+ if(obj.m_texture_cur_offset.X > 1.0f) obj.m_texture_cur_offset.X = fmod(obj.m_texture_cur_offset.X, 1.0f);
+ if(obj.m_texture_cur_offset.Y > 1.0f) obj.m_texture_cur_offset.Y = fmod(obj.m_texture_cur_offset.Y, 1.0f);
+
+ for(unsigned int i=0; igetMaterialCount(); i++)
+ {
+ video::SMaterial &irrMaterial=obj.m_node->getMaterial(i);
+ for(unsigned int j=0; jsetTextureTranslate(obj.m_texture_cur_offset.X, obj.m_texture_cur_offset.Y);
+ } // for j SpeedWeightedObjectList;
@@ -192,7 +195,7 @@ public:
void reset();
void loadInfo(const XMLNode &node);
bool loadModels(const KartProperties &kart_properties);
- void update(float rotation_dt, float steer,
+ void update(float dt, float rotation_dt, float steer,
const float suspension[4], float speed);
void setDefaultPhysicsPosition(const Vec3 ¢er_shift,
float wheel_radius);
diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp
index 0961d0e94..a06453857 100644
--- a/src/karts/kart_properties.cpp
+++ b/src/karts/kart_properties.cpp
@@ -69,6 +69,7 @@ KartProperties::KartProperties(const std::string &filename)
m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_base =
m_wheel_damping_compression = m_friction_slip = m_roll_influence =
m_wheel_radius = m_speed_weighted_strength_factor = m_speed_weighted_speed_factor =
+ m_speed_weighted_texture_speed.X = m_speed_weighted_texture_speed.Y =
m_chassis_linear_damping = m_max_suspension_force =
m_chassis_angular_damping = m_suspension_rest =
m_max_speed_reverse_ratio = m_rescue_vert_offset =
@@ -431,6 +432,8 @@ void KartProperties::getAllData(const XMLNode * root)
{
speed_weighted_node->get("strength-factor", &m_speed_weighted_strength_factor);
speed_weighted_node->get("speed-factor", &m_speed_weighted_speed_factor);
+ speed_weighted_node->get("texture-speed-x", &m_speed_weighted_texture_speed.X);
+ speed_weighted_node->get("texture-speed-y", &m_speed_weighted_texture_speed.Y);
}
if(const XMLNode *friction_node = root->getNode("friction"))
diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp
index 75cd08316..c3e21e6e2 100644
--- a/src/karts/kart_properties.hpp
+++ b/src/karts/kart_properties.hpp
@@ -267,6 +267,7 @@ private:
// Parameters for speed-weighted objects
float m_speed_weighted_strength_factor;
float m_speed_weighted_speed_factor;
+ core::vector2df m_speed_weighted_texture_speed;
/** An impulse pushing the kart down which is proportional to speed. So
* the actual impulse is speed * m_downward_impulse_factor. Set it to
@@ -539,6 +540,8 @@ public:
// ------------------------------------------------------------------------
/** Returns animation speed factor for speed-weighted objects */
float getSpeedWeightedSpeedFactor() const {return m_speed_weighted_speed_factor;}
+
+ const core::vector2df& getSpeedWeightedTextureSpeed() const {return m_speed_weighted_texture_speed;}
// ------------------------------------------------------------------------
/** Returns the wheel base (distance front to rear axis). */
diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp
index 9cfcf611a..ecd564a16 100644
--- a/src/states_screens/feature_unlocked.cpp
+++ b/src/states_screens/feature_unlocked.cpp
@@ -330,7 +330,7 @@ void FeatureUnlockedCutScene::init()
m_unlocked_stuff[n].m_root_gift_node = kart_model->attachModel(true);
kart_model->setAnimation(KartModel::AF_DEFAULT);
float susp[4]={0,0,0,0};
- kart_model->update(0.0f, 0.0f, susp, 0.0f);
+ kart_model->update(0.0f, 0.0f, 0.0f, susp, 0.0f);
#ifdef DEBUG
m_unlocked_stuff[n].m_root_gift_node->setName("unlocked kart");
diff --git a/src/states_screens/grand_prix_lose.cpp b/src/states_screens/grand_prix_lose.cpp
index d95b8c0cf..e8f6ed7d1 100644
--- a/src/states_screens/grand_prix_lose.cpp
+++ b/src/states_screens/grand_prix_lose.cpp
@@ -340,7 +340,7 @@ void GrandPrixLose::setKarts(std::vector ident_arg)
kart_main_node->updateAbsolutePosition();
kart_main_node->setRotation(vector3df(0, 90, 0));
float susp[4]={0,0,0,0};
- kart_model->update(0.0f, 0.0f, susp, 0.0f);
+ kart_model->update(0.0f, 0.0f, 0.0f, susp, 0.0f);
}
else
{
diff --git a/src/states_screens/grand_prix_win.cpp b/src/states_screens/grand_prix_win.cpp
index 16e31c329..4b5dc68e8 100644
--- a/src/states_screens/grand_prix_win.cpp
+++ b/src/states_screens/grand_prix_win.cpp
@@ -451,7 +451,7 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
m_kart_z[n]) );
kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) );
float susp[4]={0,0,0,0};
- kart_model->update(0.0f, 0.0f, susp, 0.0f);
+ kart_model->update(0.0f, 0.0f, 0.0f, susp, 0.0f);
}
else
{