1) Moved LOD node from kart into kart_model (which should
handle all graphics for the karts). 2) Fixed squashing of karts in case of disabled animations (see #283, but only partly solved). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9108 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
@@ -483,8 +482,8 @@ void Kart::reset()
|
||||
m_camera->setInitialTransform();
|
||||
}
|
||||
|
||||
// Reset squashing and animations
|
||||
m_kart_model->resetWheels();
|
||||
// Reset animations and wheels
|
||||
m_kart_model->reset();
|
||||
|
||||
// If the controller was replaced (e.g. replaced by end controller),
|
||||
// restore the original controller.
|
||||
@@ -504,7 +503,7 @@ void Kart::reset()
|
||||
m_finish_time = 0.0f;
|
||||
m_invulnerable_time = 0.0f;
|
||||
m_squash_time = 0.0f;
|
||||
m_kart_model->scaleKart(Vec3(1.0f, 1.0f, 1.0f));
|
||||
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
m_collected_energy = 0;
|
||||
m_has_started = false;
|
||||
m_wheel_rotation = 0;
|
||||
@@ -752,7 +751,7 @@ void Kart::update(float dt)
|
||||
// If squasing time ends, reset the model
|
||||
if(m_squash_time<=0)
|
||||
{
|
||||
m_kart_model->scaleKart(Vec3(1.0f, 1.0f, 1.0f));
|
||||
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH,
|
||||
/*slowdown*/1.0f, /*fade in*/0.0f);
|
||||
}
|
||||
@@ -961,7 +960,7 @@ void Kart::update(float dt)
|
||||
*/
|
||||
void Kart::setSquash(float time, float slowdown)
|
||||
{
|
||||
m_kart_model->scaleKart(Vec3(1.0f, 0.5f, 1.0f));
|
||||
m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f));
|
||||
MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, 0.1f);
|
||||
m_squash_time = time;
|
||||
} // setSquash
|
||||
@@ -1728,22 +1727,11 @@ void Kart::updatePhysics(float dt)
|
||||
/** Attaches the right model, creates the physics and loads all special
|
||||
* effects (particle systems etc.)
|
||||
*/
|
||||
void Kart::loadData(RaceManager::KartType type, bool is_first_kart, Track* track, bool animatedModel)
|
||||
void Kart::loadData(RaceManager::KartType type, bool is_first_kart,
|
||||
Track* track, bool is_animated_model)
|
||||
{
|
||||
if (animatedModel)
|
||||
{
|
||||
scene::ISceneNode* staticModel = m_kart_model->attachModel(false);
|
||||
scene::ISceneNode* animatedModelNode = m_kart_model->attachModel(animatedModel);
|
||||
LODNode* node = new LODNode(irr_driver->getSceneManager()->getRootSceneNode(),
|
||||
irr_driver->getSceneManager());
|
||||
node->add(50, animatedModelNode, true);
|
||||
node->add(500, staticModel, true);
|
||||
m_node = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_node = m_kart_model->attachModel(animatedModel);
|
||||
}
|
||||
|
||||
m_node = m_kart_model->attachModel(is_animated_model);
|
||||
|
||||
#ifdef DEBUG
|
||||
m_node->setName( (m_kart_properties->getIdent()+"(lod-node)").c_str() );
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
#include "karts/kart_model.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/mesh_tools.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
@@ -198,24 +200,34 @@ KartModel* KartModel::makeCopy()
|
||||
/** Attach the kart model and wheels to the scene node.
|
||||
* \return the node with the model attached
|
||||
*/
|
||||
scene::ISceneNode* KartModel::attachModel(bool animatedModels)
|
||||
scene::ISceneNode* KartModel::attachModel(bool animated_models)
|
||||
{
|
||||
assert(!m_is_master);
|
||||
|
||||
scene::ISceneNode* node;
|
||||
|
||||
if (animatedModels)
|
||||
if (animated_models)
|
||||
{
|
||||
LODNode* lod_node = new LODNode(
|
||||
irr_driver->getSceneManager()->getRootSceneNode(),
|
||||
irr_driver->getSceneManager() );
|
||||
|
||||
|
||||
node = irr_driver->addAnimatedMesh(m_mesh);
|
||||
lod_node->add(50, node, true);
|
||||
scene::ISceneNode* static_model = attachModel(false);
|
||||
lod_node->add(500, static_model, true);
|
||||
m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(node);
|
||||
#ifdef DEBUG
|
||||
std::string debug_name = m_model_filename+" (animated-kart-model)";
|
||||
node->setName(debug_name.c_str());
|
||||
#if SKELETON_DEBUG
|
||||
irr_driver->debug_meshes.push_back(m_animated_node);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
m_animated_node->setLoopMode(false);
|
||||
m_animated_node->grab();
|
||||
node = lod_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,20 +241,12 @@ scene::ISceneNode* KartModel::attachModel(bool animatedModels)
|
||||
main_frame->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
|
||||
node = irr_driver->addMesh(main_frame);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (animatedModels)
|
||||
{
|
||||
std::string debug_name = m_model_filename+" (animated-kart-model)";
|
||||
node->setName(debug_name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string debug_name = m_model_filename+" (kart-model)";
|
||||
node->setName(debug_name.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
@@ -377,17 +381,19 @@ void KartModel::setDefaultPhysicsPosition(const Vec3 ¢er_shift,
|
||||
} // setDefaultPhysicsPosition
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Resets the kart model. It removes any scaling (squashing) and stops
|
||||
* animation from being played.
|
||||
/** Resets the kart model. It stops animation from being played and resets
|
||||
* the wheels to the correct position (i.e. no suspension).
|
||||
*/
|
||||
void KartModel::reset()
|
||||
{
|
||||
m_animated_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
// Reset the wheels
|
||||
const float suspension[4]={0,0,0,0};
|
||||
update(0, 0.0f, suspension);
|
||||
|
||||
// Stop any animations currently being played.
|
||||
setAnimation(KartModel::AF_DEFAULT);
|
||||
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Enables- or disables the end animation.
|
||||
* \param type The type of animation to play.
|
||||
@@ -532,21 +538,3 @@ void KartModel::update(float rotation, float steer, const float suspension[4])
|
||||
m_animated_node->setCurrentFrame(frame);
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Puts all wheels in the default position. Used when displaying the karts
|
||||
* in the character selection screen.
|
||||
*/
|
||||
void KartModel::resetWheels()
|
||||
{
|
||||
const float suspension[4]={0,0,0,0};
|
||||
update(0, 0.0f, suspension);
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Scales the kart model by a certain amount. */
|
||||
void KartModel::scaleKart(const Vec3 &s)
|
||||
{
|
||||
if (m_animated_node)
|
||||
m_animated_node->setScale(s.toIrrVector());
|
||||
} // scaleKart
|
||||
|
||||
|
||||
@@ -179,9 +179,7 @@ public:
|
||||
float getWidth () const {return m_kart_width; }
|
||||
float getHeight () const {return m_kart_height; }
|
||||
void update(float rotation, float steer, const float suspension[4]);
|
||||
void resetWheels();
|
||||
void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius);
|
||||
void scaleKart(const Vec3 &s);
|
||||
|
||||
/** Enables- or disables the end animation. */
|
||||
void setAnimation(AnimationFrameType type);
|
||||
|
||||
Reference in New Issue
Block a user