Changeset 1755 for code/trunk/src/orxonox
- Timestamp:
- Sep 10, 2008, 1:37:36 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 37 edited
- 28 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gui (added) merged: 1636,1638,1640-1647,1649-1654,1656,1659-1665,1670,1672-1674,1686,1688-1692,1694-1697,1704 /code/branches/input (added) merged: 1629-1630
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CMakeLists.txt
r1747 r1755 2 2 GraphicsEngine.cc 3 3 Main.cc 4 Orxonox.cc5 4 Radar.cc 6 5 RadarListener.cc … … 8 7 Settings.cc 9 8 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 10 24 11 25 overlays/OrxonoxOverlay.cc … … 55 69 ADD_CUSTOM_COMMAND( 56 70 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.pkg58 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 59 73 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib 60 74 ) … … 84 98 ${OGRE_LIBRARIES} 85 99 ${Lua_LIBRARIES} 100 ${CEGUI_LIBRARIES} 101 ${CEGUI_SCRIPT_LIBRARIES} 86 102 tinyxml 87 103 tolualib -
code/trunk/src/orxonox/GraphicsEngine.cc
r1747 r1755 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 24 25 * Co-authors: 25 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007,Felix Schulthess26 * Felix Schulthess 26 27 * 27 28 */ 28 29 29 /** 30 @file orxonox.cc 31 @brief Orxonox class 32 */ 30 /** 31 @file 32 @brief 33 Implementation of an partial interface to Ogre. 34 */ 33 35 34 36 #include "OrxonoxStableHeaders.h" 35 37 #include "GraphicsEngine.h" 36 38 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> 46 40 47 41 #include "core/CoreIncludes.h" 48 42 #include "core/ConfigValueIncludes.h" 49 #include "core/Iterator.h"50 #include "core/CommandExecutor.h"51 #include "core/ConsoleCommand.h"52 43 #include "util/Debug.h" 53 44 54 #include "overlays/console/InGameConsole.h"55 #include "overlays/OverlayGroup.h"56 45 #include "tools/ParticleInterface.h" 57 #include "Settings.h"58 #include "tools/WindowEventListener.h"59 60 46 61 47 namespace orxonox 62 48 { 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); 72 50 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; 82 52 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() 132 60 { 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; 185 63 } 186 64 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) 188 74 { 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; 195 84 } 196 85 197 if (!root_->getInstalledPlugins().size())86 void GraphicsEngine::setConfigValues() 198 87 { 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); 202 89 } 203 90 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() 229 92 { 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_); 232 95 } 233 96 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() 237 102 { 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; 245 104 } 246 105 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 252 113 { 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; 305 118 } 306 119 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 308 127 { 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; 311 132 } 312 Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);313 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);314 return true;315 }316 133 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 322 141 { 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; 329 146 } 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 SceneManager341 */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::InputManager358 @return The window handle of the render window359 */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 else369 return 0;370 }371 372 /**373 Get the width of the current render window374 @return The width of the current render window375 */376 int GraphicsEngine::getWindowWidth() const377 {378 if (this->renderWindow_)379 return this->renderWindow_->getWidth();380 else381 return 0;382 }383 384 /**385 Get the height of the current render window386 @return The height of the current render window387 */388 int GraphicsEngine::getWindowHeight() const389 {390 if (this->renderWindow_)391 return this->renderWindow_->getHeight();392 else393 return 0;394 }395 396 /**397 @brief Returns the window aspect ratio height/width.398 @return The ratio399 */400 float GraphicsEngine::getWindowAspectRatio() const401 {402 if (this->renderWindow_)403 return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();404 else405 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 logged412 @param lml The message level the log is using413 @param maskDebug If we are printing to the console or not414 @param logName the name of this log (so you can have several listeners415 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 in442 */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 in452 * @note GraphicsEngine has a render window stored itself. This is the same453 * 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 in464 */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 in474 */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 481 147 } -
code/trunk/src/orxonox/GraphicsEngine.h
r1747 r1755 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 24 25 * Co-authors: 25 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007,Felix Schulthess26 * Felix Schulthess 26 27 * 27 28 */ … … 41 42 42 43 #include <OgrePrerequisites.h> 43 #include <OgreLog.h>44 #include <OgreRenderWindow.h>45 #include <OgreWindowEventUtilities.h>46 44 #include "core/OrxonoxClass.h" 47 48 45 49 46 namespace orxonox … … 52 49 @brief Graphics engine manager class 53 50 */ 54 class _OrxonoxExport GraphicsEngine : public O gre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass51 class _OrxonoxExport GraphicsEngine : public OrxonoxClass 55 52 { 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; 64 55 65 void destroy(); 56 public: 57 GraphicsEngine(); 58 ~GraphicsEngine(); 66 59 67 Ogre::SceneManager* getSceneManager() { return scene_; } 60 void setConfigValues(); 61 void detailLevelParticleChanged(); 68 62 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_; } 79 65 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_; } 82 68 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; } 87 77 88 89 78 inline unsigned int getDetailLevelParticle() const 79 { return this->detailLevelParticle_; } 90 80 91 static GraphicsEngine& getSingleton();92 static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }81 static GraphicsEngine& getInstance(); 82 static GraphicsEngine* getInstancePtr() { return singletonRef_s; } 93 83 84 private: 85 // don't mess with singletons 86 GraphicsEngine(GraphicsEngine&); 94 87 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 100 92 101 //! Method called by the LogListener from Ogre102 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 104 96 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 118 101 }; 119 102 } -
code/trunk/src/orxonox/Main.cc
r1747 r1755 22 22 * Author: 23 23 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 24 * Reto Grieder 24 25 * Co-authors: 25 26 * ... … … 35 36 36 37 #include <exception> 38 #include <cassert> 37 39 38 40 #include "util/OrxonoxPlatform.h" 39 41 #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" 41 52 42 53 using namespace orxonox; 54 43 55 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE 44 56 #include <CoreFoundation/CoreFoundation.h> … … 49 61 std::string macBundlePath() 50 62 { 51 char path[1024];52 CFBundleRef mainBundle = CFBundleGetMainBundle();53 assert(mainBundle);63 char path[1024]; 64 CFBundleRef mainBundle = CFBundleGetMainBundle(); 65 assert(mainBundle); 54 66 55 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);56 assert(mainBundleURL);67 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 68 assert(mainBundleURL); 57 69 58 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);59 assert(cfStringRef);70 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 71 assert(cfStringRef); 60 72 61 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);73 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 62 74 63 CFRelease(mainBundleURL);64 CFRelease(cfStringRef);75 CFRelease(mainBundleURL); 76 CFRelease(cfStringRef); 65 77 66 return std::string(path);78 return std::string(path); 67 79 } 68 80 #endif 69 81 70 #ifdef __cplusplus71 extern "C" {72 #endif73 82 74 int main(int argc, char **argv) 83 //#ifdef __cplusplus 84 //extern "C" { 85 //#endif 86 87 int main(int argc, char** argv) 75 88 { 76 //try {89 // create a signal handler (only works for linux) 77 90 SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); 78 Orxonox* orx = Orxonox::getSingleton();79 91 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; 86 100 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); 97 106 98 return 0; 107 root.addChild(&ioConsole); 108 root.addChild(&dedicated); 109 110 root.start(argc, argv); 111 112 return 0; 99 113 } 100 114 101 #ifdef __cplusplus102 }103 #endif115 //#ifdef __cplusplus 116 //} 117 //#endif -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r1625 r1755 74 74 75 75 class GraphicsEngine; 76 class Orxonox;76 class Settings; 77 77 78 78 class RadarViewable; … … 84 84 class Backlight; 85 85 class Camera; 86 class Fighter;87 86 class Model; 88 87 class NPC; … … 118 117 class OverlayGroup; 119 118 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; 120 133 } 121 134 … … 128 141 } 129 142 143 namespace CEGUI 144 { 145 class LuaScriptModule; 146 147 class OgreCEGUIRenderer; 148 class OgreCEGUIResourceProvider; 149 class OgreCEGUITexture; 150 } 151 152 struct lua_State; 153 130 154 #endif /* _OrxonoxPrereqs_H__ */ -
code/trunk/src/orxonox/OrxonoxStableHeaders.h
r1747 r1755 28 28 29 29 /** 30 @file OrxonoxStableHeaders.h31 @brief Contains the bigger (or smaller) header files in order to precompile them with MSVC30 @file 31 @brief Contains the frequently used header files of our own writing 32 32 */ 33 33 … … 37 37 #include "util/OrxonoxPlatform.h" 38 38 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) 40 40 41 41 // including std headers here is useless since they're already precompiled … … 45 45 # define WIN32_LEAN_AND_MEAN 46 46 #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> 83 53 84 //-----------------------------------------------------------------------85 // ORXONOX HEADERS86 //-----------------------------------------------------------------------87 88 #include "ois/OIS.h"89 #include "cpptcl/CppTcl.h"90 54 #include "tinyxml/ticpp.h" 91 55 #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) 92 62 93 63 #include "util/Convert.h" … … 106 76 #include "core/CoreIncludes.h" 107 77 #include "core/ConfigValueIncludes.h" 78 #include "core/CommandExecutor.h" 108 79 #include "core/Executor.h" 109 80 #include "core/XMLPort.h" … … 117 88 //#include "objects/WorldEntity.h" 118 89 119 #endif /* Compiler MSVC */ 90 #endif /* ifdef NDEBUG */ 91 92 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */ 120 93 121 94 #endif /* _OrxonoxStableHeaders_H__ */ -
code/trunk/src/orxonox/Radar.cc
r1747 r1755 34 34 #include "OrxonoxStableHeaders.h" 35 35 #include "Radar.h" 36 #include <float.h> 36 #include <cfloat> 37 #include <cassert> 37 38 #include "objects/WorldEntity.h" 38 39 #include "objects/SpaceShip.h" -
code/trunk/src/orxonox/RadarViewable.h
r1747 r1755 32 32 #include "OrxonoxPrereqs.h" 33 33 #include <string> 34 #include <cassert> 34 35 #include "util/Math.h" 35 36 #include "util/Debug.h" -
code/trunk/src/orxonox/Settings.cc
r1747 r1755 28 28 29 29 /** 30 @file 31 @brief Implementation of the Settings class. 30 @file 31 @brief 32 Implementation of the Settings class. 32 33 */ 33 34 … … 35 36 #include "Settings.h" 36 37 38 #include "util/String.h" 37 39 #include "core/CoreIncludes.h" 38 40 #include "core/ConfigValueIncludes.h" … … 40 42 namespace orxonox 41 43 { 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; 50 45 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) 79 53 { 80 ModifyConfigValue(dataPath_, set, dataPath_ + "/"); 54 RegisterRootObject(Settings); 55 assert(singletonRef_s == 0); 56 singletonRef_s = this; 57 setConfigValues(); 81 58 } 82 59 83 if (dataPath_ == "") 60 /** 61 @brief 62 Function to collect the SetConfigValue-macro calls. 63 */ 64 void Settings::setConfigValues() 84 65 { 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); 87 67 } 88 }89 68 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 } 98 79 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 } 103 86 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 112 98 } -
code/trunk/src/orxonox/Settings.h
r1747 r1755 29 29 /** 30 30 @file Core.h 31 @brief De finition of the Settings class.31 @brief Declaration of the Settings class. 32 32 33 33 The static Settings class is only used to configure some variables … … 41 41 #include <string> 42 42 #include "core/OrxonoxClass.h" 43 #include "util/Debug.h" 44 #include "util/MultiType.h" 45 #include "util/Convert.h" 43 46 44 47 namespace orxonox 45 48 { 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 48 57 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); } 51 62 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_; } 55 66 56 67 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; } 61 71 62 void _tsetDataPath(const std::string& path); 72 Settings(); 73 Settings(const Settings& instance); 74 ~Settings() { singletonRef_s = 0; } 63 75 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 66 90 } 67 91 -
code/trunk/src/orxonox/SignalHandler.h
r1747 r1755 29 29 /** 30 30 @file SignalHandler.h 31 @brief De finition of the SignalHandler class.31 @brief Declaration of the SignalHandler class. 32 32 */ 33 33 -
code/trunk/src/orxonox/gamestates/GSClient.cc
r1724 r1755 54 54 int serverPort = CommandLine::getArgument<int>("port")->getValue(); 55 55 std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue(); 56 this->client_ = ne twork::Client::createSingleton(serverIP, serverPort);56 this->client_ = new network::Client(serverIP, serverPort); 57 57 58 58 if(!client_->establishConnection()) … … 73 73 client_->closeConnection(); 74 74 75 // TODO: destroy client 75 // destroy client 76 delete this->client_; 76 77 77 78 GSLevel::leave(); -
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r1724 r1755 70 70 71 71 int serverPort = CommandLine::getArgument<int>("port")->getValue(); 72 this->server_ = ne twork::Server::createSingleton(serverPort);72 this->server_ = new network::Server(serverPort); 73 73 74 74 // call the loader … … 82 82 FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor); 83 83 functor->setObject(this); 84 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")) ;84 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 85 85 } 86 86 … … 93 93 94 94 this->server_->close(); 95 // TODO: destroy server95 delete this->server_; 96 96 97 97 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); … … 103 103 { 104 104 // 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) 106 106 it->tick(time.getDeltaTime()); 107 107 // 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) 109 109 it->tick(time.getDeltaTime() * this->timeFactor_); 110 110 -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r1724 r1755 40 40 #include <OgreWindowEventUtilities.h> 41 41 42 #include " core/Debug.h"42 #include "util/Debug.h" 43 43 #include "core/ConsoleCommand.h" 44 44 #include "core/ConfigValueIncludes.h" … … 308 308 void GSGraphics::windowMoved(Ogre::RenderWindow *rw) 309 309 { 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) 311 311 it->windowMoved(); 312 312 } … … 323 323 void GSGraphics::windowResized(Ogre::RenderWindow *rw) 324 324 { 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) 326 326 it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 327 327 } … … 335 335 void GSGraphics::windowFocusChanged(Ogre::RenderWindow *rw) 336 336 { 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) 338 338 it->windowFocusChanged(); 339 339 } -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r1724 r1755 86 86 // reset game speed to normal 87 87 timeFactor_ = 1.0f; 88 89 // TODO: insert slomo console command with 90 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 88 91 } 89 92 … … 111 114 { 112 115 // 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) 114 117 it->tick(time.getDeltaTime()); 115 118 // 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) 117 120 it->tick(time.getDeltaTime() * this->timeFactor_); 118 121 119 for ( Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; ++it)122 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it) 120 123 it->tick(time); 121 124 } … … 129 132 float change = factor / this->timeFactor_; 130 133 this->timeFactor_ = factor; 131 for ( Iterator<ParticleInterface>it = ObjectList<ParticleInterface>::begin(); it; ++it)134 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it) 132 135 it->setSpeedFactor(it->getSpeedFactor() * change); 133 136 134 for ( Iterator<Backlight>it = ObjectList<Backlight>::begin(); it; ++it)137 for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it) 135 138 it->setTimeFactor(timeFactor_); 136 139 } -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r1724 r1755 40 40 #include "core/ConsoleCommand.h" 41 41 #include "core/CommandLine.h" 42 #include " core/Debug.h"42 #include "util/Debug.h" 43 43 #include "core/Exception.h" 44 44 #include "core/TclBind.h" … … 95 95 { 96 96 #if ORXONOX_DEBUG_MODE == 1 97 ConfigFileManager::get Singleton()->setFile(CFT_Settings, "orxonox_d.ini");97 ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox_d.ini"); 98 98 #else 99 ConfigFileManager::get Singleton()->setFile(CFT_Settings, "orxonox.ini");99 ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox.ini"); 100 100 #endif 101 101 -
code/trunk/src/orxonox/gamestates/GSServer.cc
r1724 r1755 57 57 58 58 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; 60 61 61 62 this->loadLevel(); … … 66 67 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 67 68 functor->setObject(this); 68 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")) ;69 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 69 70 70 71 // level is loaded: we can start capturing the input … … 81 82 82 83 this->server_->close(); 83 // TODO: destroy server84 delete this->server_; 84 85 85 86 GSLevel::leave(); -
code/trunk/src/orxonox/gamestates/GSStandalone.cc
r1724 r1755 53 53 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 54 54 functor->setObject(this); 55 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")) ;55 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 56 56 57 57 // level is loaded: we can start capturing the input -
code/trunk/src/orxonox/gui/GUIManager.cc
r1724 r1755 57 57 namespace orxonox 58 58 { 59 SetConsoleCommandShortcut(GUIManager, showGUI_s). setKeybindMode(KeybindMode::OnPress);59 SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress); 60 60 61 61 GUIManager* GUIManager::singletonRef_s = 0; -
code/trunk/src/orxonox/objects/Ambient.cc
r1747 r1755 43 43 #include "core/XMLPort.h" 44 44 #include "core/ConsoleCommand.h" 45 #include "Settings.h" 45 46 #include "GraphicsEngine.h" 46 47 … … 66 67 bool Ambient::create() 67 68 { 68 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_); 69 if (Settings::showsGraphics()) 70 GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_); 69 71 return Synchronisable::create(); 70 72 } … … 77 79 void Ambient::setAmbientLight(const ColourValue& colour) 78 80 { 79 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour); 80 ambientLight_=colour; 81 if (Settings::showsGraphics()) 82 GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour); 83 ambientLight_ = colour; 81 84 } 82 85 83 86 /** 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 88 95 */ 89 96 void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode) -
code/trunk/src/orxonox/objects/Backlight.cc
r1747 r1755 32 32 #include <OgreBillboard.h> 33 33 #include <OgreRibbonTrail.h> 34 #include <OgreSceneManager.h> 34 35 35 36 #include "core/CoreIncludes.h" … … 38 39 #include "util/Math.h" 39 40 #include "GraphicsEngine.h" 40 #include "Orxonox.h"41 41 42 42 namespace orxonox … … 58 58 this->attachObject(this->billboard_.getBillboardSet()); 59 59 60 this->ribbonTrail_ = GraphicsEngine::get Singleton().getSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");61 this->ribbonTrailNode_ = GraphicsEngine::get Singleton().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"); 62 62 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 63 63 this->ribbonTrail_->addNode(this->getNode()); … … 68 68 this->ribbonTrail_->setMaterialName("Trail/backlighttrail"); 69 69 70 this->setTimeFactor(Orxonox::getSingleton()->getTimeFactor()); 70 //this->setTimeFactor(Orxonox::getInstance().getTimeFactor()); 71 this->setTimeFactor(1.0f); 71 72 } 72 73 … … 76 77 { 77 78 this->detachObject(this->billboard_.getBillboardSet()); 78 GraphicsEngine::get Singleton().getSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");79 GraphicsEngine::get Singleton().getSceneManager()->destroyRibbonTrail(this->ribbonTrail_);79 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode"); 80 GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_); 80 81 } 81 82 } -
code/trunk/src/orxonox/objects/Camera.cc
r1747 r1755 52 52 { 53 53 this->bHasFocus_ = false; 54 this->cameraNode_ = GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");54 this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera"); 55 55 if( node != NULL ) 56 56 this->setPositionNode(node); … … 60 60 { 61 61 CameraHandler::getInstance()->releaseFocus(this); 62 GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());62 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName()); 63 63 } 64 64 -
code/trunk/src/orxonox/objects/CameraHandler.cc
r1505 r1755 44 44 CameraHandler::CameraHandler() 45 45 { 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); 48 49 /*this->activeCamera_ = *ObjectList<Camera>::begin(); 49 50 this->activeCamera_->cam_ = this->cam_;*/ -
code/trunk/src/orxonox/objects/ParticleSpawner.cc
r1608 r1755 30 30 #include "ParticleSpawner.h" 31 31 32 #include <OgreSceneManager.h> 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/Executor.h" … … 79 80 this->setPosition(this->getNode()->getParent()->getPosition()); 80 81 this->getNode()->getParent()->removeChild(this->getNode()); 81 GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->addChild(this->getNode());82 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode()); 82 83 if (this->particle_) 83 84 this->particle_->setEnabled(false); -
code/trunk/src/orxonox/objects/Skybox.cc
r1747 r1755 39 39 #include "core/XMLPort.h" 40 40 #include "util/Debug.h" 41 #include "Settings.h" 41 42 42 43 namespace orxonox … … 56 57 void Skybox::setSkybox(const std::string& skyboxname) 57 58 { 58 GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname); 59 if (Settings::showsGraphics()) 60 GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skyboxname); 59 61 } 60 62 … … 87 89 { 88 90 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_); 90 93 } 91 94 } -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1751 r1755 49 49 #include "CameraHandler.h" 50 50 #include "ParticleSpawner.h" 51 #include "Settings.h" 51 52 #include "RotatingProjectile.h" 52 53 #include "ParticleProjectile.h" … … 79 80 } 80 81 assert(0); 82 return 0; 81 83 } 82 84 … … 194 196 void SpaceShip::init() 195 197 { 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 } 280 284 } 281 285 // END of testing crosshair … … 429 433 this->cam_->tick(dt); 430 434 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 } 451 458 } 452 459 -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1747 r1755 39 39 #include "core/XMLPort.h" 40 40 #include "tools/ParticleInterface.h" 41 #include "Settings.h" 41 42 42 43 #define ACTION_INTERVAL 1.0f … … 102 103 newenemy->XMLPort(xmlelement, XMLPort::LoadObject); 103 104 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 } 107 111 } 108 112 } … … 182 186 void SpaceShipAI::kill() 183 187 { 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 } 213 220 214 221 delete this; -
code/trunk/src/orxonox/objects/Tickable.h
r1747 r1755 29 29 /*! 30 30 @file Tickable.h 31 @brief De finition of the Tickable interface.31 @brief Declaration of the Tickable interface. 32 32 33 33 The Tickable interface provides a tick(dt) function, that gets called every frame. -
code/trunk/src/orxonox/objects/WorldEntity.cc
r1747 r1755 32 32 #include <string> 33 33 #include <sstream> 34 #include <OgreSceneManager.h> 34 35 35 36 #include "tinyxml/tinyxml.h" … … 49 50 RegisterObject(WorldEntity); 50 51 51 if (GraphicsEngine::get Singleton().getSceneManager())52 if (GraphicsEngine::getInstance().getLevelSceneManager()) 52 53 { 53 54 std::ostringstream name; 54 55 name << (WorldEntity::worldEntityCounter_s++); 55 56 this->setName("WorldEntity" + name.str()); 56 this->node_ = GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());57 this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName()); 57 58 58 59 registerAllVariables(); … … 77 78 { 78 79 this->getNode()->removeAndDestroyAllChildren(); 79 GraphicsEngine::get Singleton().getSceneManager()->destroySceneNode(this->getName());80 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName()); 80 81 } 81 82 } … … 177 178 void WorldEntity::attachObject(const WorldEntity& obj) const 178 179 { 179 GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->removeChild(obj.getNode());180 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode()); 180 181 this->getNode()->addChild(obj.getNode()); 181 182 } … … 183 184 void WorldEntity::attachObject(WorldEntity* obj) const 184 185 { 185 GraphicsEngine::get Singleton().getSceneManager()->getRootSceneNode()->removeChild(obj->getNode());186 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode()); 186 187 this->getNode()->addChild(obj->getNode()); 187 188 } -
code/trunk/src/orxonox/objects/WorldEntity.h
r1747 r1755 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 34 #include <OgreSceneManager.h>35 35 #include <OgreSceneNode.h> 36 37 36 #include "util/Math.h" 38 37 #include "util/XMLIncludes.h" -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r1747 r1755 115 115 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets 116 116 // called automatically by the GraphicsEngine. 117 this->windowResized(GraphicsEngine::get Singleton().getWindowWidth(),118 GraphicsEngine::get Singleton().getWindowHeight());117 this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), 118 GraphicsEngine::getInstance().getWindowHeight()); 119 119 120 120 this->changedVisibility(); -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r1747 r1755 46 46 #include "core/ConsoleCommand.h" 47 47 #include "core/input/InputManager.h" 48 #include "core/input/SimpleInputState.h" 49 #include "core/input/InputBuffer.h" 48 50 #include "GraphicsEngine.h" 49 51 … … 56 58 SetConsoleCommand(InGameConsole, closeConsole, true); 57 59 60 InGameConsole* InGameConsole::singletonRef_s = 0; 61 58 62 /** 59 63 @brief Constructor: Creates and initializes the InGameConsole. 60 64 */ 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) 65 72 { 66 73 RegisterObject(InGameConsole); 74 75 assert(singletonRef_s == 0); 76 singletonRef_s = this; 67 77 68 78 this->bActive_ = false; … … 82 92 InGameConsole::~InGameConsole(void) 83 93 { 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 199 99 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); 200 100 if (ovMan) … … 224 124 this->consoleOverlayTextAreas_ = 0; 225 125 } 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; 226 230 } 227 231 … … 453 457 if (output.size() > this->maxCharsPerLine_) 454 458 { 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; 459 463 460 464 output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_); … … 476 480 { 477 481 this->bActive_ = true; 478 InputManager:: setInputState(InputManager::IS_CONSOLE);482 InputManager::getInstance().requestEnterState("console"); 479 483 Shell::getInstance().registerListener(this); 480 484 … … 498 502 { 499 503 this->bActive_ = false; 500 InputManager:: setInputState(InputManager::IS_NORMAL);504 InputManager::getInstance().requestLeaveState("console"); 501 505 Shell::getInstance().unregisterListener(this); 502 506 -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r1747 r1755 37 37 38 38 #include "core/Shell.h" 39 #include " objects/Tickable.h"39 #include "core/OrxonoxClass.h" 40 40 #include "tools/WindowEventListener.h" 41 41 … … 43 43 namespace orxonox 44 44 { 45 class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener45 class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener 46 46 { 47 public: // functions 48 void initialise(); 49 void destroy(); 50 void setConfigValues(); 47 public: // functions 48 InGameConsole(); 49 ~InGameConsole(); 51 50 52 virtual void tick(float dt); 51 void initialise(); 52 void destroy(); 53 void setConfigValues(); 53 54 54 static InGameConsole& getInstance();55 virtual void tick(float dt); 55 56 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; } 58 59 59 private: // functions 60 InGameConsole(); 61 InGameConsole(const InGameConsole& other) {} 62 ~InGameConsole(); 60 static void openConsole(); 61 static void closeConsole(); 63 62 64 void activate();65 void deactivate();63 private: // functions 64 InGameConsole(const InGameConsole& other) {} 66 65 67 void linesChanged(); 68 void onlyLastLineChanged(); 69 void lineAdded(); 70 void inputChanged(); 71 void cursorChanged(); 72 void exit(); 66 void activate(); 67 void deactivate(); 73 68 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(); 78 75 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); 80 80 81 static Ogre::UTFString convert2UTF(std::string s);81 void windowResized(int newWidth, int newHeight); 82 82 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); 101 84 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; 109 113 }; 110 114 } -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
r1625 r1755 49 49 void DebugFPSText::tick(float dt) 50 50 { 51 float fps = GraphicsEngine::get Singleton().getAverageFramesPerSecond();51 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 52 this->text_->setCaption(this->getCaption() + convertToString(fps)); 53 53 } -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
r1625 r1755 49 49 void DebugRTRText::tick(float dt) 50 50 { 51 float rtr = GraphicsEngine::get Singleton().getAverageTickTime();51 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 52 this->text_->setCaption(this->getCaption() + convertToString(rtr)); 53 53 } -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc
r1626 r1755 54 54 float v = ship->getVelocity().length(); 55 55 float value = v / ship->getMaxSpeed(); 56 56 if (value != this->getValue()) 57 57 this->setValue(value); 58 58 } -
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 50 50 std::ostringstream name; 51 51 name << (BillboardSet::billboardSetCounter_s++); 52 this->billboardSet_ = GraphicsEngine::get Singleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);52 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 53 53 this->billboardSet_->createBillboard(Vector3::ZERO); 54 54 this->billboardSet_->setMaterialName(file); … … 59 59 std::ostringstream name; 60 60 name << (BillboardSet::billboardSetCounter_s++); 61 this->billboardSet_ = GraphicsEngine::get Singleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);61 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 62 62 this->billboardSet_->createBillboard(Vector3::ZERO, colour); 63 63 this->billboardSet_->setMaterialName(file); … … 68 68 std::ostringstream name; 69 69 name << (BillboardSet::billboardSetCounter_s++); 70 this->billboardSet_ = GraphicsEngine::get Singleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);70 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 71 71 this->billboardSet_->createBillboard(position); 72 72 this->billboardSet_->setMaterialName(file); … … 77 77 std::ostringstream name; 78 78 name << (BillboardSet::billboardSetCounter_s++); 79 this->billboardSet_ = GraphicsEngine::get Singleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);79 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 80 80 this->billboardSet_->createBillboard(position, colour); 81 81 this->billboardSet_->setMaterialName(file); … … 85 85 { 86 86 if (this->billboardSet_) 87 GraphicsEngine::get Singleton().getSceneManager()->destroyBillboardSet(this->billboardSet_);87 GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_); 88 88 } 89 89 } -
code/trunk/src/orxonox/tools/Light.cc
r1505 r1755 49 49 std::ostringstream name; 50 50 name << (Light::lightCounter_s++); 51 this->light_ = GraphicsEngine::get Singleton().getSceneManager()->createLight("Light" + name.str());51 this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str()); 52 52 this->light_->setType(type); 53 53 this->light_->setDiffuseColour(diffuse); … … 58 58 { 59 59 if (this->light_) 60 GraphicsEngine::get Singleton().getSceneManager()->destroyLight(this->light_);60 GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_); 61 61 } 62 62 } -
code/trunk/src/orxonox/tools/Mesh.cc
r1505 r1755 31 31 32 32 #include <sstream> 33 34 33 #include <OgreSceneManager.h> 35 36 34 #include "GraphicsEngine.h" 35 #include "Settings.h" 37 36 38 37 namespace orxonox … … 49 48 std::ostringstream name; 50 49 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); 52 52 } 53 53 54 54 Mesh::~Mesh() 55 55 { 56 if (this->entity_ )57 GraphicsEngine::get Singleton().getSceneManager()->destroyEntity(this->entity_);56 if (this->entity_ && Settings::showsGraphics()) 57 GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_); 58 58 } 59 59 } -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r1563 r1755 39 39 40 40 #include "GraphicsEngine.h" 41 #include "Orxonox.h"42 41 #include "core/CoreIncludes.h" 43 42 #include "util/Convert.h" … … 55 54 this->bEnabled_ = true; 56 55 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); 59 59 60 if (GraphicsEngine::get Singleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_)60 if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_) 61 61 { 62 62 this->bVisible_ = false; … … 72 72 { 73 73 this->particleSystem_->removeAllEmitters(); 74 GraphicsEngine::get Singleton().getSceneManager()->destroyParticleSystem(particleSystem_);74 GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_); 75 75 } 76 76 … … 171 171 void ParticleInterface::setSpeedFactor(float factor) 172 172 { 173 this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor() * factor); 173 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 174 this->particleSystem_->setSpeedFactor(1.0f * factor); 174 175 } 175 176 float ParticleInterface::getSpeedFactor() const 176 177 { 177 return (this->particleSystem_->getSpeedFactor() / Orxonox::getSingleton()->getTimeFactor()); 178 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 179 return (this->particleSystem_->getSpeedFactor() / 1.0f); 178 180 } 179 181 -
code/trunk/src/orxonox/tools/Timer.cc
r1552 r1755 36 36 #include "core/ConsoleCommand.h" 37 37 #include "core/CommandExecutor.h" 38 #include "core/Clock.h" 38 39 39 40 namespace orxonox … … 125 126 @brief Updates the timer before the frames are rendered. 126 127 */ 127 void TimerBase::tick( float dt)128 void TimerBase::tick(const Clock& time) 128 129 { 129 130 if (this->bActive_) 130 131 { 131 132 // If active: Decrease the timer by the duration of the last frame 132 this->time_ -= dt;133 this->time_ -= time.getDeltaTimeMicroseconds(); 133 134 134 135 if (this->time_ <= 0) -
code/trunk/src/orxonox/tools/Timer.h
r1608 r1755 62 62 63 63 #include "OrxonoxPrereqs.h" 64 #include " objects/Tickable.h"64 #include "core/OrxonoxClass.h" 65 65 66 66 namespace orxonox … … 72 72 73 73 //! TimerBase is the parent of the Timer class. 74 class _OrxonoxExport TimerBase : public Tickable74 class _OrxonoxExport TimerBase : public OrxonoxClass 75 75 { 76 76 public: … … 97 97 /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */ 98 98 inline float getRemainingTime() const 99 { return this->time_; }99 { return (float)this->time_ / 1000000.0f; } 100 100 /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */ 101 101 inline void addTime(float time) 102 { this->time_ += time; }102 { if (time > 0.0f) this->time_ += (long long)(time * 1000000.0f); } 103 103 /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */ 104 104 inline void removeTime(float time) 105 { this->time_ -= time; }105 { if (time > 0.0f) this->time_ -= (long long)(time * 1000000.0f); } 106 106 /** @brief Sets the interval of the Timer. @param interval The interval */ 107 107 inline void setInterval(float interval) 108 { this->interval_ = interval; }108 { this->interval_ = (long long)(interval * 1000000.0f); } 109 109 /** @brief Sets bLoop to a given value. @param bLoop True = loop */ 110 110 inline void setLoop(bool bLoop) 111 111 { this->bLoop_ = bLoop; } 112 112 113 void tick( float dt);113 void tick(const Clock& time); 114 114 115 115 protected: … … 118 118 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 119 120 float interval_; //!< The time-interval inseconds120 long long interval_; //!< The time-interval in micro seconds 121 121 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 122 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 123 124 float time_;//!< Internal variable, counting the time till the next function-call124 long long time_; //!< Internal variable, counting the time till the next function-call 125 125 }; 126 126 … … 155 155 this->deleteExecutor(); 156 156 157 this-> interval_ = interval;157 this->setInterval(interval); 158 158 this->bLoop_ = bLoop; 159 159 executor->setObject(object); … … 161 161 this->bActive_ = true; 162 162 163 this->time_ = interval;163 this->time_ = this->interval_; 164 164 } 165 165 }; … … 193 193 this->deleteExecutor(); 194 194 195 this-> interval_ = interval;195 this->setInterval(interval); 196 196 this->bLoop_ = bLoop; 197 197 this->executor_ = (Executor*)executor; 198 198 this->bActive_ = true; 199 199 200 this->time_ = interval;200 this->time_ = this->interval_; 201 201 } 202 202 }; -
code/trunk/src/orxonox/tools/WindowEventListener.h
r1625 r1755 45 45 virtual ~WindowEventListener() { } 46 46 47 48 47 /** Window has moved position */ 48 virtual void windowMoved() { } 49 49 50 51 50 /** Window has resized */ 51 virtual void windowResized(int newWidth, int newHeight) { } 52 52 53 54 53 /** Window has lost/gained focus */ 54 virtual void windowFocusChanged() { } 55 55 }; 56 56 }
Note: See TracChangeset
for help on using the changeset viewer.