Started to set the gravity for selected material based on the
normal of the triangle where the kart is on.
This commit is contained in:
parent
f1f8900c5d
commit
1709ccc36d
@ -146,6 +146,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
|
|
||||||
node->get("water-splash", &m_water_splash );
|
node->get("water-splash", &m_water_splash );
|
||||||
node->get("jump", &m_is_jump_texture );
|
node->get("jump", &m_is_jump_texture );
|
||||||
|
node->get("has-gravity", &m_has_gravity );
|
||||||
|
|
||||||
if (m_collision_reaction != NORMAL)
|
if (m_collision_reaction != NORMAL)
|
||||||
{
|
{
|
||||||
@ -344,6 +345,10 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // for i <node->getNumNodes()
|
} // for i <node->getNumNodes()
|
||||||
|
|
||||||
|
if(m_has_gravity)
|
||||||
|
m_high_tire_adhesion = true;
|
||||||
|
|
||||||
install(/*is_full_path*/false);
|
install(/*is_full_path*/false);
|
||||||
} // Material
|
} // Material
|
||||||
|
|
||||||
@ -410,6 +415,7 @@ void Material::init(unsigned int index)
|
|||||||
m_is_heightmap = false;
|
m_is_heightmap = false;
|
||||||
m_water_splash = false;
|
m_water_splash = false;
|
||||||
m_is_jump_texture = false;
|
m_is_jump_texture = false;
|
||||||
|
m_has_gravity = false;
|
||||||
|
|
||||||
for (int n=0; n<EMIT_KINDS_COUNT; n++)
|
for (int n=0; n<EMIT_KINDS_COUNT; n++)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +111,11 @@ private:
|
|||||||
* leaving it and being in the air. */
|
* leaving it and being in the air. */
|
||||||
bool m_is_jump_texture;
|
bool m_is_jump_texture;
|
||||||
|
|
||||||
|
/** 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. */
|
||||||
|
bool m_has_gravity;
|
||||||
|
|
||||||
/** Speed of the 'main' wave in the water shader. Only used if
|
/** Speed of the 'main' wave in the water shader. Only used if
|
||||||
m_graphical_effect == WATER_SHADER */
|
m_graphical_effect == WATER_SHADER */
|
||||||
float m_water_shader_speed_1;
|
float m_water_shader_speed_1;
|
||||||
@ -312,6 +317,11 @@ public:
|
|||||||
* jump animation. */
|
* jump animation. */
|
||||||
bool isJumpTexture() const { return m_is_jump_texture; }
|
bool isJumpTexture() const { return m_is_jump_texture; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
/** 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. */
|
||||||
|
bool hasGravity() const { return m_has_gravity; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the zipper parametersfor the current material. */
|
/** Returns the zipper parametersfor the current material. */
|
||||||
void getZipperParameter(float *zipper_max_speed_increase,
|
void getZipperParameter(float *zipper_max_speed_increase,
|
||||||
float *zipper_duration,
|
float *zipper_duration,
|
||||||
|
@ -1212,6 +1212,10 @@ void Kart::update(float dt)
|
|||||||
const Material* material=m_terrain_info->getMaterial();
|
const Material* material=m_terrain_info->getMaterial();
|
||||||
if (!material) // kart falling off the track
|
if (!material) // kart falling off the track
|
||||||
{
|
{
|
||||||
|
Vec3 gravity(0, -9.8f, 0);
|
||||||
|
btRigidBody *body = getVehicle()->getRigidBody();
|
||||||
|
body->setGravity(gravity);
|
||||||
|
|
||||||
// let kart fall a bit before rescuing
|
// let kart fall a bit before rescuing
|
||||||
const Vec3 *min, *max;
|
const Vec3 *min, *max;
|
||||||
World::getWorld()->getTrack()->getAABB(&min, &max);
|
World::getWorld()->getTrack()->getAABB(&min, &max);
|
||||||
@ -1221,6 +1225,16 @@ void Kart::update(float dt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Vec3 gravity(0.0f, -9.8f, 0.0f);
|
||||||
|
btRigidBody *body = getVehicle()->getRigidBody();
|
||||||
|
// If the material should overwrite the gravity,
|
||||||
|
if(material->hasGravity())
|
||||||
|
{
|
||||||
|
Vec3 normal = m_terrain_info->getNormal();
|
||||||
|
gravity = normal * -9.8f;
|
||||||
|
}
|
||||||
|
body->setGravity(gravity);
|
||||||
|
|
||||||
handleMaterialSFX(material);
|
handleMaterialSFX(material);
|
||||||
if (material->isDriveReset() && isOnGround())
|
if (material->isDriveReset() && isOnGround())
|
||||||
new RescueAnimation(this);
|
new RescueAnimation(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user