Changeset 289 for code/branches
- Timestamp:
- Nov 27, 2007, 11:54:13 PM (17 years ago)
- Location:
- code/branches/main_reto
- Files:
-
- 2 added
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/bin/resources.cfg
r182 r289 8 8 FileSystem=../Media 9 9 FileSystem=../Media/fonts 10 FileSystem=../Media/materials/programs10 #FileSystem=../Media/materials/programs 11 11 FileSystem=../Media/materials/scripts 12 12 FileSystem=../Media/materials/textures 13 13 FileSystem=../Media/models 14 #FileSystem=../Media/overlays 14 FileSystem=../Media/overlay 15 15 #FileSystem=../Media/particle 16 16 FileSystem=../Media/gui 17 #FileSystem=../Media/DeferredShadingMedia18 17 Zip=../Media/packs/cubemap.zip 19 18 #Zip=../Media/packs/cubemapsJS.zip -
code/branches/main_reto/src/CMakeLists.txt
r273 r289 3 3 # create a few variables to simplify life 4 4 SET( ORXONOX_SRC 5 camera_manager.cc6 5 inertial_node.cc 7 6 main.cc -
code/branches/main_reto/src/hud/CMakeLists.txt
r272 r289 4 4 SET( HUD_SRC 5 5 hud_overlay.cc 6 test_overlay.cc 6 7 ) 7 8 -
code/branches/main_reto/src/main.cc
r267 r289 26 26 */ 27 27 28 //#define WITH_HIERARCHY 29 28 30 #include "OgrePlatform.h" 29 31 #include "OgreException.h" … … 31 33 #include "orxonox.h" 32 34 35 #ifdef WITH_HIERARCHY 33 36 #include "class_hierarchy/BaseObject.h" 34 37 #include "class_hierarchy/Test.h" … … 36 39 #include "class_hierarchy/test2.h" 37 40 #include "class_hierarchy/test3.h" 41 #endif 38 42 39 43 … … 50 54 #endif 51 55 { 52 #if 156 #ifndef WITH_HIERARCHY 53 57 try { 54 58 // create an orxonox application and run it -
code/branches/main_reto/src/orxonox.cc
r171 r289 99 99 ogre_->initialise(); 100 100 101 runMgr_ = new RunManager(ogre_); 101 runMgr_ = RunManager::createSingleton(); 102 runMgr_->initialise(ogre_); 102 103 103 104 return true; … … 113 114 delete timer_; 114 115 if (runMgr_) 115 delete runMgr_;116 RunManager::destroySingleton(); 116 117 if (ogre_) 117 118 delete ogre_; -
code/branches/main_reto/src/orxonox_prerequisites.h
r267 r289 56 56 57 57 class HUDOverlay; 58 class TestOverlay; 58 59 59 60 } -
code/branches/main_reto/src/run_manager.cc
r267 r289 26 26 27 27 28 #include "Ogre.h" 29 //#include "OgreRoot.h" 30 //#include "OgreSceneManager.h" 31 //#include "OgreSceneNode.h" 32 //#include "OgreCamera.h" 33 //#include "OgreViewport.h" 34 //#include "OgreRenderWindow.h" 35 //#include "OgreOverlay.h" 36 //#include "OgreOverlayManager.h" 37 //#include "OgreOverlayElement.h" 38 //#include "OgreTextureManager.h" 39 //#include "OgreMaterialManager.h" 40 //#include "OgreLogManager.h" 41 //#include "OgreVector3.h" 42 //#include "OgreStringConverter.h" 43 //#include "OgreWindowEventUtilities.h" 28 #include "OgreVector3.h" 29 #include "OgreStringConverter.h" 30 #include "OgreRoot.h" 31 #include "OgreSceneManager.h" 32 #include "OgreSceneNode.h" 33 #include "OgreCamera.h" 34 #include "OgreViewport.h" 35 #include "OgreRenderWindow.h" 36 #include "OgreTextureManager.h" 37 #include "OgreMaterialManager.h" 38 #include "OgreLogManager.h" 39 #include "OgreWindowEventUtilities.h" 44 40 45 41 //Use this define to signify OIS will be used as a DLL … … 51 47 #include "orxonox_scene.h" 52 48 #include "orxonox_ship.h" 53 #include "camera_manager.h"54 49 #include "inertial_node.h" 55 50 … … 59 54 60 55 #include "hud/hud_overlay.h" 56 #include "hud/test_overlay.h" 61 57 62 58 #include "run_manager.h" 63 59 64 namespace Ogre {65 using namespace orxonox;66 template<> RunManager* Singleton<RunManager>::ms_Singleton = 0;67 }68 60 69 61 namespace orxonox { … … 85 77 */ 86 78 87 RunManager* RunManager::getSingletonPtr(void) 88 { 89 return ms_Singleton; 90 } 91 RunManager& RunManager::getSingleton(void) 92 { 93 assert( ms_Singleton ); return ( *ms_Singleton ); 94 } 95 96 97 /** 98 * Contructor only needs the render window and the Root object which are both 99 * the OgreControl object. 100 * Right now the constructor does all the initialisation work. This could also 101 * be done in a new method "initialize()", for whatever purpose. 102 * 103 * 79 80 RunManager* RunManager::singletonPtr_s = NULL; 81 82 83 /** 84 * Contructor only needs the Root object. 85 */ 86 RunManager::RunManager() 87 : ogre_(NULL), window_(NULL), screenShotCounter_(0), 88 timeUntilNextToggle_(0), mouseSensitivity_(0.003), inputManager_(0), 89 mouse_(0), keyboard_(0), joystick_(0), statsOn_(true) 90 { 91 } 92 93 /** 104 94 * @param ogre_ The OgreControl object holding the render window and the Root 105 95 */ 106 RunManager::RunManager(OgreControl * ogre) 107 : ogre_(ogre), window_(ogre->getRenderWindow()), //leftButtonDown_(false), 108 statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0), 109 filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0), 110 mouseSensitivity_(0.003), 111 debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0) 112 { 96 void RunManager::initialise(OgreControl *ogre) 97 { 98 ogre_ = ogre; 99 window_ = ogre->getRenderWindow(); 100 113 101 // SETTING UP THE SCENE 114 102 … … 129 117 130 118 // Create a space ship object and its SceneNode. 131 // Some ideas about the steering: The ship should only receive events like132 // up, down, left, right, roll left, roll right, move down, move up, etc).133 // Multiple interpretations of these commands would make the game more134 // but it also makes AI steering more difficult, since for every type of135 // steering, new methods have to be written.136 // --> clearly define how a space ship can fly (rolling?, conservation of137 // impuls?, direct mouse sight steeering?, etc.)138 119 // It should also be considered, that the ship should provide another Node 139 120 // for a camera to be attached (otherwise the spaceship in front of the 140 // would be very static, never moving at all).121 // ship would be very static, never moving at all). 141 122 142 123 // Construct a new spaceship and give it the node … … 148 129 149 130 // load all resources and create the entities by calling the initialise() 150 // methods for each object ( don't initialise in the constructor!).131 // methods for each object (no constructor initialisations!). 151 132 backgroundScene_->initialise(); 152 133 playerShip_->initialise(); … … 154 135 155 136 // CAMERA AND VIEWPORT 156 // TODO: create a camera manager. It should be able to change its position157 // around the space ship (predefined states would be nice too). And it should158 // also be able to switch between different locations (like ship, spactator,159 // certain fixed positions (e.g. finish line, etc.)). These are just ideas.160 137 161 138 // create camera and viewport … … 164 141 165 142 // create HUD 166 hud_ = new HUDOverlay();143 hud_ = new hud::TestOverlay(window_); 167 144 hud_->show(); 168 145 … … 171 148 TextureManager::getSingleton().setDefaultNumMipmaps(5); 172 149 173 174 150 175 151 // HUMAN INTERFACE 176 152 177 using namespace OIS; 178 179 //debugOverlay_ = OverlayManager::getSingleton() 180 // .getByName("Core/DebugOverlay"); 181 153 using namespace OIS; 182 154 183 155 LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***"); … … 233 205 if (bulletManager_) 234 206 delete bulletManager_; 235 } 236 237 238 /** 239 * Method to compute anyting between 2 frames. 207 if (hud_) 208 delete hud_; 209 } 210 211 212 /** 213 * Method to compute anything between 2 frames. 240 214 * 241 215 * Everything that needs to be computed during the games happens right here. … … 258 232 259 233 260 // Update the 'HUD' 261 //updateStats(); 234 // Update the HUD 235 hud_->setDebugText(" | Speed = " 236 + StringConverter::toString(playerShip_->getSpeed()) 237 + " | Left Ammo = " 238 + StringConverter::toString(playerShip_ 239 ->getMainWeapon()->getAmmoState()) 240 + " | Ammo stock = " 241 + StringConverter::toString(playerShip_->getAmmoStock())); 242 243 hud_->tick(time, deltaTime); 262 244 263 245 // update the bullet positions … … 412 394 { 413 395 statsOn_ = !statsOn_; 414 //showDebugOverlay(statsOn_);415 timeUntilNextToggle_ = 1;416 }417 418 if( keyboard_->isKeyDown(KC_T) && timeUntilNextToggle_ <= 0 )419 {420 switch(filtering_)421 {422 case TFO_BILINEAR:423 filtering_ = TFO_TRILINEAR;424 aniso_ = 1;425 break;426 case TFO_TRILINEAR:427 filtering_ = TFO_ANISOTROPIC;428 aniso_ = 8;429 break;430 case TFO_ANISOTROPIC:431 filtering_ = TFO_BILINEAR;432 aniso_ = 1;433 break;434 default: break;435 }436 MaterialManager::getSingleton().setDefaultTextureFiltering(filtering_);437 MaterialManager::getSingleton().setDefaultAnisotropy(aniso_);438 439 //showDebugOverlay(statsOn_);440 396 timeUntilNextToggle_ = 1; 441 397 } … … 447 403 window_->writeContentsToFile(ss.str()); 448 404 timeUntilNextToggle_ = 0.5; 449 debugText_ = "Saved: " + ss.str(); 450 } 451 452 if(keyboard_->isKeyDown(KC_R) && timeUntilNextToggle_ <=0) 453 { 454 sceneDetailIndex_ = (sceneDetailIndex_+1)%3 ; 455 switch(sceneDetailIndex_) { 456 case 0 : camera_->setPolygonMode(PM_SOLID); break; 457 case 1 : camera_->setPolygonMode(PM_WIREFRAME); break; 458 case 2 : camera_->setPolygonMode(PM_POINTS); break; 459 } 460 timeUntilNextToggle_ = 0.5; 461 } 462 463 static bool displayCameraDetails = false; 464 if(keyboard_->isKeyDown(KC_P) && timeUntilNextToggle_ <= 0) 465 { 466 displayCameraDetails = !displayCameraDetails; 467 timeUntilNextToggle_ = 0.5; 468 if (!displayCameraDetails) 469 debugText_ = ""; 470 } 471 472 // Print camera details 473 if(displayCameraDetails) 474 debugText_ = " | Speed = " 475 + StringConverter::toString(playerShip_->getSpeed()) 476 + " | Left Ammo = " 477 + StringConverter::toString(playerShip_ 478 ->getMainWeapon()->getAmmoState()) 479 + " | Ammo stock = " 480 + StringConverter::toString(playerShip_->getAmmoStock()); 481 // debugText_ = "P: " + StringConverter::toString(camera_ 482 // ->getDerivedPosition()) + " " + "O: " 483 // + StringConverter::toString(camera_->getDerivedOrientation()); 405 } 484 406 485 407 // Return true to continue rendering … … 515 437 516 438 /** 517 * Show the debug overlay ofdesired.439 * Show an overlay desired. 518 440 * @param show Whether or not to show the debug overlay 519 441 */ 520 442 void RunManager::showDebugOverlay(bool show) 521 443 { 522 if ( debugOverlay_)444 if (hud_) 523 445 { 524 446 if (show) 525 debugOverlay_->show();447 hud_->show(); 526 448 else 527 debugOverlay_->hide(); 528 } 529 } 530 531 532 /** 533 * Show stats (e.g. FPS) in the left lower corner of the screen. 534 * Copied from the ExampleFrameListener.h in the Ogre SDK 535 */ 536 void RunManager::updateStats(void) 537 { 538 static String currFps = "Current FPS: "; 539 static String avgFps = "Average FPS: "; 540 static String bestFps = "Best FPS: "; 541 static String worstFps = "Worst FPS: "; 542 static String tris = "Triangle Count: "; 543 static String batches = "Batch Count: "; 544 545 // update stats when necessary 546 try { 547 OverlayElement* guiAvg = OverlayManager::getSingleton() 548 .getOverlayElement("Core/AverageFps"); 549 OverlayElement* guiCurr = OverlayManager::getSingleton() 550 .getOverlayElement("Core/CurrFps"); 551 OverlayElement* guiBest = OverlayManager::getSingleton() 552 .getOverlayElement("Core/BestFps"); 553 OverlayElement* guiWorst = OverlayManager::getSingleton() 554 .getOverlayElement("Core/WorstFps"); 555 556 const RenderTarget::FrameStats& stats = window_->getStatistics(); 557 guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 558 guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS)); 559 guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS) 560 +" "+StringConverter::toString(stats.bestFrameTime)+" ms"); 561 guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS) 562 +" "+StringConverter::toString(stats.worstFrameTime)+" ms"); 563 564 OverlayElement* guiTris = OverlayManager::getSingleton() 565 .getOverlayElement("Core/NumTris"); 566 guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount)); 567 568 OverlayElement* guiBatches = OverlayManager::getSingleton() 569 .getOverlayElement("Core/NumBatches"); 570 guiBatches->setCaption(batches 571 + StringConverter::toString(stats.batchCount)); 572 573 OverlayElement* guiDbg = OverlayManager::getSingleton() 574 .getOverlayElement("Core/DebugText"); 575 guiDbg->setCaption(debugText_); 576 } 577 catch(...) { /* ignore */ } 449 hud_->hide(); 450 } 578 451 } 579 452 … … 581 454 /** 582 455 * Simple camera creator. 583 * playerShip_Node->attachObject(camera_) should no be here! This is what the camera584 * manager is for. Right now, this method should do just fine, setting the585 * cam behind the ship.586 */ 587 void RunManager::createCamera( void)456 * playerShip_Node->attachObject(camera_) should not be here! This is what 457 * the camera manager is for. Right now, this method should do just fine, 458 * setting the cam behind the ship. 459 */ 460 void RunManager::createCamera() 588 461 { 589 462 camera_ = sceneMgr_->createCamera("PlayerCam"); … … 599 472 * camera created so far. 600 473 */ 601 void RunManager::createViewports( void)474 void RunManager::createViewports() 602 475 { 603 476 // Create one viewport, entire window … … 610 483 } 611 484 485 486 RunManager* RunManager::createSingleton() 487 { 488 if (singletonPtr_s) 489 return NULL; 490 singletonPtr_s = new RunManager(); 491 return singletonPtr_s; 492 } 493 494 void RunManager::destroySingleton() 495 { 496 if (singletonPtr_s) 497 delete singletonPtr_s; 498 } 499 500 501 RunManager& RunManager::getSingleton() 502 { 503 return *singletonPtr_s; 504 } 505 506 RunManager* RunManager::getSingletonPtr() 507 { 508 return singletonPtr_s; 509 } 510 612 511 } -
code/branches/main_reto/src/run_manager.h
r267 r289 32 32 #include "OgrePrerequisites.h" 33 33 #include "OgreWindowEventUtilities.h" 34 #include "OgreTextureManager.h" 35 #include "OgreSingleton.h" 34 //#include "OgreTextureManager.h" 36 35 37 36 #include <OIS/OISPrereqs.h> … … 44 43 // let the class inherit from WindowEventListener in order for the RunMgr 45 44 // to act as the central point of all the calcuations in Orxonox 46 class RunManager : public Ogre::WindowEventListener, 47 public Ogre::Singleton<RunManager> 45 class RunManager : public Ogre::WindowEventListener 48 46 { 49 47 public: 50 RunManager(OgreControl*);51 52 48 virtual ~RunManager(); 53 //void initialise(OgreControl*); 49 50 void initialise(OgreControl*); 54 51 55 52 bool tick(unsigned long, Ogre::Real); … … 65 62 int getNumberOfAmmos(); 66 63 64 static RunManager* createSingleton(); 65 66 static void destroySingleton(); 67 67 68 static RunManager& getSingleton(void); 68 69 … … 71 72 72 73 protected: 74 RunManager(); 75 73 76 void createCamera(void); 74 77 … … 93 96 /** OUTPUT **/ 94 97 95 void updateStats(void);96 97 98 void showDebugOverlay(bool); 98 99 … … 108 109 OrxonoxScene *backgroundScene_; 109 110 OrxonoxShip *playerShip_; 110 hud:: HUDOverlay*hud_;111 hud::TestOverlay *hud_; 111 112 112 113 // Bullet manager … … 121 122 // fields from the example framework 122 123 bool statsOn_; 123 std::string debugText_;124 124 125 125 unsigned int screenShotCounter_; 126 126 // just to stop toggles flipping too fast 127 127 Ogre::Real timeUntilNextToggle_; 128 //bool leftButtonDown_;129 Ogre::TextureFilterOptions filtering_;130 int aniso_;131 int sceneDetailIndex_;132 Ogre::Overlay* debugOverlay_;133 128 134 129 //OIS Input devices … … 138 133 OIS::JoyStick* joystick_; 139 134 135 // singleton pointer 136 static RunManager *singletonPtr_s; 137 140 138 }; 141 139 -
code/branches/main_reto/src/weapon/barrel_gun.cc
r267 r289 95 95 void BarrelGun::primaryFiring(unsigned int time) 96 96 { 97 if (time > 1000/primaryFiringRate_)97 if (time > (unsigned int)1000/primaryFiringRate_) 98 98 { 99 99 currentState_ = IDLE; … … 133 133 void BarrelGun::secondaryFiring(unsigned int time) 134 134 { 135 if (time > 1000/secondaryFiringRate_)135 if (time > (unsigned int)1000/secondaryFiringRate_) 136 136 currentState_ = IDLE; 137 137 }
Note: See TracChangeset
for help on using the changeset viewer.