Added option to disable kart animations in the user config file.

For now it also disables win/lose animations, but if it's worth
keeping non-animated karts (for performance on lower end graphics
card) this will be added.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5492 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-06-09 23:33:06 +00:00
parent 01629af9ee
commit 7c0ff2772a
3 changed files with 39 additions and 16 deletions

View File

@ -240,6 +240,9 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_graphical_effects PARAM_PREFIX BoolUserConfigParam m_graphical_effects
PARAM_DEFAULT( BoolUserConfigParam(true, "gfx", &m_video_group) ); PARAM_DEFAULT( BoolUserConfigParam(true, "gfx", &m_video_group) );
PARAM_PREFIX BoolUserConfigParam m_show_steering_animations
PARAM_DEFAULT( BoolUserConfigParam(true, "steering_animations", &m_video_group, "Display steering animations in race") );
PARAM_PREFIX BoolUserConfigParam m_display_fps PARAM_PREFIX BoolUserConfigParam m_display_fps
PARAM_DEFAULT( BoolUserConfigParam(false, "show_fps", &m_video_group, "Display frame per seconds") ); PARAM_DEFAULT( BoolUserConfigParam(false, "show_fps", &m_video_group, "Display frame per seconds") );
PARAM_PREFIX IntUserConfigParam m_max_fps PARAM_PREFIX IntUserConfigParam m_max_fps

View File

@ -98,10 +98,23 @@ KartModel::~KartModel()
*/ */
void KartModel::attachModel(scene::ISceneNode **node) void KartModel::attachModel(scene::ISceneNode **node)
{ {
*node = irr_driver->addAnimatedMesh(m_mesh); if(UserConfigParams::m_show_steering_animations)
m_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node); {
m_node->setAnimationSpeed(1500); *node = irr_driver->addAnimatedMesh(m_mesh);
m_node->setLoopMode(false); m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node);
m_animated_node->setAnimationSpeed(1500);
m_animated_node->setLoopMode(false);
}
else
{
// If no animations are shown, make sure to pick the frame
// with a straight ahead animation (if exist).
int straight_frame = m_animation_frame[AF_STRAIGHT]>=0
? m_animation_frame[AF_STRAIGHT]
: 0;
*node = irr_driver->addMesh(m_mesh->getMesh(straight_frame));
}
for(unsigned int i=0; i<4; i++) for(unsigned int i=0; i<4; i++)
{ {
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i]); m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i]);
@ -117,6 +130,8 @@ void KartModel::loadModels(const KartProperties &kart_properties)
{ {
std::string full_path = kart_properties.getKartDir()+"/"+m_model_filename; std::string full_path = kart_properties.getKartDir()+"/"+m_model_filename;
m_mesh = irr_driver->getAnimatedMesh(full_path); m_mesh = irr_driver->getAnimatedMesh(full_path);
if(!UserConfigParams::m_show_steering_animations)
m_mesh->setHardwareMappingHint(scene::EHM_STATIC);
Vec3 min, max; Vec3 min, max;
if(!m_mesh) if(!m_mesh)
{ {
@ -235,21 +250,23 @@ void KartModel::setDefaultPhysicsPosition(const Vec3 &center_shift,
*/ */
void KartModel::setAnimation(AnimationFrameType type) void KartModel::setAnimation(AnimationFrameType type)
{ {
if(!UserConfigParams::m_show_steering_animations) return;
m_current_animation = type; m_current_animation = type;
if(!m_current_animation==AF_DEFAULT) if(!m_current_animation==AF_DEFAULT)
{ {
m_node->setLoopMode(false); m_animated_node->setLoopMode(false);
m_node->setFrameLoop(m_animation_frame[AF_STRAIGHT], m_animated_node->setFrameLoop(m_animation_frame[AF_STRAIGHT],
m_animation_frame[AF_STRAIGHT] ); m_animation_frame[AF_STRAIGHT] );
} }
if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1) if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1)
{ {
AnimationFrameType end = (AnimationFrameType)(type+1); AnimationFrameType end = (AnimationFrameType)(type+1);
m_node->setFrameLoop(m_animation_frame[type], m_animated_node->setFrameLoop(m_animation_frame[type],
m_animation_frame[end] ); m_animation_frame[end] );
m_node->setLoopMode(true); m_animated_node->setLoopMode(true);
m_node->setAnimationSpeed(m_animation_speed); m_animated_node->setAnimationSpeed(m_animation_speed);
} }
} // setEndAnimation } // setEndAnimation
@ -303,6 +320,8 @@ void KartModel::update(float rotation, float visual_steer,
if(m_animation_frame[AF_LEFT]<0) return; // no animations defined if(m_animation_frame[AF_LEFT]<0) return; // no animations defined
if(!UserConfigParams::m_show_steering_animations) return;
// Update animation if necessary // Update animation if necessary
// ----------------------------- // -----------------------------
// FIXME: this implementation is currently very simple, it will always // FIXME: this implementation is currently very simple, it will always
@ -321,19 +340,19 @@ void KartModel::update(float rotation, float visual_steer,
// No changes to current frame loop // No changes to current frame loop
if(end==last_end) return; if(end==last_end) return;
int begin = (int)m_node->getFrameNr(); int begin = (int)m_animated_node->getFrameNr();
last_end = end; last_end = end;
// Handle reverse animation, which are done by setting // Handle reverse animation, which are done by setting
// the animation speed to a negative number. // the animation speed to a negative number.
if(begin<end) if(begin<end)
{ {
m_node->setFrameLoop(begin, end); m_animated_node->setFrameLoop(begin, end);
m_node->setAnimationSpeed(m_animation_speed); m_animated_node->setAnimationSpeed(m_animation_speed);
} }
else else
{ {
m_node->setFrameLoop(begin, end); m_animated_node->setFrameLoop(begin, end);
m_node->setAnimationSpeed(-m_animation_speed); m_animated_node->setAnimationSpeed(-m_animation_speed);
} }
} // update } // update

View File

@ -67,8 +67,9 @@ private:
scene::IAnimatedMesh *m_mesh; scene::IAnimatedMesh *m_mesh;
/** This is a pointer to the scene node of the kart this model belongs /** This is a pointer to the scene node of the kart this model belongs
* to. It is necessary to adjust animations. */ * to. It is necessary to adjust animations, and it is not used
scene::IAnimatedMeshSceneNode *m_node; * (i.e. neither read nor written) if animations are disabled. */
scene::IAnimatedMeshSceneNode *m_animated_node;
/** Value used to indicate undefined entries. */ /** Value used to indicate undefined entries. */
static float UNDEFINED; static float UNDEFINED;