Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 10, 2008, 1:37:36 AM (16 years ago)
Author:
rgrieder
Message:

merged gui back to trunk.
update the media repository!

Location:
code/trunk
Files:
2 deleted
37 edited
28 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/CMakeLists.txt

    r1747 r1755  
    22  GraphicsEngine.cc
    33  Main.cc
    4   Orxonox.cc
    54  Radar.cc
    65  RadarListener.cc
     
    87  Settings.cc
    98  SignalHandler.cc
     9
     10  gamestates/GSClient.cc
     11  gamestates/GSDedicated.cc
     12  gamestates/GSGraphics.cc
     13  gamestates/GSGUI.cc
     14  gamestates/GSIOConsole.cc
     15  gamestates/GSLevel.cc
     16  gamestates/GSRoot.cc
     17  gamestates/GSServer.cc
     18  gamestates/GSStandalone.cc
     19
     20  gui/GUIManager.cc
     21  gui/OgreCEGUIRenderer.cpp
     22  gui/OgreCEGUIResourceProvider.cpp
     23  gui/OgreCEGUITexture.cpp
    1024
    1125  overlays/OrxonoxOverlay.cc
     
    5569ADD_CUSTOM_COMMAND(
    5670  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc
    57   COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
    58   DEPENDS tolua
     71  COMMAND ${TOLUA_EXE} -n Orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
     72  DEPENDS tolua ${CMAKE_SOURCE_DIR}/src/orxonox/tolua/tolua.pkg
    5973  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
    6074)
     
    8498  ${OGRE_LIBRARIES}
    8599  ${Lua_LIBRARIES}
     100  ${CEGUI_LIBRARIES}
     101  ${CEGUI_SCRIPT_LIBRARIES}
    86102  tinyxml
    87103  tolualib
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1747 r1755  
    2222 *   Author:
    2323 *      Reto Grieder
     24 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
    2425 *   Co-authors:
    25  *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
     26 *      Felix Schulthess
    2627 *
    2728 */
    2829
    29  /**
    30     @file orxonox.cc
    31     @brief Orxonox class
    32   */
     30/**
     31@file
     32@brief
     33    Implementation of an partial interface to Ogre.
     34*/
    3335
    3436#include "OrxonoxStableHeaders.h"
    3537#include "GraphicsEngine.h"
    3638
    37 #include <fstream>
    38 
    39 #include <OgreConfigFile.h>
    40 #include <OgreException.h>
    41 #include <OgreLogManager.h>
    42 #include <OgreRoot.h>
    43 #include <OgreSceneManager.h>
    44 #include <OgreTextureManager.h>
    45 #include <OgreViewport.h>
     39#include <OgreRenderWindow.h>
    4640
    4741#include "core/CoreIncludes.h"
    4842#include "core/ConfigValueIncludes.h"
    49 #include "core/Iterator.h"
    50 #include "core/CommandExecutor.h"
    51 #include "core/ConsoleCommand.h"
    5243#include "util/Debug.h"
    5344
    54 #include "overlays/console/InGameConsole.h"
    55 #include "overlays/OverlayGroup.h"
    5645#include "tools/ParticleInterface.h"
    57 #include "Settings.h"
    58 #include "tools/WindowEventListener.h"
    59 
    6046
    6147namespace orxonox
    6248{
    63   /**
    64     @brief Returns the singleton instance and creates it the first time.
    65     @return The only instance of GraphicsEngine.
    66   */
    67   /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
    68   {
    69     static GraphicsEngine theOnlyInstance;
    70     return theOnlyInstance;
    71   }
     49    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
    7250
    73   /**
    74     @brief Only use constructor to initialise variables and pointers!
    75   */
    76   GraphicsEngine::GraphicsEngine() :
    77     root_(0),
    78     scene_(0),
    79     renderWindow_(0)
    80   {
    81     RegisterObject(GraphicsEngine);
     51    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
    8252
    83     this->detailLevelParticle_ = 0;
    84 
    85     this->setConfigValues();
    86     CCOUT(4) << "Constructed" << std::endl;
    87   }
    88 
    89   void GraphicsEngine::setConfigValues()
    90   {
    91     SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
    92     SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
    93     SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
    94     SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
    95                                                              Use \"\" to suppress log file creation.");
    96     SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
    97     SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
    98     SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    99 
    100     SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
    101   }
    102 
    103   void GraphicsEngine::detailLevelParticleChanged()
    104   {
    105     for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    106       it->detailLevelChanged(this->detailLevelParticle_);
    107   }
    108 
    109   /**
    110     @brief Called after main() --> call destroyObjects()!
    111   */
    112   GraphicsEngine::~GraphicsEngine()
    113   {
    114     this->destroy();
    115   }
    116 
    117   /**
    118     @brief Destroys all the internal objects. Call this method when you
    119            normally would call the destructor.
    120   */
    121   void GraphicsEngine::destroy()
    122   {
    123     CCOUT(4) << "Destroying objects..." << std::endl;
    124     Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
    125     if (this->root_)
    126       delete this->root_;
    127     this->root_ = 0;
    128     this->scene_ = 0;
    129     this->renderWindow_ = 0;
    130     // delete the ogre log and the logManager (since we have created it).
    131     if (Ogre::LogManager::getSingletonPtr() != 0)
     53    /**
     54    @brief
     55        Returns the singleton instance.
     56    @return
     57        The only instance of GraphicsEngine.
     58    */
     59    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
    13260    {
    133       Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
    134       Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    135       delete Ogre::LogManager::getSingletonPtr();
    136     }
    137     CCOUT(4) << "Destroying objects done" << std::endl;
    138   }
    139 
    140   /**
    141     @brief Creates the Ogre Root object and sets up the ogre log.
    142   */
    143   bool GraphicsEngine::setup()
    144   {
    145     CCOUT(3) << "Setting up..." << std::endl;
    146     // temporary overwrite of dataPath, change ini file for permanent change
    147 
    148 // TODO: LogManager doesn't work on specific systems. The why is unknown yet.
    149 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    150     // create a logManager
    151     // note: If there's already a logManager, Ogre will complain by a failed assertation.
    152     // but that shouldn't happen, since this is the first time to create a logManager..
    153     Ogre::LogManager* logger = new Ogre::LogManager();
    154     CCOUT(4) << "Ogre LogManager created" << std::endl;
    155 
    156     // create our own log that we can listen to
    157     Ogre::Log *myLog;
    158     if (this->ogreLogFile_ == "")
    159       myLog = logger->createLog("ogre.log", true, false, true);
    160     else
    161       myLog = logger->createLog(this->ogreLogFile_, true, false, false);
    162     CCOUT(4) << "Ogre Log created" << std::endl;
    163 
    164     myLog->setLogDetail(Ogre::LL_BOREME);
    165     myLog->addListener(this);
    166 #endif
    167 
    168     // Root will detect that we've already created a Log
    169     CCOUT(4) << "Creating Ogre Root..." << std::endl;
    170 
    171     if (ogrePluginsFile_ == "")
    172     {
    173       COUT(1) << "Error: Ogre plugins file set to \"\". Cannot load." << std::endl;
    174       return false;
    175     }
    176     if (ogreConfigFile_ == "")
    177     {
    178       COUT(1) << "Error: Ogre config file set to \"\". Cannot load." << std::endl;
    179       return false;
    180     }
    181     if (ogreLogFile_ == "")
    182     {
    183       COUT(1) << "Error: Ogre log file set to \"\". Cannot load." << std::endl;
    184       return false;
     61        assert(singletonRef_s);
     62        return *singletonRef_s;
    18563    }
    18664
    187     try
     65    /**
     66    @brief
     67        Non-initialising constructor.
     68    */
     69    GraphicsEngine::GraphicsEngine()
     70        : root_(0)
     71        , renderWindow_(0)
     72        , levelSceneManager_(0)
     73        , viewport_(0)
    18874    {
    189       root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
    190     }
    191     catch (Ogre::Exception ex)
    192     {
    193       COUT(2) << "Error: There was an exception when creating Ogre Root." << std::endl;
    194       return false;
     75        RegisterObject(GraphicsEngine);
     76
     77        assert(singletonRef_s == 0);
     78        singletonRef_s = this;
     79
     80        this->detailLevelParticle_ = 0;
     81
     82        this->setConfigValues();
     83        CCOUT(4) << "Constructed" << std::endl;
    19584    }
    19685
    197     if (!root_->getInstalledPlugins().size())
     86    void GraphicsEngine::setConfigValues()
    19887    {
    199       COUT(1) << "Error: No plugins declared. Cannot load Ogre." << std::endl;
    200       COUT(0) << "Is the plugins file correctly declared?" << std::endl;
    201       return false;
     88        SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
    20289    }
    20390
    204 #if 0
    205     // tame the ogre ouput so we don't get all the mess in the console
    206     Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
    207     defaultLog->setDebugOutputEnabled(false);
    208     defaultLog->setLogDetail(Ogre::LL_BOREME);
    209     defaultLog->addListener(this);
    210 #endif
    211 
    212     CCOUT(4) << "Creating Ogre Root done" << std::endl;
    213 
    214     // specify where Ogre has to look for resources. This call doesn't parse anything yet!
    215     if (!declareRessourceLocations())
    216       return false;
    217 
    218     CCOUT(3) << "Set up done." << std::endl;
    219     return true;
    220   }
    221 
    222   bool GraphicsEngine::declareRessourceLocations()
    223   {
    224     CCOUT(4) << "Declaring Resources" << std::endl;
    225     //TODO: Specify layout of data file and maybe use xml-loader
    226     //TODO: Work with ressource groups (should be generated by a special loader)
    227 
    228     if (resourceFile_ == "")
     91    void GraphicsEngine::detailLevelParticleChanged()
    22992    {
    230       COUT(1) << "Error: Resource file set to \"\". Cannot load." << std::endl;
    231       return false;
     93        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
     94            it->detailLevelChanged(this->detailLevelParticle_);
    23295    }
    23396
    234     // Load resource paths from data file using configfile ressource type
    235     Ogre::ConfigFile cf;
    236     try
     97    /**
     98    @brief
     99        Destroys all the Ogre related objects
     100    */
     101    GraphicsEngine::~GraphicsEngine()
    237102    {
    238       cf.load(Settings::getDataPath() + resourceFile_);
    239     }
    240     catch (Ogre::Exception ex)
    241     {
    242       COUT(1) << "Error: Could not load resources.cfg in path " << Settings::getDataPath() << std::endl;
    243       COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
    244       return false;
     103        singletonRef_s = 0;
    245104    }
    246105
    247     // Go through all sections & settings in the file
    248     Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    249 
    250     std::string secName, typeName, archName;
    251     while (seci.hasMoreElements())
     106    /**
     107    @brief
     108        Get the width of the render window
     109    @return
     110        The width of the render window
     111    */
     112    int GraphicsEngine::getWindowWidth() const
    252113    {
    253       try
    254       {
    255         secName = seci.peekNextKey();
    256         Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
    257         Ogre::ConfigFile::SettingsMultiMap::iterator i;
    258         for (i = settings->begin(); i != settings->end(); ++i)
    259         {
    260           typeName = i->first; // for instance "FileSystem" or "Zip"
    261           archName = i->second; // name (and location) of archive
    262 
    263           Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    264               std::string(Settings::getDataPath() + archName), typeName, secName);
    265         }
    266       }
    267       catch (Ogre::Exception ex)
    268       {
    269         COUT(2) << "Exception while reading resources.cfg. Proceeding.." << ex.getDescription() << std::endl;
    270       }
    271     }
    272     return true;
    273   }
    274 
    275   bool GraphicsEngine::loadRenderer()
    276   {
    277     CCOUT(4) << "Configuring Renderer" << std::endl;
    278 
    279     // check for file existence because Ogre displays exceptions if not
    280     std::ifstream probe;
    281     probe.open(ogreConfigFile_.c_str());
    282     if (!probe)
    283     {
    284       // create a zero sized file
    285       std::ofstream creator;
    286       creator.open(ogreConfigFile_.c_str());
    287       creator.close();
    288     }
    289     else
    290       probe.close();
    291 
    292     if (!root_->restoreConfig())
    293       if (!root_->showConfigDialog())
    294         return false;
    295 
    296     CCOUT(4) << "Creating render window" << std::endl;
    297     try
    298     {
    299       this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
    300     }
    301     catch (Ogre::Exception ex)
    302     {
    303       COUT(2) << "Error: There was an exception when initialising Ogre Root." << std::endl;
    304       return false;
     114        if (this->renderWindow_)
     115            return this->renderWindow_->getWidth();
     116        else
     117            return 0;
    305118    }
    306119
    307     if (!root_->isInitialised())
     120    /**
     121    @brief
     122        Get the height of the render window
     123    @return
     124        The height of the render window
     125    */
     126    int GraphicsEngine::getWindowHeight() const
    308127    {
    309       CCOUT(2) << "Error: Initialising Ogre root object failed." << std::endl;
    310       return false;
     128        if (this->renderWindow_)
     129            return this->renderWindow_->getHeight();
     130        else
     131            return 0;
    311132    }
    312     Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
    313     Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    314     return true;
    315   }
    316133
    317   bool GraphicsEngine::initialiseResources()
    318   {
    319     CCOUT(4) << "Initialising resources" << std::endl;
    320     //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    321     try
     134    /**
     135    @brief
     136        Returns the window aspect ratio height/width.
     137    @return
     138        The window aspect ratio
     139    */
     140    float GraphicsEngine::getWindowAspectRatio() const
    322141    {
    323       Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    324       /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
    325       for (unsigned int i = 0; i < str.size(); i++)
    326       {
    327         Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
    328       }*/
     142        if (this->renderWindow_)
     143            return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
     144        else
     145            return 1.0f;
    329146    }
    330     catch (Ogre::Exception e)
    331     {
    332       CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
    333       CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
    334       return false;
    335     }
    336     return true;
    337   }
    338 
    339   /**
    340    * @brief Creates the SceneManager
    341    */
    342   bool GraphicsEngine::createNewScene()
    343   {
    344     CCOUT(4) << "Creating new SceneManager..." << std::endl;
    345     if (scene_)
    346     {
    347       CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
    348       return false;
    349     }
    350     scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
    351     CCOUT(3) << "Created SceneManager: " << scene_ << std::endl;
    352     return true;
    353   }
    354 
    355   /**
    356     Returns the window handle of the render window.
    357     At least the InputHandler uses this to create the OIS::InputManager
    358     @return The window handle of the render window
    359   */
    360   size_t GraphicsEngine::getWindowHandle()
    361   {
    362     if (this->renderWindow_)
    363     {
    364       size_t windowHnd = 0;
    365       this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
    366       return windowHnd;
    367     }
    368     else
    369       return 0;
    370   }
    371 
    372   /**
    373     Get the width of the current render window
    374     @return The width of the current render window
    375   */
    376   int GraphicsEngine::getWindowWidth() const
    377   {
    378     if (this->renderWindow_)
    379       return this->renderWindow_->getWidth();
    380     else
    381       return 0;
    382   }
    383 
    384   /**
    385     Get the height of the current render window
    386     @return The height of the current render window
    387   */
    388   int GraphicsEngine::getWindowHeight() const
    389   {
    390     if (this->renderWindow_)
    391       return this->renderWindow_->getHeight();
    392     else
    393       return 0;
    394   }
    395 
    396   /**
    397     @brief Returns the window aspect ratio height/width.
    398     @return The ratio
    399   */
    400   float GraphicsEngine::getWindowAspectRatio() const
    401   {
    402     if (this->renderWindow_)
    403         return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
    404     else
    405         return 1.0f;
    406   }
    407 
    408   /**
    409     @brief Method called by the LogListener interface from Ogre.
    410     We use it to capture Ogre log messages and handle it ourselves.
    411     @param message The message to be logged
    412     @param lml The message level the log is using
    413     @param maskDebug If we are printing to the console or not
    414     @param logName the name of this log (so you can have several listeners
    415                    for different logs, and identify them)
    416   */
    417   void GraphicsEngine::messageLogged(const std::string& message,
    418     Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName)
    419   {
    420     int orxonoxLevel;
    421     switch (lml)
    422     {
    423       case Ogre::LML_TRIVIAL:
    424         orxonoxLevel = this->ogreLogLevelTrivial_;
    425         break;
    426       case Ogre::LML_NORMAL:
    427         orxonoxLevel = this->ogreLogLevelNormal_;
    428         break;
    429       case Ogre::LML_CRITICAL:
    430         orxonoxLevel = this->ogreLogLevelCritical_;
    431         break;
    432       default:
    433         orxonoxLevel = 0;
    434     }
    435     OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
    436         << "Ogre: " << message << std::endl;
    437   }
    438 
    439   /**
    440   * Window has moved.
    441   * @param rw The render window it occured in
    442   */
    443   void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
    444   {
    445     for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    446       it->windowMoved();
    447   }
    448 
    449   /**
    450   * Window has resized.
    451   * @param rw The render window it occured in
    452   * @note GraphicsEngine has a render window stored itself. This is the same
    453   *       as rw. But we have to be careful when using multiple render windows!
    454   */
    455   void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
    456   {
    457     for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    458       it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    459   }
    460 
    461   /**
    462   * Window has changed Focus.
    463   * @param rw The render window it occured in
    464   */
    465   void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
    466   {
    467     for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    468       it->windowFocusChanged();
    469   }
    470 
    471   /**
    472   * Window was closed.
    473   * @param rw The render window it occured in
    474   */
    475   void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
    476   {
    477     // using CommandExecutor in order to avoid depending on Orxonox.h.
    478     CommandExecutor::execute("exit", false);
    479   }
    480 
    481147}
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1747 r1755  
    2222 *   Author:
    2323 *      Reto Grieder
     24 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
    2425 *   Co-authors:
    25  *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
     26 *      Felix Schulthess
    2627 *
    2728 */
     
    4142
    4243#include <OgrePrerequisites.h>
    43 #include <OgreLog.h>
    44 #include <OgreRenderWindow.h>
    45 #include <OgreWindowEventUtilities.h>
    4644#include "core/OrxonoxClass.h"
    47 
    4845
    4946namespace orxonox
     
    5249    @brief Graphics engine manager class
    5350    */
    54     class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
     51    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
    5552    {
    56         public:
    57             void setConfigValues();
    58             void detailLevelParticleChanged();
    59             bool setup();
    60             bool declareRessourceLocations();
    61             bool loadRenderer();
    62             bool initialiseResources();
    63             bool createNewScene();
     53        // HACK: temporary means
     54        friend class GSGraphics;
    6455
    65             void destroy();
     56    public:
     57        GraphicsEngine();
     58        ~GraphicsEngine();
    6659
    67             Ogre::SceneManager* getSceneManager() { return scene_; }
     60        void setConfigValues();
     61        void detailLevelParticleChanged();
    6862
    69             // several window properties
    70             Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
    71             size_t getWindowHandle();
    72             int getWindowWidth() const;
    73             int getWindowHeight() const;
    74             float getWindowAspectRatio() const;
    75             float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; }
    76             float getAverageTickTime() const { return this->avgTickTime_; }
    77             void setAverageTickTime(float tickTime) { this->avgTickTime_ = tickTime; }
    78             void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
     63        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
     64        Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
    7965
    80             void setWindowActivity(bool activity)
    81             { if (this->renderWindow_) this->renderWindow_->setActive(activity); }
     66        Ogre::Viewport* getViewport() { return this->viewport_; }
     67        Ogre::Root*     getOgreRoot() { return this->root_; }
    8268
    83             void windowMoved       (Ogre::RenderWindow* rw);
    84             void windowResized     (Ogre::RenderWindow* rw);
    85             void windowFocusChanged(Ogre::RenderWindow* rw);
    86             void windowClosed      (Ogre::RenderWindow* rw);
     69        // several window properties
     70        int getWindowWidth() const;
     71        int getWindowHeight() const;
     72        float getWindowAspectRatio() const;
     73        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
     74        float getAverageTickTime() const          { return this->avgTickTime_; }
     75        void setAverageTickTime(float tickTime)   { this->avgTickTime_ = tickTime; }
     76        void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
    8777
    88             inline unsigned int getDetailLevelParticle() const
    89               { return this->detailLevelParticle_; }
     78        inline unsigned int getDetailLevelParticle() const
     79        { return this->detailLevelParticle_; }
    9080
    91             static GraphicsEngine& getSingleton();
    92             static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
     81        static GraphicsEngine& getInstance();
     82        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
    9383
     84    private:
     85        // don't mess with singletons
     86        GraphicsEngine(GraphicsEngine&);
    9487
    95         private:
    96             // don't mess with singletons
    97             GraphicsEngine();
    98             ~GraphicsEngine();
    99             GraphicsEngine(GraphicsEngine&) { }
     88        Ogre::Root*         root_;                  //!< Ogre's root
     89        Ogre::RenderWindow* renderWindow_;          //!< the current render window
     90        Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
     91        Ogre::Viewport*     viewport_;              //!< default full size viewport
    10092
    101             //! Method called by the LogListener from Ogre
    102             void messageLogged(const std::string&, Ogre::LogMessageLevel,
    103                              bool, const std::string&);
     93        // stats
     94        float               avgTickTime_;           //!< time in ms to tick() one frame
     95        float               avgFramesPerSecond_;    //!< number of frames processed in one second
    10496
    105             Ogre::Root*         root_;                  //!< Ogre's root
    106             Ogre::SceneManager* scene_;                 //!< scene manager of the game
    107             Ogre::RenderWindow* renderWindow_;          //!< the current render window
    108             std::string         resourceFile_;          //!< resources file name
    109             std::string         ogreConfigFile_;        //!< ogre config file name
    110             std::string         ogrePluginsFile_;       //!< ogre plugins file name
    111             std::string         ogreLogFile_;           //!< log file name for Ogre log messages
    112             int                 ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
    113             int                 ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
    114             int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
    115             unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
    116             float               avgTickTime_;           //!< time in ms to tick() one frame
    117             float               avgFramesPerSecond_;    //!< number of frames processed in one second
     97        // config values
     98        unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
     99
     100        static GraphicsEngine* singletonRef_s;      //!< Pointer to the Singleton
    118101    };
    119102}
  • code/trunk/src/orxonox/Main.cc

    r1747 r1755  
    2222 *   Author:
    2323 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
     24 *      Reto Grieder
    2425 *   Co-authors:
    2526 *      ...
     
    3536
    3637#include <exception>
     38#include <cassert>
    3739
    3840#include "util/OrxonoxPlatform.h"
    3941#include "SignalHandler.h"
    40 #include "Orxonox.h"
     42#include "util/Debug.h"
     43
     44#include "gamestates/GSRoot.h"
     45#include "gamestates/GSGraphics.h"
     46#include "gamestates/GSStandalone.h"
     47#include "gamestates/GSServer.h"
     48#include "gamestates/GSClient.h"
     49#include "gamestates/GSDedicated.h"
     50#include "gamestates/GSGUI.h"
     51#include "gamestates/GSIOConsole.h"
    4152
    4253using namespace orxonox;
     54
    4355#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    4456#include <CoreFoundation/CoreFoundation.h>
     
    4961             std::string macBundlePath()
    5062{
    51   char path[1024];
    52   CFBundleRef mainBundle = CFBundleGetMainBundle();
    53   assert(mainBundle);
     63    char path[1024];
     64    CFBundleRef mainBundle = CFBundleGetMainBundle();
     65    assert(mainBundle);
    5466
    55   CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
    56   assert(mainBundleURL);
     67    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
     68    assert(mainBundleURL);
    5769
    58   CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
    59   assert(cfStringRef);
     70    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
     71    assert(cfStringRef);
    6072
    61   CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
     73    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
    6274
    63   CFRelease(mainBundleURL);
    64   CFRelease(cfStringRef);
     75    CFRelease(mainBundleURL);
     76    CFRelease(cfStringRef);
    6577
    66   return std::string(path);
     78    return std::string(path);
    6779}
    6880#endif
    6981
    70 #ifdef __cplusplus
    71 extern "C" {
    72 #endif
    7382
    74 int main(int argc, char **argv)
     83//#ifdef __cplusplus
     84//extern "C" {
     85//#endif
     86
     87int main(int argc, char** argv)
    7588{
    76   //try {
     89    // create a signal handler (only works for linux)
    7790    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
    78     Orxonox* orx = Orxonox::getSingleton();
    7991
    80     bool res = false;
    81 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    82     res = orx->init(argc, argv, macBundlePath());
    83 #else
    84     res = orx->init(argc, argv);
    85 #endif
     92    GSRoot root;
     93    GSGraphics graphics;
     94    GSStandalone standalone;
     95    GSServer server;
     96    GSClient client;
     97    GSDedicated dedicated;
     98    GSGUI gui;
     99    GSIOConsole ioConsole;
    86100
    87     if (res)
    88       orx->start();
    89     orx->destroySingleton();
    90   /*}
    91   catch (std::exception &ex)
    92   {
    93     std::cerr << "Exception:\n";
    94     std::cerr << ex.what() << "\n";
    95     return 1;
    96   }*/
     101    root.addChild(&graphics);
     102    graphics.addChild(&standalone);
     103    graphics.addChild(&server);
     104    graphics.addChild(&client);
     105    graphics.addChild(&gui);
    97106
    98   return 0;
     107    root.addChild(&ioConsole);
     108    root.addChild(&dedicated);
     109
     110    root.start(argc, argv);
     111
     112    return 0;
    99113}
    100114
    101 #ifdef __cplusplus
    102 }
    103 #endif
     115//#ifdef __cplusplus
     116//}
     117//#endif
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r1625 r1755  
    7474
    7575    class GraphicsEngine;
    76     class Orxonox;
     76    class Settings;
    7777
    7878    class RadarViewable;
     
    8484    class Backlight;
    8585    class Camera;
    86     class Fighter;
    8786    class Model;
    8887    class NPC;
     
    118117    class OverlayGroup;
    119118    class OverlayText;
     119
     120    //gui
     121    class GUIManager;
     122
     123    // game states
     124    class GSRoot;
     125    class GSGraphics;
     126    class GSIO;
     127    class GSIOConsole;
     128    class GSLevel;
     129    class GSStandalone;
     130    class GSServer;
     131    class GSClient;
     132    class GSGUI;
    120133}
    121134
     
    128141}
    129142
     143namespace CEGUI
     144{
     145    class LuaScriptModule;
     146
     147    class OgreCEGUIRenderer;
     148    class OgreCEGUIResourceProvider;
     149    class OgreCEGUITexture;
     150}
     151
     152struct lua_State;
     153
    130154#endif /* _OrxonoxPrereqs_H__ */
  • code/trunk/src/orxonox/OrxonoxStableHeaders.h

    r1747 r1755  
    2828
    2929/**
    30  @file  OrxonoxStableHeaders.h
    31  @brief Contains the bigger (or smaller) header files in order to precompile them with MSVC
     30 @file
     31 @brief Contains the frequently used header files of our own writing
    3232 */
    3333
     
    3737#include "util/OrxonoxPlatform.h"
    3838
    39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     39#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH)
    4040
    4141// including std headers here is useless since they're already precompiled
     
    4545#  define WIN32_LEAN_AND_MEAN
    4646#endif
    47 // not including the entire Ogre.h doesn't exceed the default heap size for pch
    48 //#include <Ogre.h>
    49 #include <OgreBillboardSet.h>
    50 #include <OgreCamera.h>
    51 #include <OgreColourValue.h>
    52 #include <OgreConfigFile.h>
    53 #include <OgreEntity.h>
    54 #include <OgreException.h>
    55 #include <OgreFrameListener.h>
    56 #include <OgreLight.h>
    57 #include <OgreLog.h>
    58 #include <OgreLogManager.h>
    59 #include <OgreMath.h>
    60 #include <OgreMatrix3.h>
    61 #include <OgreMatrix4.h>
    62 #include <OgreMesh.h>
    63 #include <OgreOverlay.h>
    64 #include <OgreOverlayElement.h>
    65 #include <OgreOverlayManager.h>
    66 #include <OgreParticleEmitter.h>
    67 #include <OgreParticleSystem.h>
    68 #include <OgreQuaternion.h>
    69 #include <OgreResourceGroupManager.h>
    70 #include <OgreRenderWindow.h>
    71 #include <OgreRoot.h>
    72 #include <OgreSceneManager.h>
    73 #include <OgreSceneNode.h>
    74 #include <OgreString.h>
    75 #include <OgreStringConverter.h>
    76 #include <OgreTextureManager.h>
    77 #include <OgreTimer.h>
    78 #include <OgreVector2.h>
    79 #include <OgreVector3.h>
    80 #include <OgreVector3.h>
    81 #include <OgreViewport.h>
    82 #include <OgreWindowEventUtilities.h>
     47#include <Ogre.h>
     48#include <CEGUI.h>
     49#include <boost/thread/recursive_mutex.hpp>
     50#include <boost/thread/mutex.hpp>
     51#include <boost/thread/condition.hpp>
     52#include <boost/thread/thread.hpp>
    8353
    84 //-----------------------------------------------------------------------
    85 // ORXONOX HEADERS
    86 //-----------------------------------------------------------------------
    87 
    88 #include "ois/OIS.h"
    89 #include "cpptcl/CppTcl.h"
    9054#include "tinyxml/ticpp.h"
    9155#include "tinyxml/tinyxml.h"
     56
     57
     58//----------- Our files ----------
     59//--------------------------------
     60// only include when not debugging so that we may find issues with missing headers quicker
     61#if defined(NDEBUG)
    9262
    9363#include "util/Convert.h"
     
    10676#include "core/CoreIncludes.h"
    10777#include "core/ConfigValueIncludes.h"
     78#include "core/CommandExecutor.h"
    10879#include "core/Executor.h"
    10980#include "core/XMLPort.h"
     
    11788//#include "objects/WorldEntity.h"
    11889
    119 #endif /* Compiler MSVC */
     90#endif /* ifdef NDEBUG */
     91
     92#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
    12093
    12194#endif /* _OrxonoxStableHeaders_H__ */
  • code/trunk/src/orxonox/Radar.cc

    r1747 r1755  
    3434#include "OrxonoxStableHeaders.h"
    3535#include "Radar.h"
    36 #include <float.h>
     36#include <cfloat>
     37#include <cassert>
    3738#include "objects/WorldEntity.h"
    3839#include "objects/SpaceShip.h"
  • code/trunk/src/orxonox/RadarViewable.h

    r1747 r1755  
    3232#include "OrxonoxPrereqs.h"
    3333#include <string>
     34#include <cassert>
    3435#include "util/Math.h"
    3536#include "util/Debug.h"
  • code/trunk/src/orxonox/Settings.cc

    r1747 r1755  
    2828
    2929/**
    30     @file
    31     @brief Implementation of the Settings class.
     30@file
     31@brief
     32    Implementation of the Settings class.
    3233*/
    3334
     
    3536#include "Settings.h"
    3637
     38#include "util/String.h"
    3739#include "core/CoreIncludes.h"
    3840#include "core/ConfigValueIncludes.h"
     
    4042namespace orxonox
    4143{
    42   /**
    43     @brief Constructor: Registers the object and sets the config-values.
    44   */
    45   Settings::Settings()
    46   {
    47     RegisterRootObject(Settings);
    48     setConfigValues();
    49   }
     44    Settings* Settings::singletonRef_s = 0;
    5045
    51   Settings::~Settings()
    52   {
    53   }
    54 
    55   /**
    56     @brief Returns a unique instance of Core.
    57     @return The instance
    58   */
    59   Settings& Settings::getSingleton()
    60   {
    61     static Settings instance;
    62     return instance;
    63   }
    64 
    65   /**
    66     @brief Function to collect the SetConfigValue-macro calls.
    67   */
    68   void Settings::setConfigValues()
    69   {
    70     SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
    71   }
    72 
    73   /**
    74     @brief Callback function if the datapath has changed.
    75   */
    76   void Settings::dataPathChanged()
    77   {
    78     if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/')
     46    /**
     47    @brief
     48        Constructor: Registers the object and sets the config-values.
     49    */
     50    Settings::Settings()
     51        : bShowsGraphics_(false)
     52        , bHasServer_(false)
    7953    {
    80       ModifyConfigValue(dataPath_, set, dataPath_ + "/");
     54        RegisterRootObject(Settings);
     55        assert(singletonRef_s == 0);
     56        singletonRef_s = this;
     57        setConfigValues();
    8158    }
    8259
    83     if (dataPath_ == "")
     60    /**
     61    @brief
     62        Function to collect the SetConfigValue-macro calls.
     63    */
     64    void Settings::setConfigValues()
    8465    {
    85       ModifyConfigValue(dataPath_, set, "/");
    86       COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
     66        SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
    8767    }
    88   }
    8968
    90   /**
    91     @brief Temporary sets the data path
    92     @param path The new data path
    93   */
    94   void Settings::_tsetDataPath(const std::string& path)
    95   {
    96     ModifyConfigValue(dataPath_, tset, path);
    97   }
     69    /**
     70    @brief
     71        Callback function if the datapath has changed.
     72    */
     73    void Settings::dataPathChanged()
     74    {
     75        if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/')
     76        {
     77            ModifyConfigValue(dataPath_, set, dataPath_ + "/");
     78        }
    9879
    99   /*static*/ void Settings::tsetDataPath(const std::string& path)
    100   {
    101     getSingleton()._tsetDataPath(path);
    102   }
     80        if (dataPath_ == "")
     81        {
     82            ModifyConfigValue(dataPath_, set, "/");
     83            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
     84        }
     85    }
    10386
    104   /**
    105     @brief Returns the relative path to the game data.
    106     @return The path to the game data
    107   */
    108   /*static*/ const std::string& Settings::getDataPath()
    109   {
    110     return getSingleton().dataPath_;
    111   }
     87    /**
     88    @brief
     89        Temporary sets the data path
     90    @param path
     91        The new data path
     92    */
     93    void Settings::_tsetDataPath(const std::string& path)
     94    {
     95        ModifyConfigValue(dataPath_, tset, path);
     96    }
     97
    11298}
  • code/trunk/src/orxonox/Settings.h

    r1747 r1755  
    2929/**
    3030    @file Core.h
    31     @brief Definition of the Settings class.
     31    @brief Declaration of the Settings class.
    3232
    3333    The static Settings class is only used to configure some variables
     
    4141#include <string>
    4242#include "core/OrxonoxClass.h"
     43#include "util/Debug.h"
     44#include "util/MultiType.h"
     45#include "util/Convert.h"
    4346
    4447namespace orxonox
    4548{
    46   class _OrxonoxExport Settings : public OrxonoxClass
    47   {
     49    class _OrxonoxExport Settings : public OrxonoxClass
     50    {
     51        friend class ClassIdentifier<Settings>;
     52        friend class GSRoot;
     53        friend class GSGraphics;
     54        friend class GSServer;
     55        friend class GSDedicated;
     56
    4857    public:
    49       void setConfigValues();
    50       void dataPathChanged();
     58        static const std::string& getDataPath()
     59        { assert(singletonRef_s); return singletonRef_s->dataPath_; }
     60        static void tsetDataPath(const std::string& path)
     61        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
    5162
    52       static const std::string& getDataPath();
    53 
    54       static void tsetDataPath(const std::string& path);
     63        // an alternative to a global game mode variable
     64        static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }
     65        static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; }
    5566
    5667    private:
    57       Settings();
    58       Settings(const Settings& instance);
    59       ~Settings();
    60       static Settings& getSingleton();
     68        // GSRoot has access to these
     69        static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; }
     70        static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; }
    6171
    62       void _tsetDataPath(const std::string& path);
     72        Settings();
     73        Settings(const Settings& instance);
     74        ~Settings() { singletonRef_s = 0; }
    6375
    64       std::string dataPath_;               //!< Path to the game data
    65   };
     76        static Settings& _getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     77        void _tsetDataPath(const std::string& path);
     78        void dataPathChanged();
     79
     80        void setConfigValues();
     81
     82        bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
     83        bool bHasServer_;                                      //!< global variable that tells whether this is a server
     84
     85        std::string dataPath_;                                 //!< Path to the game data
     86
     87        static Settings* singletonRef_s;                       //!< Static pointer to the only instance.
     88    };
     89
    6690}
    6791
  • code/trunk/src/orxonox/SignalHandler.h

    r1747 r1755  
    2929/**
    3030    @file SignalHandler.h
    31     @brief Definition of the SignalHandler class.
     31    @brief Declaration of the SignalHandler class.
    3232*/
    3333
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r1724 r1755  
    5454        int serverPort = CommandLine::getArgument<int>("port")->getValue();
    5555        std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue();
    56         this->client_ = network::Client::createSingleton(serverIP, serverPort);
     56        this->client_ = new network::Client(serverIP, serverPort);
    5757
    5858        if(!client_->establishConnection())
     
    7373        client_->closeConnection();
    7474
    75         // TODO: destroy client
     75        // destroy client
     76        delete this->client_;
    7677
    7778        GSLevel::leave();
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r1724 r1755  
    7070
    7171        int serverPort = CommandLine::getArgument<int>("port")->getValue();
    72         this->server_ = network::Server::createSingleton(serverPort);
     72        this->server_ = new network::Server(serverPort);
    7373
    7474        // call the loader
     
    8282        FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    8383        functor->setObject(this);
    84         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor"));
     84        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8585    }
    8686
     
    9393
    9494        this->server_->close();
    95         // TODO: destroy server
     95        delete this->server_;
    9696
    9797        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
     
    103103    {
    104104        // Call those objects that need the real time
    105         for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     105        for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
    106106            it->tick(time.getDeltaTime());
    107107        // Call the scene objects
    108         for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
     108        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    109109            it->tick(time.getDeltaTime() * this->timeFactor_);
    110110
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r1724 r1755  
    4040#include <OgreWindowEventUtilities.h>
    4141
    42 #include "core/Debug.h"
     42#include "util/Debug.h"
    4343#include "core/ConsoleCommand.h"
    4444#include "core/ConfigValueIncludes.h"
     
    308308    void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
    309309    {
    310         for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
     310        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    311311            it->windowMoved();
    312312    }
     
    323323    void GSGraphics::windowResized(Ogre::RenderWindow *rw)
    324324    {
    325         for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
     325        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    326326            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    327327    }
     
    335335    void GSGraphics::windowFocusChanged(Ogre::RenderWindow *rw)
    336336    {
    337         for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
     337        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    338338            it->windowFocusChanged();
    339339    }
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r1724 r1755  
    8686        // reset game speed to normal
    8787        timeFactor_ = 1.0f;
     88
     89        // TODO: insert slomo console command with
     90        // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    8891    }
    8992
     
    111114    {
    112115        // Call those objects that need the real time
    113         for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     116        for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
    114117            it->tick(time.getDeltaTime());
    115118        // Call the scene objects
    116         for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
     119        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    117120            it->tick(time.getDeltaTime() * this->timeFactor_);
    118121
    119         for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; ++it)
     122        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
    120123            it->tick(time);
    121124    }
     
    129132        float change = factor / this->timeFactor_;
    130133        this->timeFactor_ = factor;
    131         for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     134        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    132135            it->setSpeedFactor(it->getSpeedFactor() * change);
    133136
    134         for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it)
     137        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    135138            it->setTimeFactor(timeFactor_);
    136139    }
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r1724 r1755  
    4040#include "core/ConsoleCommand.h"
    4141#include "core/CommandLine.h"
    42 #include "core/Debug.h"
     42#include "util/Debug.h"
    4343#include "core/Exception.h"
    4444#include "core/TclBind.h"
     
    9595    {
    9696#if ORXONOX_DEBUG_MODE == 1
    97         ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
     97        ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox_d.ini");
    9898#else
    99         ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
     99        ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox.ini");
    100100#endif
    101101
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r1724 r1755  
    5757
    5858        int serverPort = CommandLine::getArgument<int>("port")->getValue();
    59         this->server_ = network::Server::createSingleton(serverPort);
     59        this->server_ = new network::Server(serverPort);
     60        COUT(0) << "Loading scene in server mode" << std::endl;
    6061
    6162        this->loadLevel();
     
    6667        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    6768        functor->setObject(this);
    68         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor"));
     69        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    6970
    7071        // level is loaded: we can start capturing the input
     
    8182
    8283        this->server_->close();
    83         // TODO: destroy server
     84        delete this->server_;
    8485
    8586        GSLevel::leave();
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r1724 r1755  
    5353        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    5454        functor->setObject(this);
    55         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor"));
     55        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    5656
    5757        // level is loaded: we can start capturing the input
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r1724 r1755  
    5757namespace orxonox
    5858{
    59     SetConsoleCommandShortcut(GUIManager, showGUI_s).setKeybindMode(KeybindMode::OnPress);
     59    SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
    6060
    6161    GUIManager* GUIManager::singletonRef_s = 0;
  • code/trunk/src/orxonox/objects/Ambient.cc

    r1747 r1755  
    4343#include "core/XMLPort.h"
    4444#include "core/ConsoleCommand.h"
     45#include "Settings.h"
    4546#include "GraphicsEngine.h"
    4647
     
    6667    bool Ambient::create()
    6768    {
    68         GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
     69        if (Settings::showsGraphics())
     70            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_);
    6971        return Synchronisable::create();
    7072    }
     
    7779    void Ambient::setAmbientLight(const ColourValue& colour)
    7880    {
    79         GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
    80         ambientLight_=colour;
     81        if (Settings::showsGraphics())
     82            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour);
     83        ambientLight_ = colour;
    8184    }
    8285
    8386    /**
    84         @brief XML loading and saving.
    85         @param xmlelement The XML-element
    86         @param loading Loading (true) or saving (false)
    87         @return The XML-element
     87    @brief
     88        XML loading and saving.
     89    @param
     90        xmlelement The XML-element
     91    @param
     92        loading Loading (true) or saving (false)
     93    @return
     94        The XML-element
    8895    */
    8996    void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode)
  • code/trunk/src/orxonox/objects/Backlight.cc

    r1747 r1755  
    3232#include <OgreBillboard.h>
    3333#include <OgreRibbonTrail.h>
     34#include <OgreSceneManager.h>
    3435
    3536#include "core/CoreIncludes.h"
     
    3839#include "util/Math.h"
    3940#include "GraphicsEngine.h"
    40 #include "Orxonox.h"
    4141
    4242namespace orxonox
     
    5858        this->attachObject(this->billboard_.getBillboardSet());
    5959
    60         this->ribbonTrail_ = GraphicsEngine::getSingleton().getSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    61         this->ribbonTrailNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
     60        this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
     61        this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    6262        this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    6363        this->ribbonTrail_->addNode(this->getNode());
     
    6868        this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
    6969
    70         this->setTimeFactor(Orxonox::getSingleton()->getTimeFactor());
     70        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
     71        this->setTimeFactor(1.0f);
    7172    }
    7273
     
    7677        {
    7778            this->detachObject(this->billboard_.getBillboardSet());
    78             GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
    79             GraphicsEngine::getSingleton().getSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
     79            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
     80            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
    8081        }
    8182    }
  • code/trunk/src/orxonox/objects/Camera.cc

    r1747 r1755  
    5252  {
    5353    this->bHasFocus_ = false;
    54     this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
     54    this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
    5555    if( node != NULL )
    5656      this->setPositionNode(node);
     
    6060  {
    6161    CameraHandler::getInstance()->releaseFocus(this);
    62     GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
     62    GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
    6363  }
    6464
  • code/trunk/src/orxonox/objects/CameraHandler.cc

    r1505 r1755  
    4444  CameraHandler::CameraHandler()
    4545  {
    46     this->cam_ = GraphicsEngine::getSingleton().getSceneManager()->createCamera("Cam");
    47     GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
     46    this->cam_ = GraphicsEngine::getInstance().getLevelSceneManager()->createCamera("Cam");
     47    GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
     48    //GraphicsEngine::getInstance().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2);
    4849    /*this->activeCamera_ = *ObjectList<Camera>::begin();
    4950    this->activeCamera_->cam_ = this->cam_;*/
  • code/trunk/src/orxonox/objects/ParticleSpawner.cc

    r1608 r1755  
    3030#include "ParticleSpawner.h"
    3131
     32#include <OgreSceneManager.h>
    3233#include "core/CoreIncludes.h"
    3334#include "core/Executor.h"
     
    7980        this->setPosition(this->getNode()->getParent()->getPosition());
    8081        this->getNode()->getParent()->removeChild(this->getNode());
    81         GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->addChild(this->getNode());
     82        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode());
    8283        if (this->particle_)
    8384            this->particle_->setEnabled(false);
  • code/trunk/src/orxonox/objects/Skybox.cc

    r1747 r1755  
    3939#include "core/XMLPort.h"
    4040#include "util/Debug.h"
     41#include "Settings.h"
    4142
    4243namespace orxonox
     
    5657    void Skybox::setSkybox(const std::string& skyboxname)
    5758    {
    58         GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);
     59        if (Settings::showsGraphics())
     60            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skyboxname);
    5961    }
    6062
     
    8789    {
    8890        SUPER(Skybox, changedVisibility);
    89         GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
     91        if (Settings::showsGraphics())
     92            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
    9093    }
    9194}
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1751 r1755  
    4949#include "CameraHandler.h"
    5050#include "ParticleSpawner.h"
     51#include "Settings.h"
    5152#include "RotatingProjectile.h"
    5253#include "ParticleProjectile.h"
     
    7980      }
    8081      assert(0);
     82      return 0;
    8183    }
    8284
     
    194196    void SpaceShip::init()
    195197    {
    196         // START CREATING THRUSTERS
    197         this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
    198         this->tt1_->createNewEmitter();
    199         this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
    200         this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
    201         this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
    202         this->tt1_->setSpeedFactor(3.0);
    203 
    204         Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
    205         node2a->setInheritScale(false);
    206         node2a->setScale(1, 1, 1);
    207         tt1_->addToSceneNode(node2a);
    208 
    209         this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
    210         this->tt2_->createNewEmitter();
    211         this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
    212         this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
    213         this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
    214 
    215         Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
    216         node2b->setInheritScale(false);
    217         node2b->setScale(0.5, 0.5, 0.5);
    218         tt2_->addToSceneNode(node2b);
    219 
    220         this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
    221         this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
    222 
    223         Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
    224         node2c->setInheritScale(false);
    225         node2c->setScale(2, 2, 2);
    226         node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
    227         node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
    228         // END CREATING THRUSTERS
    229 
    230         // START CREATING BLINKING LIGHTS
    231         this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
    232         this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
    233 
    234         this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
    235         this->redNode_->setInheritScale(false);
    236         this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
    237         this->greenNode_->setInheritScale(false);
    238 
    239         this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
    240         this->redNode_->setScale(0.3, 0.3, 0.3);
    241 
    242         this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
    243         this->greenNode_->setScale(0.3, 0.3, 0.3);
    244         // END CREATING BLINKING LIGHTS
    245 
    246         // START CREATING ADDITIONAL EFFECTS
    247         /*if(!network::Host::running() || network::Host::isServer()){
    248           this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
    249           this->attachObject(this->backlight_);
    250           this->backlight_->setPosition(-2.35, 0, 0.2);
    251           this->backlight_->setColour(this->getProjectileColour());
    252    
    253           this->smoke_ = new ParticleSpawner();
    254           this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
    255           this->attachObject(this->smoke_);
    256    
    257           this->fire_ = new ParticleSpawner();
    258           this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
    259           this->attachObject(this->fire_);
    260         }*/
    261         // END CREATING ADDITIONAL EFFECTS
    262 
    263         if (this->isExactlyA(Class(SpaceShip)))
    264         {
    265             // START of testing crosshair
    266             this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    267             this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    268 
    269             this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
    270             this->chNearNode_->setInheritScale(false);
    271             this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
    272             this->chFarNode_->setInheritScale(false);
    273 
    274             this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    275             this->chNearNode_->setScale(0.2, 0.2, 0.2);
    276 
    277             this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    278             this->chFarNode_->setScale(0.4, 0.4, 0.4);
    279             // END of testing crosshair
     198        if (Settings::showsGraphics())
     199        {
     200            // START CREATING THRUSTERS
     201            this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
     202            this->tt1_->createNewEmitter();
     203            this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
     204            this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
     205            this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
     206            this->tt1_->setSpeedFactor(3.0);
     207
     208            Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
     209            node2a->setInheritScale(false);
     210            node2a->setScale(1, 1, 1);
     211            tt1_->addToSceneNode(node2a);
     212
     213            this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
     214            this->tt2_->createNewEmitter();
     215            this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
     216            this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
     217            this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
     218
     219            Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
     220            node2b->setInheritScale(false);
     221            node2b->setScale(0.5, 0.5, 0.5);
     222            tt2_->addToSceneNode(node2b);
     223
     224            this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
     225            this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
     226
     227            Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
     228            node2c->setInheritScale(false);
     229            node2c->setScale(2, 2, 2);
     230            node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
     231            node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
     232            // END CREATING THRUSTERS
     233
     234            // START CREATING BLINKING LIGHTS
     235            this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
     236            this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
     237
     238            this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
     239            this->redNode_->setInheritScale(false);
     240            this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
     241            this->greenNode_->setInheritScale(false);
     242
     243            this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
     244            this->redNode_->setScale(0.3, 0.3, 0.3);
     245
     246            this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
     247            this->greenNode_->setScale(0.3, 0.3, 0.3);
     248            // END CREATING BLINKING LIGHTS
     249
     250            // START CREATING ADDITIONAL EFFECTS
     251            /*this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
     252            this->attachObject(this->backlight_);
     253            this->backlight_->setPosition(-2.35, 0, 0.2);
     254            this->backlight_->setColour(this->getProjectileColour());
     255
     256            this->smoke_ = new ParticleSpawner();
     257            this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
     258            this->attachObject(this->smoke_);
     259
     260            this->fire_ = new ParticleSpawner();
     261            this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
     262            this->attachObject(this->fire_);
     263            */
     264            // END CREATING ADDITIONAL EFFECTS
     265
     266            if (this->isExactlyA(Class(SpaceShip)))
     267            {
     268                // START of testing crosshair
     269                this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     270                this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     271
     272                this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
     273                this->chNearNode_->setInheritScale(false);
     274                this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
     275                this->chFarNode_->setInheritScale(false);
     276
     277                this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
     278                this->chNearNode_->setScale(0.2, 0.2, 0.2);
     279
     280                this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
     281                this->chFarNode_->setScale(0.4, 0.4, 0.4);
     282                // END of testing crosshair
     283            }
    280284        }
    281285        // END of testing crosshair
     
    429433            this->cam_->tick(dt);
    430434
    431         if (this->smoke_)
    432             this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
    433         if (this->fire_)
    434             this->fire_->setVisible(this->isVisible() && this->health_ < 20);
    435 
    436         if (this->backlight_)
    437         {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
    438             if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
    439                 this->backlight_->setActive(false);
    440             else
    441                 this->backlight_->setActive(true);
    442         }
    443 
    444         if (this->redNode_ && this->greenNode_)
    445         {
    446             this->blinkTime_ += dt;
    447             float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
    448             float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
    449             this->redNode_->setScale(redScale, redScale, redScale);
    450             this->greenNode_->setScale(greenScale, greenScale, greenScale);
     435        if (Settings::showsGraphics())
     436        {
     437            if (this->smoke_)
     438                this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
     439            if (this->fire_)
     440                this->fire_->setVisible(this->isVisible() && this->health_ < 20);
     441
     442            if (this->backlight_)
     443            {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
     444                if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
     445                    this->backlight_->setActive(false);
     446                else
     447                    this->backlight_->setActive(true);
     448            }
     449
     450            if (this->redNode_ && this->greenNode_)
     451            {
     452                this->blinkTime_ += dt;
     453                float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
     454                float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
     455                this->redNode_->setScale(redScale, redScale, redScale);
     456                this->greenNode_->setScale(greenScale, greenScale, greenScale);
     457            }
    451458        }
    452459
  • code/trunk/src/orxonox/objects/SpaceShipAI.cc

    r1747 r1755  
    3939#include "core/XMLPort.h"
    4040#include "tools/ParticleInterface.h"
     41#include "Settings.h"
    4142
    4243#define ACTION_INTERVAL 1.0f
     
    102103            newenemy->XMLPort(xmlelement, XMLPort::LoadObject);
    103104
    104             ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth());
    105             spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50);
    106             spawneffect->create();
     105            if (Settings::showsGraphics())
     106            {
     107                ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth());
     108                spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50);
     109                spawneffect->create();
     110            }
    107111        }
    108112    }
     
    182186    void SpaceShipAI::kill()
    183187    {
    184         ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0);
    185         explosion->setPosition(this->getPosition());
    186         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    187         explosion->setScale(4);
    188         explosion->create();
    189 
    190         explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0);
    191         explosion->setPosition(this->getPosition());
    192         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    193         explosion->setScale(4);
    194         explosion->create();
    195         explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0);
    196         explosion->setPosition(this->getPosition());
    197         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    198         explosion->setScale(4);
    199         explosion->create();
    200 
    201         Vector3 ringdirection = Vector3(rnd(), rnd(), rnd());
    202         ringdirection.normalise();
    203         explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection);
    204         explosion->setPosition(this->getPosition());
    205         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    206         explosion->setScale(4);
    207         explosion->create();
    208         explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection);
    209         explosion->setPosition(this->getPosition());
    210         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    211         explosion->setScale(4);
    212         explosion->create();
     188        if (Settings::showsGraphics())
     189        {
     190            ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0);
     191            explosion->setPosition(this->getPosition());
     192            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     193            explosion->setScale(4);
     194            explosion->create();
     195
     196            explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0);
     197            explosion->setPosition(this->getPosition());
     198            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     199            explosion->setScale(4);
     200            explosion->create();
     201            explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0);
     202            explosion->setPosition(this->getPosition());
     203            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     204            explosion->setScale(4);
     205            explosion->create();
     206
     207            Vector3 ringdirection = Vector3(rnd(), rnd(), rnd());
     208            ringdirection.normalise();
     209            explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection);
     210            explosion->setPosition(this->getPosition());
     211            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     212            explosion->setScale(4);
     213            explosion->create();
     214            explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection);
     215            explosion->setPosition(this->getPosition());
     216            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     217            explosion->setScale(4);
     218            explosion->create();
     219        }
    213220
    214221        delete this;
  • code/trunk/src/orxonox/objects/Tickable.h

    r1747 r1755  
    2929/*!
    3030    @file Tickable.h
    31     @brief Definition of the Tickable interface.
     31    @brief Declaration of the Tickable interface.
    3232
    3333    The Tickable interface provides a tick(dt) function, that gets called every frame.
  • code/trunk/src/orxonox/objects/WorldEntity.cc

    r1747 r1755  
    3232#include <string>
    3333#include <sstream>
     34#include <OgreSceneManager.h>
    3435
    3536#include "tinyxml/tinyxml.h"
     
    4950        RegisterObject(WorldEntity);
    5051
    51         if (GraphicsEngine::getSingleton().getSceneManager())
     52        if (GraphicsEngine::getInstance().getLevelSceneManager())
    5253        {
    5354            std::ostringstream name;
    5455            name << (WorldEntity::worldEntityCounter_s++);
    5556            this->setName("WorldEntity" + name.str());
    56             this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
     57            this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
    5758
    5859            registerAllVariables();
     
    7778        {
    7879            this->getNode()->removeAndDestroyAllChildren();
    79             GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName());
     80            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName());
    8081        }
    8182    }
     
    177178    void WorldEntity::attachObject(const WorldEntity& obj) const
    178179    {
    179         GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
     180        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
    180181        this->getNode()->addChild(obj.getNode());
    181182    }
     
    183184    void WorldEntity::attachObject(WorldEntity* obj) const
    184185    {
    185         GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
     186        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
    186187        this->getNode()->addChild(obj->getNode());
    187188    }
  • code/trunk/src/orxonox/objects/WorldEntity.h

    r1747 r1755  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include <OgrePrerequisites.h>
    3334
    34 #include <OgreSceneManager.h>
    3535#include <OgreSceneNode.h>
    36 
    3736#include "util/Math.h"
    3837#include "util/XMLIncludes.h"
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r1747 r1755  
    115115            // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
    116116            // called automatically by the GraphicsEngine.
    117             this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
    118                 GraphicsEngine::getSingleton().getWindowHeight());
     117            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
     118                GraphicsEngine::getInstance().getWindowHeight());
    119119
    120120            this->changedVisibility();
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r1747 r1755  
    4646#include "core/ConsoleCommand.h"
    4747#include "core/input/InputManager.h"
     48#include "core/input/SimpleInputState.h"
     49#include "core/input/InputBuffer.h"
    4850#include "GraphicsEngine.h"
    4951
     
    5658    SetConsoleCommand(InGameConsole, closeConsole, true);
    5759
     60    InGameConsole* InGameConsole::singletonRef_s = 0;
     61
    5862    /**
    5963        @brief Constructor: Creates and initializes the InGameConsole.
    6064    */
    61     InGameConsole::InGameConsole() :
    62         consoleOverlay_(0), consoleOverlayContainer_(0),
    63         consoleOverlayNoise_(0), consoleOverlayCursor_(0), consoleOverlayBorder_(0),
    64         consoleOverlayTextAreas_(0)
     65    InGameConsole::InGameConsole()
     66        : consoleOverlay_(0)
     67        , consoleOverlayContainer_(0)
     68        , consoleOverlayNoise_(0)
     69        , consoleOverlayCursor_(0)
     70        , consoleOverlayBorder_(0)
     71        , consoleOverlayTextAreas_(0)
    6572    {
    6673        RegisterObject(InGameConsole);
     74
     75        assert(singletonRef_s == 0);
     76        singletonRef_s = this;
    6777
    6878        this->bActive_ = false;
     
    8292    InGameConsole::~InGameConsole(void)
    8393    {
    84         this->destroy();
    85     }
    86 
    87     /**
    88         @brief Returns a reference to the only existing instance of InGameConsole.
    89     */
    90     InGameConsole& InGameConsole::getInstance()
    91     {
    92         static InGameConsole instance;
    93         return instance;
    94     }
    95 
    96     /**
    97         @brief Sets the config values, describing the size of the console.
    98     */
    99     void InGameConsole::setConfigValues()
    100     {
    101         SetConfigValue(relativeWidth, 0.8);
    102         SetConfigValue(relativeHeight, 0.4);
    103         SetConfigValue(blinkTime, 0.5);
    104         SetConfigValue(scrollSpeed_, 3.0f);
    105         SetConfigValue(noiseSize_, 1.0f);
    106         SetConfigValue(cursorSymbol_, '|');
    107     }
    108 
    109     /**
    110         @brief Initializes the InGameConsole.
    111     */
    112     void InGameConsole::initialise()
    113     {
    114         // create overlay and elements
    115         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    116 
    117         // create actual overlay
    118         this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
    119 
    120         // create a container
    121         this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
    122         this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
    123         this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
    124         this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
    125         this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
    126 
    127         // create BorderPanel
    128         this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
    129         this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
    130         this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
    131         this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
    132         this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
    133         this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
    134         this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
    135         this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
    136         this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
    137         this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
    138         this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
    139 
    140         // create a new font to match the requested size exactly
    141         Ogre::FontPtr font = static_cast<Ogre::FontPtr>
    142             (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
    143         font->setType(Ogre::FT_TRUETYPE);
    144         font->setSource("Monofur.ttf");
    145         font->setTrueTypeSize(18);
    146         // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
    147         font->setTrueTypeResolution(192);
    148         font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
    149         font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
    150 
    151         // create the text lines
    152         this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
    153         for (int i = 0; i < LINES; i++)
    154         {
    155             this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
    156             this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
    157             this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
    158             this->consoleOverlayTextAreas_[i]->setCharHeight(18);
    159             this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
    160             this->consoleOverlayTextAreas_[i]->setLeft(8);
    161             this->consoleOverlayTextAreas_[i]->setCaption("");
    162             this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
    163         }
    164 
    165         // create cursor (also a text area overlay element)
    166         this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
    167         this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
    168         this->consoleOverlayCursor_->setFontName("MonofurConsole");
    169         this->consoleOverlayCursor_->setCharHeight(18);
    170         this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
    171         this->consoleOverlayCursor_->setLeft(7);
    172         this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
    173         this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
    174 
    175         // create noise
    176         this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
    177         this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
    178         this->consoleOverlayNoise_->setPosition(5,0);
    179         this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
    180         // comment following line to disable noise
    181         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    182 
    183         this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
    184 
    185         // move overlay "above" the top edge of the screen
    186         // we take -1.2 because the border makes the panel bigger
    187         this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
    188 
    189         Shell::getInstance().addOutputLevel(true);
    190 
    191         COUT(4) << "Info: InGameConsole initialized" << std::endl;
    192     }
    193 
    194     /**
    195         @brief Destroys all the elements if necessary.
    196     */
    197     void InGameConsole::destroy()
    198     {
     94        this->deactivate();
     95
     96        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
     97        InputManager::getInstance().requestDestroyState("console");
     98
    19999        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    200100        if (ovMan)
     
    224124            this->consoleOverlayTextAreas_ = 0;
    225125        }
     126
     127        singletonRef_s = 0;
     128    }
     129
     130    /**
     131        @brief Sets the config values, describing the size of the console.
     132    */
     133    void InGameConsole::setConfigValues()
     134    {
     135        SetConfigValue(relativeWidth, 0.8);
     136        SetConfigValue(relativeHeight, 0.4);
     137        SetConfigValue(blinkTime, 0.5);
     138        SetConfigValue(scrollSpeed_, 3.0f);
     139        SetConfigValue(noiseSize_, 1.0f);
     140        SetConfigValue(cursorSymbol_, '|');
     141    }
     142
     143    /**
     144        @brief Initializes the InGameConsole.
     145    */
     146    void InGameConsole::initialise()
     147    {
     148        // create the corresponding input state
     149        InputManager::getInstance().createInputState<SimpleInputState>("console", 40)
     150            ->setKeyHandler(Shell::getInstance().getInputBuffer());
     151
     152        // create overlay and elements
     153        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     154
     155        // create actual overlay
     156        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
     157
     158        // create a container
     159        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
     160        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
     161        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
     162        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
     163        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
     164
     165        // create BorderPanel
     166        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
     167        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
     168        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
     169        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
     170        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
     171        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
     172        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
     173        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
     174        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
     175        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
     176        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
     177
     178        // create a new font to match the requested size exactly
     179        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
     180            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
     181        font->setType(Ogre::FT_TRUETYPE);
     182        font->setSource("Monofur.ttf");
     183        font->setTrueTypeSize(18);
     184        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
     185        font->setTrueTypeResolution(192);
     186        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
     187        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
     188
     189        // create the text lines
     190        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
     191        for (int i = 0; i < LINES; i++)
     192        {
     193            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
     194            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
     195            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
     196            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
     197            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
     198            this->consoleOverlayTextAreas_[i]->setLeft(8);
     199            this->consoleOverlayTextAreas_[i]->setCaption("");
     200            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
     201        }
     202
     203        // create cursor (also a text area overlay element)
     204        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
     205        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
     206        this->consoleOverlayCursor_->setFontName("MonofurConsole");
     207        this->consoleOverlayCursor_->setCharHeight(18);
     208        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
     209        this->consoleOverlayCursor_->setLeft(7);
     210        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
     211        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
     212
     213        // create noise
     214        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
     215        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
     216        this->consoleOverlayNoise_->setPosition(5,0);
     217        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
     218        // comment following line to disable noise
     219        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
     220
     221        this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
     222
     223        // move overlay "above" the top edge of the screen
     224        // we take -1.2 because the border makes the panel bigger
     225        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
     226
     227        Shell::getInstance().addOutputLevel(true);
     228
     229        COUT(4) << "Info: InGameConsole initialized" << std::endl;
    226230    }
    227231
     
    453457                if (output.size() > this->maxCharsPerLine_)
    454458                {
    455                     if (Shell::getInstance().getInputBuffer().getCursorPosition() < this->inputWindowStart_)
    456                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition();
    457                     else if (Shell::getInstance().getInputBuffer().getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
    458                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition() - this->maxCharsPerLine_ + 1;
     459                    if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
     460                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
     461                    else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
     462                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
    459463
    460464                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
     
    476480        {
    477481            this->bActive_ = true;
    478             InputManager::setInputState(InputManager::IS_CONSOLE);
     482            InputManager::getInstance().requestEnterState("console");
    479483            Shell::getInstance().registerListener(this);
    480484
     
    498502        {
    499503            this->bActive_ = false;
    500             InputManager::setInputState(InputManager::IS_NORMAL);
     504            InputManager::getInstance().requestLeaveState("console");
    501505            Shell::getInstance().unregisterListener(this);
    502506
  • code/trunk/src/orxonox/overlays/console/InGameConsole.h

    r1747 r1755  
    3737
    3838#include "core/Shell.h"
    39 #include "objects/Tickable.h"
     39#include "core/OrxonoxClass.h"
    4040#include "tools/WindowEventListener.h"
    4141
     
    4343namespace orxonox
    4444{
    45     class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener
     45    class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener
    4646    {
    47         public: // functions
    48             void initialise();
    49             void destroy();
    50             void setConfigValues();
     47    public: // functions
     48        InGameConsole();
     49        ~InGameConsole();
    5150
    52             virtual void tick(float dt);
     51        void initialise();
     52        void destroy();
     53        void setConfigValues();
    5354
    54             static InGameConsole& getInstance();
     55        virtual void tick(float dt);
    5556
    56             static void openConsole();
    57             static void closeConsole();
     57        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     58        static InGameConsole* getInstancePtr() { return singletonRef_s; }
    5859
    59         private: // functions
    60             InGameConsole();
    61             InGameConsole(const InGameConsole& other) {}
    62             ~InGameConsole();
     60        static void openConsole();
     61        static void closeConsole();
    6362
    64             void activate();
    65             void deactivate();
     63    private: // functions
     64        InGameConsole(const InGameConsole& other) {}
    6665
    67             void linesChanged();
    68             void onlyLastLineChanged();
    69             void lineAdded();
    70             void inputChanged();
    71             void cursorChanged();
    72             void exit();
     66        void activate();
     67        void deactivate();
    7368
    74             void shiftLines();
    75             void colourLine(int colourcode, int index);
    76             void setCursorPosition(unsigned int pos);
    77             void print(const std::string& text, int index, bool alwaysShift = false);
     69        void linesChanged();
     70        void onlyLastLineChanged();
     71        void lineAdded();
     72        void inputChanged();
     73        void cursorChanged();
     74        void exit();
    7875
    79             void windowResized(int newWidth, int newHeight);
     76        void shiftLines();
     77        void colourLine(int colourcode, int index);
     78        void setCursorPosition(unsigned int pos);
     79        void print(const std::string& text, int index, bool alwaysShift = false);
    8080
    81             static Ogre::UTFString convert2UTF(std::string s);
     81        void windowResized(int newWidth, int newHeight);
    8282
    83         private: // variables
    84             bool bActive_;
    85             int windowW_;
    86             int windowH_;
    87             int desiredTextWidth_;
    88             unsigned int maxCharsPerLine_;
    89             unsigned int numLinesShifted_;
    90             int scroll_;
    91             float cursor_;
    92             unsigned int inputWindowStart_;
    93             bool bShowCursor_;
    94             std::string displayedText_;
    95             Ogre::Overlay* consoleOverlay_;
    96             Ogre::OverlayContainer* consoleOverlayContainer_;
    97             Ogre::PanelOverlayElement* consoleOverlayNoise_;
    98             Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
    99             Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
    100             Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
     83        static Ogre::UTFString convert2UTF(std::string s);
    10184
    102             // config values
    103             float relativeWidth;
    104             float relativeHeight;
    105             float blinkTime;
    106             float scrollSpeed_;
    107             float noiseSize_;
    108             char cursorSymbol_;
     85    private: // variables
     86        bool bActive_;
     87        int windowW_;
     88        int windowH_;
     89        int desiredTextWidth_;
     90        unsigned int maxCharsPerLine_;
     91        unsigned int numLinesShifted_;
     92        int scroll_;
     93        float cursor_;
     94        unsigned int inputWindowStart_;
     95        bool bShowCursor_;
     96        std::string displayedText_;
     97        Ogre::Overlay* consoleOverlay_;
     98        Ogre::OverlayContainer* consoleOverlayContainer_;
     99        Ogre::PanelOverlayElement* consoleOverlayNoise_;
     100        Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
     101        Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
     102        Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
     103
     104        // config values
     105        float relativeWidth;
     106        float relativeHeight;
     107        float blinkTime;
     108        float scrollSpeed_;
     109        float noiseSize_;
     110        char cursorSymbol_;
     111
     112        static InGameConsole* singletonRef_s;
    109113    };
    110114}
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

    r1625 r1755  
    4949    void DebugFPSText::tick(float dt)
    5050    {
    51         float fps = GraphicsEngine::getSingleton().getAverageFramesPerSecond();
     51        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5252        this->text_->setCaption(this->getCaption() + convertToString(fps));
    5353    }
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc

    r1625 r1755  
    4949    void DebugRTRText::tick(float dt)
    5050    {
    51         float rtr = GraphicsEngine::getSingleton().getAverageTickTime();
     51        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5252        this->text_->setCaption(this->getCaption() + convertToString(rtr));
    5353    }
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r1626 r1755  
    5454            float v = ship->getVelocity().length();
    5555            float value = v / ship->getMaxSpeed();
    56                         if (value != this->getValue())
     56            if (value != this->getValue())
    5757                this->setValue(value);
    5858        }
  • code/trunk/src/orxonox/tolua/tolua.pkg

    r1505 r1755  
     1$cfile "../../src/orxonox/gui/GUIManager.h"
  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r1602 r1755  
    5050        std::ostringstream name;
    5151        name << (BillboardSet::billboardSetCounter_s++);
    52         this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     52        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    5353        this->billboardSet_->createBillboard(Vector3::ZERO);
    5454        this->billboardSet_->setMaterialName(file);
     
    5959        std::ostringstream name;
    6060        name << (BillboardSet::billboardSetCounter_s++);
    61         this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     61        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    6262        this->billboardSet_->createBillboard(Vector3::ZERO, colour);
    6363        this->billboardSet_->setMaterialName(file);
     
    6868        std::ostringstream name;
    6969        name << (BillboardSet::billboardSetCounter_s++);
    70         this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     70        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    7171        this->billboardSet_->createBillboard(position);
    7272        this->billboardSet_->setMaterialName(file);
     
    7777        std::ostringstream name;
    7878        name << (BillboardSet::billboardSetCounter_s++);
    79         this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     79        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    8080        this->billboardSet_->createBillboard(position, colour);
    8181        this->billboardSet_->setMaterialName(file);
     
    8585    {
    8686        if (this->billboardSet_)
    87             GraphicsEngine::getSingleton().getSceneManager()->destroyBillboardSet(this->billboardSet_);
     87            GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
    8888    }
    8989}
  • code/trunk/src/orxonox/tools/Light.cc

    r1505 r1755  
    4949        std::ostringstream name;
    5050        name << (Light::lightCounter_s++);
    51         this->light_ = GraphicsEngine::getSingleton().getSceneManager()->createLight("Light" + name.str());
     51        this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str());
    5252        this->light_->setType(type);
    5353        this->light_->setDiffuseColour(diffuse);
     
    5858    {
    5959        if (this->light_)
    60             GraphicsEngine::getSingleton().getSceneManager()->destroyLight(this->light_);
     60            GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_);
    6161    }
    6262}
  • code/trunk/src/orxonox/tools/Mesh.cc

    r1505 r1755  
    3131
    3232#include <sstream>
    33 
    3433#include <OgreSceneManager.h>
    35 
    3634#include "GraphicsEngine.h"
     35#include "Settings.h"
    3736
    3837namespace orxonox
     
    4948        std::ostringstream name;
    5049        name << (Mesh::meshCounter_s++);
    51         this->entity_ = GraphicsEngine::getSingleton().getSceneManager()->createEntity("Mesh" + name.str(), file);
     50        if (Settings::showsGraphics())
     51            this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
    5252    }
    5353
    5454    Mesh::~Mesh()
    5555    {
    56         if (this->entity_)
    57             GraphicsEngine::getSingleton().getSceneManager()->destroyEntity(this->entity_);
     56        if (this->entity_ && Settings::showsGraphics())
     57            GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
    5858    }
    5959}
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r1563 r1755  
    3939
    4040#include "GraphicsEngine.h"
    41 #include "Orxonox.h"
    4241#include "core/CoreIncludes.h"
    4342#include "util/Convert.h"
     
    5554    this->bEnabled_ = true;
    5655    this->detaillevel_ = (unsigned int)detaillevel;
    57     this->particleSystem_ = GraphicsEngine::getSingleton().getSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    58     this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor());
     56    this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     57    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     58    this->particleSystem_->setSpeedFactor(1.0f);
    5959
    60     if (GraphicsEngine::getSingleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
     60    if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
    6161    {
    6262      this->bVisible_ = false;
     
    7272  {
    7373    this->particleSystem_->removeAllEmitters();
    74     GraphicsEngine::getSingleton().getSceneManager()->destroyParticleSystem(particleSystem_);
     74    GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
    7575  }
    7676
     
    171171  void ParticleInterface::setSpeedFactor(float factor)
    172172  {
    173     this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor() * factor);
     173    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
     174    this->particleSystem_->setSpeedFactor(1.0f * factor);
    174175  }
    175176  float ParticleInterface::getSpeedFactor() const
    176177  {
    177     return (this->particleSystem_->getSpeedFactor() / Orxonox::getSingleton()->getTimeFactor());
     178    //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
     179    return (this->particleSystem_->getSpeedFactor() / 1.0f);
    178180  }
    179181
  • code/trunk/src/orxonox/tools/Timer.cc

    r1552 r1755  
    3636#include "core/ConsoleCommand.h"
    3737#include "core/CommandExecutor.h"
     38#include "core/Clock.h"
    3839
    3940namespace orxonox
     
    125126        @brief Updates the timer before the frames are rendered.
    126127    */
    127     void TimerBase::tick(float dt)
     128    void TimerBase::tick(const Clock& time)
    128129    {
    129130        if (this->bActive_)
    130131        {
    131132            // If active: Decrease the timer by the duration of the last frame
    132             this->time_ -= dt;
     133            this->time_ -= time.getDeltaTimeMicroseconds();
    133134
    134135            if (this->time_ <= 0)
  • code/trunk/src/orxonox/tools/Timer.h

    r1608 r1755  
    6262
    6363#include "OrxonoxPrereqs.h"
    64 #include "objects/Tickable.h"
     64#include "core/OrxonoxClass.h"
    6565
    6666namespace orxonox
     
    7272
    7373    //! TimerBase is the parent of the Timer class.
    74     class _OrxonoxExport TimerBase : public Tickable
     74    class _OrxonoxExport TimerBase : public OrxonoxClass
    7575    {
    7676        public:
     
    9797            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
    9898            inline float getRemainingTime() const
    99                 { return this->time_; }
     99                { return (float)this->time_ / 1000000.0f; }
    100100            /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
    101101            inline void addTime(float time)
    102                 { this->time_ += time; }
     102                { if (time > 0.0f) this->time_ += (long long)(time * 1000000.0f); }
    103103            /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
    104104            inline void removeTime(float time)
    105                 { this->time_ -= time; }
     105                { if (time > 0.0f) this->time_ -= (long long)(time * 1000000.0f); }
    106106            /** @brief Sets the interval of the Timer. @param interval The interval */
    107107            inline void setInterval(float interval)
    108                 { this->interval_ = interval; }
     108                { this->interval_ = (long long)(interval * 1000000.0f); }
    109109            /** @brief Sets bLoop to a given value. @param bLoop True = loop */
    110110            inline void setLoop(bool bLoop)
    111111                { this->bLoop_ = bLoop; }
    112112
    113             void tick(float dt);
     113            void tick(const Clock& time);
    114114
    115115        protected:
     
    118118            Executor* executor_; //!< The executor of the function that should be called when the time expires
    119119
    120             float interval_;     //!< The time-interval in seconds
     120            long long interval_; //!< The time-interval in micro seconds
    121121            bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
    122122            bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
    123123
    124             float time_;         //!< Internal variable, counting the time till the next function-call
     124            long long time_;     //!< Internal variable, counting the time till the next function-call
    125125    };
    126126
     
    155155                this->deleteExecutor();
    156156
    157                 this->interval_ = interval;
     157                this->setInterval(interval);
    158158                this->bLoop_ = bLoop;
    159159                executor->setObject(object);
     
    161161                this->bActive_ = true;
    162162
    163                 this->time_ = interval;
     163                this->time_ = this->interval_;
    164164            }
    165165    };
     
    193193                this->deleteExecutor();
    194194
    195                 this->interval_ = interval;
     195                this->setInterval(interval);
    196196                this->bLoop_ = bLoop;
    197197                this->executor_ = (Executor*)executor;
    198198                this->bActive_ = true;
    199199
    200                 this->time_ = interval;
     200                this->time_ = this->interval_;
    201201            }
    202202    };
  • code/trunk/src/orxonox/tools/WindowEventListener.h

    r1625 r1755  
    4545        virtual ~WindowEventListener() { }
    4646
    47                     /** Window has moved position */
    48                     virtual void windowMoved() { }
     47            /** Window has moved position */
     48            virtual void windowMoved() { }
    4949
    50                     /** Window has resized */
    51                     virtual void windowResized(int newWidth, int newHeight) { }
     50            /** Window has resized */
     51            virtual void windowResized(int newWidth, int newHeight) { }
    5252
    53                     /** Window has lost/gained focus */
    54                     virtual void windowFocusChanged() { }
     53            /** Window has lost/gained focus */
     54            virtual void windowFocusChanged() { }
    5555    };
    5656}
Note: See TracChangeset for help on using the changeset viewer.