Add animation setting middleground : only human players karts are animted
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7487 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
* \param init_transform The initial position and rotation for this kart.
|
||||
*/
|
||||
Kart::Kart (const std::string& ident, int position,
|
||||
const btTransform& init_transform)
|
||||
const btTransform& init_transform, RaceManager::KartType type)
|
||||
: TerrainInfo(1),
|
||||
Moveable(), EmergencyAnimation(this), MaxSpeed(this), m_powerup(this)
|
||||
|
||||
@@ -139,7 +139,18 @@ Kart::Kart (const std::string& ident, int position,
|
||||
fprintf(stdout, "Error: Could not allocate a sfx object for the kart. Further errors may ensue!\n");
|
||||
}
|
||||
|
||||
loadData();
|
||||
bool animations = true;
|
||||
const int anims = UserConfigParams::m_show_steering_animations;
|
||||
if (anims == ANIMS_NONE)
|
||||
{
|
||||
animations = false;
|
||||
}
|
||||
else if (anims == ANIMS_PLAYERS_ONLY && type != RaceManager::KT_PLAYER)
|
||||
{
|
||||
animations = false;
|
||||
}
|
||||
|
||||
loadData(animations);
|
||||
|
||||
reset();
|
||||
} // Kart
|
||||
@@ -1438,9 +1449,9 @@ void Kart::updatePhysics(float dt)
|
||||
/** Attaches the right model, creates the physics and loads all special
|
||||
* effects (particle systems etc.)
|
||||
*/
|
||||
void Kart::loadData()
|
||||
void Kart::loadData(bool animatedModel)
|
||||
{
|
||||
m_kart_model->attachModel(&m_node);
|
||||
m_kart_model->attachModel(&m_node, animatedModel);
|
||||
// Attachment must be created after attachModel, since only then the
|
||||
// scene node will exist (to which the attachment is added). But the
|
||||
// attachment is needed in createPhysics (which gets the mass, which
|
||||
|
||||
@@ -189,11 +189,11 @@ protected:
|
||||
|
||||
public:
|
||||
Kart(const std::string& ident, int position,
|
||||
const btTransform& init_transform);
|
||||
const btTransform& init_transform, RaceManager::KartType type);
|
||||
virtual ~Kart();
|
||||
unsigned int getWorldKartId() const { return m_world_kart_id; }
|
||||
void setWorldKartId(unsigned int n) { m_world_kart_id=n; }
|
||||
void loadData();
|
||||
void loadData(bool animatedModel);
|
||||
virtual void updateGraphics(const Vec3& off_xyz,
|
||||
const btQuaternion& off_rotation);
|
||||
void createPhysics ();
|
||||
|
||||
@@ -187,24 +187,11 @@ KartModel* KartModel::makeCopy()
|
||||
/** Attach the kart model and wheels to the scene node.
|
||||
* \param node Node to attach the models to.
|
||||
*/
|
||||
void KartModel::attachModel(scene::ISceneNode **node)
|
||||
void KartModel::attachModel(scene::ISceneNode **node, bool animatedModels)
|
||||
{
|
||||
assert(!m_is_master);
|
||||
|
||||
bool animations = true;
|
||||
|
||||
const int anims = UserConfigParams::m_show_steering_animations;
|
||||
if (anims == ANIMS_NONE)
|
||||
{
|
||||
animations = false;
|
||||
}
|
||||
else if (anims == ANIMS_PLAYERS_ONLY && m_kart != NULL && m_kart->getController() != NULL &&
|
||||
!m_kart->getController()->isPlayerController())
|
||||
{
|
||||
animations = false;
|
||||
}
|
||||
|
||||
if (animations)
|
||||
if (animatedModels)
|
||||
{
|
||||
*node = irr_driver->addAnimatedMesh(m_mesh);
|
||||
m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node);
|
||||
@@ -218,9 +205,13 @@ void KartModel::attachModel(scene::ISceneNode **node)
|
||||
int straight_frame = m_animation_frame[AF_STRAIGHT]>=0
|
||||
? m_animation_frame[AF_STRAIGHT]
|
||||
: 0;
|
||||
printf("straight_frame = %i\n", straight_frame);
|
||||
*node = irr_driver->addMesh(m_mesh->getMesh(straight_frame));
|
||||
|
||||
scene::IMesh* main_frame = m_mesh->getMesh(straight_frame);
|
||||
main_frame->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
|
||||
*node = irr_driver->addMesh(main_frame);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::string debug_name = m_model_filename+" (kart-model)";
|
||||
(*node)->setName(debug_name.c_str());
|
||||
@@ -254,17 +245,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
|
||||
full_path.c_str(), kart_properties.getIdent().c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int anims = UserConfigParams::m_show_steering_animations;
|
||||
if (anims == ANIMS_NONE ||
|
||||
(anims == ANIMS_PLAYERS_ONLY && m_kart != NULL && m_kart->getController() != NULL &&
|
||||
!m_kart->getController()->isPlayerController()))
|
||||
{
|
||||
m_mesh->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vec3 min, max;
|
||||
MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &min, &max);
|
||||
|
||||
@@ -372,10 +353,8 @@ void KartModel::setDefaultPhysicsPosition(const Vec3 ¢er_shift,
|
||||
*/
|
||||
void KartModel::setAnimation(AnimationFrameType type)
|
||||
{
|
||||
const int anims = UserConfigParams::m_show_steering_animations;
|
||||
if (anims == ANIMS_NONE) return;
|
||||
if (m_kart != NULL && anims == ANIMS_PLAYERS_ONLY&& m_kart->getController() != NULL &&
|
||||
!m_kart->getController()->isPlayerController()) return;
|
||||
// if animations disabled, give up
|
||||
if (m_animated_node == NULL) return;
|
||||
|
||||
m_current_animation = type;
|
||||
if(m_current_animation==AF_DEFAULT)
|
||||
@@ -489,17 +468,15 @@ void KartModel::update(float rotation, float steer, const float suspension[4])
|
||||
if(m_wheel_node[2]) m_wheel_node[2]->setRotation(wheel_rear );
|
||||
if(m_wheel_node[3]) m_wheel_node[3]->setRotation(wheel_rear );
|
||||
|
||||
// If animaitons are disabled, stop here
|
||||
if (m_animated_node == NULL) return;
|
||||
|
||||
// Check if the end animation is being played, if so, don't
|
||||
// play steering animation.
|
||||
if(m_current_animation!=AF_DEFAULT) return;
|
||||
|
||||
if(m_animation_frame[AF_LEFT]<0) return; // no animations defined
|
||||
|
||||
const int anims = UserConfigParams::m_show_steering_animations;
|
||||
if (anims == ANIMS_NONE) return;
|
||||
if (m_kart != NULL && anims == ANIMS_PLAYERS_ONLY && m_kart->getController() != NULL &&
|
||||
!m_kart->getController()->isPlayerController()) return;
|
||||
|
||||
// Update animation if necessary
|
||||
// -----------------------------
|
||||
float frame;
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
KartModel* makeCopy();
|
||||
void loadInfo(const XMLNode &node);
|
||||
bool loadModels(const KartProperties &kart_properties);
|
||||
void attachModel(scene::ISceneNode **node);
|
||||
void attachModel(scene::ISceneNode **node, bool animatedModels);
|
||||
scene::IAnimatedMesh*
|
||||
getModel() const { return m_mesh; }
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ Kart *ProfileWorld::createKart(const std::string &kart_ident, int index,
|
||||
race_manager->getNumberOfKarts()-1);
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
|
||||
Kart *new_kart = new Kart(prof_kart_id, index+1, init_pos);
|
||||
Kart *new_kart = new Kart(prof_kart_id, index+1, init_pos, RaceManager::KT_AI);
|
||||
|
||||
Controller *controller = loadAIController(new_kart);
|
||||
new_kart->setController(controller);
|
||||
|
||||
@@ -174,7 +174,7 @@ Kart *World::createKart(const std::string &kart_ident, int index,
|
||||
{
|
||||
int position = index+1;
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
Kart *new_kart = new Kart(kart_ident, position, init_pos);
|
||||
Kart *new_kart = new Kart(kart_ident, position, init_pos, race_manager->getKartType(index));
|
||||
Controller *controller = NULL;
|
||||
switch(race_manager->getKartType(index))
|
||||
{
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
from the network manager.
|
||||
*/
|
||||
NetworkKart::NetworkKart(const std::string &kart_name, int position,
|
||||
const btTransform &init_transform, int global_player_id)
|
||||
: Kart(kart_name, position, init_transform)
|
||||
const btTransform &init_transform, int global_player_id,
|
||||
RaceManager::KartType type)
|
||||
: Kart(kart_name, position, init_transform, type)
|
||||
{
|
||||
m_global_player_id = global_player_id;
|
||||
} // NetworkKart
|
||||
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
public:
|
||||
NetworkKart(const std::string& kart_name, int position,
|
||||
const btTransform& init_transform,
|
||||
int global_player_id);
|
||||
int global_player_id, RaceManager::KartType type);
|
||||
void setControl(const KartControl& kc);
|
||||
virtual bool isNetworkKart() const { return true; }
|
||||
}; // NetworkKart
|
||||
|
||||
@@ -225,7 +225,7 @@ void FeatureUnlockedCutScene::init()
|
||||
KartModel *kart_model =
|
||||
m_unlocked_stuff[n].m_unlocked_kart->getKartModelCopy();
|
||||
m_all_kart_models.push_back(kart_model);
|
||||
kart_model->attachModel(&(m_unlocked_stuff[n].m_root_gift_node));
|
||||
kart_model->attachModel(&(m_unlocked_stuff[n].m_root_gift_node), true);
|
||||
kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
float susp[4]={0,0,0,0};
|
||||
kart_model->update(0.0f, 0.0f, susp);
|
||||
|
||||
@@ -314,12 +314,11 @@ void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
||||
m_kart_y = KART_Y;
|
||||
m_kart_z = KART_Z;
|
||||
|
||||
kart_model->attachModel(&kart_main_node);
|
||||
kart_model->attachModel(&kart_main_node, false);
|
||||
kart_main_node->setPosition( core::vector3df(m_kart_x, m_kart_y, m_kart_z) );
|
||||
//kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) );
|
||||
kart_main_node->updateAbsolutePosition();
|
||||
kart_main_node->setRotation(vector3df(0, 90, 0));
|
||||
kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
float susp[4]={0,0,0,0};
|
||||
kart_model->update(0.0f, 0.0f, susp);
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
||||
{
|
||||
KartModel *kart_model = kp->getKartModelCopy();
|
||||
m_all_kart_models.push_back(kart_model);
|
||||
kart_model->attachModel(&kart_main_node);
|
||||
kart_model->attachModel(&kart_main_node, false);
|
||||
|
||||
m_kart_x[n] = m_podium_x[n];
|
||||
m_kart_y[n] = INITIAL_Y + KARTS_DELTA_Y;
|
||||
@@ -445,7 +445,6 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
||||
m_kart_y[n],
|
||||
m_kart_z[n]) );
|
||||
kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) );
|
||||
kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
float susp[4]={0,0,0,0};
|
||||
kart_model->update(0.0f, 0.0f, susp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user