Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 288


Ignore:
Timestamp:
Nov 27, 2007, 11:49:42 PM (16 years ago)
Author:
rgrieder
Message:
  • added Chai's HUD overlay
  • abstracted debugOverlay —> TestOverlay
  • added overlay media files
  • cleaned up RunManager a little bit
  • omitted using ogre's Singleton template
  • added useful CMake structure
  • some more things
Location:
code/branches/main_reto_vs05
Files:
55 added
3 deleted
15 edited
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto_vs05/bin/Debug

    • Property svn:ignore
      •  

        old new  
        1717Ogre.log
        1818weapon_framework.exe
         19obs_dlls
  • code/branches/main_reto_vs05/bin/Debug/Plugins.cfg

    r157 r288  
    88Plugin=RenderSystem_GL_d
    99Plugin=Plugin_ParticleFX_d
    10 Plugin=Plugin_BSPSceneManager_d
    11 Plugin=Plugin_OctreeSceneManager_d
    12 Plugin=Plugin_CgProgramManager_d
     10#Plugin=Plugin_BSPSceneManager_d
     11#Plugin=Plugin_OctreeSceneManager_d
     12#Plugin=Plugin_CgProgramManager_d
    1313
    1414
  • code/branches/main_reto_vs05/bin/Debug/resources.cfg

    r159 r288  
    88FileSystem=../../media
    99FileSystem=../../media/fonts
     10FileSystem=../../media/gui
    1011FileSystem=../../media/materials/scripts
    1112FileSystem=../../media/materials/textures
    1213FileSystem=../../media/models
    13 FileSystem=../../media/gui
     14FileSystem=../../media/overlay
     15FileSystem=../../media/particle
    1416Zip=../../media/packs/cubemap.zip
    1517Zip=../../media/packs/skybox.zip
     18Zip=../../media/packs/models.zip
  • code/branches/main_reto_vs05/bin/Release

    • Property svn:ignore
      •  

        old new  
        1616Ogre.log
        1717weapon_framework.exe
         18obs_dlls
  • code/branches/main_reto_vs05/bin/Release/Plugins.cfg

    r157 r288  
    88Plugin=RenderSystem_GL
    99Plugin=Plugin_ParticleFX
    10 Plugin=Plugin_BSPSceneManager
    11 Plugin=Plugin_OctreeSceneManager
    12 Plugin=Plugin_CgProgramManager
     10#Plugin=Plugin_BSPSceneManager
     11#Plugin=Plugin_OctreeSceneManager
     12#Plugin=Plugin_CgProgramManager
    1313
    1414
  • code/branches/main_reto_vs05/bin/Release/resources.cfg

    r159 r288  
    88FileSystem=../../media
    99FileSystem=../../media/fonts
     10FileSystem=../../media/gui
    1011FileSystem=../../media/materials/scripts
    1112FileSystem=../../media/materials/textures
    1213FileSystem=../../media/models
    13 FileSystem=../../media/gui
     14FileSystem=../../media/overlay
     15FileSystem=../../media/particle
    1416Zip=../../media/packs/cubemap.zip
    1517Zip=../../media/packs/skybox.zip
     18Zip=../../media/packs/models.zip
  • code/branches/main_reto_vs05/media/materials/scripts/Ogre.material

    r170 r288  
    118118        }
    119119}
     120
     121
     122
     123material Orxonox/SuperEgg
     124{
     125        technique
     126        {
     127                pass
     128                {
     129                        lighting off
     130                        scene_blend alpha_blend
     131                        depth_check off
     132
     133                        texture_unit
     134                        {
     135                                texture superegg.png
     136                        }
     137                }
     138        }
     139}
     140
     141material Orxonox/Shot
     142{
     143        technique
     144        {
     145                pass
     146                {
     147                        lighting off
     148                        scene_blend alpha_blend
     149                        depth_check off
     150
     151                        texture_unit
     152                        {
     153                                texture shot.png
     154                        }
     155                }
     156        }
     157}
     158
     159
     160material Orxonox/Red
     161{
     162        technique
     163        {
     164                pass
     165                {
     166                        lighting off
     167                        depth_check off
     168                        scene_blend 0.5 0.5
     169                        ambient 0 0 0 0.5
     170
     171                        texture_unit
     172                        {
     173                                texture OrxonoxRED.png
     174                        }
     175                }
     176        }
     177}
     178
     179
     180material Orxonox/Black
     181{
     182        technique
     183        {
     184                pass
     185                {
     186                        lighting off
     187                        depth_check off
     188                        scene_blend 0.5 0.5
     189                        ambient 0 0 0 0.5
     190
     191                        texture_unit
     192                        {
     193                                texture OrxonoxBlack.png
     194                        }
     195                }
     196        }
     197}
     198
     199
     200material Orxonox/BackGround
     201{
     202        technique
     203        {
     204                pass
     205                {
     206
     207                        lighting off
     208                        scene_blend alpha_blend
     209                        depth_check off
     210                        texture_unit
     211                        {
     212                                texture backGround.png
     213                        }
     214                }
     215        }
     216}
     217
     218material Orxonox/EnergyBackground
     219{
     220        technique
     221        {
     222                pass
     223                {
     224
     225                        lighting off
     226                        scene_blend alpha_blend
     227                        depth_check off
     228                        texture_unit
     229                        {
     230                                texture EnergyBackground.png
     231                        }
     232                }
     233        }
     234}
     235
     236material Orxonox/Clock
     237{
     238        technique
     239        {
     240                pass
     241                {
     242                        lighting off
     243                        scene_blend alpha_blend
     244                        depth_check off
     245
     246                        texture_unit
     247                        {
     248                                texture clock.png
     249                        }
     250                }
     251        }
     252}
     253
     254material Orxonox/Gun
     255{
     256        technique
     257        {
     258                pass
     259                {
     260                        lighting off
     261                        scene_blend alpha_blend
     262                        depth_check off
     263
     264                        texture_unit
     265                        {
     266                                texture gun.png
     267                        }
     268                }
     269        }
     270}
     271
     272material Orxonox/Man
     273{
     274        technique
     275        {
     276                pass
     277                {
     278                        lighting off
     279                        scene_blend alpha_blend
     280                        depth_check off
     281
     282                        texture_unit
     283                        {
     284                                texture man.png
     285                        }
     286                }
     287        }
     288}
     289
     290material Orxonox/MapBackGround
     291{
     292        technique
     293        {
     294                pass
     295                {
     296                        lighting off
     297                        scene_blend alpha_blend
     298                        depth_check off
     299
     300                        texture_unit
     301                        {
     302                                texture MapBackGround.png
     303                        }
     304                }
     305        }
     306}
     307
     308material Orxonox/MyShip
     309{
     310        technique
     311        {
     312                pass
     313                {
     314                        lighting off
     315                        scene_blend alpha_blend
     316                        depth_check off
     317
     318                        texture_unit
     319                        {
     320                                texture MyShip.png
     321                        }
     322                }
     323        }
     324}
     325
     326material Orxonox/RacketBackground
     327{
     328        technique
     329        {
     330                pass
     331                {
     332                        lighting off
     333                        scene_blend alpha_blend
     334                        depth_check off
     335
     336                        texture_unit
     337                        {
     338                                texture RacketBackground.png
     339                        }
     340                }
     341        }
     342}
     343
     344
     345material Orxonox/TargetBackground
     346{
     347        technique
     348        {
     349                pass
     350                {
     351                        lighting off
     352                        scene_blend alpha_blend
     353                        depth_check off
     354
     355                        texture_unit
     356                        {
     357                                texture TargetBackground.png
     358                        }
     359                }
     360        }
     361}
     362
     363material Orxonox/PrimarBackground
     364{
     365        technique
     366        {
     367                pass
     368                {
     369                        lighting off
     370                        scene_blend alpha_blend
     371                        depth_check off
     372
     373                        texture_unit
     374                        {
     375                                texture PrimarBackground.png
     376                        }
     377                }
     378        }
     379}
     380
     381material Orxonox/PrimarSample
     382{
     383        technique
     384        {
     385                pass
     386                {
     387                        lighting off
     388                        scene_blend alpha_blend
     389                        depth_check off
     390
     391                        texture_unit
     392                        {
     393                                texture PrimarSample.png
     394                        }
     395                }
     396        }
     397}
     398
     399material Orxonox/PrimarChoice
     400{
     401        technique
     402        {
     403                pass
     404                {
     405                        lighting off
     406                        scene_blend alpha_blend
     407                        depth_check off
     408
     409                        texture_unit
     410                        {
     411                                texture PrimarChoice.png
     412                        }
     413                }
     414        }
     415}
     416
     417material Orxonox/RedPoint
     418{
     419        technique
     420        {
     421                pass
     422                {
     423                        lighting off
     424                        scene_blend alpha_blend
     425                        depth_check off
     426
     427                        texture_unit
     428                        {
     429                                texture RedPoint.png
     430                        }
     431                }
     432        }
     433}
     434
     435material Orxonox/EnergyDistrBackground
     436{
     437        technique
     438        {
     439                pass
     440                {
     441                        lighting off
     442                        scene_blend alpha_blend
     443                        depth_check off
     444
     445                        texture_unit
     446                        {
     447                                texture EnergyDistrBackground.png
     448                        }
     449                }
     450        }
     451}
     452
     453material Orxonox/ShildLeftTop
     454{
     455        technique
     456        {
     457                pass
     458                {
     459                        lighting off
     460                        scene_blend alpha_blend
     461                        depth_check off
     462
     463                        texture_unit
     464                        {
     465                                texture ShildLeftTop.png
     466                        }
     467                }
     468        }
     469}
     470
     471material Orxonox/ShildRightTop
     472{
     473        technique
     474        {
     475                pass
     476                {
     477                        lighting off
     478                        scene_blend alpha_blend
     479                        depth_check off
     480
     481                        texture_unit
     482                        {
     483                                texture ShildRightTop.png
     484                        }
     485                }
     486        }
     487}
     488
     489material Orxonox/ShildLeftBottom
     490{
     491        technique
     492        {
     493                pass
     494                {
     495                        lighting off
     496                        scene_blend alpha_blend
     497                        depth_check off
     498
     499                        texture_unit
     500                        {
     501                                texture ShildLeftBottom.png
     502                        }
     503                }
     504        }
     505}
     506
     507material Orxonox/ShildRightBottom
     508{
     509        technique
     510        {
     511                pass
     512                {
     513                        lighting off
     514                        scene_blend alpha_blend
     515                        depth_check off
     516
     517                        texture_unit
     518                        {
     519                                texture ShildRightBottom.png
     520                        }
     521                }
     522        }
     523}
     524
     525material Orxonox/TimeBackground
     526{
     527        technique
     528        {
     529                pass
     530                {
     531                        lighting off
     532                        scene_blend alpha_blend
     533                        depth_check off
     534
     535                        texture_unit
     536                        {
     537                                texture TimeBackground.png
     538                        }
     539                }
     540        }
     541}
     542
  • code/branches/main_reto_vs05/scripts/weapon_framework.vcproj

    r232 r288  
    184184                        >
    185185                        <File
    186                                 RelativePath="..\src\camera_manager.cc"
    187                                 >
    188                         </File>
    189                         <File
    190186                                RelativePath="..\src\inertial_node.cc"
    191187                                >
     
    227223                                </File>
    228224                                <File
    229                                         RelativePath="..\src\weapon\base_weapon.cpp"
     225                                        RelativePath="..\src\weapon\base_weapon.cc"
    230226                                        >
    231227                                </File>
     
    280276                                <File
    281277                                        RelativePath="..\src\class_hierarchy\test3.cc"
     278                                        >
     279                                </File>
     280                        </Filter>
     281                        <Filter
     282                                Name="hud"
     283                                >
     284                                <File
     285                                        RelativePath="..\src\hud\hud_overlay.cc"
     286                                        >
     287                                </File>
     288                                <File
     289                                        RelativePath="..\src\hud\test_overlay.cc"
    282290                                        >
    283291                                </File>
     
    290298                        >
    291299                        <File
    292                                 RelativePath="..\src\camera_manager.h"
    293                                 >
    294                         </File>
    295                         <File
    296300                                RelativePath="..\src\inertial_node.h"
    297301                                >
     
    398402                                <File
    399403                                        RelativePath="..\src\class_hierarchy\test3.h"
     404                                        >
     405                                </File>
     406                        </Filter>
     407                        <Filter
     408                                Name="hud"
     409                                >
     410                                <File
     411                                        RelativePath="..\src\hud\hud_overlay.h"
     412                                        >
     413                                </File>
     414                                <File
     415                                        RelativePath="..\src\hud\test_overlay.h"
    400416                                        >
    401417                                </File>
  • code/branches/main_reto_vs05/src/main.cc

    r232 r288  
    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_vs05/src/orxonox.cc

    r169 r288  
    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_vs05/src/orxonox_prerequisites.h

    r232 r288  
    5252  }
    5353
     54
     55  namespace hud {
     56   
     57    class HUDOverlay;
     58    class TestOverlay;
     59
     60  }
     61
    5462}
    5563
  • code/branches/main_reto_vs05/src/orxonox_ship.cc

    r232 r288  
    3232#include "OgreEntity.h"
    3333#include "OgreSceneManager.h"
     34#include "OgreParticleSystem.h"
    3435
    3536#include "inertial_node.h"
     
    127128    railGunStation_->selectWeapon(0);
    128129
     130    // create some nice effects
     131
     132    ParticleSystem *particles = RunManager::getSingletonPtr()
     133      ->getSceneManagerPtr()->createParticleSystem("asdf", "Examples/Smoke");
     134
     135    fishNode->getSceneNode()->attachObject(particles);
     136
     137
     138
     139
    129140          return true;
    130141  }
  • code/branches/main_reto_vs05/src/run_manager.cc

    r232 r288  
    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
     
    5853#include "weapon/base_weapon.h"
    5954
     55#include "hud/hud_overlay.h"
     56#include "hud/test_overlay.h"
     57
    6058#include "run_manager.h"
    6159
    62 namespace Ogre {
    63   using namespace orxonox;
    64   template<> RunManager* Singleton<RunManager>::ms_Singleton = 0;
    65 }
    6660
    6761namespace orxonox {
    6862  using namespace Ogre;
    6963  using namespace weapon;
     64  using namespace hud;
    7065
    7166  /**
     
    8277  */
    8378
    84   RunManager* RunManager::getSingletonPtr(void)
    85   {
    86       return ms_Singleton;
    87   }
    88   RunManager& RunManager::getSingleton(void)
    89   { 
    90       assert( ms_Singleton );  return ( *ms_Singleton ); 
    91   }
    92 
    93 
    94   /**
    95   * Contructor only needs the render window and the Root object which are both
    96   * the OgreControl object.
    97   * Right now the constructor does all the initialisation work. This could also
    98   * be done in a new method "initialize()", for whatever purpose.
    99   *
    100   *
     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  /**
    10194  * @param ogre_ The OgreControl object holding the render window and the Root
    10295  */
    103   RunManager::RunManager(OgreControl * ogre)
    104         : ogre_(ogre), window_(ogre->getRenderWindow()), //leftButtonDown_(false),
    105         statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0),
    106         filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0),
    107         mouseSensitivity_(0.003),
    108         debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0)
    109   {
     96  void RunManager::initialise(OgreControl *ogre)
     97    {
     98    ogre_ = ogre;
     99    window_ = ogre->getRenderWindow();
     100
    110101    // SETTING UP THE SCENE
    111102
     
    126117
    127118    // Create a space ship object and its SceneNode.
    128     // Some ideas about the steering: The ship should only receive events like
    129     // up, down, left, right, roll left, roll right, move down, move up, etc).
    130     // Multiple interpretations of these commands would make the game more
    131     // but it also makes AI steering more difficult, since for every type of
    132     // steering, new methods have to be written.
    133     // --> clearly define how a space ship can fly (rolling?, conservation of
    134     // impuls?, direct mouse sight steeering?, etc.)
    135119    // It should also be considered, that the ship should provide another Node
    136120    // for a camera to be attached (otherwise the spaceship in front of the
    137     // would be very static, never moving at all).
     121    // ship would be very static, never moving at all).
    138122
    139123    // Construct a new spaceship and give it the node
     
    145129
    146130    // load all resources and create the entities by calling the initialise()
    147     // methods for each object (don't initialise in the constructor!).
     131    // methods for each object (no constructor initialisations!).
    148132    backgroundScene_->initialise();
    149133    playerShip_->initialise();
     
    151135
    152136    // CAMERA AND VIEWPORT
    153     // TODO: create a camera manager. It should be able to change its position
    154     // around the space ship (predefined states would be nice too). And it should
    155     // also be able to switch between different locations (like ship, spactator,
    156     // certain fixed positions (e.g. finish line, etc.)). These are just ideas.
    157137
    158138    // create camera and viewport
     
    160140    createViewports();
    161141
     142    // create HUD
     143    hud_ = new hud::TestOverlay(window_);
     144    hud_->show();
     145
    162146
    163147    // Set default mipmap level (NB some APIs ignore this)
    164148    TextureManager::getSingleton().setDefaultNumMipmaps(5);
    165149
    166    
    167150
    168151    // HUMAN INTERFACE
    169152
    170     using namespace OIS;
    171 
    172     debugOverlay_ = OverlayManager::getSingleton()
    173       .getByName("Core/DebugOverlay");
     153    using namespace OIS;   
    174154
    175155    LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    201181    windowResized(window_);
    202182
    203     showDebugOverlay(true);
     183    //showDebugOverlay(true);
    204184
    205185    // REGISTER THIS OBJECT AS A WINDOW EVENT LISTENER IN OGRE
     
    225205    if (bulletManager_)
    226206      delete bulletManager_;
    227   }
    228 
    229 
    230   /**
    231   * 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.
    232214  *
    233215  * Everything that needs to be computed during the games happens right here.
     
    250232
    251233
    252     // Update the 'HUD'
    253     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);
    254244
    255245    // update the bullet positions
     
    404394    {
    405395      statsOn_ = !statsOn_;
    406       showDebugOverlay(statsOn_);
    407       timeUntilNextToggle_ = 1;
    408     }
    409 
    410     if( keyboard_->isKeyDown(KC_T) && timeUntilNextToggle_ <= 0 )
    411     {
    412       switch(filtering_)
    413       {
    414       case TFO_BILINEAR:
    415         filtering_ = TFO_TRILINEAR;
    416         aniso_ = 1;
    417         break;
    418       case TFO_TRILINEAR:
    419         filtering_ = TFO_ANISOTROPIC;
    420         aniso_ = 8;
    421         break;
    422       case TFO_ANISOTROPIC:
    423         filtering_ = TFO_BILINEAR;
    424         aniso_ = 1;
    425         break;
    426       default: break;
    427       }
    428       MaterialManager::getSingleton().setDefaultTextureFiltering(filtering_);
    429       MaterialManager::getSingleton().setDefaultAnisotropy(aniso_);
    430 
    431       showDebugOverlay(statsOn_);
    432396      timeUntilNextToggle_ = 1;
    433397    }
     
    439403      window_->writeContentsToFile(ss.str());
    440404      timeUntilNextToggle_ = 0.5;
    441       debugText_ = "Saved: " + ss.str();
    442     }
    443 
    444     if(keyboard_->isKeyDown(KC_R) && timeUntilNextToggle_ <=0)
    445     {
    446       sceneDetailIndex_ = (sceneDetailIndex_+1)%3 ;
    447       switch(sceneDetailIndex_) {
    448           case 0 : camera_->setPolygonMode(PM_SOLID); break;
    449           case 1 : camera_->setPolygonMode(PM_WIREFRAME); break;
    450           case 2 : camera_->setPolygonMode(PM_POINTS); break;
    451       }
    452       timeUntilNextToggle_ = 0.5;
    453     }
    454 
    455     static bool displayCameraDetails = false;
    456     if(keyboard_->isKeyDown(KC_P) && timeUntilNextToggle_ <= 0)
    457     {
    458       displayCameraDetails = !displayCameraDetails;
    459       timeUntilNextToggle_ = 0.5;
    460       if (!displayCameraDetails)
    461         debugText_ = "";
    462     }
    463 
    464     // Print camera details
    465     if(displayCameraDetails)
    466       debugText_ = " | Speed = "
    467             + StringConverter::toString(playerShip_->getSpeed())
    468             + " | Left Ammo = "
    469             + StringConverter::toString(playerShip_
    470             ->getMainWeapon()->getAmmoState())
    471             + " | Ammo stock = "
    472             + StringConverter::toString(playerShip_->getAmmoStock());
    473     // debugText_ = "P: " + StringConverter::toString(camera_
    474     //      ->getDerivedPosition()) + " " + "O: "
    475     //      + StringConverter::toString(camera_->getDerivedOrientation());
     405    }
    476406
    477407    // Return true to continue rendering
     
    507437
    508438  /**
    509   * Show the debug overlay of desired.
     439  * Show an overlay desired.
    510440  * @param show Whether or not to show the debug overlay
    511441  */
    512442  void RunManager::showDebugOverlay(bool show)
    513443  {
    514     if (debugOverlay_)
     444    if (hud_)
    515445    {
    516446      if (show)
    517         debugOverlay_->show();
     447        hud_->show();
    518448      else
    519         debugOverlay_->hide();
    520     }
    521   }
    522 
    523 
    524   /**
    525   * Show stats (e.g. FPS) in the left lower corner of the screen.
    526   * Copied from the ExampleFrameListener.h in the Ogre SDK
    527   */
    528   void RunManager::updateStats(void)
    529   {
    530     static String currFps = "Current FPS: ";
    531     static String avgFps = "Average FPS: ";
    532     static String bestFps = "Best FPS: ";
    533     static String worstFps = "Worst FPS: ";
    534     static String tris = "Triangle Count: ";
    535     static String batches = "Batch Count: ";
    536 
    537     // update stats when necessary
    538     try {
    539       OverlayElement* guiAvg = OverlayManager::getSingleton()
    540         .getOverlayElement("Core/AverageFps");
    541       OverlayElement* guiCurr = OverlayManager::getSingleton()
    542         .getOverlayElement("Core/CurrFps");
    543       OverlayElement* guiBest = OverlayManager::getSingleton()
    544         .getOverlayElement("Core/BestFps");
    545       OverlayElement* guiWorst = OverlayManager::getSingleton()
    546         .getOverlayElement("Core/WorstFps");
    547 
    548       const RenderTarget::FrameStats& stats = window_->getStatistics();
    549       guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
    550       guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
    551       guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
    552         +" "+StringConverter::toString(stats.bestFrameTime)+" ms");
    553       guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
    554         +" "+StringConverter::toString(stats.worstFrameTime)+" ms");
    555 
    556       OverlayElement* guiTris = OverlayManager::getSingleton()
    557         .getOverlayElement("Core/NumTris");
    558       guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));
    559 
    560       OverlayElement* guiBatches = OverlayManager::getSingleton()
    561         .getOverlayElement("Core/NumBatches");
    562       guiBatches->setCaption(batches
    563         + StringConverter::toString(stats.batchCount));
    564 
    565       OverlayElement* guiDbg = OverlayManager::getSingleton()
    566         .getOverlayElement("Core/DebugText");
    567       guiDbg->setCaption(debugText_);
    568     }
    569     catch(...) { /* ignore */ }
    570   }
    571 
     449        hud_->hide();
     450    }
     451  }
    572452
    573453
    574454  /**
    575455  * Simple camera creator.
    576   * playerShip_Node->attachObject(camera_) should no be here! This is what the camera
    577   * manager is for. Right now, this method should do just fine, setting the
    578   * cam behind the ship.
    579   */
    580   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()
    581461  {
    582462    camera_ = sceneMgr_->createCamera("PlayerCam");
     
    589469  /**
    590470  * Simple viewport creator.
    591   * TODO: fully understand the concept of viewports concerning orxnox.
    592   * E.g. do we need splitscreen mode?
    593471  * For now the viewport uses the entire render window and is based on the one
    594472  * camera created so far.
    595473  */
    596   void RunManager::createViewports(void)
     474  void RunManager::createViewports()
    597475  {
    598476    // Create one viewport, entire window
     
    605483  }
    606484
     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
    607511}
  • code/branches/main_reto_vs05/src/run_manager.h

    r232 r288  
    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
    99100  protected:
     101    // directly Ogre related fields
    100102          Ogre::SceneManager *sceneMgr_;
    101103          Ogre::RenderWindow *window_;
    102104          Ogre::Camera       *camera_;
     105
     106
     107    // self made orxonox fields
    103108          OgreControl  *ogre_;
    104109          OrxonoxScene *backgroundScene_;
    105110          OrxonoxShip  *playerShip_;
     111    hud::TestOverlay *hud_;
    106112
     113    // Bullet manager
     114    weapon::BulletManager *bulletManager_;
     115
     116    const Ogre::Real mouseSensitivity_;
     117
     118          // previously elapsed render time
     119          unsigned long totalTime_;
     120
     121
     122    // fields from the example framework
    107123          bool statsOn_;
    108           std::string debugText_;
    109124
    110125          unsigned int screenShotCounter_;
    111126          // just to stop toggles flipping too fast
    112127          Ogre::Real timeUntilNextToggle_;
    113           //bool leftButtonDown_;
    114           Ogre::TextureFilterOptions filtering_;
    115           int aniso_;
    116 
    117           int sceneDetailIndex_;
    118           Ogre::Overlay* debugOverlay_;
    119128
    120129          //OIS Input devices
     
    124133          OIS::JoyStick* joystick_;
    125134
    126     const Ogre::Real mouseSensitivity_;
    127 
    128     // Bullet array
    129           /*Bullet **bullets_;
    130           int bulletsSize_;
    131           int bulletsIndex_;*/
    132     weapon::BulletManager *bulletManager_;
    133 
    134           // previously elapsed render time
    135           unsigned long totalTime_;
     135    // singleton pointer
     136    static RunManager *singletonPtr_s;
    136137
    137138  };
  • code/branches/main_reto_vs05/src/weapon/barrel_gun.cc

    r232 r288  
    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  }
  • code/branches/main_reto_vs05/src/weapon/base_weapon.cc

    r232 r288  
    9898    }
    9999
    100     switch (currentState_)
     100    if (currentState_ != IDLE)
    101101    {
    102     case IDLE:
     102      switch (currentState_)
     103      {
     104      case PRIMARY_FIRE:
     105        primaryFiring((unsigned int)(time - actionStartTime_));
     106        break;
     107
     108      case SECONDARY_FIRE:
     109        secondaryFiring((unsigned int)(time - actionStartTime_));
     110        break;
     111
     112      case RELOADING:
     113        break;
     114
     115      case CHANGING_AMMO:
     116        break;
     117      }
     118    }
     119
     120    if (currentState_ == IDLE)
     121    {
    103122      // first, process next action
    104123      if (nextAction_ != NOTHING)
     
    142161        }
    143162      }
    144 
    145       break;
    146 
    147     case PRIMARY_FIRE:
    148       primaryFiring((unsigned int)(time - actionStartTime_));
    149       break;
    150 
    151     case SECONDARY_FIRE:
    152       secondaryFiring((unsigned int)(time - actionStartTime_));
    153       break;
    154 
    155     case RELOADING:
    156       break;
    157 
    158     case CHANGING_AMMO:
    159       break;
    160163    }
    161164
Note: See TracChangeset for help on using the changeset viewer.