00001 #ifndef __VECTRACER_TRACK_H 00002 #define __VECTRACER_TRACK_H 00003 00004 /* 00005 ----------------------------------------------------------------------------- 00006 Filename: Track.h 00007 Description: Main editable track for the game. 00008 ----------------------------------------------------------------------------- 00009 */ 00010 00011 #include "Common.h" 00012 #include "GameObject.h" 00013 #include "TrackControlObject.h" 00014 #include "TrackPhysicalObject.h" 00015 00016 class TrackControlObject; 00017 class TrackPhysicalObject; 00018 00019 #include <vector> 00020 #include <list> 00021 00028 class Track : public GameObject 00029 { 00030 public: 00031 Track(Ogre::SceneManager* _manager); 00032 ~Track() {} 00033 00034 Ogre::ManualObject* getManual() const; 00035 void setManual(Ogre::ManualObject* _val); 00036 00037 Ogre::SimpleSpline* getSpline() const; 00038 void setSpline(Ogre::SimpleSpline* _val); 00039 00040 Ogre::SimpleSpline* getSplineEqualised() const; 00041 void setSplineEqualised(Ogre::SimpleSpline* _val); 00042 00043 int getClosePoints() const; 00044 void setClosePoints(const int& _val); 00045 00046 Ogre::Real getTrackWidth() const; 00047 void setTrackWidth(const Ogre::Real& _val); 00048 00050 int getInterpSteps() const; 00051 void setInterpSteps(const int &_val); 00052 Ogre::Real getInterpAmount() const; 00053 00057 void equaliseSpline(Ogre::Real _dist = 0.0f); 00058 00060 void controlObjectMoved(); 00061 00063 void recalc(); 00064 00066 void redraw(); 00067 00071 void closeSpline(); 00072 00074 void linkClosedSpline(); 00075 00077 void buildTrackFromSpline(); 00078 00081 void finalise(); 00082 00085 void buildIntroTrackType(int _length, Ogre::Real _distBetween, Ogre::Vector3 _startPos, Ogre::Real _distSideways); 00086 00088 void createFromFakeTrack(Ogre::Vector3 _startPos, Track* _fakeTrack); 00089 00091 void startRace(); 00092 00094 void endRace(); 00095 00097 void updateLapCount(); 00098 00100 void updateLapTimes(); 00101 00102 // Lap counters. 00103 int getTotalLaps(); 00104 int getCurrentLap(); 00105 00106 // Timers. 00107 Ogre::Real getTotalTime(); 00108 Ogre::Real getCurrentLapTime(); 00109 Ogre::Real getBestLapTime(); 00110 00111 // Lap counters. 00112 void setTotalLaps(int _val); 00113 void setCurrentLap(int _val); 00114 00115 // Timers. 00116 void setTotalTime(Ogre::Real _val); 00117 void setCurrentLapTime(Ogre::Real _val); 00118 void setBestLapTime(Ogre::Real _val); 00119 00121 bool move(Ogre::Real _time); 00122 00124 void informOfContact(TrackPhysicalObject* _val); 00125 00127 void regenerateFakeTrack(int _val); 00128 00130 void redrawFake(); 00131 00132 Ogre::SceneManager* getSceneManager(); 00133 00135 void hideNodes(); 00136 00137 protected: 00138 00139 // set ID 00140 void setID(); 00141 static int s_nextID; 00142 00146 void recalcControlObjects(); 00147 00150 void recalcPhysicalObjects(); 00151 00152 Ogre::ManualObject* m_manual; 00153 00154 Ogre::SimpleSpline* m_spline; 00155 Ogre::SimpleSpline* m_splineEqualised; 00156 00157 Ogre::Real m_trackWidth; 00158 Ogre::Real m_interpAmount; 00159 int m_interpSteps; 00160 00161 std::vector<TrackControlObject*> m_controlObjects; 00162 std::vector<TrackPhysicalObject*> m_controlObjectsEqualised; 00163 00164 std::list<TrackPhysicalObject*> m_encounters; 00165 00166 // Number of points used to close the spline. 00167 int m_numClosePoints; 00168 00169 // Used to store the equalisation distance. 00170 float m_equaliseDistance; 00171 00172 // Lap counters. 00173 int m_totalLaps; 00174 int m_currentLap; 00175 00176 // Timers. 00177 Ogre::Real m_totalTime; 00178 Ogre::Real m_currentLapTime; 00179 Ogre::Real m_bestLapTime; 00180 00181 // We have two different scene managers, after all... 00182 Ogre::SceneManager* m_sceneManager; 00183 }; 00184 00185 #endif