Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 27, 2008, 10:56:51 PM (16 years ago)
Author:
rgrieder
Message:
  • Added support for dedicated server. Could not network test it yet, client still segfaults me.
  • Also kicked GraphicsEngine::levelSceneManager_, there are only the statistic methods left.
  • GSDedicated also derives from GSLevel, but GSLevel is not anymore a real GameState.
  • CameraHandler and LevelManager get created in GSLevel now.
Location:
code/branches/objecthierarchy/src/orxonox
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/GraphicsEngine.cc

    r1755 r2023  
    6868    */
    6969    GraphicsEngine::GraphicsEngine()
    70         : root_(0)
    71         , renderWindow_(0)
    72         , levelSceneManager_(0)
    73         , viewport_(0)
     70//        : root_(0)
     71//        , renderWindow_(0)
     72//        , viewport_(0)
    7473    {
    7574        RegisterObject(GraphicsEngine);
     
    103102        singletonRef_s = 0;
    104103    }
    105 
    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
    113     {
    114         if (this->renderWindow_)
    115             return this->renderWindow_->getWidth();
    116         else
    117             return 0;
    118     }
    119 
    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
    127     {
    128         if (this->renderWindow_)
    129             return this->renderWindow_->getHeight();
    130         else
    131             return 0;
    132     }
    133 
    134     /**
    135     @brief
    136         Returns the window aspect ratio height/width.
    137     @return
    138         The window aspect ratio
    139     */
    140     float GraphicsEngine::getWindowAspectRatio() const
    141     {
    142         if (this->renderWindow_)
    143             return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
    144         else
    145             return 1.0f;
    146     }
    147104}
  • code/branches/objecthierarchy/src/orxonox/GraphicsEngine.h

    r1755 r2023  
    6161        void detailLevelParticleChanged();
    6262
    63         void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
    64         Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
    65 
    66         Ogre::Viewport* getViewport() { return this->viewport_; }
    67         Ogre::Root*     getOgreRoot() { return this->root_; }
    68 
    69         // several window properties
    70         int getWindowWidth() const;
    71         int getWindowHeight() const;
    72         float getWindowAspectRatio() const;
    7363        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
    7464        float getAverageTickTime() const          { return this->avgTickTime_; }
     
    8676        GraphicsEngine(GraphicsEngine&);
    8777
    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
    92 
    9378        // stats
    9479        float               avgTickTime_;           //!< time in ms to tick() one frame
  • code/branches/objecthierarchy/src/orxonox/LevelManager.cc

    r2019 r2023  
    3838namespace orxonox
    3939{
     40    LevelManager* LevelManager::singletonRef_s = 0;
     41
    4042    LevelManager::LevelManager()
    4143    {
    4244        RegisterRootObject(LevelManager);
    4345
     46        assert(singletonRef_s == 0);
     47        singletonRef_s = this;
     48
    4449        this->getConnectedClients();
    4550    }
    4651
    47     LevelManager& LevelManager::getInstance()
     52    LevelManager::~LevelManager()
    4853    {
    49         static LevelManager instance;
    50         return instance;
     54        assert(singletonRef_s != 0);
     55        singletonRef_s = 0;
    5156    }
    5257
  • code/branches/objecthierarchy/src/orxonox/LevelManager.h

    r2019 r2023  
    3434#include <list>
    3535#include <map>
     36#include <cassert>
    3637
    3738#include "network/ClientConnectionListener.h"
     
    4243    {
    4344        public:
    44             static LevelManager& getInstance();
     45            LevelManager();
     46            virtual ~LevelManager();
    4547
    4648            void requestActivity(Level* level);
     
    5254                { return this->clients_; }
    5355
     56            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     57
    5458        private:
    55             LevelManager();
    56             virtual ~LevelManager() {}
     59            LevelManager(const LevelManager&);
    5760
    5861            void clientConnected(unsigned int clientID);
     
    6366            std::list<Level*> levels_s;
    6467            std::map<unsigned int, PlayerInfo*> clients_;
     68
     69            static LevelManager* singletonRef_s;
    6570    };
    6671}
  • code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h

    r2019 r2023  
    8080    class RadarListener;
    8181
     82    class CameraHandler;
    8283    class LevelManager;
    8384
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc

    r2004 r2023  
    4040
    4141    GSClient::GSClient()
    42         : GSLevel("client")
     42        : GameState<GSGraphics>("client")
    4343        , client_(0)
    4444    {
     
    5353        Core::setIsClient(true);
    5454
    55         GSLevel::enter();
    56 
    5755        this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
    5856
     
    6058            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    6159
     60        GSLevel::enter(this->getParent()->getViewport());
     61
    6262        client_->tick(0);
    63 
    64         // level is loaded: we can start capturing the input
    65         InputManager::getInstance().requestEnterState("game");
    6663    }
    6764
    6865    void GSClient::leave()
    6966    {
    70         InputManager::getInstance().requestLeaveState("game");
    71 
    72         // TODO: How do we unload the level in client mode?
     67        GSLevel::leave();
    7368
    7469        client_->closeConnection();
     
    7671        // destroy client
    7772        delete this->client_;
    78 
    79         GSLevel::leave();
    8073
    8174        Core::setIsClient(false);
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.h

    r1755 r2023  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSClient : public GSLevel
     39    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc

    r2010 r2023  
    3030#include "GSDedicated.h"
    3131
    32 #include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
    34 #include "core/ConsoleCommand.h"
    3532#include "core/CommandLine.h"
    36 #include "core/Loader.h"
    37 #include "core/XMLFile.h"
    3833#include "core/Core.h"
    3934#include "network/Server.h"
    40 #include "objects/Tickable.h"
    41 #include "Settings.h"
    42 #include "GraphicsEngine.h"
    4335
    4436namespace orxonox
     
    4638    GSDedicated::GSDedicated()
    4739        : GameState<GSRoot>("dedicated")
    48         , timeFactor_(0)
    4940        , server_(0)
    50         , sceneManager_(0)
    51         , startFile_(0)
    5241    {
    5342    }
     
    6150        Core::setHasServer(true);
    6251
    63         // create Ogre SceneManager for the level
    64         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    65         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
     52        this->server_ = new network::Server(CommandLine::getValue("port"));
     53        COUT(0) << "Loading scene in server mode" << std::endl;
    6654
    67         // temporary hack
    68         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    69 
    70         // reset game speed to normal
    71         timeFactor_ = 1.0f;
    72 
    73         this->server_ = new network::Server(CommandLine::getValue("port"));
    74 
    75         // call the loader
    76         COUT(0) << "Loading level..." << std::endl;
    77         startFile_ = new XMLFile(Settings::getDataPath() + "levels/sample.oxw");
    78         Loader::open(startFile_);
     55        GSLevel::enter(0);
    7956
    8057        server_->open();
    81 
    82         // add console commands
    83         FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    84         functor->setObject(this);
    85         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8658    }
    8759
    8860    void GSDedicated::leave()
    8961    {
    90         // TODO: Remove and destroy console command
    91 
    92         Loader::unload(startFile_);
    93         delete this->startFile_;
     62        GSLevel::leave();
    9463
    9564        this->server_->close();
    9665        delete this->server_;
    97 
    98         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    9966
    10067        Core::setHasServer(false);
     
    10370    void GSDedicated::ticked(const Clock& time)
    10471    {
    105         // Call the scene objects
    106         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    107             it->tick(time.getDeltaTime() * this->timeFactor_);
    108 
     72        GSLevel::ticked(time);
    10973        server_->tick(time.getDeltaTime());
    11074        this->tickChild(time);
    11175    }
    112 
    113     /**
    114     @brief
    115         Changes the speed of Orxonox
    116     */
    117     void GSDedicated::setTimeFactor(float factor)
    118     {
    119         this->timeFactor_ = factor;
    120     }
    12176}
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.h

    r2010 r2023  
    3232#include "OrxonoxPrereqs.h"
    3333#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
    3435#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSDedicated : public GameState<GSRoot>
     39    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
    3940    {
    4041    public:
    4142        GSDedicated();
    4243        ~GSDedicated();
    43 
    44         void setTimeFactor(float factor);
    45         float getTimeFactor() { return this->timeFactor_; }
    4644
    4745    private:
     
    5048        void ticked(const Clock& time);
    5149
    52         void loadLevel();
    53         void unloadLevel();
    54 
    55         float                 timeFactor_;       //!< A factor to change the gamespeed
    5650        network::Server*      server_;
    57         Ogre::SceneManager*   sceneManager_;
    58         XMLFile*              startFile_;        //!< current hard coded default level
    5951    };
    6052}
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSGUI.cc

    r1755 r2023  
    3131
    3232#include <OgreViewport.h>
    33 #include "GraphicsEngine.h"
    3433#include "core/input/InputManager.h"
    3534#include "core/input/SimpleInputState.h"
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc

    r2013 r2023  
    116116
    117117        // HACK: temporary:
    118         graphicsEngine_->renderWindow_  = this->renderWindow_;
    119         graphicsEngine_->root_          = this->ogreRoot_;
    120         graphicsEngine_->viewport_      = this->viewport_;
     118        //graphicsEngine_->renderWindow_  = this->renderWindow_;
     119        //graphicsEngine_->root_          = this->ogreRoot_;
     120        //graphicsEngine_->viewport_      = this->viewport_;
    121121
    122122
     
    134134        // Load the InGameConsole
    135135        console_ = new InGameConsole();
    136         console_->initialise();
     136        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    137137
    138138        // load the CEGUI interface
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSIOConsole.cc

    r2013 r2023  
    3636
    3737#include "core/ConsoleCommand.h"
    38 #include "GraphicsEngine.h"
    3938
    4039namespace orxonox
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc

    r2010 r2023  
    3030#include "GSLevel.h"
    3131
    32 #include <OgreSceneManager.h>
    33 #include <OgreRoot.h>
    3432#include "core/input/InputManager.h"
    3533#include "core/input/SimpleInputState.h"
     
    4139#include "core/ConfigValueIncludes.h"
    4240#include "core/CoreIncludes.h"
     41#include "core/Core.h"
    4342//#include "objects/Backlight.h"
     43#include "objects/CameraHandler.h"
    4444#include "objects/Tickable.h"
    4545#include "objects/Radar.h"
    4646//#include "tools/ParticleInterface.h"
    47 #include "GraphicsEngine.h"
     47#include "LevelManager.h"
    4848#include "Settings.h"
    4949
    5050namespace orxonox
    5151{
    52     GSLevel::GSLevel(const std::string& name)
    53         : GameState<GSGraphics>(name)
    54         , timeFactor_(1.0f)
    55         , sceneManager_(0)
     52    GSLevel::GSLevel()
     53//        : GameState<GSGraphics>(name)
     54        : timeFactor_(1.0f)
    5655        , keyBinder_(0)
    5756        , inputState_(0)
    5857        , radar_(0)
    5958        , startFile_(0)
     59        , cameraHandler_(0)
     60        , levelManager_(0)
    6061    {
    6162        RegisterObject(GSLevel);
     
    7273    }
    7374
    74     void GSLevel::enter()
    75     {
    76         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
    77         keyBinder_ = new KeyBinder();
    78         keyBinder_->loadBindings("keybindings.ini");
    79         inputState_->setHandler(keyBinder_);
    80 
    81         // create Ogre SceneManager for the level
    82         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    83         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
    84 
    85         this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
    86 
    87         // temporary hack
    88         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    89 
    90         // Start the Radar
    91         this->radar_ = new Radar();
    92 
    93         // reset game speed to normal
    94         timeFactor_ = 1.0f;
    95 
    96         // TODO: insert slomo console command with
    97         // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    98 
    99         // keybind console command
    100         FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    101         functor1->setObject(this);
    102         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
    103         FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    104         functor2->setObject(this);
    105         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
    106         // set our console command as callback for the key detector
    107         InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     75    void GSLevel::enter(Ogre::Viewport* viewport)
     76    {
     77        if (Core::showsGraphics())
     78        {
     79            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
     80            keyBinder_ = new KeyBinder();
     81            keyBinder_->loadBindings("keybindings.ini");
     82            inputState_->setHandler(keyBinder_);
     83
     84            // create the global CameraHandler
     85            assert(viewport);
     86            this->cameraHandler_ = new CameraHandler(viewport);
     87
     88            // Start the Radar
     89            this->radar_ = new Radar();
     90        }
     91
     92        if (Core::isMaster())
     93        {
     94            // create the global LevelManager
     95            this->levelManager_ = new LevelManager();
     96
     97            // reset game speed to normal
     98            timeFactor_ = 1.0f;
     99
     100            this->loadLevel();
     101        }
     102
     103        if (Core::showsGraphics())
     104        {
     105            // TODO: insert slomo console command with
     106            // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
     107
     108            // keybind console command
     109            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     110            functor1->setObject(this);
     111            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     112            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
     113            functor2->setObject(this);
     114            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     115            // set our console command as callback for the key detector
     116            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     117
     118            // level is loaded: we can start capturing the input
     119            InputManager::getInstance().requestEnterState("game");
     120        }
     121
     122        if (Core::isMaster())
     123        {
     124            // time factor console command
     125            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
     126            functor->setObject(this);
     127            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     128        }
    108129    }
    109130
     
    116137        //Loader::close();
    117138
    118         delete this->radar_;
    119 
    120         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    121 
    122         inputState_->setHandler(0);
    123         InputManager::getInstance().requestDestroyState("game");
    124         delete this->keyBinder_;
     139        if (Core::showsGraphics())
     140            InputManager::getInstance().requestLeaveState("game");
     141
     142        if (Core::isMaster())
     143            this->unloadLevel();
     144
     145        if (this->radar_)
     146            delete this->radar_;
     147
     148        if (this->cameraHandler_)
     149            delete this->cameraHandler_;
     150
     151        if (this->levelManager_)
     152            delete this->levelManager_;
     153
     154        if (Core::showsGraphics())
     155        {
     156            inputState_->setHandler(0);
     157            InputManager::getInstance().requestDestroyState("game");
     158            if (this->keyBinder_)
     159                delete this->keyBinder_;
     160        }
    125161    }
    126162
     
    185221    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    186222    {
    187         static std::string bindingString = "";
    188         static bool bTemporarySaved = false;
    189         static bool bound = true;
    190         // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
    191         // Howerver there will be no real issue if it happens anyway.
    192         if (command.find(keyDetectorCallbackCode_) != 0)
    193         {
    194             if (bound)
     223        if (Core::showsGraphics())
     224        {
     225            static std::string bindingString = "";
     226            static bool bTemporarySaved = false;
     227            static bool bound = true;
     228            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
     229            // Howerver there will be no real issue if it happens anyway.
     230            if (command.find(keyDetectorCallbackCode_) != 0)
    195231            {
    196                 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
    197                 InputManager::getInstance().requestEnterState("detector");
    198                 bindingString = command;
    199                 bTemporarySaved = bTemporary;
    200                 bound = false;
     232                if (bound)
     233                {
     234                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
     235                    InputManager::getInstance().requestEnterState("detector");
     236                    bindingString = command;
     237                    bTemporarySaved = bTemporary;
     238                    bound = false;
     239                }
     240                //else:  We're still in a keybind command. ignore this call.
    201241            }
    202             //else:  We're still in a keybind command. ignore this call.
    203         }
    204         else
    205         {
    206             if (!bound)
     242            else
    207243            {
    208                 // user has pressed the key
    209                 std::string name = command.substr(this->keyDetectorCallbackCode_.size());
    210                 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
    211                 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
    212                 InputManager::getInstance().requestLeaveState("detector");
    213                 bound = true;
     244                if (!bound)
     245                {
     246                    // user has pressed the key
     247                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
     248                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
     249                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
     250                    InputManager::getInstance().requestLeaveState("detector");
     251                    bound = true;
     252                }
     253                // else: A key was pressed within the same tick, ignore it.
    214254            }
    215             // else: A key was pressed within the same tick, ignore it.
    216255        }
    217256    }
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h

    r2010 r2023  
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass
     39    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
    4040    {
    4141        friend class ClassIdentifier<GSLevel>;
    4242    public:
    43         GSLevel(const std::string& name);
    44         virtual ~GSLevel();
     43        GSLevel();
     44        ~GSLevel();
    4545
    4646        // this has to be public because proteced triggers a bug in msvc
     
    5050
    5151    protected:
    52         virtual void enter();
    53         virtual void leave();
    54         virtual void ticked(const Clock& time);
     52        void enter(Ogre::Viewport* viewport);
     53        void leave();
     54        void ticked(const Clock& time);
    5555
    5656        void loadLevel();
    5757        void unloadLevel();
    5858
    59         float timeFactor_;       //!< A factor to change the gamespeed
     59        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6060
    6161        // console commands
     
    6464        void keybindInternal(const std::string& command, bool bTemporary);
    6565
    66         Ogre::SceneManager*   sceneManager_;
    6766        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    6867        SimpleInputState*     inputState_;
    6968        Radar*                radar_;            //!< represents the Radar (not the HUD part)
    7069        XMLFile*              startFile_;        //!< current hard coded default level
     70        CameraHandler*        cameraHandler_;
     71        LevelManager*         levelManager_;
    7172
    7273        // config values
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSRoot.cc

    r2003 r2023  
    4141#include "core/TclThreadManager.h"
    4242#include "tools/Timer.h"
    43 #include "GraphicsEngine.h"
    4443#include "Settings.h"
    4544
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc

    r2003 r2023  
    3030#include "GSServer.h"
    3131
    32 #include "core/ConsoleCommand.h"
    33 #include "core/input/InputManager.h"
    3432#include "core/CommandLine.h"
    3533#include "core/Core.h"
     
    4139
    4240    GSServer::GSServer()
    43         : GSLevel("server")
     41        : GameState<GSGraphics>("server")
    4442        , server_(0)
    4543    {
     
    5452        Core::setHasServer(true);
    5553
    56         GSLevel::enter();
    57 
    5854        this->server_ = new network::Server(CommandLine::getValue("port"));
    5955        COUT(0) << "Loading scene in server mode" << std::endl;
    6056
    61         this->loadLevel();
     57        GSLevel::enter(this->getParent()->getViewport());
    6258
    6359        server_->open();
    64 
    65         // add console commands
    66         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    67         functor->setObject(this);
    68         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    69 
    70         // level is loaded: we can start capturing the input
    71         InputManager::getInstance().requestEnterState("game");
    7260    }
    7361
    7462    void GSServer::leave()
    7563    {
    76         InputManager::getInstance().requestLeaveState("game");
    77 
    78         // TODO: Remove and destroy console command
    79 
    80         this->unloadLevel();
     64        GSLevel::leave();
    8165
    8266        this->server_->close();
    8367        delete this->server_;
    84 
    85         GSLevel::leave();
    8668
    8769        Core::setHasServer(false);
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.h

    r1755 r2023  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSServer : public GSLevel
     39    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    4142        GSServer();
    4243        ~GSServer();
    43 
    4444
    4545    private:
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc

    r1989 r2023  
    3030#include "GSStandalone.h"
    3131
    32 #include "core/input/InputManager.h"
    33 #include "core/ConsoleCommand.h"
    3432#include "core/Core.h"
    3533
     
    3735{
    3836    GSStandalone::GSStandalone()
    39         : GSLevel("standalone")
     37        : GameState<GSGraphics>("standalone")
    4038    {
    4139    }
     
    4745    void GSStandalone::enter()
    4846    {
    49         GSLevel::enter();
     47        Core::setIsStandalone(true);
    5048
    51         Core::setIsStandalone(true);
    52         this->loadLevel();
    53 
    54         // add console commands
    55         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    56         functor->setObject(this);
    57         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    58 
    59         // level is loaded: we can start capturing the input
    60         InputManager::getInstance().requestEnterState("game");
     49        GSLevel::enter(this->getParent()->getViewport());
    6150    }
    6251
    6352    void GSStandalone::leave()
    6453    {
    65         InputManager::getInstance().requestLeaveState("game");
    66 
    67         // TODO: Remove and destroy console command
    68 
    69         this->unloadLevel();
    70 
    7154        GSLevel::leave();
    7255
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.h

    r1755 r2023  
    3232#include "OrxonoxPrereqs.h"
    3333#include "GSLevel.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSStandalone : public GSLevel
     38    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
    3839    {
    3940    public:
  • code/branches/objecthierarchy/src/orxonox/gui/GUIManager.cc

    r1887 r2023  
    4747#include "core/Core.h"
    4848#include "tolua/tolua_bind.h"
    49 #include "GraphicsEngine.h"
    5049#include "OgreCEGUIRenderer.h"
    5150
  • code/branches/objecthierarchy/src/orxonox/objects/Camera.cc

    r2019 r2023  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "Camera.h"
    31 #include "CameraHandler.h"
    3231
    3332#include <string>
    3433#include <cassert>
    3534
     35#include <OgreCamera.h>
    3636#include <OgreSceneManager.h>
    3737#include <OgreSceneNode.h>
    38 #include <OgreRenderWindow.h>
    3938#include <OgreViewport.h>
    4039
    41 #include "tinyxml/tinyxml.h"
    42 #include "util/SubString.h"
    43 #include "util/Math.h"
    44 #include "util/String.h"
    45 #include "util/Debug.h"
    4640#include "core/CoreIncludes.h"
    4741#include "core/ConfigValueIncludes.h"
    48 #include "GraphicsEngine.h"
    4942#include "objects/Scene.h"
     43#include "objects/CameraHandler.h"
    5044
    5145namespace orxonox
  • code/branches/objecthierarchy/src/orxonox/objects/Camera.h

    r2019 r2023  
    3030#define _Camera_H__
    3131
     32#include "OrxonoxPrereqs.h"
     33
    3234#include <OgrePrerequisites.h>
    33 #include <OgreSceneNode.h>
    34 #include <OgreCamera.h>
    35 
    36 #include "OrxonoxPrereqs.h"
    3735#include "objects/worldentities/PositionableEntity.h"
    3836#include "objects/Tickable.h"
  • code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc

    r2019 r2023  
    2929#include "CameraHandler.h"
    3030
    31 #include <OgreSceneManager.h>
    32 #include <OgreRenderWindow.h>
     31#include <OgreViewport.h>
    3332
    34 #include "core/ObjectList.h"
    3533#include "core/Core.h"
    3634#include "Camera.h"
    37 #include "GraphicsEngine.h"
    3835
    39 #include <OgreCamera.h>
    4036
    4137namespace orxonox
    4238{
    43     CameraHandler::CameraHandler()
     39    CameraHandler* CameraHandler::singletonRef_s = 0;
     40
     41    CameraHandler::CameraHandler(Ogre::Viewport* viewport)
     42        : viewport_(viewport)
    4443    {
    45 //        GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
     44        assert(singletonRef_s == 0);
     45        singletonRef_s = this;
    4646    }
    4747
    48     CameraHandler& CameraHandler::getInstance()
     48    CameraHandler::~CameraHandler()
    4949    {
    50         static CameraHandler instance;
    51         return instance;
     50        assert(singletonRef_s != 0);
     51        singletonRef_s = 0;
    5252    }
    5353
     
    7171        // add to list
    7272        this->cameraList_.push_front(camera);
    73         camera->setFocus(GraphicsEngine::getInstance().getViewport());
     73        camera->setFocus(this->viewport_);
    7474    }
    7575
     
    8787            // set new focus if necessary
    8888            if (cameraList_.size() > 0)
    89                 cameraList_.front()->setFocus(GraphicsEngine::getInstance().getViewport());
     89                cameraList_.front()->setFocus(this->viewport_);
    9090        }
    9191        else
  • code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h

    r2019 r2023  
    3838#include "OrxonoxPrereqs.h"
    3939
     40#include <cassert>
    4041#include <list>
    41 #include <OgreCamera.h>
    42 
    43 #include "core/BaseObject.h"
     42#include <OgrePrerequisites.h>
    4443
    4544namespace orxonox
     
    4847    {
    4948        public:
    50             static CameraHandler& getInstance();
     49            CameraHandler(Ogre::Viewport* viewport);
     50            ~CameraHandler();
    5151
    5252            Camera* getActiveCamera() const;
     
    5555            void releaseFocus(Camera* camera);
    5656
     57            static CameraHandler& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     58
    5759        private:
    58             CameraHandler();
    59             ~CameraHandler() {}
     60            CameraHandler(const CameraHandler&);
    6061
    6162            std::list<Camera*> cameraList_;
     63            Ogre::Viewport* viewport_;
     64
     65            static CameraHandler* singletonRef_s;
    6266    };
    6367}
  • code/branches/objecthierarchy/src/orxonox/objects/Scene.cc

    r2019 r2023  
    3131
    3232#include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
     33#include <OgreSceneManagerEnumerator.h>
    3434#include <OgreSceneNode.h>
    3535#include <OgreLight.h>
    3636
    3737#include "core/CoreIncludes.h"
     38#include "core/Core.h"
    3839#include "core/XMLPort.h"
    3940
     
    4950        this->bShadows_ = false;
    5051
    51         if (Ogre::Root::getSingletonPtr())
     52        if (Core::showsGraphics())
    5253        {
    53             this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
    54             this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     54            if (Ogre::Root::getSingletonPtr())
     55            {
     56                this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
     57                this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     58            }
     59            else
     60            {
     61                this->sceneManager_ = 0;
     62                this->rootSceneNode_ = 0;
     63            }
    5564        }
    5665        else
    5766        {
    58             this->sceneManager_ = 0;
    59             this->rootSceneNode_ = 0;
     67            // create a dummy SceneManager of our own since we don't have Ogre::Root.
     68            this->sceneManager_ = new Ogre::DefaultSceneManager("");
     69            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
    6070        }
    6171
    6272        // test test test
    63         if (this->sceneManager_)
     73        if (Core::showsGraphics() && this->sceneManager_)
    6474        {
    6575            Ogre::Light* light;
     
    8090            Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    8191        }
    82         else
     92        else if (!Core::showsGraphics())
    8393        {
     94            delete this->sceneManager_;
    8495        }
    8596    }
     
    104115    void Scene::setSkybox(const std::string& skybox)
    105116    {
    106         if (this->sceneManager_)
     117        if (Core::showsGraphics() && this->sceneManager_)
    107118            this->sceneManager_->setSkyBox(true, skybox);
    108119
     
    112123    void Scene::setAmbientLight(const ColourValue& colour)
    113124    {
    114         if (this->sceneManager_)
     125        if (Core::showsGraphics() && this->sceneManager_)
    115126            this->sceneManager_->setAmbientLight(colour);
    116127
     
    120131    void Scene::setShadow(bool bShadow)
    121132    {
    122         if (this->sceneManager_)
     133        if (Core::showsGraphics() && this->sceneManager_)
    123134        {
    124135            if (bShadow)
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc

    r2019 r2023  
    3737#include "util/Convert.h"
    3838
    39 #include "GraphicsEngine.h"
    4039#include "objects/Scene.h"
    4140
  • code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc

    r2019 r2023  
    4444#include "core/XMLPort.h"
    4545#include "core/ConsoleCommand.h"
    46 #include "GraphicsEngine.h"
    4746
    4847namespace orxonox
     
    115114
    116115            // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
    117             // called automatically by the GraphicsEngine.
    118             this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
    119                 GraphicsEngine::getInstance().getWindowHeight());
     116            // called automatically by GSGraphics.
     117            //this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
     118            //    GraphicsEngine::getInstance().getWindowHeight());
     119            this->windowAspectRatio_ = Ogre::OverlayManager::getSingleton().getViewportAspectRatio();
     120            this->sizeCorrectionChanged();
    120121
    121122            this->changedVisibility();
  • code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.cc

    r1953 r2023  
    4848#include "core/input/SimpleInputState.h"
    4949#include "core/input/InputBuffer.h"
    50 #include "GraphicsEngine.h"
    5150
    5251namespace orxonox
     
    170169        @brief Initializes the InGameConsole.
    171170    */
    172     void InGameConsole::initialise()
     171    void InGameConsole::initialise(int windowWidth, int windowHeight)
    173172    {
    174173        // create the corresponding input state
     
    246245        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    247246
    248         this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
     247        this->windowResized(windowWidth, windowHeight);
    249248
    250249        // move overlay "above" the top edge of the screen
  • code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.h

    r1953 r2023  
    4949        ~InGameConsole();
    5050
    51         void initialise();
     51        void initialise(int windowWidth, int windowHeight);
    5252        void destroy();
    5353        void setConfigValues();
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc

    r2019 r2023  
    3838#include "network/ClientInformation.h"
    3939
    40 #include "GraphicsEngine.h"
    4140#include "LevelManager.h"
    4241#include "objects/infos/PlayerInfo.h"
  • code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc

    r2019 r2023  
    3434#include <OgreSceneManager.h>
    3535
    36 #include "GraphicsEngine.h"
    3736#include "util/Math.h"
    3837
  • code/branches/objecthierarchy/src/orxonox/tools/Light.cc

    r2019 r2023  
    3535#include <OgreSceneManager.h>
    3636
    37 #include "GraphicsEngine.h"
    38 
    3937namespace orxonox
    4038{
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc

    r2019 r2023  
    3535
    3636#include "core/Core.h"
    37 #include "GraphicsEngine.h"
    3837#include "util/Convert.h"
    3938#include "util/String.h"
     
    6463            this->scenemanager_->destroyEntity(this->entity_);
    6564
    66         try
     65        if (Core::showsGraphics())
    6766        {
    68             this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
    69             this->entity_->setCastShadows(this->bCastShadows_);
    70         }
    71         catch (...)
    72         {
    73             COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
     67            try
     68            {
     69                this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     70                this->entity_->setCastShadows(this->bCastShadows_);
     71            }
     72            catch (...)
     73            {
     74                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
     75            }
    7476        }
    7577    }
Note: See TracChangeset for help on using the changeset viewer.