Added support for jump animation, which will triggered
if either the estimated jump duration is long enough, or the texture the kart was on before it jumped has a jump property set. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13265 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8f77aac50a
commit
2ff62c4d97
@ -147,6 +147,12 @@
|
||||
<camera distance="1.5" forward-up-angle="15"
|
||||
backward-up-angle="30"/>
|
||||
|
||||
<!-- Jump animation related values:
|
||||
animation-time: only if the estimated time for a jump is larger
|
||||
than this value will the jump animation being
|
||||
shown. -->
|
||||
<jump animation-time="0.5" />
|
||||
|
||||
<!-- If a kart starts within the specified time after 'go',
|
||||
it receives the corresponding bonus from 'boost'. Those
|
||||
fields must have the same size, and must be sorted by
|
||||
|
@ -483,6 +483,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
||||
node->get("mask", &m_mask );
|
||||
|
||||
node->get("water-splash", &m_water_splash );
|
||||
node->get("jump", &m_is_jump_texture );
|
||||
|
||||
if (m_collision_reaction != NORMAL)
|
||||
{
|
||||
@ -732,6 +733,7 @@ void Material::init(unsigned int index)
|
||||
m_is_heightmap = false;
|
||||
m_alpha_to_coverage = false;
|
||||
m_water_splash = false;
|
||||
m_is_jump_texture = false;
|
||||
|
||||
m_shaders.resize(SHADER_COUNT, NULL);
|
||||
|
||||
|
@ -114,11 +114,16 @@ private:
|
||||
* surface is not a physical object), but the location of the water
|
||||
* effect is on the surface. */
|
||||
bool m_surface;
|
||||
|
||||
/** If the material is a zipper, i.e. gives a speed boost. */
|
||||
bool m_zipper;
|
||||
|
||||
/** If a kart is rescued when driving on this surface. */
|
||||
bool m_drive_reset;
|
||||
|
||||
/** True if this is a texture that will start the jump animatoin when
|
||||
* leaving it and being in the air. */
|
||||
bool m_is_jump_texture;
|
||||
|
||||
/** Speed of the 'main' wave in the water shader. Only used if
|
||||
m_graphical_effect == WATER_SHADER */
|
||||
@ -321,6 +326,10 @@ public:
|
||||
* the special falling camera. */
|
||||
bool hasFallingEffect() const {return m_falling_effect; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if being in the air after this texture should start the
|
||||
* jump animation. */
|
||||
bool isJumpTexture() const { return m_is_jump_texture; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the zipper parametersfor the current material. */
|
||||
void getZipperParameter(float *zipper_max_speed_increase,
|
||||
float *zipper_duration,
|
||||
|
@ -119,10 +119,8 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_flying = false;
|
||||
m_sky_particles_emitter= NULL;
|
||||
m_stars_effect = NULL;
|
||||
m_timeFlying = 0;
|
||||
m_isTimeFlying = false;
|
||||
m_hitGround = NULL;
|
||||
|
||||
m_jump_time = 0;
|
||||
m_is_jumping = false;
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
|
||||
@ -339,6 +337,8 @@ void Kart::reset()
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_bubblegum_torque = 0.0f;
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
m_is_jumping = false;
|
||||
|
||||
// In case that the kart was in the air, in which case its
|
||||
// linear damping is 0
|
||||
m_body->setDamping(m_kart_properties->getChassisLinearDamping(),
|
||||
@ -1198,17 +1198,39 @@ void Kart::update(float dt)
|
||||
// values for the raycasts).
|
||||
if (!isOnGround())
|
||||
{
|
||||
m_timeFlying+=dt;
|
||||
m_isTimeFlying = true;
|
||||
const Material *m = getMaterial();
|
||||
const Material *last_m = getLastMaterial();
|
||||
|
||||
// A jump starts only the kart isn't already jumping, is on a new
|
||||
// (or no) texture.
|
||||
if(!m_is_jumping && last_m && last_m!=m )
|
||||
{
|
||||
float v = getVelocity().getY();
|
||||
float force = World::getWorld()->getTrack()->getGravity();;
|
||||
// Velocity / force is the time it takes to reach the peak
|
||||
// of the jump (i.e. when vertical speed becomes 0). Assuming
|
||||
// that jump start height and end height are the same, it will
|
||||
// take the same time again to reach the bottom
|
||||
float t = 2.0f * v/force;
|
||||
|
||||
// Jump if either the jump is estimated to be long enough, or
|
||||
// the texture has the jump property set.
|
||||
if(t>getKartProperties()->getJumpAnimationTime() ||
|
||||
last_m->isJumpTexture() )
|
||||
m_kart_model->setAnimation(KartModel::AF_BEGIN_JUMP);
|
||||
m_is_jumping = true;
|
||||
}
|
||||
m_jump_time+=dt;
|
||||
}
|
||||
|
||||
if(isOnGround() && m_isTimeFlying)
|
||||
else if (m_is_jumping)
|
||||
{
|
||||
m_isTimeFlying = false;
|
||||
m_hitGround = new Explosion(getXYZ(), "jump",
|
||||
"jump_explosion.xml");
|
||||
projectile_manager->addHitEffect(m_hitGround);
|
||||
m_timeFlying = 0;
|
||||
// Kart touched ground again
|
||||
m_is_jumping = false;
|
||||
HitEffect *effect = new Explosion(getXYZ(), "jump",
|
||||
"jump_explosion.xml");
|
||||
projectile_manager->addHitEffect(effect);
|
||||
m_kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
m_jump_time = 0;
|
||||
}
|
||||
|
||||
if( (!isOnGround() || emergency) && m_shadow_enabled)
|
||||
|
@ -41,6 +41,7 @@ class Attachment;
|
||||
class Controller;
|
||||
class Item;
|
||||
class AbstractKartAnimation;
|
||||
class HitEffect;
|
||||
class KartGFX;
|
||||
class MaxSpeed;
|
||||
class ParticleEmitter;
|
||||
@ -51,7 +52,6 @@ class Skidding;
|
||||
class SkidMarks;
|
||||
class SlipStream;
|
||||
class Stars;
|
||||
class HitEffect;
|
||||
|
||||
/** The main kart class. All type of karts are of this object, but with
|
||||
* different controllers. The controllers are what turn a kart into a
|
||||
@ -149,14 +149,11 @@ private:
|
||||
|
||||
// Graphical effects
|
||||
// -----------------
|
||||
/** The time where a kart is flying */
|
||||
float m_timeFlying;
|
||||
|
||||
/** For the effect when the kart touch the ground */
|
||||
HitEffect *m_hitGround;
|
||||
/** Time a kart is jumping. */
|
||||
float m_jump_time;
|
||||
|
||||
/** Is time flying activated */
|
||||
bool m_isTimeFlying;
|
||||
bool m_is_jumping;
|
||||
|
||||
/** The shadow of a kart. */
|
||||
Shadow *m_shadow;
|
||||
|
@ -120,6 +120,8 @@ void KartModel::loadInfo(const XMLNode &node)
|
||||
animation_node->get("end-losing", &m_animation_frame[AF_LOSE_END] );
|
||||
animation_node->get("start-explosion",&m_animation_frame[AF_LOSE_START]);
|
||||
animation_node->get("end-explosion", &m_animation_frame[AF_LOSE_END] );
|
||||
animation_node->get("start-jump", &m_animation_frame[AF_BEGIN_JUMP]);
|
||||
animation_node->get("end-jump", &m_animation_frame[AF_END_JUMP] );
|
||||
animation_node->get("speed", &m_animation_speed );
|
||||
}
|
||||
|
||||
@ -130,14 +132,6 @@ void KartModel::loadInfo(const XMLNode &node)
|
||||
loadWheelInfo(*wheels_node, "rear-right", 2);
|
||||
loadWheelInfo(*wheels_node, "rear-left", 3);
|
||||
}
|
||||
|
||||
// FIXME fallback for karts that don't have nitro emitter
|
||||
/*
|
||||
m_nitro_emitter_position[0] = Vec3 (0, m_kart_height*0.35f,
|
||||
-m_kart_length*0.35f);
|
||||
|
||||
m_nitro_emitter_position[1] = Vec3 (0, m_kart_height*0.35f,
|
||||
-m_kart_length*0.35f); */
|
||||
|
||||
m_nitro_emitter_position[0] = Vec3 (0,0.1f,0);
|
||||
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
AF_LOSE_END, // End losing animation
|
||||
AF_BEGIN_EXPLOSION, // Begin explosion animation
|
||||
AF_END_EXPLOSION, // End explosion animation
|
||||
AF_BEGIN_JUMP, // Begin of jump
|
||||
AF_END_JUMP, // End of jump
|
||||
AF_WIN_START, // Begin of win animation
|
||||
AF_WIN_LOOP_START, // Begin of win loop animation
|
||||
AF_WIN_END, // End of win animation
|
||||
|
@ -90,7 +90,8 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_swatter_distance2 = m_swatter_duration = m_squash_slowdown =
|
||||
m_squash_duration = m_downward_impulse_factor =
|
||||
m_bubblegum_fade_in_time = m_bubblegum_speed_fraction =
|
||||
m_bubblegum_time = m_bubblegum_torque = UNDEFINED;
|
||||
m_bubblegum_time = m_bubblegum_torque = m_jump_animation_time =
|
||||
UNDEFINED;
|
||||
|
||||
m_engine_power.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
|
||||
m_max_speed.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
|
||||
@ -519,6 +520,11 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
m_lean_speed *= DEGREE_TO_RAD;
|
||||
}
|
||||
|
||||
if(const XMLNode *jump_node= root->getNode("jump"))
|
||||
{
|
||||
jump_node->get("animation-time", &m_jump_animation_time);
|
||||
}
|
||||
|
||||
if(const XMLNode *camera_node= root->getNode("camera"))
|
||||
{
|
||||
camera_node->get("distance", &m_camera_distance);
|
||||
|
@ -243,6 +243,9 @@ private:
|
||||
* (in radians/second). */
|
||||
float m_lean_speed;
|
||||
|
||||
/** How long a jump must be in order to trigger the jump animation. */
|
||||
float m_jump_animation_time;
|
||||
|
||||
/** Engine sound effect. */
|
||||
std::string m_engine_sfx_type;
|
||||
|
||||
@ -844,6 +847,10 @@ public:
|
||||
/** The speed with which a kart should lean (in radians/s). */
|
||||
float getLeanSpeed() const { return m_lean_speed; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return show long a jump must last in order to play the jump
|
||||
* animation. */
|
||||
float getJumpAnimationTime() const { return m_jump_animation_time; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if wheels should have random rotation at start. */
|
||||
bool hasRandomWheels() const { return m_has_rand_wheels; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user