Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2007, 11:54:13 PM (17 years ago)
Author:
rgrieder
Message:
  • updated the source files and CMLs
  • adjusted resources.cfg for the new hud overlay
Location:
code/branches/main_reto/src
Files:
2 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/src/CMakeLists.txt

    r273 r289  
    33# create a few variables to simplify life
    44SET( ORXONOX_SRC
    5         camera_manager.cc
    65        inertial_node.cc
    76        main.cc
  • code/branches/main_reto/src/hud/CMakeLists.txt

    r272 r289  
    44SET( HUD_SRC
    55        hud_overlay.cc
     6        test_overlay.cc
    67   )
    78
  • code/branches/main_reto/src/main.cc

    r267 r289  
    2626 */
    2727
     28//#define WITH_HIERARCHY
     29
    2830#include "OgrePlatform.h"
    2931#include "OgreException.h"
     
    3133#include "orxonox.h"
    3234
     35#ifdef WITH_HIERARCHY
    3336#include "class_hierarchy/BaseObject.h"
    3437#include "class_hierarchy/Test.h"
     
    3639#include "class_hierarchy/test2.h"
    3740#include "class_hierarchy/test3.h"
     41#endif
    3842
    3943
     
    5054#endif
    5155  {
    52 #if 1
     56#ifndef WITH_HIERARCHY
    5357    try {
    5458      // create an orxonox application and run it
  • code/branches/main_reto/src/orxonox.cc

    r171 r289  
    9999          ogre_->initialise();
    100100
    101           runMgr_ = new RunManager(ogre_);
     101    runMgr_ = RunManager::createSingleton();
     102    runMgr_->initialise(ogre_);
    102103
    103104          return true;
     
    113114                  delete timer_;
    114115          if (runMgr_)
    115                   delete runMgr_;
     116      RunManager::destroySingleton();
    116117          if (ogre_)
    117118                  delete ogre_;
  • code/branches/main_reto/src/orxonox_prerequisites.h

    r267 r289  
    5656   
    5757    class HUDOverlay;
     58    class TestOverlay;
    5859
    5960  }
  • code/branches/main_reto/src/run_manager.cc

    r267 r289  
    2626
    2727
    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"
    4440
    4541//Use this define to signify OIS will be used as a DLL
     
    5147#include "orxonox_scene.h"
    5248#include "orxonox_ship.h"
    53 #include "camera_manager.h"
    5449#include "inertial_node.h"
    5550
     
    5954
    6055#include "hud/hud_overlay.h"
     56#include "hud/test_overlay.h"
    6157
    6258#include "run_manager.h"
    6359
    64 namespace Ogre {
    65   using namespace orxonox;
    66   template<> RunManager* Singleton<RunManager>::ms_Singleton = 0;
    67 }
    6860
    6961namespace orxonox {
     
    8577  */
    8678
    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  /**
    10494  * @param ogre_ The OgreControl object holding the render window and the Root
    10595  */
    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
    113101    // SETTING UP THE SCENE
    114102
     
    129117
    130118    // Create a space ship object and its SceneNode.
    131     // Some ideas about the steering: The ship should only receive events like
    132     // up, down, left, right, roll left, roll right, move down, move up, etc).
    133     // Multiple interpretations of these commands would make the game more
    134     // but it also makes AI steering more difficult, since for every type of
    135     // steering, new methods have to be written.
    136     // --> clearly define how a space ship can fly (rolling?, conservation of
    137     // impuls?, direct mouse sight steeering?, etc.)
    138119    // It should also be considered, that the ship should provide another Node
    139120    // 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).
    141122
    142123    // Construct a new spaceship and give it the node
     
    148129
    149130    // 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!).
    151132    backgroundScene_->initialise();
    152133    playerShip_->initialise();
     
    154135
    155136    // CAMERA AND VIEWPORT
    156     // TODO: create a camera manager. It should be able to change its position
    157     // around the space ship (predefined states would be nice too). And it should
    158     // also be able to switch between different locations (like ship, spactator,
    159     // certain fixed positions (e.g. finish line, etc.)). These are just ideas.
    160137
    161138    // create camera and viewport
     
    164141
    165142    // create HUD
    166     hud_ = new HUDOverlay();
     143    hud_ = new hud::TestOverlay(window_);
    167144    hud_->show();
    168145
     
    171148    TextureManager::getSingleton().setDefaultNumMipmaps(5);
    172149
    173    
    174150
    175151    // HUMAN INTERFACE
    176152
    177     using namespace OIS;
    178 
    179     //debugOverlay_ = OverlayManager::getSingleton()
    180     //  .getByName("Core/DebugOverlay");
    181    
     153    using namespace OIS;   
    182154
    183155    LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    233205    if (bulletManager_)
    234206      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.
    240214  *
    241215  * Everything that needs to be computed during the games happens right here.
     
    258232
    259233
    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);
    262244
    263245    // update the bullet positions
     
    412394    {
    413395      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_);
    440396      timeUntilNextToggle_ = 1;
    441397    }
     
    447403      window_->writeContentsToFile(ss.str());
    448404      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    }
    484406
    485407    // Return true to continue rendering
     
    515437
    516438  /**
    517   * Show the debug overlay of desired.
     439  * Show an overlay desired.
    518440  * @param show Whether or not to show the debug overlay
    519441  */
    520442  void RunManager::showDebugOverlay(bool show)
    521443  {
    522     if (debugOverlay_)
     444    if (hud_)
    523445    {
    524446      if (show)
    525         debugOverlay_->show();
     447        hud_->show();
    526448      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    }
    578451  }
    579452
     
    581454  /**
    582455  * Simple camera creator.
    583   * playerShip_Node->attachObject(camera_) should no be here! This is what the camera
    584   * manager is for. Right now, this method should do just fine, setting the
    585   * 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()
    588461  {
    589462    camera_ = sceneMgr_->createCamera("PlayerCam");
     
    599472  * camera created so far.
    600473  */
    601   void RunManager::createViewports(void)
     474  void RunManager::createViewports()
    602475  {
    603476    // Create one viewport, entire window
     
    610483  }
    611484
     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
    612511}
  • code/branches/main_reto/src/run_manager.h

    r267 r289  
    3232#include "OgrePrerequisites.h"
    3333#include "OgreWindowEventUtilities.h"
    34 #include "OgreTextureManager.h"
    35 #include "OgreSingleton.h"
     34//#include "OgreTextureManager.h"
    3635
    3736#include <OIS/OISPrereqs.h>
     
    4443  // let the class inherit from WindowEventListener in order for the RunMgr
    4544  // 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
    4846  {
    4947  public:
    50     RunManager(OgreControl*);
    51 
    5248    virtual ~RunManager();
    53     //void initialise(OgreControl*);
     49   
     50    void initialise(OgreControl*);
    5451
    5552    bool tick(unsigned long, Ogre::Real);
     
    6562    int getNumberOfAmmos();
    6663
     64    static RunManager* createSingleton();
     65
     66    static void destroySingleton();
     67
    6768    static RunManager& getSingleton(void);
    6869
     
    7172
    7273  protected:
     74    RunManager();
     75
    7376          void createCamera(void);
    7477
     
    9396          /** OUTPUT **/
    9497
    95           void updateStats(void);
    96 
    9798          void showDebugOverlay(bool);
    9899
     
    108109          OrxonoxScene *backgroundScene_;
    109110          OrxonoxShip  *playerShip_;
    110     hud::HUDOverlay  *hud_;
     111    hud::TestOverlay *hud_;
    111112
    112113    // Bullet manager
     
    121122    // fields from the example framework
    122123          bool statsOn_;
    123           std::string debugText_;
    124124
    125125          unsigned int screenShotCounter_;
    126126          // just to stop toggles flipping too fast
    127127          Ogre::Real timeUntilNextToggle_;
    128           //bool leftButtonDown_;
    129           Ogre::TextureFilterOptions filtering_;
    130           int aniso_;
    131           int sceneDetailIndex_;
    132           Ogre::Overlay* debugOverlay_;
    133128
    134129          //OIS Input devices
     
    138133          OIS::JoyStick* joystick_;
    139134
     135    // singleton pointer
     136    static RunManager *singletonPtr_s;
     137
    140138  };
    141139
  • code/branches/main_reto/src/weapon/barrel_gun.cc

    r267 r289  
    9595  void BarrelGun::primaryFiring(unsigned int time)
    9696  {
    97     if (time > 1000/primaryFiringRate_)
     97    if (time > (unsigned int)1000/primaryFiringRate_)
    9898    {
    9999      currentState_ = IDLE;
     
    133133  void BarrelGun::secondaryFiring(unsigned int time)
    134134  {
    135     if (time > 1000/secondaryFiringRate_)
     135    if (time > (unsigned int)1000/secondaryFiringRate_)
    136136      currentState_ = IDLE;
    137137  }
Note: See TracChangeset for help on using the changeset viewer.