Track Class Reference

#include <Track.h>

Inheritance diagram for Track:
GameObject

List of all members.

Public Member Functions

 Track (Ogre::SceneManager *_manager)
 ~Track ()
Ogre::ManualObject * getManual () const
void setManual (Ogre::ManualObject *_val)
Ogre::SimpleSpline * getSpline () const
void setSpline (Ogre::SimpleSpline *_val)
Ogre::SimpleSpline * getSplineEqualised () const
void setSplineEqualised (Ogre::SimpleSpline *_val)
int getClosePoints () const
void setClosePoints (const int &_val)
Ogre::Real getTrackWidth () const
void setTrackWidth (const Ogre::Real &_val)
int getInterpSteps () const
 Sets the number of interpolation steps between each track segment.
void setInterpSteps (const int &_val)
Ogre::Real getInterpAmount () const
void equaliseSpline (Ogre::Real _dist=0.0f)
void controlObjectMoved ()
 Used when a control object is moved. Every time the control object moves, the equalised spline must be recalculated.
void recalc ()
 Used to create the control objects so we can interact with the spline directly.
void redraw ()
 Draw. This isn't an actual "draw to screen" method, more an "update the model" method.
void closeSpline ()
void linkClosedSpline ()
 After the control objects have been created, we can finally link them together (so they move together).
void buildTrackFromSpline ()
 Create the physical track from the spline.
void finalise ()
void buildIntroTrackType (int _length, Ogre::Real _distBetween, Ogre::Vector3 _startPos, Ogre::Real _distSideways)
void createFromFakeTrack (Ogre::Vector3 _startPos, Track *_fakeTrack)
 Turn a "fake" track into a real one.
void startRace ()
 Start the "race".
void endRace ()
 End the "race".
void updateLapCount ()
 Called whenever the player completes a lap.
void updateLapTimes ()
 Called to update the lap times if needs be.
int getTotalLaps ()
int getCurrentLap ()
Ogre::Real getTotalTime ()
Ogre::Real getCurrentLapTime ()
Ogre::Real getBestLapTime ()
void setTotalLaps (int _val)
void setCurrentLap (int _val)
void setTotalTime (Ogre::Real _val)
void setCurrentLapTime (Ogre::Real _val)
void setBestLapTime (Ogre::Real _val)
bool move (Ogre::Real _time)
 Hacking into GameObject's move function to some timer-related things.
void informOfContact (TrackPhysicalObject *_val)
 Called when a control object encounters the craft.
void regenerateFakeTrack (int _val)
 Make a fake track for use in the GUI. Doesn't do the physical stages.
void redrawFake ()
 Custom redraw function for fake track.
Ogre::SceneManager * getSceneManager ()
void hideNodes ()
 Hide all of the track editing nodes.

Protected Member Functions

void setID ()
void recalcControlObjects ()
void recalcPhysicalObjects ()

Protected Attributes

Ogre::ManualObject * m_manual
Ogre::SimpleSpline * m_spline
Ogre::SimpleSpline * m_splineEqualised
Ogre::Real m_trackWidth
Ogre::Real m_interpAmount
int m_interpSteps
std::vector< TrackControlObject * > m_controlObjects
std::vector
< TrackPhysicalObject * > 
m_controlObjectsEqualised
std::list< TrackPhysicalObject * > m_encounters
int m_numClosePoints
float m_equaliseDistance
int m_totalLaps
int m_currentLap
Ogre::Real m_totalTime
Ogre::Real m_currentLapTime
Ogre::Real m_bestLapTime
Ogre::SceneManager * m_sceneManager

Static Protected Attributes

static int s_nextID = 0

Detailed Description

Track. This class contains all of the manipulation and construction methods for the game's track. One thing of note; to get a "decent" looking closed spline, the two points on either side of the start point all must be in line and not too close. We'll make them "lockable" when it comes to track editing (as in, just not making them moveable). We probably want a straight section of track for the finishing line anyway!

Definition at line 28 of file Track.h.


Constructor & Destructor Documentation

Track::Track ( Ogre::SceneManager *  _manager  ) 

Definition at line 13 of file Track.cpp.

Track::~Track (  )  [inline]

Definition at line 32 of file Track.h.


Member Function Documentation

void Track::buildIntroTrackType ( int  _length,
Ogre::Real  _distBetween,
Ogre::Vector3  _startPos,
Ogre::Real  _distSideways 
)

Build an "intro" track of _val track nodes in length. This is a track which is non-editable, and which finalises itself after creation. It will also load physical geometry as a starting location, and handle the transition to a real track area.

Definition at line 598 of file Track.cpp.

void Track::buildTrackFromSpline (  ) 

Create the physical track from the spline.

Definition at line 507 of file Track.cpp.

void Track::closeSpline (  ) 

Close the spline up; to close a Catmull-Rom spline like Ogre offers, we have to recreate a number of points overlapping at start and end. Essentially, we add points 0, 1 and 2 to the end of the spline Giving the illusion of it being a loop.

Definition at line 464 of file Track.cpp.

void Track::controlObjectMoved (  ) 

Used when a control object is moved. Every time the control object moves, the equalised spline must be recalculated.

Definition at line 301 of file Track.cpp.

void Track::createFromFakeTrack ( Ogre::Vector3  _startPos,
Track _fakeTrack 
)

Turn a "fake" track into a real one.

Definition at line 692 of file Track.cpp.

void Track::endRace (  ) 

End the "race".

Definition at line 888 of file Track.cpp.

void Track::equaliseSpline ( Ogre::Real  _dist = 0.0f  ) 

Based on http://www.ogre3d.org/wiki/index.php/Equal_Length_Spline and http://www.ogre3d.org/forums/viewtopic.php?p=224334 Used to divide a created/modified spline into arcs of equal length.

Definition at line 169 of file Track.cpp.

void Track::finalise (  ) 

Finalise the track and make it a series of physical meshes. It can no longer be edited after this point.

Definition at line 574 of file Track.cpp.

Ogre::Real Track::getBestLapTime (  ) 

Definition at line 847 of file Track.cpp.

int Track::getClosePoints (  )  const

Definition at line 130 of file Track.cpp.

int Track::getCurrentLap (  ) 

Definition at line 833 of file Track.cpp.

Ogre::Real Track::getCurrentLapTime (  ) 

Definition at line 843 of file Track.cpp.

Ogre::Real Track::getInterpAmount (  )  const

Definition at line 161 of file Track.cpp.

int Track::getInterpSteps (  )  const

Sets the number of interpolation steps between each track segment.

Definition at line 150 of file Track.cpp.

Ogre::ManualObject * Track::getManual (  )  const

Reimplemented from GameObject.

Definition at line 99 of file Track.cpp.

Ogre::SceneManager * Track::getSceneManager (  ) 

Definition at line 1018 of file Track.cpp.

Ogre::SimpleSpline * Track::getSpline (  )  const

Definition at line 109 of file Track.cpp.

Ogre::SimpleSpline * Track::getSplineEqualised (  )  const

Definition at line 120 of file Track.cpp.

int Track::getTotalLaps (  ) 

Definition at line 829 of file Track.cpp.

Ogre::Real Track::getTotalTime (  ) 

Definition at line 839 of file Track.cpp.

Ogre::Real Track::getTrackWidth (  )  const

Definition at line 140 of file Track.cpp.

void Track::hideNodes (  ) 

Hide all of the track editing nodes.

Definition at line 1023 of file Track.cpp.

void Track::informOfContact ( TrackPhysicalObject _val  ) 

Called when a control object encounters the craft.

Definition at line 925 of file Track.cpp.

void Track::linkClosedSpline (  ) 

After the control objects have been created, we can finally link them together (so they move together).

Definition at line 472 of file Track.cpp.

bool Track::move ( Ogre::Real  _time  )  [virtual]

Hacking into GameObject's move function to some timer-related things.

Reimplemented from GameObject.

Definition at line 913 of file Track.cpp.

void Track::recalc (  ) 

Used to create the control objects so we can interact with the spline directly.

Definition at line 451 of file Track.cpp.

void Track::recalcControlObjects (  )  [protected]

Used to create the control objects so we can interact with the spline directly. Internal function, called from the public version. Now called from recalc.

Definition at line 321 of file Track.cpp.

void Track::recalcPhysicalObjects (  )  [protected]

Recalculates the positions of the physical objects. called from recalc.

Definition at line 396 of file Track.cpp.

void Track::redraw (  ) 

Draw. This isn't an actual "draw to screen" method, more an "update the model" method.

Definition at line 32 of file Track.cpp.

void Track::redrawFake (  ) 

Custom redraw function for fake track.

Definition at line 952 of file Track.cpp.

void Track::regenerateFakeTrack ( int  _val  ) 

Make a fake track for use in the GUI. Doesn't do the physical stages.

Produces a "fake" track, that we can use to manipulate the control points. Fake tracks work on the XY plane.

Definition at line 724 of file Track.cpp.

void Track::setBestLapTime ( Ogre::Real  _val  ) 

Definition at line 871 of file Track.cpp.

void Track::setClosePoints ( const int &  _val  ) 

Definition at line 135 of file Track.cpp.

void Track::setCurrentLap ( int  _val  ) 

Definition at line 857 of file Track.cpp.

void Track::setCurrentLapTime ( Ogre::Real  _val  ) 

Definition at line 867 of file Track.cpp.

void Track::setID (  )  [protected, virtual]

Reimplemented from GameObject.

Definition at line 7 of file Track.cpp.

void Track::setInterpSteps ( const int &  _val  ) 

Definition at line 155 of file Track.cpp.

void Track::setManual ( Ogre::ManualObject *  _val  ) 

Reimplemented from GameObject.

Definition at line 104 of file Track.cpp.

void Track::setSpline ( Ogre::SimpleSpline *  _val  ) 

Definition at line 114 of file Track.cpp.

void Track::setSplineEqualised ( Ogre::SimpleSpline *  _val  ) 

Definition at line 125 of file Track.cpp.

void Track::setTotalLaps ( int  _val  ) 

Definition at line 853 of file Track.cpp.

void Track::setTotalTime ( Ogre::Real  _val  ) 

Definition at line 863 of file Track.cpp.

void Track::setTrackWidth ( const Ogre::Real &  _val  ) 

Definition at line 145 of file Track.cpp.

void Track::startRace (  ) 

Start the "race".

Definition at line 876 of file Track.cpp.

void Track::updateLapCount (  ) 

Called whenever the player completes a lap.

Definition at line 894 of file Track.cpp.

void Track::updateLapTimes (  ) 

Called to update the lap times if needs be.

Definition at line 908 of file Track.cpp.


Member Data Documentation

Ogre::Real Track::m_bestLapTime [protected]

Definition at line 179 of file Track.h.

std::vector<TrackControlObject*> Track::m_controlObjects [protected]

Definition at line 161 of file Track.h.

Definition at line 162 of file Track.h.

int Track::m_currentLap [protected]

Definition at line 174 of file Track.h.

Ogre::Real Track::m_currentLapTime [protected]

Definition at line 178 of file Track.h.

std::list<TrackPhysicalObject*> Track::m_encounters [protected]

Definition at line 164 of file Track.h.

float Track::m_equaliseDistance [protected]

Definition at line 170 of file Track.h.

Ogre::Real Track::m_interpAmount [protected]

Definition at line 158 of file Track.h.

int Track::m_interpSteps [protected]

Definition at line 159 of file Track.h.

Ogre::ManualObject* Track::m_manual [protected]

Reimplemented from GameObject.

Definition at line 152 of file Track.h.

int Track::m_numClosePoints [protected]

Definition at line 167 of file Track.h.

Ogre::SceneManager* Track::m_sceneManager [protected]

Definition at line 182 of file Track.h.

Ogre::SimpleSpline* Track::m_spline [protected]

Definition at line 154 of file Track.h.

Ogre::SimpleSpline* Track::m_splineEqualised [protected]

Definition at line 155 of file Track.h.

int Track::m_totalLaps [protected]

Definition at line 173 of file Track.h.

Ogre::Real Track::m_totalTime [protected]

Definition at line 177 of file Track.h.

Ogre::Real Track::m_trackWidth [protected]

Definition at line 157 of file Track.h.

int Track::s_nextID = 0 [static, protected]

Reimplemented from GameObject.

Definition at line 141 of file Track.h.


The documentation for this class was generated from the following files:
Generated on Fri Aug 20 08:28:49 2010 for VecTRacer by  doxygen 1.6.3