Team indicators added.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/soccer@13167 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
yasin-ghannam 2013-07-10 22:49:51 +00:00
parent c22941d354
commit d16a5a0552
5 changed files with 351 additions and 324 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -283,39 +283,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models)
lod_node->add(500, static_model, true);
m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(node);
m_hat_node = NULL;
if(m_hat_name.size()>0)
{
scene::IBoneSceneNode *bone = m_animated_node->getJointNode("Head");
if(!bone)
bone = m_animated_node->getJointNode("head");
if(bone)
{
// Till we have all models fixed, accept Head and head as bone naartme
scene::IMesh *hat_mesh =
irr_driver->getAnimatedMesh(
file_manager->getModelFile(m_hat_name));
m_hat_node = irr_driver->addMesh(hat_mesh);
bone->addChild(m_hat_node);
m_animated_node->setCurrentFrame((float)m_animation_frame[AF_STRAIGHT]);
m_animated_node->OnAnimate(0);
bone->updateAbsolutePosition();
// With the hat node attached to the head bone, we have to
// reverse the transformation of the bone, so that the hat
// is still properly placed. Esp. the hat offset needs
// to be rotated.
const core::matrix4 mat = bone->getAbsoluteTransformation();
core::matrix4 inv;
mat.getInverse(inv);
core::vector3df rotated_offset;
inv.rotateVect(rotated_offset, m_hat_offset);
m_hat_node->setPosition(rotated_offset);
m_hat_node->setScale(inv.getScale());
m_hat_node->setRotation(inv.getRotationDegrees());
} // if bone
} // if(m_hat_name)
attachHat();
#ifdef DEBUG
std::string debug_name = m_model_filename+" (animated-kart-model)";
@ -701,4 +669,40 @@ void KartModel::update(float rotation_dt, float steer, const float suspension[4]
m_animated_node->setCurrentFrame(frame);
} // update
//-----------------------------------------------------------------------------
void KartModel::attachHat(){
m_hat_node = NULL;
if(m_hat_name.size()>0)
{
scene::IBoneSceneNode *bone = m_animated_node->getJointNode("Head");
if(!bone)
bone = m_animated_node->getJointNode("head");
if(bone)
{
// Till we have all models fixed, accept Head and head as bone naartme
scene::IMesh *hat_mesh =
irr_driver->getAnimatedMesh(
file_manager->getModelFile(m_hat_name));
m_hat_node = irr_driver->addMesh(hat_mesh);
bone->addChild(m_hat_node);
m_animated_node->setCurrentFrame((float)m_animation_frame[AF_STRAIGHT]);
m_animated_node->OnAnimate(0);
bone->updateAbsolutePosition();
// With the hat node attached to the head bone, we have to
// reverse the transformation of the bone, so that the hat
// is still properly placed. Esp. the hat offset needs
// to be rotated.
const core::matrix4 mat = bone->getAbsoluteTransformation();
core::matrix4 inv;
mat.getInverse(inv);
core::vector3df rotated_offset;
inv.rotateVect(rotated_offset, m_hat_offset);
m_hat_node->setPosition(rotated_offset);
m_hat_node->setScale(inv.getScale());
m_hat_node->setRotation(inv.getRotationDegrees());
} // if bone
} // if(m_hat_name)
}

View File

@ -229,8 +229,14 @@ public:
/** Name of the hat mesh to use. */
void setHatMeshName(const std::string &name) {m_hat_name = name; }
// ------------------------------------------------------------------------
void attachHat();
// ------------------------------------------------------------------------
/** Returns the array of wheel nodes. */
scene::ISceneNode** getWheelNodes() { return m_wheel_node; }
// ------------------------------------------------------------------------
scene::IAnimatedMeshSceneNode* getAnimatedNode(){ return m_animated_node; }
// ------------------------------------------------------------------------
core::vector3df getHatOffset() { return m_hat_offset; }
}; // KartModel
#endif

View File

@ -313,6 +313,23 @@ void SoccerWorld::initKartList()
}// next kart
}
//Loading the indicator textures
irr::video::ITexture *redTeamTexture = irr_driver->getTexture(
file_manager->getTextureFile("soccer_player_red.png"));
irr::video::ITexture *blueTeamTexture = irr_driver->getTexture(
file_manager->getTextureFile("soccer_player_blue.png"));
//Assigning indicators
for(int i=0; i<kart_amount; i++){
scene::ISceneNode *hatNode;
if(race_manager->getLocalKartInfo(i).getSoccerTeam() == SOCCER_TEAM_RED)
hatNode = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3,0.3)
,redTeamTexture,m_karts[i]->getKartModel()->getAnimatedNode()->getJointNode("Head"));
else
hatNode = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3,0.3)
,blueTeamTexture,m_karts[i]->getKartModel()->getAnimatedNode()->getJointNode("Head"));
hatNode->setPosition(m_karts[i]->getKartModel()->getHatOffset());
}
// Compute start positions for each team
int team_cur_position[NB_SOCCER_TEAMS];
team_cur_position[0] = 1;