Changeset 2023 for code/branches/objecthierarchy
- Timestamp:
- Oct 27, 2008, 10:56:51 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/GraphicsEngine.cc
r1755 r2023 68 68 */ 69 69 GraphicsEngine::GraphicsEngine() 70 : root_(0) 71 , renderWindow_(0) 72 , levelSceneManager_(0) 73 , viewport_(0) 70 // : root_(0) 71 // , renderWindow_(0) 72 // , viewport_(0) 74 73 { 75 74 RegisterObject(GraphicsEngine); … … 103 102 singletonRef_s = 0; 104 103 } 105 106 /**107 @brief108 Get the width of the render window109 @return110 The width of the render window111 */112 int GraphicsEngine::getWindowWidth() const113 {114 if (this->renderWindow_)115 return this->renderWindow_->getWidth();116 else117 return 0;118 }119 120 /**121 @brief122 Get the height of the render window123 @return124 The height of the render window125 */126 int GraphicsEngine::getWindowHeight() const127 {128 if (this->renderWindow_)129 return this->renderWindow_->getHeight();130 else131 return 0;132 }133 134 /**135 @brief136 Returns the window aspect ratio height/width.137 @return138 The window aspect ratio139 */140 float GraphicsEngine::getWindowAspectRatio() const141 {142 if (this->renderWindow_)143 return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();144 else145 return 1.0f;146 }147 104 } -
code/branches/objecthierarchy/src/orxonox/GraphicsEngine.h
r1755 r2023 61 61 void detailLevelParticleChanged(); 62 62 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 properties70 int getWindowWidth() const;71 int getWindowHeight() const;72 float getWindowAspectRatio() const;73 63 float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; } 74 64 float getAverageTickTime() const { return this->avgTickTime_; } … … 86 76 GraphicsEngine(GraphicsEngine&); 87 77 88 Ogre::Root* root_; //!< Ogre's root89 Ogre::RenderWindow* renderWindow_; //!< the current render window90 Ogre::SceneManager* levelSceneManager_; //!< scene manager of the game91 Ogre::Viewport* viewport_; //!< default full size viewport92 93 78 // stats 94 79 float avgTickTime_; //!< time in ms to tick() one frame -
code/branches/objecthierarchy/src/orxonox/LevelManager.cc
r2019 r2023 38 38 namespace orxonox 39 39 { 40 LevelManager* LevelManager::singletonRef_s = 0; 41 40 42 LevelManager::LevelManager() 41 43 { 42 44 RegisterRootObject(LevelManager); 43 45 46 assert(singletonRef_s == 0); 47 singletonRef_s = this; 48 44 49 this->getConnectedClients(); 45 50 } 46 51 47 LevelManager & LevelManager::getInstance()52 LevelManager::~LevelManager() 48 53 { 49 static LevelManager instance;50 return instance;54 assert(singletonRef_s != 0); 55 singletonRef_s = 0; 51 56 } 52 57 -
code/branches/objecthierarchy/src/orxonox/LevelManager.h
r2019 r2023 34 34 #include <list> 35 35 #include <map> 36 #include <cassert> 36 37 37 38 #include "network/ClientConnectionListener.h" … … 42 43 { 43 44 public: 44 static LevelManager& getInstance(); 45 LevelManager(); 46 virtual ~LevelManager(); 45 47 46 48 void requestActivity(Level* level); … … 52 54 { return this->clients_; } 53 55 56 static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 57 54 58 private: 55 LevelManager(); 56 virtual ~LevelManager() {} 59 LevelManager(const LevelManager&); 57 60 58 61 void clientConnected(unsigned int clientID); … … 63 66 std::list<Level*> levels_s; 64 67 std::map<unsigned int, PlayerInfo*> clients_; 68 69 static LevelManager* singletonRef_s; 65 70 }; 66 71 } -
code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
r2019 r2023 80 80 class RadarListener; 81 81 82 class CameraHandler; 82 83 class LevelManager; 83 84 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc
r2004 r2023 40 40 41 41 GSClient::GSClient() 42 : G SLevel("client")42 : GameState<GSGraphics>("client") 43 43 , client_(0) 44 44 { … … 53 53 Core::setIsClient(true); 54 54 55 GSLevel::enter();56 57 55 this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port")); 58 56 … … 60 58 ThrowException(InitialisationFailed, "Could not establish connection with server."); 61 59 60 GSLevel::enter(this->getParent()->getViewport()); 61 62 62 client_->tick(0); 63 64 // level is loaded: we can start capturing the input65 InputManager::getInstance().requestEnterState("game");66 63 } 67 64 68 65 void GSClient::leave() 69 66 { 70 InputManager::getInstance().requestLeaveState("game"); 71 72 // TODO: How do we unload the level in client mode? 67 GSLevel::leave(); 73 68 74 69 client_->closeConnection(); … … 76 71 // destroy client 77 72 delete this->client_; 78 79 GSLevel::leave();80 73 81 74 Core::setIsClient(false); -
code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.h
r1755 r2023 33 33 #include "network/NetworkPrereqs.h" 34 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSClient : public G SLevel39 class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: -
code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc
r2010 r2023 30 30 #include "GSDedicated.h" 31 31 32 #include <OgreRoot.h>33 #include <OgreSceneManager.h>34 #include "core/ConsoleCommand.h"35 32 #include "core/CommandLine.h" 36 #include "core/Loader.h"37 #include "core/XMLFile.h"38 33 #include "core/Core.h" 39 34 #include "network/Server.h" 40 #include "objects/Tickable.h"41 #include "Settings.h"42 #include "GraphicsEngine.h"43 35 44 36 namespace orxonox … … 46 38 GSDedicated::GSDedicated() 47 39 : GameState<GSRoot>("dedicated") 48 , timeFactor_(0)49 40 , server_(0) 50 , sceneManager_(0)51 , startFile_(0)52 41 { 53 42 } … … 61 50 Core::setHasServer(true); 62 51 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; 66 54 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); 79 56 80 57 server_->open(); 81 82 // add console commands83 FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);84 functor->setObject(this);85 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;86 58 } 87 59 88 60 void GSDedicated::leave() 89 61 { 90 // TODO: Remove and destroy console command 91 92 Loader::unload(startFile_); 93 delete this->startFile_; 62 GSLevel::leave(); 94 63 95 64 this->server_->close(); 96 65 delete this->server_; 97 98 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);99 66 100 67 Core::setHasServer(false); … … 103 70 void GSDedicated::ticked(const Clock& time) 104 71 { 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); 109 73 server_->tick(time.getDeltaTime()); 110 74 this->tickChild(time); 111 75 } 112 113 /**114 @brief115 Changes the speed of Orxonox116 */117 void GSDedicated::setTimeFactor(float factor)118 {119 this->timeFactor_ = factor;120 }121 76 } -
code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.h
r2010 r2023 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h" 34 35 #include "GSRoot.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSDedicated : public GameState<GSRoot> 39 class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel 39 40 { 40 41 public: 41 42 GSDedicated(); 42 43 ~GSDedicated(); 43 44 void setTimeFactor(float factor);45 float getTimeFactor() { return this->timeFactor_; }46 44 47 45 private: … … 50 48 void ticked(const Clock& time); 51 49 52 void loadLevel();53 void unloadLevel();54 55 float timeFactor_; //!< A factor to change the gamespeed56 50 network::Server* server_; 57 Ogre::SceneManager* sceneManager_;58 XMLFile* startFile_; //!< current hard coded default level59 51 }; 60 52 } -
code/branches/objecthierarchy/src/orxonox/gamestates/GSGUI.cc
r1755 r2023 31 31 32 32 #include <OgreViewport.h> 33 #include "GraphicsEngine.h"34 33 #include "core/input/InputManager.h" 35 34 #include "core/input/SimpleInputState.h" -
code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc
r2013 r2023 116 116 117 117 // 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_; 121 121 122 122 … … 134 134 // Load the InGameConsole 135 135 console_ = new InGameConsole(); 136 console_->initialise( );136 console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 137 137 138 138 // load the CEGUI interface -
code/branches/objecthierarchy/src/orxonox/gamestates/GSIOConsole.cc
r2013 r2023 36 36 37 37 #include "core/ConsoleCommand.h" 38 #include "GraphicsEngine.h"39 38 40 39 namespace orxonox -
code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc
r2010 r2023 30 30 #include "GSLevel.h" 31 31 32 #include <OgreSceneManager.h>33 #include <OgreRoot.h>34 32 #include "core/input/InputManager.h" 35 33 #include "core/input/SimpleInputState.h" … … 41 39 #include "core/ConfigValueIncludes.h" 42 40 #include "core/CoreIncludes.h" 41 #include "core/Core.h" 43 42 //#include "objects/Backlight.h" 43 #include "objects/CameraHandler.h" 44 44 #include "objects/Tickable.h" 45 45 #include "objects/Radar.h" 46 46 //#include "tools/ParticleInterface.h" 47 #include " GraphicsEngine.h"47 #include "LevelManager.h" 48 48 #include "Settings.h" 49 49 50 50 namespace orxonox 51 51 { 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) 56 55 , keyBinder_(0) 57 56 , inputState_(0) 58 57 , radar_(0) 59 58 , startFile_(0) 59 , cameraHandler_(0) 60 , levelManager_(0) 60 61 { 61 62 RegisterObject(GSLevel); … … 72 73 } 73 74 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 } 108 129 } 109 130 … … 116 137 //Loader::close(); 117 138 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 } 125 161 } 126 162 … … 185 221 void GSLevel::keybindInternal(const std::string& command, bool bTemporary) 186 222 { 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) 195 231 { 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. 201 241 } 202 //else: We're still in a keybind command. ignore this call. 203 } 204 else 205 { 206 if (!bound) 242 else 207 243 { 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. 214 254 } 215 // else: A key was pressed within the same tick, ignore it.216 255 } 217 256 } -
code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h
r2010 r2023 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass39 class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics> 40 40 { 41 41 friend class ClassIdentifier<GSLevel>; 42 42 public: 43 GSLevel( const std::string& name);44 virtual~GSLevel();43 GSLevel(); 44 ~GSLevel(); 45 45 46 46 // this has to be public because proteced triggers a bug in msvc … … 50 50 51 51 protected: 52 v irtual void enter();53 v irtual void leave();54 v irtual void ticked(const Clock& time);52 void enter(Ogre::Viewport* viewport); 53 void leave(); 54 void ticked(const Clock& time); 55 55 56 56 void loadLevel(); 57 57 void unloadLevel(); 58 58 59 float timeFactor_; //!< A factor t o change the gamespeed59 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 60 60 61 61 // console commands … … 64 64 void keybindInternal(const std::string& command, bool bTemporary); 65 65 66 Ogre::SceneManager* sceneManager_;67 66 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 68 67 SimpleInputState* inputState_; 69 68 Radar* radar_; //!< represents the Radar (not the HUD part) 70 69 XMLFile* startFile_; //!< current hard coded default level 70 CameraHandler* cameraHandler_; 71 LevelManager* levelManager_; 71 72 72 73 // config values -
code/branches/objecthierarchy/src/orxonox/gamestates/GSRoot.cc
r2003 r2023 41 41 #include "core/TclThreadManager.h" 42 42 #include "tools/Timer.h" 43 #include "GraphicsEngine.h"44 43 #include "Settings.h" 45 44 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc
r2003 r2023 30 30 #include "GSServer.h" 31 31 32 #include "core/ConsoleCommand.h"33 #include "core/input/InputManager.h"34 32 #include "core/CommandLine.h" 35 33 #include "core/Core.h" … … 41 39 42 40 GSServer::GSServer() 43 : G SLevel("server")41 : GameState<GSGraphics>("server") 44 42 , server_(0) 45 43 { … … 54 52 Core::setHasServer(true); 55 53 56 GSLevel::enter();57 58 54 this->server_ = new network::Server(CommandLine::getValue("port")); 59 55 COUT(0) << "Loading scene in server mode" << std::endl; 60 56 61 this->loadLevel();57 GSLevel::enter(this->getParent()->getViewport()); 62 58 63 59 server_->open(); 64 65 // add console commands66 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 input71 InputManager::getInstance().requestEnterState("game");72 60 } 73 61 74 62 void GSServer::leave() 75 63 { 76 InputManager::getInstance().requestLeaveState("game"); 77 78 // TODO: Remove and destroy console command 79 80 this->unloadLevel(); 64 GSLevel::leave(); 81 65 82 66 this->server_->close(); 83 67 delete this->server_; 84 85 GSLevel::leave();86 68 87 69 Core::setHasServer(false); -
code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.h
r1755 r2023 33 33 #include "network/NetworkPrereqs.h" 34 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSServer : public G SLevel39 class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: 41 42 GSServer(); 42 43 ~GSServer(); 43 44 44 45 45 private: -
code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc
r1989 r2023 30 30 #include "GSStandalone.h" 31 31 32 #include "core/input/InputManager.h"33 #include "core/ConsoleCommand.h"34 32 #include "core/Core.h" 35 33 … … 37 35 { 38 36 GSStandalone::GSStandalone() 39 : G SLevel("standalone")37 : GameState<GSGraphics>("standalone") 40 38 { 41 39 } … … 47 45 void GSStandalone::enter() 48 46 { 49 GSLevel::enter();47 Core::setIsStandalone(true); 50 48 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()); 61 50 } 62 51 63 52 void GSStandalone::leave() 64 53 { 65 InputManager::getInstance().requestLeaveState("game");66 67 // TODO: Remove and destroy console command68 69 this->unloadLevel();70 71 54 GSLevel::leave(); 72 55 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.h
r1755 r2023 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "GSLevel.h" 34 #include "GSGraphics.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GSStandalone : public G SLevel38 class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel 38 39 { 39 40 public: -
code/branches/objecthierarchy/src/orxonox/gui/GUIManager.cc
r1887 r2023 47 47 #include "core/Core.h" 48 48 #include "tolua/tolua_bind.h" 49 #include "GraphicsEngine.h"50 49 #include "OgreCEGUIRenderer.h" 51 50 -
code/branches/objecthierarchy/src/orxonox/objects/Camera.cc
r2019 r2023 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "Camera.h" 31 #include "CameraHandler.h"32 31 33 32 #include <string> 34 33 #include <cassert> 35 34 35 #include <OgreCamera.h> 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreRenderWindow.h>39 38 #include <OgreViewport.h> 40 39 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"46 40 #include "core/CoreIncludes.h" 47 41 #include "core/ConfigValueIncludes.h" 48 #include "GraphicsEngine.h"49 42 #include "objects/Scene.h" 43 #include "objects/CameraHandler.h" 50 44 51 45 namespace orxonox -
code/branches/objecthierarchy/src/orxonox/objects/Camera.h
r2019 r2023 30 30 #define _Camera_H__ 31 31 32 #include "OrxonoxPrereqs.h" 33 32 34 #include <OgrePrerequisites.h> 33 #include <OgreSceneNode.h>34 #include <OgreCamera.h>35 36 #include "OrxonoxPrereqs.h"37 35 #include "objects/worldentities/PositionableEntity.h" 38 36 #include "objects/Tickable.h" -
code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc
r2019 r2023 29 29 #include "CameraHandler.h" 30 30 31 #include <OgreSceneManager.h> 32 #include <OgreRenderWindow.h> 31 #include <OgreViewport.h> 33 32 34 #include "core/ObjectList.h"35 33 #include "core/Core.h" 36 34 #include "Camera.h" 37 #include "GraphicsEngine.h"38 35 39 #include <OgreCamera.h>40 36 41 37 namespace orxonox 42 38 { 43 CameraHandler::CameraHandler() 39 CameraHandler* CameraHandler::singletonRef_s = 0; 40 41 CameraHandler::CameraHandler(Ogre::Viewport* viewport) 42 : viewport_(viewport) 44 43 { 45 // GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_); 44 assert(singletonRef_s == 0); 45 singletonRef_s = this; 46 46 } 47 47 48 CameraHandler & CameraHandler::getInstance()48 CameraHandler::~CameraHandler() 49 49 { 50 static CameraHandler instance;51 return instance;50 assert(singletonRef_s != 0); 51 singletonRef_s = 0; 52 52 } 53 53 … … 71 71 // add to list 72 72 this->cameraList_.push_front(camera); 73 camera->setFocus( GraphicsEngine::getInstance().getViewport());73 camera->setFocus(this->viewport_); 74 74 } 75 75 … … 87 87 // set new focus if necessary 88 88 if (cameraList_.size() > 0) 89 cameraList_.front()->setFocus( GraphicsEngine::getInstance().getViewport());89 cameraList_.front()->setFocus(this->viewport_); 90 90 } 91 91 else -
code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h
r2019 r2023 38 38 #include "OrxonoxPrereqs.h" 39 39 40 #include <cassert> 40 41 #include <list> 41 #include <OgreCamera.h> 42 43 #include "core/BaseObject.h" 42 #include <OgrePrerequisites.h> 44 43 45 44 namespace orxonox … … 48 47 { 49 48 public: 50 static CameraHandler& getInstance(); 49 CameraHandler(Ogre::Viewport* viewport); 50 ~CameraHandler(); 51 51 52 52 Camera* getActiveCamera() const; … … 55 55 void releaseFocus(Camera* camera); 56 56 57 static CameraHandler& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 58 57 59 private: 58 CameraHandler(); 59 ~CameraHandler() {} 60 CameraHandler(const CameraHandler&); 60 61 61 62 std::list<Camera*> cameraList_; 63 Ogre::Viewport* viewport_; 64 65 static CameraHandler* singletonRef_s; 62 66 }; 63 67 } -
code/branches/objecthierarchy/src/orxonox/objects/Scene.cc
r2019 r2023 31 31 32 32 #include <OgreRoot.h> 33 #include <OgreSceneManager .h>33 #include <OgreSceneManagerEnumerator.h> 34 34 #include <OgreSceneNode.h> 35 35 #include <OgreLight.h> 36 36 37 37 #include "core/CoreIncludes.h" 38 #include "core/Core.h" 38 39 #include "core/XMLPort.h" 39 40 … … 49 50 this->bShadows_ = false; 50 51 51 if ( Ogre::Root::getSingletonPtr())52 if (Core::showsGraphics()) 52 53 { 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 } 55 64 } 56 65 else 57 66 { 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(); 60 70 } 61 71 62 72 // test test test 63 if ( this->sceneManager_)73 if (Core::showsGraphics() && this->sceneManager_) 64 74 { 65 75 Ogre::Light* light; … … 80 90 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 81 91 } 82 else 92 else if (!Core::showsGraphics()) 83 93 { 94 delete this->sceneManager_; 84 95 } 85 96 } … … 104 115 void Scene::setSkybox(const std::string& skybox) 105 116 { 106 if ( this->sceneManager_)117 if (Core::showsGraphics() && this->sceneManager_) 107 118 this->sceneManager_->setSkyBox(true, skybox); 108 119 … … 112 123 void Scene::setAmbientLight(const ColourValue& colour) 113 124 { 114 if ( this->sceneManager_)125 if (Core::showsGraphics() && this->sceneManager_) 115 126 this->sceneManager_->setAmbientLight(colour); 116 127 … … 120 131 void Scene::setShadow(bool bShadow) 121 132 { 122 if ( this->sceneManager_)133 if (Core::showsGraphics() && this->sceneManager_) 123 134 { 124 135 if (bShadow) -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2019 r2023 37 37 #include "util/Convert.h" 38 38 39 #include "GraphicsEngine.h"40 39 #include "objects/Scene.h" 41 40 -
code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc
r2019 r2023 44 44 #include "core/XMLPort.h" 45 45 #include "core/ConsoleCommand.h" 46 #include "GraphicsEngine.h"47 46 48 47 namespace orxonox … … 115 114 116 115 // 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(); 120 121 121 122 this->changedVisibility(); -
code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.cc
r1953 r2023 48 48 #include "core/input/SimpleInputState.h" 49 49 #include "core/input/InputBuffer.h" 50 #include "GraphicsEngine.h"51 50 52 51 namespace orxonox … … 170 169 @brief Initializes the InGameConsole. 171 170 */ 172 void InGameConsole::initialise( )171 void InGameConsole::initialise(int windowWidth, int windowHeight) 173 172 { 174 173 // create the corresponding input state … … 246 245 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 247 246 248 this->windowResized( GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());247 this->windowResized(windowWidth, windowHeight); 249 248 250 249 // move overlay "above" the top edge of the screen -
code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.h
r1953 r2023 49 49 ~InGameConsole(); 50 50 51 void initialise( );51 void initialise(int windowWidth, int windowHeight); 52 52 void destroy(); 53 53 void setConfigValues(); -
code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc
r2019 r2023 38 38 #include "network/ClientInformation.h" 39 39 40 #include "GraphicsEngine.h"41 40 #include "LevelManager.h" 42 41 #include "objects/infos/PlayerInfo.h" -
code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc
r2019 r2023 34 34 #include <OgreSceneManager.h> 35 35 36 #include "GraphicsEngine.h"37 36 #include "util/Math.h" 38 37 -
code/branches/objecthierarchy/src/orxonox/tools/Light.cc
r2019 r2023 35 35 #include <OgreSceneManager.h> 36 36 37 #include "GraphicsEngine.h"38 39 37 namespace orxonox 40 38 { -
code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc
r2019 r2023 35 35 36 36 #include "core/Core.h" 37 #include "GraphicsEngine.h"38 37 #include "util/Convert.h" 39 38 #include "util/String.h" … … 64 63 this->scenemanager_->destroyEntity(this->entity_); 65 64 66 try65 if (Core::showsGraphics()) 67 66 { 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 } 74 76 } 75 77 }
Note: See TracChangeset
for help on using the changeset viewer.