Initial rotation of thunderbird now takes heading of
kart into account. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9832 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -30,7 +30,14 @@ class Kart;
|
||||
/**
|
||||
* \ingroup graphics
|
||||
* This implements the referee, a character that is displayed at the start
|
||||
* of the race holding a 'ready-set-go' traffic light (or so)
|
||||
* of the race holding a 'ready-set-go' traffic light (or so). It contains
|
||||
* various static functions and variables which are used to store the
|
||||
* original mesh, offsets, rotation, ... of the referee.
|
||||
* Each instance of Referee then has a scene node where the referee is
|
||||
* shown. One instance of this object is used to display the referee
|
||||
* for all(!) karts, i.e. the scene node is moved and rotated before
|
||||
* rendering the view for each of the cameras. This reduces rendering
|
||||
* effect somewhat, and helps making the startup less crowded.
|
||||
*/
|
||||
class Referee
|
||||
{
|
||||
@@ -83,12 +90,21 @@ public:
|
||||
void setPosition(const Vec3 &xyz)
|
||||
{m_scene_node->setPosition(xyz.toIrrVector()); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the rotation of the scene node (in degrees).
|
||||
* \param hpr Rotation in degrees. */
|
||||
void setRotation(const Vec3 &hpr)
|
||||
{ m_scene_node->setRotation(hpr.toIrrVector()); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this referee is attached to the scene graph. */
|
||||
bool isAttached() const {return m_scene_node->getParent()!=NULL;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the graphical offset the referee should be drawn at at the
|
||||
* start of a race. */
|
||||
static const Vec3& getStartOffset() {return m_st_start_offset; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the rotation of the mesh so that it faces the kart (when
|
||||
* applied to a kart with heading 0). */
|
||||
static const Vec3& getStartRotation() {return m_st_start_rotation; }
|
||||
}; // Referee
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "modes/follow_the_leader.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
#include <ICameraSceneNode.h>
|
||||
|
||||
@@ -91,7 +92,6 @@ RaceGUIBase::RaceGUIBase()
|
||||
* In the base gui this is used to initialise the referee data (which needs
|
||||
* the start positions of the karts).
|
||||
*/
|
||||
|
||||
void RaceGUIBase::init()
|
||||
{
|
||||
// While we actually only need the positions for local players,
|
||||
@@ -102,6 +102,9 @@ void RaceGUIBase::init()
|
||||
{
|
||||
const Kart *kart = World::getWorld()->getKart(i);
|
||||
m_referee_pos.push_back(kart->getTrans()(Referee::getStartOffset()));
|
||||
Vec3 hpr = Referee::getStartRotation()
|
||||
+ Vec3(0, kart->getHeading()*RAD_TO_DEGREE, 0);
|
||||
m_referee_rotation.push_back(hpr);
|
||||
}
|
||||
|
||||
m_referee = new Referee();
|
||||
@@ -454,6 +457,7 @@ void RaceGUIBase::preRenderCallback(const Kart &kart)
|
||||
Vec3 xyz = m_referee_pos[kart.getWorldKartId()];
|
||||
xyz.setY(xyz.getY()+m_referee_height);
|
||||
m_referee->setPosition(xyz);
|
||||
m_referee->setRotation(m_referee_rotation[kart.getWorldKartId()]);
|
||||
} // preRenderCallback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -130,6 +130,9 @@ private:
|
||||
/** The position of the referee for all karts. */
|
||||
std::vector<Vec3> m_referee_pos;
|
||||
|
||||
/** The actual rotation to use for the referee for each kart. */
|
||||
std::vector<Vec3> m_referee_rotation;
|
||||
|
||||
/** The height of the referee. This is used to make the referee fly
|
||||
* into view. This is the same Y-offset for all karts, so only a
|
||||
* single value needs to be used. */
|
||||
|
||||
Reference in New Issue
Block a user