1 #pragma once 2 #include "common/Gui_Def.h" 3 #include "BaseApp.h" 4 #include "Replay.h" 5 #include "ReplayTrk.h" 6 #include "../vdrift/cardefs.h" 7 #include "CarPosInfo.h" 8 9 #include <boost/thread.hpp> 10 #include <OgreShadowCameraSetup.h> 11 #include "../shiny/Main/Factory.hpp" 12 #include "../network/networkcallbacks.hpp" 13 #include "../oics/ICSChannelListener.h" 14 #include "common/PreviewTex.h" 15 16 17 namespace Ogre { class SceneNode; class SceneManager; } 18 namespace BtOgre { class DebugDrawer; } 19 class CScene; class CData; class CInput; class GraphView; 20 class GAME; class CHud; class CGui; class CGuiCom; 21 22 23 class App : public BaseApp, 24 public sh::MaterialListener, 25 public ICS::ChannelListener 26 { 27 public: 28 App(SETTINGS* settings, GAME* game); 29 virtual ~App(); 30 void ShutDown(); 31 32 CScene* scn; 33 CData* data; //p 34 35 GAME* pGame; 36 37 38 // BaseApp init 39 void postInit(), SetFactoryDefaults(); 40 41 42 /// Game Cars Data 43 // new positions info for every CarModel 44 PosInfo carPoses[CarPosCnt][MAX_CARS]; // max 16cars 45 int iCurPoses[MAX_CARS]; // current index for carPoses queue 46 std::map<int,int> carsCamNum; // picked camera number for cars 47 48 void newPoses(float time), newPerfTest(float time); // vdrift 49 void updatePoses(float time); // ogre 50 void UpdThr(); 51 52 // replay - full, saved by user 53 // ghost - saved on best lap 54 // ghplay - ghost ride replay, loaded if was on disk, replaced when new 55 Replay2 replay, ghost, ghplay; 56 Rewind rewind; // to take car back in time (after crash etc.) 57 TrackGhost ghtrk; // ghtrk - track's ghost 58 59 std::vector<ReplayFrame2> frm; //size:16 // frm - used when playing replay for hud and sounds 60 61 bool isGhost2nd; // if present (ghost but from other car) 62 std::vector<float> vTimeAtChks; // track ghost's times at road checkpoints 63 float fLastTime; // thk ghost total time 64 65 66 boost::thread mThread; // 2nd thread for simulation 67 68 69 virtual void createScene(); 70 virtual void destroyScene(); 71 72 virtual bool frameStart(Ogre::Real time); void DoNetworking(); 73 virtual bool frameEnd(Ogre::Real time); 74 float fLastFrameDT; 75 76 bool isTweakTab(); 77 78 BtOgre::DebugDrawer *dbgdraw; /// blt dbg 79 80 // mtr reload 81 enum eMaterials { 82 Mtr_CarBody, Mtr_CarInterior, Mtr_CarGlass, 83 Mtr_CarTireFront, Mtr_CarTireRear, 84 Mtr_Road, NumMaterials }; 85 Ogre::String sMtr[NumMaterials]; 86 87 88 /// HUD 89 CHud* hud; 90 91 92 /// create . . . . . . . . . . . . . . . . . . . . . . . . 93 Ogre::String resCar, resTrk, resDrv; 94 void CreateCar(), CreateRoad(); 95 void CreateObjects(), DestroyObjects(bool clear), ResetObjects(); 96 97 void NewGame(bool force=false); 98 void NewGameDoLoad(); bool IsVdrTrack(); bool newGameRpl; 99 100 bool dstTrk; // destroy track, false if same 101 Ogre::String oldTrack; bool oldTrkUser; 102 103 // fluids to destroy 104 std::vector<Ogre::String/*MeshPtr*/> vFlSMesh; 105 std::vector<Ogre::Entity*> vFlEnt; 106 std::vector<Ogre::SceneNode*> vFlNd; 107 108 // vdrift 109 void CreateVdrTrack(std::string strack, class TRACK* pTrack); 110 111 static Ogre::ManualObject* CreateModel(Ogre::SceneManager* sceneMgr, const Ogre::String& mat, 112 class VERTEXARRAY* a, Ogre::Vector3 vPofs, bool flip, bool track=false, const Ogre::String& name=""); 113 114 115 // Loading 116 void LoadCleanUp(), LoadGame(), LoadScene(), LoadCar(), LoadTerrain(), LoadRoad(), LoadObjects(), LoadTrees(), LoadMisc(); 117 enum ELoadState { LS_CLEANUP=0, LS_GAME, LS_SCENE, LS_CAR, LS_TERRAIN, LS_ROAD, LS_OBJECTS, LS_TREES, LS_MISC, LS_ALL }; 118 static Ogre::String cStrLoad[LS_ALL+1]; 119 int curLoadState; 120 std::map<int, std::string> loadingStates; 121 122 float mTimer; // wind,water 123 124 125 // mtr from ter . . . 126 int blendMapSize; char* blendMtr; 127 void GetTerMtrIds(); 128 129 130 void recreateReflections(); // call after refl_mode changed 131 132 virtual void materialCreated(sh::MaterialInstance* m, const std::string& configuration, unsigned short lodIndex); 133 134 135 // Input 136 CInput* input; 137 138 virtual bool keyPressed (const SDL_KeyboardEvent &arg); 139 void channelChanged(ICS::Channel *channel, float currentValue, float previousValue); 140 141 142 /// Gui 143 //----------------------------------------------------------------- 144 CGui* gui; 145 CGuiCom* gcom; 146 147 PreviewTex prvView,prvRoad,prvTer; // track tab 148 PreviewTex prvStCh; // champ,chall stage view 149 150 bool bHideHudBeam; // hides beam when replay or no road 151 bool bHideHudArr; // hides arrow when replay,splitscreen 152 bool bHideHudPace; // hides pacenotes when same or deny by challenge 153 154 bool bRplPlay,bRplPause, bRplRec, bRplWnd; // game 155 int carIdWin, iRplCarOfs, iRplSkip; 156 157 // race pos 158 int GetRacePos(float timeCur, float timeTrk, float carTimeMul, bool coldStart, float* pPoints=0); 159 float GetCarTimeMul(const std::string& car, const std::string& sim_mode); 160 161 void Ch_NewGame(); 162 163 164 /// graphs 165 std::vector<GraphView*> graphs; 166 void CreateGraphs(), DestroyGraphs(); 167 void UpdateGraphs(), GraphsNewVals(); 168 169 ///* tire edit */ 170 const static int TireNG; 171 int iEdTire, iTireLoad, iCurLat,iCurLong,iCurAlign, iUpdTireGr; 172 173 /// car perf test 174 bool bPerfTest; EPerfTest iPerfTestStage; 175 void PerfLogVel(class CAR* pCar, float time); 176 }; 177