Changeset 8079 for code/trunk/src
- Timestamp:
- Mar 15, 2011, 9:47:11 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 74 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/CMakeLists.txt
r7955 r8079 119 119 ADD_SUBDIRECTORY(libraries) 120 120 ADD_SUBDIRECTORY(orxonox) 121 SET(ORXONOX_MODULES CACHE INTERNAL "") 121 122 ADD_SUBDIRECTORY(modules) 122 123 -
code/trunk/src/external/enet/win32.c
r7954 r8079 11 11 #define ENET_BUILDING_LIB 1 12 12 #include "enet/enet.h" 13 #include <ws2tcpip.h> 13 14 14 15 static enet_uint32 timeBase = 0; -
code/trunk/src/libraries/core/CMakeLists.txt
r7284 r8079 35 35 OrxonoxClass.cc 36 36 Resource.cc 37 WindowEventListener.cc38 37 39 38 # hierarchy … … 49 48 Template.cc 50 49 XMLPort.cc 50 51 COMPILATION_BEGIN ListenerCompilation.cc 52 ViewportEventListener.cc 53 WindowEventListener.cc 51 54 XMLNameListener.cc 55 COMPILATION_END 52 56 53 57 COMPILATION_BEGIN FilesystemCompilation.cc … … 76 80 Game.h 77 81 GameMode.h 82 GraphicsManager.h 78 83 GUIManager.h 79 84 Loader.h -
code/trunk/src/libraries/core/Core.cc
r7872 r8079 208 208 #ifdef ORXONOX_RELEASE 209 209 const unsigned int defaultLevelLogFile = 3; 210 SetConfigValue(bDevMode_, false) 211 .description("Developer mode. If not set, hides some things from the user to not confuse him."); 210 212 #else 211 213 const unsigned int defaultLevelLogFile = 4; 214 SetConfigValue(bDevMode_, true) 215 .description("Developer mode. If not set, hides some things from the user to not confuse him."); 212 216 #endif 213 217 SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile) -
code/trunk/src/libraries/core/Core.h
r7870 r8079 91 91 { return this->ogreConfigTimestamp_; } 92 92 93 inline bool inDevMode(void) const 94 { return this->bDevMode_; } 95 93 96 private: 94 97 Core(const Core&); //!< Don't use (undefined symbol) … … 130 133 long long lastLevelTimestamp_; ///< Timestamp when the last level was started 131 134 long long ogreConfigTimestamp_; ///< Timestamp wehen the ogre config level was modified 135 bool bDevMode_; //!< Developers bit. If set to false, some options are not available as to not confuse the normal user. 132 136 133 137 static Core* singletonPtr_s; -
code/trunk/src/libraries/core/CorePrereqs.h
r7849 r8079 182 182 class Thread; 183 183 class ThreadPool; 184 class ViewportEventListener; 184 185 template <class T> 185 186 class WeakPtr; -
code/trunk/src/libraries/core/GUIManager.cc
r7876 r8079 32 32 #include <boost/bind.hpp> 33 33 #include <memory> 34 extern "C" { 35 #include <lua.h> 36 } 34 37 35 #include <CEGUIDefaultLogger.h> 38 36 #include <CEGUIExceptions.h> … … 107 105 SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false); 108 106 SetConsoleCommand("hideGUI", &GUIManager::hideGUI); 107 SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false); 109 108 110 109 /** … … 284 283 { 285 284 GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")"); 285 } 286 287 /** 288 @brief 289 Toggles specified GUI. 290 If the GUI with the input name is already shown and on the top, it is hidden, else it is shown. 291 */ 292 /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput) 293 { 294 GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")"); 295 } 296 297 /** 298 @brief 299 Helper method to toggle a specified GUI. 300 Is called by lua. 301 */ 302 void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show) 303 { 304 if(show) 305 GUIManager::showGUI(name, bHidePrevious, bNoInput); 306 else 307 GUIManager::hideGUI(name); 286 308 } 287 309 … … 512 534 void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight) 513 535 { 514 this->guiRenderer_->setDisplaySize(CEGUI::Size( newWidth,newHeight));515 } 516 517 /** 518 @brief Notify CEGUI if the windows loses the focus (stops hig lightof menu items, etc).536 this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight)); 537 } 538 539 /** 540 @brief Notify CEGUI if the windows loses the focus (stops highlighting of menu items, etc). 519 541 */ 520 542 void GUIManager::windowFocusChanged(bool bFocus) -
code/trunk/src/libraries/core/GUIManager.h
r7874 r8079 49 49 #include "util/Singleton.h" 50 50 #include "input/InputHandler.h" 51 #include "Core.h" 51 52 #include "OrxonoxClass.h" 52 53 #include "WindowEventListener.h" … … 88 89 void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false); 89 90 static void hideGUI(const std::string& name); 91 static void toggleGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false); 92 void toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show); // tolua_export 90 93 void keyESC(); 91 94 void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export 92 95 void setBackgroundImage(const std::string& image); 96 97 /** 98 @brief Helper method to get the developer's mode without having to export Core.h. 99 @see Core::inDevMode 100 */ 101 static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export 93 102 94 103 //! Creates a new InputState to be used with a GUI Sheet -
code/trunk/src/libraries/core/Game.cc
r7284 r8079 50 50 #include "GameMode.h" 51 51 #include "GameState.h" 52 #include "GraphicsManager.h" 52 53 #include "GUIManager.h" 53 54 #include "command/ConsoleCommand.h" … … 60 61 static void printFPS() 61 62 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; } 62 SetConsoleCommand(" printFPS", &printFPS);63 SetConsoleCommand("Stats", "printFPS", &printFPS); 63 64 static void printTickTime() 64 65 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; } 65 SetConsoleCommand(" printTickTime", &printTickTime);66 SetConsoleCommand("Stats", "printTickTime", &printTickTime); 66 67 67 68 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; … … 142 143 SetConfigValue(statisticsAvgLength_, 1000000) 143 144 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 144 SetConfigValue(fpsLimit_, 50) 145 146 SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50) 145 147 .description("Sets the desired frame rate (0 for no limit)."); 146 148 } … … 207 209 208 210 // Limit frame rate 209 this->updateFPSLimiter(); 211 static bool hasVSync = GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart 212 if (this->fpsLimit_ > 0 && !hasVSync) 213 this->updateFPSLimiter(); 210 214 } 211 215 -
code/trunk/src/libraries/core/GraphicsManager.cc
r7874 r8079 49 49 #include "SpecialConfig.h" 50 50 #include "util/Clock.h" 51 #include "util/Convert.h" 51 52 #include "util/Exception.h" 52 53 #include "util/StringUtils.h" … … 57 58 #include "Game.h" 58 59 #include "GameMode.h" 60 #include "GUIManager.h" 59 61 #include "Loader.h" 60 62 #include "MemoryArchive.h" 61 63 #include "PathConfig.h" 64 #include "ViewportEventListener.h" 62 65 #include "WindowEventListener.h" 63 66 #include "XMLFile.h" 64 67 #include "command/ConsoleCommand.h" 68 #include "input/InputManager.h" 65 69 66 70 namespace orxonox 67 71 { 72 static const std::string __CC_GraphicsManager_group = "GraphicsManager"; 73 static const std::string __CC_setScreenResolution_name = "setScreenResolution"; 74 static const std::string __CC_setFSAA_name = "setFSAA"; 75 static const std::string __CC_setVSync_name = "setVSync"; 76 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name, &prototype::string__uint_uint_bool); 77 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name, &prototype::string__string); 78 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name, &prototype::string__bool); 79 68 80 static const std::string __CC_printScreen_name = "printScreen"; 69 81 DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void); … … 95 107 , renderWindow_(0) 96 108 , viewport_(0) 109 , lastFrameStartTime_(0.0f) 110 , lastFrameEndTime_(0.0f) 97 111 { 98 112 RegisterObject(GraphicsManager); … … 136 150 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 137 151 ModifyConsoleCommand(__CC_printScreen_name).resetFunction(); 152 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction(); 153 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction(); 154 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction(); 138 155 139 156 // Undeclare the resources … … 304 321 CCOUT(4) << "Configuring Renderer" << std::endl; 305 322 306 if (!ogreRoot_->restoreConfig() || Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp()) 323 bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp(); 324 if (updatedConfig) 325 COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl; 326 327 if (!ogreRoot_->restoreConfig() || updatedConfig) 307 328 { 308 329 if (!ogreRoot_->showConfigDialog()) … … 330 351 // add console commands 331 352 ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this); 353 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).setFunction(&GraphicsManager::setScreenResolution, this); 354 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).setFunction(&GraphicsManager::setFSAA, this); 355 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).setFunction(&GraphicsManager::setVSync, this); 332 356 } 333 357 … … 343 367 @note 344 368 A note about the Ogre::FrameListener: Even though we don't use them, 345 they still get called. However, the delta times are not correct (except 346 for timeSinceLastFrame, which is the most important). A little research 347 as shown that there is probably only one FrameListener that doesn't even 348 need the time. So we shouldn't run into problems. 369 they still get called. 349 370 */ 350 371 void GraphicsManager::postUpdate(const Clock& time) 351 372 { 373 // Time before rendering 374 uint64_t timeBeforeTick = time.getRealMicroseconds(); 375 376 // Ogre's time keeping object 352 377 Ogre::FrameEvent evt; 353 evt.timeSinceLastFrame = time.getDeltaTime(); 354 evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway 355 356 // don't forget to call _fireFrameStarted to OGRE to make sure 357 // everything goes smoothly 378 379 // Translate to Ogre float times before the update 380 float temp = lastFrameStartTime_; 381 lastFrameStartTime_ = (float)timeBeforeTick * 0.000001f; 382 evt.timeSinceLastFrame = lastFrameStartTime_ - temp; 383 evt.timeSinceLastEvent = lastFrameStartTime_ - lastFrameEndTime_; 384 385 // Ogre requires the time too 358 386 ogreRoot_->_fireFrameStarted(evt); 359 387 … … 361 389 // This calls the WindowEventListener objects. 362 390 Ogre::WindowEventUtilities::messagePump(); 363 // make sure the window stays active even when not focused391 // Make sure the window stays active even when not focused 364 392 // (probably only necessary on windows) 365 393 this->renderWindow_->setActive(true); 366 367 // Time before rendering368 uint64_t timeBeforeTick = time.getRealMicroseconds();369 394 370 395 // Render frame … … 375 400 Game::getInstance().subtractTickTime((int32_t)(timeAfterTick - timeBeforeTick)); 376 401 377 // again, just to be sure OGRE works fine 378 ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 402 // Translate to Ogre float times after the update 403 temp = lastFrameEndTime_; 404 lastFrameEndTime_ = (float)timeBeforeTick * 0.000001f; 405 evt.timeSinceLastFrame = lastFrameEndTime_ - temp; 406 evt.timeSinceLastEvent = lastFrameEndTime_ - lastFrameStartTime_; 407 408 // Ogre also needs the time after the frame finished 409 ogreRoot_->_fireFrameEnded(evt); 379 410 } 380 411 381 412 void GraphicsManager::setCamera(Ogre::Camera* camera) 382 413 { 414 Ogre::Camera* oldCamera = this->viewport_->getCamera(); 415 383 416 this->viewport_->setCamera(camera); 417 GUIManager::getInstance().setCamera(camera); 418 419 for (ObjectList<ViewportEventListener>::iterator it = ObjectList<ViewportEventListener>::begin(); it != ObjectList<ViewportEventListener>::end(); ++it) 420 it->cameraChanged(this->viewport_, oldCamera); 384 421 } 385 422 … … 440 477 bool GraphicsManager::isFullScreen() const 441 478 { 479 return this->renderWindow_->isFullScreen(); 480 } 481 482 unsigned int GraphicsManager::getWindowWidth() const 483 { 484 return this->renderWindow_->getWidth(); 485 } 486 487 unsigned int GraphicsManager::getWindowHeight() const 488 { 489 return this->renderWindow_->getHeight(); 490 } 491 492 bool GraphicsManager::hasVSyncEnabled() const 493 { 442 494 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 443 if (options.find("Full Screen") != options.end()) 444 { 445 if (options["Full Screen"].currentValue == "Yes") 446 return true; 447 else 448 return false; 449 } 495 Ogre::ConfigOptionMap::iterator it = options.find("VSync"); 496 if (it != options.end()) 497 return (it->second.currentValue == "Yes"); 450 498 else 451 {452 COUT(0) << "Could not find 'Full Screen' render system option. Fix This!!!" << std::endl;453 499 return false; 454 } 500 } 501 502 std::string GraphicsManager::getFSAAMode() const 503 { 504 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 505 Ogre::ConfigOptionMap::iterator it = options.find("FSAA"); 506 if (it != options.end()) 507 return it->second.currentValue; 508 else 509 return ""; 510 } 511 512 std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen) 513 { 514 // workaround to detect if the colour depth should be written to the config file 515 bool bWriteColourDepth = false; 516 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 517 Ogre::ConfigOptionMap::iterator it = options.find("Video Mode"); 518 if (it != options.end()) 519 bWriteColourDepth = (it->second.currentValue.find('@') != std::string::npos); 520 521 if (bWriteColourDepth) 522 { 523 this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) 524 + " x " + multi_cast<std::string>(height) 525 + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour"); 526 } 527 else 528 { 529 this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) 530 + " x " + multi_cast<std::string>(height)); 531 } 532 533 this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No"); 534 535 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 536 537 if (validate == "") 538 { 539 GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height); 540 this->ogreRoot_->saveConfig(); 541 Core::getInstance().updateOgreConfigTimestamp(); 542 // Also reload the input devices 543 InputManager::getInstance().reload(); 544 } 545 546 return validate; 547 } 548 549 std::string GraphicsManager::setFSAA(const std::string& mode) 550 { 551 this->ogreRoot_->getRenderSystem()->setConfigOption("FSAA", mode); 552 553 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 554 555 if (validate == "") 556 { 557 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 558 this->ogreRoot_->saveConfig(); 559 Core::getInstance().updateOgreConfigTimestamp(); 560 } 561 562 return validate; 563 } 564 565 std::string GraphicsManager::setVSync(bool vsync) 566 { 567 this->ogreRoot_->getRenderSystem()->setConfigOption("VSync", vsync ? "Yes" : "No"); 568 569 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 570 571 if (validate == "") 572 { 573 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 574 this->ogreRoot_->saveConfig(); 575 Core::getInstance().updateOgreConfigTimestamp(); 576 } 577 578 return validate; 455 579 } 456 580 -
code/trunk/src/libraries/core/GraphicsManager.h
r7401 r8079 54 54 #include "OrxonoxClass.h" 55 55 56 // tolua_begin 56 57 namespace orxonox 57 58 { … … 60 61 Graphics engine manager class 61 62 */ 62 class _CoreExport GraphicsManager : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener 63 { 63 class _CoreExport GraphicsManager 64 // tolua_end 65 : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener 66 { // tolua_export 64 67 friend class Singleton<GraphicsManager>; 65 68 public: … … 74 77 Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; } 75 78 size_t getRenderWindowHandle(); 79 80 // tolua_begin 81 static GraphicsManager& getInstance() { return Singleton<GraphicsManager>::getInstance(); } // tolua_export 82 76 83 bool isFullScreen() const; 84 unsigned int getWindowWidth() const; 85 unsigned int getWindowHeight() const; 86 87 bool hasVSyncEnabled() const; 88 std::string getFSAAMode() const; 89 // tolua_end 77 90 78 91 void upgradeToGraphics(); … … 96 109 // console commands 97 110 void printScreen(); 111 std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen); 112 std::string setFSAA(const std::string& mode); 113 std::string setVSync(bool vsync); 98 114 99 115 scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h … … 105 121 Ogre::RenderWindow* renderWindow_; //!< the one and only render window 106 122 Ogre::Viewport* viewport_; //!< default full size viewport 123 float lastFrameStartTime_; //!< Time stamp of the beginning of the last frame 124 float lastFrameEndTime_; //!< Time stamp of the end of the last frame 107 125 108 126 // XML files for the resources and the debug overlay … … 121 139 122 140 static GraphicsManager* singletonPtr_s; //!< Pointer to the Singleton 141 // tolua_begin 123 142 }; 124 143 } 144 // tolua_end 125 145 126 146 #endif /* _GraphicsManager_H__ */ -
code/trunk/src/libraries/core/Loader.cc
r7648 r8079 147 147 Returns true if successful. 148 148 */ 149 bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose )149 bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags) 150 150 { 151 151 if (!file) … … 155 155 156 156 std::string xmlInput; 157 if (file->getLuaSupport() )157 if (file->getLuaSupport() && !bRemoveLuaTags) 158 158 { 159 159 // Use the LuaState to replace the XML tags (calls our function) … … 172 172 } 173 173 xmlInput = Resource::open(file->getFilename())->getAsString(); 174 175 if (bRemoveLuaTags) 176 { 177 // Remove all Lua code. 178 // Note: we only need this to speed up parsing of level files at the 179 // start of the program. 180 // Assumption: the LevelInfo tag does not use Lua scripting 181 xmlInput = removeLuaTags(xmlInput); 182 } 174 183 } 175 184 … … 271 280 } 272 281 273 std::string Loader::replaceLuaTags(const std::string& text) 274 { 275 // create map with all Lua tags 276 std::map<size_t, bool> luaTags; 282 bool Loader::getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags) 283 { 284 // fill map with all Lua tags 277 285 { 278 286 size_t pos = 0; … … 328 336 { 329 337 COUT(2) << "Warning: Error in level file" << std::endl; 330 // todo: errorhandling 331 return ""; 332 } 333 } 338 // TODO: error handling 339 return false; 340 } 341 } 342 343 return true; 344 } 345 346 std::string Loader::replaceLuaTags(const std::string& text) 347 { 348 // create a map with all lua tags 349 std::map<size_t, bool> luaTags; 350 if (!getLuaTags(text, luaTags)) 351 return ""; 334 352 335 353 // Use a stringstream object to speed up the parsing … … 421 439 return output.str(); 422 440 } 441 442 std::string Loader::removeLuaTags(const std::string& text) 443 { 444 // create a map with all lua tags 445 std::map<size_t, bool> luaTags; 446 if (!getLuaTags(text, luaTags)) 447 return ""; 448 449 // Use a stringstream object to speed up the concatenation 450 std::ostringstream output; 451 452 // cut the original string into pieces and only write the non Lua parts 453 std::map<size_t, bool>::iterator it = luaTags.begin(); 454 bool bLuaCode = false; 455 size_t start = 0; 456 size_t end = 0; 457 458 do 459 { 460 if (it != luaTags.end()) 461 end = (it++)->first; 462 else 463 end = std::string::npos; 464 465 if (!bLuaCode) 466 { 467 output << text.substr(start, end - start); 468 start = end + 5; 469 } 470 else 471 start = end + 2; 472 473 bLuaCode = !bLuaCode; 474 } 475 while (end != std::string::npos); 476 477 return output.str(); 478 } 423 479 } -
code/trunk/src/libraries/core/Loader.h
r7648 r8079 42 42 #include "CorePrereqs.h" 43 43 44 #include <map> 44 45 #include <vector> 45 46 #include "ClassTreeMask.h" … … 61 62 static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true); 62 63 63 static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true); 64 static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), 65 bool verbose = true, bool bRemoveLuaTags = false); 64 66 static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 65 67 static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true); 66 68 67 69 static std::string replaceLuaTags(const std::string& text); 70 static std::string removeLuaTags(const std::string& text); 68 71 69 72 static ClassTreeMask currentMask_s; 70 73 71 74 private: 75 static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags); 76 72 77 static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s; 73 78 }; -
code/trunk/src/libraries/core/OrxonoxClass.h
r7850 r8079 194 194 195 195 protected: 196 virtual ~DestructionListener() {} 197 196 198 inline void registerAsDestructionListener(OrxonoxClass* object) 197 199 { if (object) { object->registerDestructionListener(this); } } -
code/trunk/src/libraries/core/WeakPtr.h
r7850 r8079 129 129 130 130 /// Destructor 131 inline ~WeakPtr()131 inline virtual ~WeakPtr() 132 132 { 133 133 this->unregisterAsDestructionListener(this->base_); -
code/trunk/src/libraries/core/command/CommandEvaluation.h
r7401 r8079 70 70 71 71 @remarks execCommand_ and hintCommand_ can be different in this case: There are multiple 72 commands avaliable, let's say "tcl" , "tclexecute", and "tclquery". The user enters73 "tcl", which is already a valid command. Now execCommand_ points to the "tcl"-command,74 but hintCommand_ still points to the autocompletion command of CommandExecutor, because75 the auto-completion list must still return the three possible commands, "tcl tclexecute tclquery"76 because the user may want to execute "tclquery" and needs auto-completion.72 commands avaliable, let's say "tcl" and "TclThreadManager". The user enters "tcl", which 73 is already a valid command. Now execCommand_ points to the "tcl"-command, but hintCommand_ 74 still points to the autocompletion command of CommandExecutor, because the auto-completion 75 list must still return the two possible commands, "tcl TclThreadManager" because the user 76 may want to write "TclThreadManager ..." and needs auto-completion. 77 77 78 78 @see See @ref CommandExecutorExample "this description" for an example. -
code/trunk/src/libraries/core/command/ConsoleCommand.h
r7861 r8079 317 317 inline void void__void(void) {} 318 318 inline void void__string(const std::string&) {} 319 320 inline std::string string__bool(bool) { return ""; } 321 inline std::string string__string(const std::string&) { return ""; } 322 inline std::string string__uint_uint_bool(unsigned int, unsigned int, bool) { return ""; } 319 323 } 320 324 -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
r7401 r8079 46 46 namespace orxonox 47 47 { 48 SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); 48 // SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 49 49 SetConsoleCommand("echo", echo); 50 SetConsoleCommand("puts", puts); 51 52 SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); 53 SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); 54 SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); 50 // SetConsoleCommand("puts", puts); // disabled because we use the implementation in Tcl 51 52 // SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 53 // SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 54 // SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 55 55 56 56 SetConsoleCommand("calculate", calculate); -
code/trunk/src/libraries/core/command/Shell.cc
r7401 r8079 46 46 { 47 47 SetConsoleCommand("log", OutputHandler::log ); 48 SetConsoleCommand("error", OutputHandler::error ) ;49 SetConsoleCommand("warning", OutputHandler::warning) ;50 SetConsoleCommand("info", OutputHandler::info ) ;51 SetConsoleCommand("debug", OutputHandler::debug ) ;48 SetConsoleCommand("error", OutputHandler::error ).hide(); 49 SetConsoleCommand("warning", OutputHandler::warning).hide(); 50 SetConsoleCommand("info", OutputHandler::info ).hide(); 51 SetConsoleCommand("debug", OutputHandler::debug ).hide(); 52 52 53 53 unsigned int Shell::cacheSize_s; -
code/trunk/src/libraries/core/command/TclBind.cc
r7401 r8079 45 45 { 46 46 SetConsoleCommand("tcl", &TclBind::tcl); 47 SetConsoleCommand("bgerror", &TclBind::bgerror) ;47 SetConsoleCommand("bgerror", &TclBind::bgerror).hide(); 48 48 49 49 TclBind* TclBind::singletonPtr_s = 0; … … 91 91 92 92 this->interpreter_->def("::orxonox::query", TclBind::tcl_query, Tcl::variadic()); 93 this->interpreter_->def("::orxonox::execute", TclBind::tcl_execute, Tcl::variadic()); 93 94 this->interpreter_->def("::orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic()); 94 this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());95 95 this->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic()); 96 96 97 97 try 98 98 { 99 this->interpreter_->eval("proc query {args} { ::orxonox::query $args }"); 99 this->interpreter_->def("query", TclBind::tcl_query, Tcl::variadic()); 100 this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic()); 100 101 this->interpreter_->eval("proc crossquery {id args} { ::orxonox::crossquery 0 $id $args }"); 101 this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::cross query0 $id $args }");102 this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossexecute 0 $id $args }"); 102 103 this->interpreter_->eval("proc running {} { return 1 }"); 103 104 this->interpreter_->eval("set id 0"); … … 154 155 { 155 156 COUT(4) << "Tcl_query: " << args.get() << std::endl; 156 157 return TclBind::tcl_helper(args, true); 158 } 159 160 /** 161 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor. 162 */ 163 void TclBind::tcl_execute(Tcl::object const &args) 164 { 165 COUT(4) << "Tcl_execute: " << args.get() << std::endl; 166 TclBind::tcl_helper(args, false); 167 } 168 169 /** 170 @brief Helper function, used by tcl_query() and tcl_execute(). 171 */ 172 std::string TclBind::tcl_helper(Tcl::object const &args, bool bQuery) 173 { 157 174 const std::string& command = stripEnclosingBraces(args.get()); 158 175 159 176 int error; 177 std::string result; 178 160 179 CommandEvaluation evaluation = CommandExecutor::evaluate(command); 161 const std::string& result = evaluation.query(&error); 180 181 if (bQuery) 182 result = evaluation.query(&error).getString(); 183 else 184 error = evaluation.execute(); 185 162 186 switch (error) 163 187 { … … 175 199 176 200 /** 177 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor.178 */179 void TclBind::tcl_execute(Tcl::object const &args)180 {181 COUT(4) << "Tcl_execute: " << args.get() << std::endl;182 const std::string& command = stripEnclosingBraces(args.get());183 184 if (CommandExecutor::execute(command, false))185 {186 COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;187 }188 }189 190 /**191 201 @brief Console command, executes Tcl code. Can be used to bind Tcl-commands to a key, because native 192 202 Tcl-commands can not be evaluated and are thus not supported by the key-binder. … … 198 208 try 199 209 { 200 const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode); 201 if (!output.empty()) 202 { 203 COUT(0) << "tcl> " << output << std::endl; 204 } 205 return output; 210 return TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode); 206 211 } 207 212 catch (Tcl::tcl_error const &e) 208 { COUT(1) << " tcl> Error: " << e.what() << std::endl; }213 { COUT(1) << "Tcl error: " << e.what() << std::endl; } 209 214 } 210 215 -
code/trunk/src/libraries/core/command/TclBind.h
r7401 r8079 126 126 TclBind(const TclBind& other); ///< Copy-constructor, not implemented 127 127 128 static std::string tcl_helper(Tcl::object const &args, bool bQuery); 129 128 130 Tcl::interpreter* interpreter_; ///< The wrapped Tcl interpreter 129 131 std::string tclDataPath_; ///< The path to the directory that contains the Orxonox-specific Tcl-files -
code/trunk/src/libraries/core/command/TclThreadManager.cc
r7401 r8079 55 55 const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f; 56 56 57 SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());58 SetConsoleCommand("tclquery", &TclThreadManager::query ).argumentCompleter(0, autocompletion::tclthreads());59 57 SetConsoleCommand("TclThreadManager", "create", &TclThreadManager::create); 60 58 SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads()); -
code/trunk/src/libraries/core/input/InputManager.cc
r7874 r8079 641 641 state->destroy(); 642 642 } 643 644 bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value) 645 { 646 if (name == "empty") 647 { 648 COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl; 649 return false; 650 } 651 std::map<std::string, InputState*>::iterator it = statesByName_.find(name); 652 if (it != statesByName_.end()) 653 { 654 it->second->setMouseExclusive(value); 655 return true; 656 } 657 return false; 658 } 643 659 } -
code/trunk/src/libraries/core/input/InputManager.h
r7874 r8079 163 163 */ 164 164 bool destroyState(const std::string& name); // tolua_export 165 /** 166 @brief 167 Changes the mouse mode of an input state. 168 @return 169 True if the call was successful, fals if the name was not found 170 */ 171 bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export 165 172 166 173 //------------------------------- -
code/trunk/src/libraries/core/input/KeyBinder.cc
r7958 r8079 431 431 // decrease counter 432 432 button->nCommands_[mode_index]--; 433 // note: we don't replace the old array - it's not one element too large, but no one cares since nCommands_ defines the size 433 // old array would not get deleted if nCommands_ is now 0 434 // otherwise: nobody cares about an array that is one element too large - nCommands_ defines the size 435 if (button->nCommands_[mode_index] == 0) 436 { 437 delete[] button->commands_[mode_index]; 438 button->commands_[mode_index] = 0; 439 } 434 440 435 441 // decrement the index since we shifted the array and continue searching for more occurrences of the command -
code/trunk/src/libraries/core/input/Keyboard.cc
r6422 r8079 36 36 { 37 37 // update modifiers 38 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 39 modifiers_ |= KeyboardModifier::Alt; // alt key 40 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 41 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 42 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 43 modifiers_ |= KeyboardModifier::Shift; // shift key 38 switch (arg.key) 39 { 40 case OIS::KC_RMENU: 41 case OIS::KC_LMENU: 42 modifiers_ |= KeyboardModifier::Alt; // alt key 43 break; 44 case OIS::KC_RCONTROL: 45 case OIS::KC_LCONTROL: 46 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 47 break; 48 case OIS::KC_RSHIFT: 49 case OIS::KC_LSHIFT: 50 modifiers_ |= KeyboardModifier::Shift; // shift key 51 break; 52 case OIS::KC_TAB: 53 // Do not distribute the alt+tab event (messes with the operating system) 54 if ((modifiers_ & KeyboardModifier::Alt) != 0) 55 return true; 56 default:; 57 } 44 58 45 // Do not distribute the alt+tab event (messes with the operating system) 46 if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB) 47 return true; 48 49 KeyEvent evt(arg); 59 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 50 60 super::buttonPressed(evt); 51 61 return true; … … 56 66 { 57 67 // update modifiers 58 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 59 modifiers_ &= ~KeyboardModifier::Alt; // alt key 60 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 61 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 62 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 63 modifiers_ &= ~KeyboardModifier::Shift; // shift key 68 switch (arg.key) 69 { 70 case OIS::KC_RMENU: 71 case OIS::KC_LMENU: 72 modifiers_ &= ~KeyboardModifier::Alt; // alt key 73 break; 74 case OIS::KC_RCONTROL: 75 case OIS::KC_LCONTROL: 76 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 77 break; 78 case OIS::KC_RSHIFT: 79 case OIS::KC_LSHIFT: 80 modifiers_ &= ~KeyboardModifier::Shift; // shift key 81 break; 82 default:; 83 } 64 84 65 KeyEvent evt( arg);85 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 66 86 super::buttonReleased(evt); 67 87 return true; 68 88 } 89 90 /// A map which returns the corresponding chars for some key codes 91 unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg) 92 { 93 switch (arg.key) 94 { 95 case OIS::KC_NUMPAD0: return static_cast<unsigned int>('0'); 96 case OIS::KC_NUMPAD1: return static_cast<unsigned int>('1'); 97 case OIS::KC_NUMPAD2: return static_cast<unsigned int>('2'); 98 case OIS::KC_NUMPAD3: return static_cast<unsigned int>('3'); 99 case OIS::KC_NUMPAD4: return static_cast<unsigned int>('4'); 100 case OIS::KC_NUMPAD5: return static_cast<unsigned int>('5'); 101 case OIS::KC_NUMPAD6: return static_cast<unsigned int>('6'); 102 case OIS::KC_NUMPAD7: return static_cast<unsigned int>('7'); 103 case OIS::KC_NUMPAD8: return static_cast<unsigned int>('8'); 104 case OIS::KC_NUMPAD9: return static_cast<unsigned int>('9'); 105 case OIS::KC_DECIMAL: return static_cast<unsigned int>('.'); 106 case OIS::KC_DIVIDE: return static_cast<unsigned int>('/'); 107 case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n'); 108 default: return arg.text; 109 } 110 } 69 111 } -
code/trunk/src/libraries/core/input/Keyboard.h
r7809 r8079 83 83 static std::string getClassNameImpl() { return "Keyboard"; } 84 84 85 static unsigned int getKeyText(const OIS::KeyEvent& arg); 86 85 87 //! Bit mask representing keyboard modifiers 86 88 int modifiers_; -
code/trunk/src/libraries/network/Host.cc
r7801 r8079 38 38 namespace orxonox { 39 39 40 static const std::string __CC_printRTT_group = "Stats"; 40 41 static const std::string __CC_printRTT_name = "printRTT"; 41 42 42 43 SetConsoleCommand("chat", &Host::Chat); 43 SetConsoleCommand(__CC_printRTT_ name, &Host::printRTT);44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 44 45 45 46 // Host* Host::instance_=0; … … 55 56 // assert(instance_==0); 56 57 instances_s.push_back(this); 57 ModifyConsoleCommand(__CC_printRTT_ name).setObject(this);58 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this); 58 59 this->bIsActive_ = false; 59 60 } … … 67 68 assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() ); 68 69 instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this )); 69 ModifyConsoleCommand(__CC_printRTT_ name).setObject(0);70 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(0); 70 71 } 71 72 -
code/trunk/src/libraries/tools/ResourceLocation.cc
r7709 r8079 30 30 31 31 #include <OgreResourceGroupManager.h> 32 #include <OgreException.h> 32 33 #include <boost/filesystem.hpp> 33 34 -
code/trunk/src/libraries/tools/Shader.cc
r6417 r8079 30 30 31 31 #include <OgreCompositorManager.h> 32 #include <OgreCompositorInstance.h>33 #include <OgreSceneManager.h>34 32 #include <OgreRoot.h> 35 33 #include <OgrePlugin.h> 36 #include <OgreMaterial.h>37 #include <OgreTechnique.h>38 #include <OgrePass.h>39 #include <OgreMaterialManager.h>40 34 41 35 #include "core/CoreIncludes.h" … … 45 39 namespace orxonox 46 40 { 47 bool Shader::bLoadedCgPlugin_s = false;48 Shader::MaterialMap Shader::parameters_s;49 41 /** 42 @brief Initializes the values and sets the scene manager. 43 */ 50 44 Shader::Shader(Ogre::SceneManager* scenemanager) : compositorInstance_(0) 51 45 { … … 53 47 54 48 this->scenemanager_ = scenemanager; 55 this->compositorInstance_ = 0;56 49 this->bVisible_ = true; 57 50 this->bLoadCompositor_ = GameMode::showsGraphics(); 58 this->bViewportInitialized_ = false; 59 60 if (this->bLoadCompositor_ && Ogre::Root::getSingletonPtr()) 61 { 62 Shader::bLoadedCgPlugin_s = false; 51 this->registeredAsListener_ = false; 52 53 static bool hasCgProgramManager = Shader::hasCgProgramManager(); 54 55 this->bLoadCompositor_ &= hasCgProgramManager; 56 } 57 58 /** 59 @brief Removes the compositor and frees the resources. 60 */ 61 Shader::~Shader() 62 { 63 if (this->compositorInstance_ && GraphicsManager::getInstance().getViewport()) 64 Ogre::CompositorManager::getSingleton().removeCompositor(GraphicsManager::getInstance().getViewport(), this->compositorName_); 65 } 66 67 /** 68 @brief Inherited from ViewportEventListener - called if the camera changes. 69 70 Since the new camera could be in a different scene, the shader has to make sure 71 it deactivates or activates itself accordingly. 72 73 Additionally the shader has to be turned off and on even if the camera stays in 74 the same scene to fix a weird behavior of Ogre. 75 */ 76 void Shader::cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera) 77 { 78 if (!this->bLoadCompositor_ || !this->scenemanager_) 79 return; 80 81 // load the compositor if not already done 82 if (!this->compositorName_.empty() && !this->compositorInstance_) 83 this->changedCompositorName(viewport); 84 85 // update compositor in viewport (shader should only be active if the current camera is in the same scene as the shader) 86 87 // Note: 88 // The shader needs also to be switched off and on after changing the camera in the 89 // same scene to avoid weird behaviour with active compositors while switching the 90 // camera (like freezing the image) 91 // 92 // Last known Ogre version needing this workaround: 93 // 1.4.8 94 // 1.7.2 95 96 if (oldCamera && this->scenemanager_ == oldCamera->getSceneManager()) 97 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, false); 98 99 if (viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager()) 100 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, this->isVisible()); 101 } 102 103 /** 104 @brief Changes the compositor - default viewport. 105 */ 106 void Shader::changedCompositorName() 107 { 108 // For the moment, we get the viewport always from the graphics manager 109 // TODO: Try to support multiple viewports - note however that scenemanager_->getCurrentViewport() returns NULL 110 // after switching to a camera in a different scene (only for the first time this scene is displayed though) 111 this->changedCompositorName(GraphicsManager::getInstance().getViewport()); 112 } 113 114 /** 115 @brief Changes the compositor. 116 */ 117 void Shader::changedCompositorName(Ogre::Viewport* viewport) 118 { 119 if (this->bLoadCompositor_) 120 { 121 assert(viewport); 122 if (this->compositorInstance_) 123 { 124 // remove the old compositor, remove the listener 125 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositorName_); 126 this->compositorInstance_->removeListener(this); 127 this->compositorInstance_ = 0; 128 } 129 if (!this->compositorName_.empty()) 130 { 131 // add the new compositor 132 this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositorName_); 133 if (this->compositorInstance_) 134 { 135 // register as listener if required 136 if (this->registeredAsListener_) 137 this->compositorInstance_->addListener(this); 138 // set visibility according to the isVisible() and the camera/viewport 139 if (viewport->getCamera()) 140 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, this->isVisible() && viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager()); 141 } 142 else 143 COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositorName_ << "\"." << std::endl; 144 } 145 this->oldcompositorName_ = this->compositorName_; 146 } 147 } 148 149 /** 150 @brief Changes the visibility of the shader. Doesn't free any resources if set to invisible. 151 */ 152 void Shader::updateVisibility() 153 { 154 if (this->compositorInstance_) 155 Ogre::CompositorManager::getSingleton().setCompositorEnabled(GraphicsManager::getInstance().getViewport(), this->compositorName_, this->isVisible()); 156 } 157 158 /** 159 @brief Defines a new integer value for a given parameter. The parameter will be updated if the compositor is rendered the next time. 160 */ 161 void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, int value) 162 { 163 ParameterContainer container = {technique, pass, parameter, value, 0.0f, MT_Type::Int}; 164 this->parameters_.push_back(container); 165 this->addAsListener(); 166 } 167 168 /** 169 @brief Defines a new float value for a given parameter. The parameter will be updated if the compositor is rendered the next time. 170 */ 171 void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, float value) 172 { 173 ParameterContainer container = {technique, pass, parameter, 0, value, MT_Type::Float}; 174 this->parameters_.push_back(container); 175 this->addAsListener(); 176 } 177 178 /** 179 @brief Registers the shader as CompositorInstance::Listener at the compositor. Used to change parameters. 180 */ 181 void Shader::addAsListener() 182 { 183 if (!this->registeredAsListener_) 184 { 185 this->registeredAsListener_ = true; 186 if (this->compositorInstance_) 187 this->compositorInstance_->addListener(this); 188 } 189 } 190 191 /** 192 @brief Inherited by Ogre::CompositorInstance::Listener, called whenever the material is rendered. Used to change parameters. 193 */ 194 void Shader::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr) 195 { 196 // iterate through the list of parameters 197 for (std::list<ParameterContainer>::iterator it = this->parameters_.begin(); it != this->parameters_.end(); ++it) 198 { 199 Ogre::Technique* techniquePtr = materialPtr->getTechnique(it->technique_); 200 if (techniquePtr) 201 { 202 Ogre::Pass* passPtr = techniquePtr->getPass(it->pass_); 203 if (passPtr) 204 { 205 // change the value of the parameter depending on its type 206 switch (it->valueType_) 207 { 208 case MT_Type::Int: 209 passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueInt_); 210 break; 211 case MT_Type::Float: 212 passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueFloat_); 213 break; 214 default: 215 break; 216 } 217 } 218 else 219 COUT(2) << "Warning: No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << std::endl; 220 } 221 else 222 COUT(2) << "Warning: No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << std::endl; 223 } 224 this->parameters_.clear(); 225 } 226 227 /** 228 @brief Detects if the Cg program manager plugin is active. 229 */ 230 /* static */ bool Shader::hasCgProgramManager() 231 { 232 if (Ogre::Root::getSingletonPtr()) 233 { 63 234 const Ogre::Root::PluginInstanceList& plugins = Ogre::Root::getSingleton().getInstalledPlugins(); 64 235 for (size_t i = 0; i < plugins.size(); ++i) 65 {66 236 if (plugins[i]->getName() == "Cg Program Manager") 67 {68 Shader::bLoadedCgPlugin_s = true;69 break;70 }71 }72 }73 74 this->bLoadCompositor_ &= Shader::bLoadedCgPlugin_s;75 }76 77 Shader::~Shader()78 {79 if (this->compositorInstance_ && this->bLoadCompositor_)80 {81 Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();82 assert(viewport);83 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_);84 }85 86 }87 88 void Shader::setSceneManager(Ogre::SceneManager* scenemanager)89 {90 this->scenemanager_ = scenemanager;91 this->bViewportInitialized_ = false;92 }93 94 void Shader::tick(float dt)95 {96 SUPER(Shader, tick, dt);97 98 if (this->bLoadCompositor_ && !this->bViewportInitialized_ && this->scenemanager_ && this->scenemanager_->getCurrentViewport())99 {100 this->bViewportInitialized_ = true;101 this->updateVisibility();102 }103 }104 105 void Shader::changedCompositor()106 {107 if (this->bLoadCompositor_)108 {109 Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();110 assert(viewport);111 if (!this->oldcompositor_.empty())112 {113 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositor_);114 this->compositorInstance_ = 0;115 }116 if (!this->compositor_.empty())117 {118 this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositor_);119 if (!this->compositorInstance_)120 COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositor_ << "\"." << std::endl;121 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, this->bViewportInitialized_ && this->isVisible());122 }123 this->oldcompositor_ = this->compositor_;124 }125 }126 127 void Shader::updateVisibility()128 {129 if (this->compositorInstance_ && this->scenemanager_)130 this->compositorInstance_->setEnabled(this->scenemanager_->getCurrentViewport() && this->isVisible());131 }132 133 void Shader::setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value)134 {135 if (Shader::_setParameter(material, technique, pass, parameter, value))136 {137 if (this->bViewportInitialized_ && this->compositorInstance_ && this->isVisible())138 {139 this->compositorInstance_->setEnabled(false);140 this->compositorInstance_->setEnabled(true);141 }142 }143 }144 145 void Shader::setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value)146 {147 if (Shader::_setParameter(material, technique, pass, parameter, value))148 {149 if (this->bViewportInitialized_ && this->compositorInstance_ && this->isVisible())150 {151 this->compositorInstance_->setEnabled(false);152 this->compositorInstance_->setEnabled(true);153 }154 }155 }156 157 bool Shader::_setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value)158 {159 ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);160 if (pointer)161 {162 if (pointer->first)163 {164 if ((*static_cast<float*>(pointer->second)) != value)165 {166 (*static_cast<float*>(pointer->second)) = value;167 237 return true; 168 }169 }170 else171 {172 if ((*static_cast<int*>(pointer->second)) != static_cast<int>(value))173 {174 (*static_cast<int*>(pointer->second)) = static_cast<int>(value);175 return true;176 }177 }178 238 } 179 239 return false; 180 240 } 181 182 bool Shader::_setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value)183 {184 ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);185 if (pointer)186 {187 if (pointer->first)188 {189 if ((*static_cast<float*>(pointer->second)) != static_cast<float>(value))190 {191 (*static_cast<float*>(pointer->second)) = static_cast<float>(value);192 return true;193 }194 }195 else196 {197 if ((*static_cast<int*>(pointer->second)) != value)198 {199 (*static_cast<int*>(pointer->second)) = value;200 return true;201 }202 }203 }204 return false;205 }206 207 float Shader::getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter)208 {209 ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);210 if (pointer)211 {212 if (pointer->first)213 return (*static_cast<float*>(pointer->second));214 else215 return static_cast<float>(*static_cast<int*>(pointer->second));216 }217 else218 return 0;219 }220 221 bool Shader::getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter)222 {223 ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);224 if (pointer)225 return pointer->first;226 else227 return false;228 }229 230 bool Shader::getParameterIsInt(const std::string& material, size_t technique, size_t pass, const std::string& parameter)231 {232 ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);233 if (pointer)234 return (!pointer->first);235 else236 return false;237 }238 239 Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter)240 {241 if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)242 return 0;243 244 MaterialMap::iterator material_iterator = Shader::parameters_s.find(material);245 if (material_iterator != Shader::parameters_s.end())246 {247 TechniqueVector& technique_vector = material_iterator->second;248 if (technique < technique_vector.size())249 {250 PassVector& pass_vector = technique_vector[technique];251 if (pass < pass_vector.size())252 {253 ParameterMap& parameter_map = pass_vector[pass];254 ParameterMap::iterator parameter_iterator = parameter_map.find(parameter);255 256 if (parameter_iterator != parameter_map.end())257 return (¶meter_iterator->second);258 else259 COUT(2) << "Warning: No shader parameter \"" << parameter << "\" in pass " << pass << " in technique " << technique << " in material \"" << material << "\"." << std::endl;260 }261 else262 COUT(2) << "Warning: No pass " << pass << " in technique " << technique << " in material \"" << material << "\" or pass has no shader." << std::endl;263 }264 else265 COUT(2) << "Warning: No technique " << technique << " in material \"" << material << "\" or technique has no pass with shader." << std::endl;266 }267 else268 {269 bool foundAtLeastOneShaderParameter = false;270 Ogre::MaterialManager::ResourceMapIterator iterator = Ogre::MaterialManager::getSingleton().getResourceIterator();271 Ogre::Material* material_pointer = 0;272 273 while (iterator.hasMoreElements())274 {275 Ogre::Resource* resource = iterator.getNext().get();276 if (resource->getName() == material)277 material_pointer = (Ogre::Material*)resource;278 }279 280 if (!material_pointer)281 {282 COUT(2) << "Warning: No material with name \"" << material << "\" found." << std::endl;283 return 0;284 }285 286 for (unsigned int t = 0; t < material_pointer->getNumTechniques(); ++t)287 {288 Ogre::Technique* technique_pointer = material_pointer->getTechnique(t);289 if (!technique_pointer)290 continue;291 292 for (unsigned int p = 0; p < technique_pointer->getNumPasses(); ++p)293 {294 Ogre::Pass* pass_pointer = technique_pointer->getPass(p);295 if (!pass_pointer)296 continue;297 298 if (!pass_pointer->getFragmentProgramName().empty())299 {300 Ogre::GpuProgramParameters* parameter_pointer = pass_pointer->getFragmentProgramParameters().get();301 if (!parameter_pointer)302 continue;303 304 const Ogre::GpuConstantDefinitionMap& constant_definitions = parameter_pointer->getConstantDefinitions().map;305 for (Ogre::GpuConstantDefinitionMap::const_iterator definition_iterator = constant_definitions.begin(); definition_iterator != constant_definitions.end(); ++definition_iterator)306 {307 void* temp = (definition_iterator->second.isFloat())308 ? static_cast<void*>(parameter_pointer->getFloatPointer(definition_iterator->second.physicalIndex))309 : static_cast<void*>(parameter_pointer->getIntPointer(definition_iterator->second.physicalIndex));310 ParameterPointer parameter_pointer = ParameterPointer(definition_iterator->second.isFloat(), temp);311 312 TechniqueVector& technique_vector = Shader::parameters_s[material];313 technique_vector.resize(technique + 1);314 PassVector& pass_vector = technique_vector[technique];315 pass_vector.resize(pass + 1);316 pass_vector[pass][definition_iterator->first] = parameter_pointer;317 foundAtLeastOneShaderParameter = true;318 }319 }320 }321 }322 323 // recursive call if the material was added to the map324 if (foundAtLeastOneShaderParameter)325 return Shader::getParameterPointer(material, technique, pass, parameter);326 }327 return 0;328 }329 241 } -
code/trunk/src/libraries/tools/Shader.h
r5781 r8079 36 36 #include <vector> 37 37 38 #include <OgreCompositorInstance.h> 39 40 #include "util/MultiType.h" 38 41 #include "util/OgreForwardRefs.h" 39 #include " tools/interfaces/Tickable.h"42 #include "core/ViewportEventListener.h" 40 43 41 44 namespace orxonox 42 45 { 43 class _ToolsExport Shader : public Tickable 46 /** 47 @brief Shader is a wrapper class around Ogre::CompositorInstance. It provides some 48 functions to easily change the visibility and parameters for shader programs. 49 */ 50 class _ToolsExport Shader : public ViewportEventListener, public Ogre::CompositorInstance::Listener 44 51 { 45 typedef std::pair<bool, void*> ParameterPointer;46 typedef std::map<std::string, ParameterPointer> ParameterMap;47 typedef std::vector<ParameterMap> PassVector;48 typedef std::vector<PassVector> TechniqueVector;49 typedef std::map<std::string, TechniqueVector> MaterialMap;50 51 52 public: 52 53 Shader(Ogre::SceneManager* scenemanager = 0); 53 54 virtual ~Shader(); 54 55 55 virtual void tick(float dt); 56 56 /// Defines if the shader is visible or not. 57 57 inline void setVisible(bool bVisible) 58 58 { … … 63 63 } 64 64 } 65 /// Returns whether or not the shader is visible. 65 66 inline bool isVisible() const 66 67 { return this->bVisible_; } 67 68 void updateVisibility(); 68 69 69 inline void setCompositor(const std::string& compositor) 70 /// Defines the compositor's name (located in a .compositor file). 71 inline void setCompositorName(const std::string& name) 70 72 { 71 if (this->compositor _ != compositor)73 if (this->compositorName_ != name) 72 74 { 73 this->compositor _ = compositor;74 this->changedCompositor ();75 this->compositorName_ = name; 76 this->changedCompositorName(); 75 77 } 76 78 } 77 inline const std::string& getCompositor() const 78 { return this->compositor_; } 79 void changedCompositor(); 79 /// Returns the compositor's name. 80 inline const std::string& getCompositorName() const 81 { return this->compositorName_; } 82 void changedCompositorName(); 83 void changedCompositorName(Ogre::Viewport* viewport); 80 84 81 void setSceneManager(Ogre::SceneManager* scenemanager); 85 /// Sets the scenemanager (usually provided in the constructor, but can be set later). Shouldn't be changed once it's set. 86 inline void setSceneManager(Ogre::SceneManager* scenemanager) 87 { this->scenemanager_ = scenemanager; } 88 /// Returns the scene manager. 82 89 inline Ogre::SceneManager* getSceneManager() const 83 90 { return this->scenemanager_; } 84 91 85 void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value); 86 void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value); 92 virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera); 87 93 88 static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value); 89 static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value); 90 static float getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter); 91 static bool getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter); 92 static bool getParameterIsInt (const std::string& material, size_t technique, size_t pass, const std::string& parameter); 93 static ParameterPointer* getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter); 94 void setParameter(size_t technique, size_t pass, const std::string& parameter, float value); 95 void setParameter(size_t technique, size_t pass, const std::string& parameter, int value); 96 97 virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr); 94 98 95 99 private: 96 Ogre::SceneManager* scenemanager_; 97 Ogre::CompositorInstance* compositorInstance_; 98 bool bVisible_; 99 bool bLoadCompositor_; 100 bool bViewportInitialized_; 101 std::string compositor_; 102 std::string oldcompositor_; 100 static bool hasCgProgramManager(); 103 101 104 static MaterialMap parameters_s; 105 static bool bLoadedCgPlugin_s; 102 Ogre::SceneManager* scenemanager_; ///< The scenemanager for which the shader is active 103 Ogre::CompositorInstance* compositorInstance_; ///< The compositor instance representing the wrapped compositor 104 bool bVisible_; ///< True if the shader should be visible 105 bool bLoadCompositor_; ///< True if the compositor should be loaded (usually false if no graphics) 106 std::string compositorName_; ///< The name of the current compositor 107 std::string oldcompositorName_; ///< The name of the previous compositor (used to unregister) 108 109 private: 110 void addAsListener(); 111 112 /// Helper struct to store parameters for shader programs. 113 struct ParameterContainer 114 { 115 size_t technique_; ///< The ID of the technique 116 size_t pass_; ///< The ID of the pass 117 std::string parameter_; ///< The name of the parameter 118 119 int valueInt_; ///< The desired int value of the parameter 120 float valueFloat_; ///< The desired float value of the parameter 121 122 MT_Type::Value valueType_; ///< The type of the parameter (currently only int or float) 123 }; 124 125 std::list<ParameterContainer> parameters_; ///< The list of parameters that should be set on the next update 126 bool registeredAsListener_; ///< True if the shader should register itself as listener at the compositor 106 127 }; 107 128 } -
code/trunk/src/libraries/tools/Timer.cc
r7401 r8079 35 35 36 36 #include <set> 37 38 #include <boost/bimap.hpp> 37 39 38 40 #include "util/Clock.h" … … 41 43 #include "core/command/CommandExecutor.h" 42 44 #include "core/command/Functor.h" 45 #include "tools/interfaces/TimeFactorListener.h" 43 46 44 47 namespace orxonox 45 48 { 46 49 SetConsoleCommand("delay", &delay).argumentCompleter(1, autocompletion::command()); 50 SetConsoleCommand("delayreal", &delayreal).argumentCompleter(1, autocompletion::command()); 51 SetConsoleCommand("killdelay", &killdelay); 47 52 SetConsoleCommand("killdelays", &killdelays); 48 53 49 static std::set<Timer*> delaytimerset; 50 51 /** 52 @brief Console-command: Calls another console command after @a delay seconds. 54 static boost::bimap<unsigned int, Timer*> delaytimers; 55 static unsigned int delayHandleCounter = 0; 56 57 /** 58 @brief Console-command: Calls another console command after @a delay seconds (game time). 53 59 @param delay The delay in seconds 54 60 @param command The console command 55 */ 56 void delay(float delay, const std::string& command) 57 { 58 Timer* delaytimer = new Timer(); 59 delaytimerset.insert(delaytimer); 61 @return The handle of the delayed command, can be used as argument for killdelay() 62 */ 63 unsigned int delay(float delay, const std::string& command) 64 { 65 return addDelayedCommand(new Timer(), delay, command); 66 } 67 68 /** 69 @brief Console-command: Calls another console command after @a delay seconds (real time) 70 @param delay The delay in seconds 71 @param command The console command 72 @return The handle of the delayed command, can be used as argument for killdelay() 73 */ 74 unsigned int delayreal(float delay, const std::string& command) 75 { 76 return addDelayedCommand(new RealTimer(), delay, command); 77 } 78 79 /** 80 @brief Helper function, used by delay() and delayreal() to add a delayed command. 81 @param timer The timer which will execute the command 82 @param delay The delay in seconds 83 @param command The console command 84 @return The handle of the delayed command, can be used as argument for killdelay() 85 */ 86 unsigned int addDelayedCommand(Timer* timer, float delay, const std::string& command) 87 { 88 delaytimers.insert(boost::bimap<unsigned int, Timer*>::value_type(++delayHandleCounter, timer)); 60 89 61 90 const ExecutorStaticPtr& delayexecutor = createExecutor(createFunctor(&executeDelayedCommand)); 62 delayexecutor->setDefaultValues(delaytimer, command); 63 delaytimer->setTimer(delay, false, delayexecutor); 91 delayexecutor->setDefaultValues(timer, command); 92 timer->setTimer(delay, false, delayexecutor); 93 94 return delayHandleCounter; 64 95 } 65 96 … … 73 104 CommandExecutor::execute(command); 74 105 timer->destroy(); 75 delaytimers et.erase(timer);106 delaytimers.right.erase(timer); 76 107 } 77 108 … … 81 112 void killdelays() 82 113 { 83 for (std::set<Timer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it) 84 (*it)->destroy(); 85 86 delaytimerset.clear(); 114 for (boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.begin(); it != delaytimers.left.end(); ++it) 115 it->second->destroy(); 116 117 delaytimers.clear(); 118 } 119 120 /** 121 @brief Console-command: Kills a delayed command with given handle. 122 */ 123 void killdelay(unsigned int handle) 124 { 125 boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.find(handle); 126 if (it != delaytimers.left.end()) 127 { 128 it->second->destroy(); 129 delaytimers.left.erase(it); 130 } 87 131 } 88 132 … … 93 137 { 94 138 this->init(); 95 Register Object(Timer);139 RegisterRootObject(Timer); 96 140 } 97 141 … … 106 150 { 107 151 this->init(); 108 Register Object(Timer);152 RegisterRootObject(Timer); 109 153 110 154 this->setTimer(interval, bLoop, executor, bKillAfterCall); … … 123 167 124 168 this->time_ = 0; 169 } 170 171 /** 172 @brief Returns the current time factor of the game. 173 */ 174 float Timer::getTimeFactor() 175 { 176 return TimeFactorListener::getTimeFactor(); 125 177 } 126 178 … … 168 220 } 169 221 } 222 223 /////////////// 224 // RealTimer // 225 /////////////// 226 /// @copydoc Timer::Timer 227 RealTimer::RealTimer() 228 { 229 RegisterObject(RealTimer); 230 } 231 232 /// @copydoc Timer::Timer(float, bool, const ExecutorPtr&, bool) 233 RealTimer::RealTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall) : Timer(interval, bLoop, executor, bKillAfterCall) 234 { 235 RegisterObject(RealTimer); 236 } 237 238 /// Returns always 1 because RealTimer doesn't depend on the game time. 239 float RealTimer::getTimeFactor() 240 { 241 return 1; 242 } 170 243 } -
code/trunk/src/libraries/tools/Timer.h
r7851 r8079 81 81 #include "core/OrxonoxClass.h" 82 82 #include "core/command/Executor.h" 83 #include "tools/interfaces/TimeFactorListener.h"84 83 85 84 namespace orxonox 86 85 { 87 void delay(float delay, const std::string& command); 88 void killdelays(); 86 unsigned int delay(float delay, const std::string& command); 87 unsigned int delayreal(float delay, const std::string& command); 88 89 unsigned int addDelayedCommand(Timer* timer, float delay, const std::string& command); 89 90 void executeDelayedCommand(Timer* timer, const std::string& command); 90 91 92 void killdelay(unsigned int handle); 93 void killdelays(); 94 91 95 /** 92 @brief Timer is a helper class that executes a function after a given amount of time.96 @brief Timer is a helper class that executes a function after a given amount of seconds in game-time. 93 97 94 98 @see See @ref TimerExample "Timer.h" for an example. 99 100 The time interval of Timer depends on the game time, hence it stops if the game is paused or runs 101 slower/faster if the game-speed is modified. See RealTimer for a timer class which doesn't depend 102 on the game time. 95 103 */ 96 class _ToolsExport Timer : public TimeFactorListener104 class _ToolsExport Timer : virtual public OrxonoxClass 97 105 { 98 106 public: … … 123 131 void run(); 124 132 125 /// Re-starts the Timer: The executor will be called after @a interval seconds.133 /// Re-starts the timer: The executor will be called after @a interval seconds. 126 134 inline void startTimer() 127 135 { this->bActive_ = true; this->time_ = this->interval_; } 128 /// Stops the Timer.136 /// Stops the timer. 129 137 inline void stopTimer() 130 138 { this->bActive_ = false; this->time_ = this->interval_; } 131 /// Pauses the Timer - it will continue with the actual state if you call unpauseTimer().139 /// Pauses the timer - it will continue with the actual state if you call unpauseTimer(). 132 140 inline void pauseTimer() 133 141 { this->bActive_ = false; } 134 /// Unpauses the Timer - continues with the given state.142 /// Unpauses the timer - continues with the given state. 135 143 inline void unpauseTimer() 136 144 { this->bActive_ = true; } 137 /// Returns true if the Timer is active (neither stopped nor paused).145 /// Returns true if the timer is active (neither stopped nor paused). 138 146 inline bool isActive() const 139 147 { return this->bActive_; } 140 /// Returns the remaining time until the Timer calls the executor.148 /// Returns the remaining time until the timer calls the executor. 141 149 inline float getRemainingTime() const 142 150 { return static_cast<float>(this->time_ / 1000000.0f); } 143 /// Increases the remaining time of the Timer by the given amount of time (in seconds).151 /// Increases the remaining time of the timer by the given amount of time (in seconds). 144 152 inline void addTime(float time) 145 153 { if (time > 0.0f) this->time_ += static_cast<long long>(time * 1000000.0f); } 146 /// Decreases the remaining time of the Timer by the given amount of time (in seconds)154 /// Decreases the remaining time of the timer by the given amount of time (in seconds) 147 155 inline void removeTime(float time) 148 156 { if (time > 0.0f) this->time_ -= static_cast<long long>(time * 1000000.0f); } … … 156 164 void tick(const Clock& time); 157 165 166 protected: 167 virtual float getTimeFactor(); 168 158 169 private: 159 170 void init(); … … 163 174 long long interval_; //!< The time-interval in micro seconds 164 175 bool bLoop_; //!< If true, the executor gets called every @a interval seconds 165 bool bActive_; //!< If true, the Timer ticks and calls the executor if the time's up176 bool bActive_; //!< If true, the timer ticks and calls the executor if the time's up 166 177 bool bKillAfterCall_; //!< If true the timer gets deleted after it expired and called the executor 167 178 168 179 long long time_; //!< Internal variable, counting the time untill the next executor-call 169 180 }; 181 182 /** 183 @brief RealTimer is a helper class that executes a function after a given amount of seconds in real-time. 184 185 The time interval of RealTimer doesn't depend on the game time, it will also call the function 186 if the game is paused. See Timer for a timer class that depends on the game time. 187 */ 188 class _ToolsExport RealTimer : public Timer 189 { 190 public: 191 RealTimer(); 192 RealTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 193 194 protected: 195 virtual float getTimeFactor(); 196 }; 170 197 } 171 198 -
code/trunk/src/libraries/tools/ToolsPrereqs.h
r7163 r8079 85 85 class Mesh; 86 86 class ParticleInterface; 87 class RealTimer; 87 88 class ResourceCollection; 88 89 class ResourceLocation; -
code/trunk/src/modules/designtools/ScreenshotManager.cc
r7284 r8079 25 25 { 26 26 Ogre::RenderWindow* pRenderWindow = GraphicsManager::getInstance().getRenderWindow(); 27 int gridSize = 3;28 std::string fileExtension = ".png";29 bool overlayFlag = true;30 27 31 28 //set file extension for the Screenshot files 32 mFileExtension = fileExtension;29 this->mFileExtension_ = ".png"; 33 30 // the gridsize 34 mGridSize = gridSize;31 this->mGridSize_ = 3; 35 32 // flag for overlay rendering 36 mDisableOverlays = overlayFlag;33 this->mDisableOverlays_ = true; 37 34 //get current window size 38 mWindowWidth= pRenderWindow->getWidth();39 mWindowHeight= pRenderWindow->getHeight();35 this->mWindowWidth_ = pRenderWindow->getWidth(); 36 this->mWindowHeight_ = pRenderWindow->getHeight(); 40 37 //create temporary texture 41 mTempTex = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex", 42 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 43 mWindowWidth, mWindowHeight,0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET); 38 this->mTempTex_ = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, this->mWindowWidth_, this->mWindowHeight_, 0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET); 44 39 45 40 //get The current Render Target of the temp Texture 46 mRT = mTempTex->getBuffer()->getRenderTarget();41 this->mRT_ = this->mTempTex_->getBuffer()->getRenderTarget(); 47 42 48 43 //HardwarePixelBufferSharedPtr to the Buffer of the temp Texture 49 mBuffer = mTempTex->getBuffer();44 this->mBuffer_ = this->mTempTex_->getBuffer(); 50 45 51 46 //create PixelBox 52 uint8_t* data_ = new uint8_t[(mWindowWidth * mGridSize) * (mWindowHeight * mGridSize) * 3];53 mFinalPicturePB = Ogre::PixelBox(mWindowWidth * mGridSize,mWindowHeight * mGridSize,1,Ogre::PF_B8G8R8,data_);47 uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3]; 48 this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_); 54 49 55 50 } … … 63 58 64 59 65 /* Creates a screenshot with the given camera. 66 * @param camera Pointer to the camera "looking at" the scene of interest 67 * @param fileName the filename of the screenshot file. 60 /** 61 @brief 62 Creates a screenshot with the given camera. 63 @param camera 64 Pointer to the camera "looking at" the scene of interest 65 @param fileName 66 the filename of the screenshot file. 68 67 */ 69 68 void ScreenshotManager::makeScreenshot() const … … 73 72 74 73 //Remove all viewports, so the added Viewport(camera) ist the only 75 mRT ->removeAllViewports();76 mRT ->addViewport(camera);74 mRT_->removeAllViewports(); 75 mRT_->addViewport(camera); 77 76 78 77 //set the viewport settings 79 Ogre::Viewport *vp = mRT ->getViewport(0);78 Ogre::Viewport *vp = mRT_->getViewport(0); 80 79 vp->setClearEveryFrame(true); 81 80 vp->setOverlaysEnabled(false); … … 85 84 86 85 // we disable overlay rendering if it is set in config file and the viewport setting is enabled 87 if(mDisableOverlays && enableOverlayFlag)86 if(mDisableOverlays_ && enableOverlayFlag) 88 87 GraphicsManager::getInstance().getViewport()->setOverlaysEnabled(false); 89 88 90 if(mGridSize <= 1)89 if(mGridSize_ <= 1) 91 90 { 92 91 // Simple case where the contents of the screen are taken directly 93 92 // Also used when an invalid value is passed within gridSize (zero or negative grid size) 94 mRT ->update(); //render93 mRT_->update(); //render 95 94 96 95 //write the file on the Harddisk 97 mRT ->writeContentsToFile(fileName + "." + mFileExtension);96 mRT_->writeContentsToFile(fileName + "." + mFileExtension_); 98 97 } 99 98 else … … 105 104 106 105 // compute the Stepsize for the drid 107 Ogre::Real frustumGridStepHorizontal = (originalFrustumRight * 2) / mGridSize ;108 Ogre::Real frustumGridStepVertical = (originalFrustumTop * 2) / mGridSize ;106 Ogre::Real frustumGridStepHorizontal = (originalFrustumRight * 2) / mGridSize_; 107 Ogre::Real frustumGridStepVertical = (originalFrustumTop * 2) / mGridSize_; 109 108 110 109 // process each grid 111 110 Ogre::Real frustumLeft, frustumRight, frustumTop, frustumBottom; 112 for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize * mGridSize; nbScreenshots++)111 for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize_ * mGridSize_; nbScreenshots++) 113 112 { 114 int y = nbScreenshots / mGridSize ;115 int x = nbScreenshots - y * mGridSize ;113 int y = nbScreenshots / mGridSize_; 114 int x = nbScreenshots - y * mGridSize_; 116 115 117 116 // Shoggoth frustum extents setting … … 127 126 // ignore time duration between frames 128 127 Ogre::Root::getSingletonPtr()->clearEventTimes(); 129 mRT ->update(); //render128 mRT_->update(); //render 130 129 131 130 //define the current 132 Ogre::Box subBox = Ogre::Box(x* mWindowWidth ,y * mWindowHeight,x * mWindowWidth + mWindowWidth, y * mWindowHeight + mWindowHeight);131 Ogre::Box subBox = Ogre::Box(x* mWindowWidth_,y * mWindowHeight_,x * mWindowWidth_ + mWindowWidth_, y * mWindowHeight_ + mWindowHeight_); 133 132 //copy the content from the temp buffer into the final picture PixelBox 134 133 //Place the tempBuffer content at the right position 135 mBuffer ->blitToMemory(mFinalPicturePB.getSubVolume(subBox));134 mBuffer_->blitToMemory(mFinalPicturePB_.getSubVolume(subBox)); 136 135 137 136 } … … 142 141 Ogre::Image finalImage; //declare the final Image Object 143 142 //insert the PixelBox data into the Image Object 144 finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB .data), mFinalPicturePB.getWidth(),mFinalPicturePB.getHeight(),Ogre::PF_B8G8R8);143 finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB_.data), mFinalPicturePB_.getWidth(), mFinalPicturePB_.getHeight(),Ogre::PF_B8G8R8); 145 144 // Save the Final image to a file 146 finalImage.save(fileName + "." + mFileExtension );145 finalImage.save(fileName + "." + mFileExtension_); 147 146 148 147 } … … 157 156 } 158 157 158 /** 159 @brief 160 Set the size of the grid. 161 @param size 162 The size of the grid. 163 */ 164 void ScreenshotManager::setGridSize(unsigned int size) 165 { 166 if(size == this->mGridSize_) 167 return; 168 169 this->mGridSize_ = size; 170 // New PixelBox for the changed size. 171 uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3]; 172 this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_); 173 } 174 175 /** 176 @brief 177 Get a timestamp for the curent time instant. 178 @return 179 Returns a string with the timestamp. 180 */ 159 181 std::string ScreenshotManager::getTimestamp() 160 182 { -
code/trunk/src/modules/designtools/ScreenshotManager.h
r7163 r8079 20 20 { 21 21 22 23 /* Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. 24 * pRenderWindow: Pointer to the render window. This could be "mWindow" from the ExampleApplication, 25 * the window automatically created obtained when calling 26 * Ogre::Root::getSingletonPtr()->initialise(false) and retrieved by calling 27 * "Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()", or the manually created 28 * window from calling "mRoot->createRenderWindow()". 29 * gridSize: The magnification factor. A 2 will create a 2x2 grid, doubling the size of the 30 screenshot. A 3 will create a 3x3 grid, tripling the size of the screenshot. 31 * fileExtension: The extension of the screenshot file name, hence the type of graphics file to generate. 32 * To generate "MyScreenshot.png" this parameter would contain ".png". 22 /** 23 @brief 24 Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. 33 25 */ 34 26 class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> … … 36 28 friend class Singleton<ScreenshotManager>; 37 29 38 public:39 ScreenshotManager();40 ~ScreenshotManager();30 public: 31 ScreenshotManager(); 32 virtual ~ScreenshotManager(); 41 33 42 /* Creates a screenshot with the given camera. 43 * @param camera Pointer to the camera "looking at" the scene of interest 44 * @param fileName the filename of the screenshot file. 45 */ 46 void makeScreenshot() const; 34 void makeScreenshot() const; //!< Creates a screenshot with the given camera. 47 35 48 static void makeScreenshot_s() 49 { getInstance().makeScreenshot(); } 36 /** 37 @brief Creates a screenshot with a given size. 38 @param size Size is factor by which the current screen size is scaled. 39 */ 40 static void makeScreenshot_s(unsigned int size) 41 { getInstance().setGridSize(size); getInstance().makeScreenshot(); } 50 42 51 protected: 52 static std::string getTimestamp(); 43 void setGridSize(unsigned int size); //!< Set the size of the grid. 53 44 54 std::string mFileExtension; 55 unsigned int mGridSize, mWindowWidth, mWindowHeight; 56 bool mDisableOverlays; 57 //temp texture with current screensize 58 Ogre::TexturePtr mTempTex; 59 Ogre::RenderTexture* mRT; 60 Ogre::HardwarePixelBufferSharedPtr mBuffer; 61 //PixelBox for a large Screenshot, if grid size is > 1 62 Ogre::PixelBox mFinalPicturePB; 63 uint8_t* data_; 45 protected: 46 static std::string getTimestamp(); 64 47 65 static ScreenshotManager* singletonPtr_s; 48 std::string mFileExtension_; 49 unsigned int mGridSize_; //!< The magnification factor. A 2 will create a 2x2 grid, doubling the size of the screenshot. A 3 will create a 3x3 grid, tripling the size of the screenshot. 50 unsigned int mWindowWidth_, mWindowHeight_; 51 bool mDisableOverlays_; 52 //! temp texture with current screensize 53 Ogre::TexturePtr mTempTex_; 54 Ogre::RenderTexture* mRT_; 55 Ogre::HardwarePixelBufferSharedPtr mBuffer_; 56 //! PixelBox for a large Screenshot, if grid size is > 1 57 Ogre::PixelBox mFinalPicturePB_; 58 uint8_t* data_; 59 60 static ScreenshotManager* singletonPtr_s; 66 61 }; 67 62 -
code/trunk/src/modules/designtools/SkyboxGenerator.cc
r7284 r8079 59 59 60 60 this->setConfigValues(); 61 t akeScreenshot_ = false;61 this->takeScreenshot_ = false; 62 62 this->captionsRemoved_ = false; 63 63 } -
code/trunk/src/modules/notifications/NotificationManager.cc
r7552 r8079 103 103 { 104 104 // Destroys all NotificationQueues that have been registered with the NotificationManager. 105 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) 105 std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); 106 while(it != this->queues_.end()) 107 { 106 108 it->second->destroy(true); 109 it = this->queues_.begin(); 110 } 107 111 108 112 this->queues_.clear(); … … 298 302 } 299 303 304 COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl; 305 300 306 // Remove the NotificationListener from the list of NotificationListeners. 301 307 this->listenerList_.erase(listener); 302 308 // Remove the Notifications list that was associated with the input NotificationListener. 303 309 this->notificationLists_.erase(identifier); 304 305 COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;306 310 } 307 311 … … 361 365 bool NotificationManager::registerQueue(NotificationQueue* queue) 362 366 { 367 COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl; 363 368 return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second; 364 369 } … … 372 377 void NotificationManager::unregisterQueue(NotificationQueue* queue) 373 378 { 379 COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl; 374 380 this->queues_.erase(queue->getName()); 375 381 } -
code/trunk/src/modules/notifications/NotificationQueue.cc
r7489 r8079 137 137 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); 138 138 139 COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl; 140 139 141 this->OrxonoxClass::destroy(); 140 142 } … … 167 169 while(it != this->ordering_.upper_bound(&this->timeLimit_)) 168 170 { 169 std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator temp = it; 170 it++; 171 this->remove(temp); // Remove the Notifications that have expired. 171 this->remove(it); // Remove the Notifications that have expired. 172 it = this->ordering_.begin(); 172 173 } 173 174 … … 248 249 if(GameMode::showsGraphics()) 249 250 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 251 252 COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl; 250 253 } 251 254 … … 259 262 // Get all the NotificationContainers that were sent the same time the NotificationContainer we want to pop was sent. 260 263 std::pair<std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator, std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator> iterators = this->ordering_.equal_range(container); 264 261 265 // Iterate through all suspects and remove the container as soon as we find it. 262 266 for(std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = iterators.first; it != iterators.second; it++) … … 264 268 if(container == *it) 265 269 { 270 COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" popped from NotificationQueue '" << this->getName() << "'" << endl; 266 271 this->ordering_.erase(it); 267 272 break; … … 290 295 // Get the index at which the Notification is. 291 296 std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin (); 297 298 COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl; 299 292 300 this->ordering_.erase(containerIterator); 293 301 this->notifications_.erase(it); … … 310 318 void NotificationQueue::clear(bool noGraphics) 311 319 { 320 COUT(4) << "Clearing NotificationQueue " << this->getName() << "." << endl; 312 321 this->ordering_.clear(); 313 322 // Delete all NotificationContainers in the list. … … 372 381 /** 373 382 @brief 374 Produces all targets of the NotificationQueue concatinated as string, with kommas (',') as seperators.383 Produces all targets of the NotificationQueue concatinated as string, with commas (',') as seperators. 375 384 @return 376 385 Returns the targets as a string. -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
r7601 r8079 54 54 55 55 this->distance_ = 100.0f; 56 this->targetName_ = BLANKSTRING;56 this->targetName_ = ""; 57 57 this->singleTargetMode_ = false; 58 58 } … … 181 181 { 182 182 // If the targetname is no blank string single-target mode is enabled. 183 if(targetname .compare(BLANKSTRING) != 0)183 if(targetname != "") 184 184 this->singleTargetMode_ = true; 185 185 else -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r7601 r8079 50 50 this->distance_ = 100; 51 51 this->targetMask_.exclude(Class(BaseObject)); 52 this->targetName_ = BLANKSTRING;52 this->targetName_ = ""; 53 53 this->singleTargetMode_ = false; 54 54 } -
code/trunk/src/modules/objects/triggers/DistanceTrigger.h
r7601 r8079 70 70 71 71 inline void setTargetName(const std::string& targetname) 72 { if(targetname .compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }72 { if(targetname != "") this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; } 73 73 inline const std::string& getTargetName(void) 74 74 { return this->targetName_; } -
code/trunk/src/modules/overlays/OverlaysPrereqs.h
r7655 r8079 89 89 class KillMessage; 90 90 class LastManStandingInfos; 91 class PauseNotice; 91 92 class TeamBaseMatchScore; 92 93 class UnderAttackHealthBar; -
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r7655 r8079 16 16 GametypeFadingMessage.cc 17 17 LastManStandingInfos.cc 18 PauseNotice.cc 18 19 ) -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r7548 r8079 156 156 { 157 157 COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl; 158 if(this->spawnerTemplate_ == BLANKSTRING)158 if(this->spawnerTemplate_ == "") 159 159 { 160 160 COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl; -
code/trunk/src/modules/questsystem/QuestItem.cc
r7456 r8079 87 87 void QuestItem::setId(const std::string & id) 88 88 { 89 if(id .compare(BLANKSTRING) == 0) // Checks whether the id is a valid id.89 if(id == "") // Checks whether the id is a valid id. 90 90 { 91 91 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/modules/questsystem/QuestManager.cc
r7552 r8079 91 91 /** 92 92 @brief 93 Registers a Quest with the QuestManager to make it globally access able.93 Registers a Quest with the QuestManager to make it globally accessible. 94 94 Uses it's id to make sure to be able to be identify and retrieve it later. 95 95 @param quest … … 129 129 /** 130 130 @brief 131 Registers a QuestHint with the QuestManager to make it globally access able.131 Registers a QuestHint with the QuestManager to make it globally accessible. 132 132 Uses it's id to make sure to be able to be identify and retrieve it later. 133 133 @param hint … … 178 178 Quest* QuestManager::findQuest(const std::string & questId) 179 179 { 180 if(questId .compare(BLANKSTRING) == 1) // Check vor validity of the given id.180 if(questId == "") // Check for validity of the given id. 181 181 ThrowException(Argument, "Invalid questId."); 182 182 … … 207 207 QuestHint* QuestManager::findHint(const std::string & hintId) 208 208 { 209 if(hintId .compare(BLANKSTRING) == 1) // Check vor validity of the given id.209 if(hintId == "") // Check for validity of the given id. 210 210 ThrowException(Argument, "Invalid hintId."); 211 211 -
code/trunk/src/modules/questsystem/effects/AddQuestHint.cc
r7552 r8079 86 86 bool AddQuestHint::setHintId(const std::string & id) 87 87 { 88 if(id .compare(BLANKSTRING) == 0)88 if(id == "") 89 89 { 90 90 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
r7456 r8079 81 81 bool ChangeQuestStatus::setQuestId(const std::string & id) 82 82 { 83 if(id .compare(BLANKSTRING) == 0)83 if(id == "") 84 84 { 85 85 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/orxonox/CameraManager.cc
r7879 r8079 29 29 #include "CameraManager.h" 30 30 31 #include <cassert> 32 31 33 #include <OgreSceneManager.h> 32 34 #include <OgreViewport.h> 33 35 #include <OgreCompositorManager.h> 34 36 35 #include "util/StringUtils.h"36 37 #include "util/ScopedSingletonManager.h" 37 38 #include "core/GameMode.h" 38 39 #include "core/GraphicsManager.h" 39 #include "core/GUIManager.h"40 40 #include "core/ObjectList.h" 41 41 #include "tools/Shader.h" 42 42 #include "graphics/Camera.h" 43 #include "Scene.h"44 43 45 44 namespace orxonox … … 48 47 49 48 CameraManager::CameraManager() 50 : viewport_(GraphicsManager::getInstance().getViewport())51 49 { 52 50 assert(GameMode::showsGraphics()); … … 55 53 CameraManager::~CameraManager() 56 54 { 57 GUIManager::getInstance().setCamera(0);58 55 } 59 56 … … 95 92 if (!this->cameraList_.empty()) 96 93 this->cameraList_.front()->setFocus(); 94 else 95 this->useCamera(NULL); 97 96 } 98 97 else … … 102 101 void CameraManager::useCamera(Ogre::Camera* camera) 103 102 { 104 // This workaround is needed to avoid weird behaviour with active compositors while 105 // switching the camera (like freezing the image) 106 // 107 // Last known Ogre version needing this workaround: 108 // 1.4.8 109 // 1.7.2 110 111 // deactivate all compositors 112 { 113 Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator(); 114 while (iterator.hasMoreElements()) 115 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false); 116 } 117 118 this->viewport_->setCamera(camera); 119 GUIManager::getInstance().setCamera(camera); 120 121 // reactivate all visible compositors 122 { 123 for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it) 124 it->updateVisibility(); 125 } 103 GraphicsManager::getInstance().setCamera(camera); 126 104 } 127 105 } -
code/trunk/src/orxonox/CameraManager.h
r6746 r8079 38 38 #include "OrxonoxPrereqs.h" 39 39 40 #include <cassert>41 40 #include <list> 42 41 #include "util/OgreForwardRefs.h" 43 42 #include "util/Singleton.h" 44 43 #include "core/OrxonoxClass.h" 45 #include "core/SmartPtr.h"46 44 47 45 namespace orxonox … … 65 63 66 64 std::list<Camera*> cameraList_; 67 Ogre::Viewport* viewport_;68 65 69 66 static CameraManager* singletonPtr_s; -
code/trunk/src/orxonox/ChatInputHandler.cc
r7284 r8079 28 28 29 29 #include "ChatInputHandler.h" 30 31 #include <cassert> 32 #include <string> 33 #include <CEGUIWindow.h> 34 #include <CEGUIWindowManager.h> 35 #include <elements/CEGUIListbox.h> 36 #include <elements/CEGUIListboxItem.h> 37 #include <elements/CEGUIListboxTextItem.h> 38 30 39 #include "util/ScopedSingletonManager.h" 31 40 #include "core/CoreIncludes.h" 32 41 #include "core/GUIManager.h" 33 #include "core/CorePrereqs.h"34 42 #include "core/command/ConsoleCommand.h" 35 #include <CEGUIWindow.h> 36 #include <elements/CEGUIListbox.h> 37 #include <elements/CEGUIListboxItem.h> 38 #include <elements/CEGUIListboxTextItem.h> 39 #include <CEGUIWindowManager.h> 40 #include <string> 43 #include "core/input/InputBuffer.h" 44 #include "core/input/InputManager.h" 45 #include "core/input/InputState.h" 46 #include "network/Host.h" 47 48 #include "PlayerManager.h" 49 #include "infos/PlayerInfo.h" 41 50 42 51 namespace orxonox … … 72 81 this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic ); 73 82 this->inputState->setKeyHandler(this->inpbuf); 83 } 84 85 ChatInputHandler::~ChatInputHandler() 86 { 87 /* Clean up */ 88 InputManager::getInstance().destroyState("chatinput"); 89 delete this->inpbuf; 74 90 } 75 91 … … 125 141 // reds 126 142 for( i = 0; i < NumberOfColors/3; ++i ) 127 { this->text_colors[ i ] = new CEGUI::colour( red, green, blue ); 128 assert( this->text_colors[ i ] ); 143 { this->text_colors[ i ] = CEGUI::colour( red, green, blue ); 129 144 green += 0.2f, blue += 0.2f; 130 145 } … … 133 148 red = 0.5, green = 1, blue = 0.5; 134 149 for( ; i < NumberOfColors*2/3; ++i ) 135 { this->text_colors[ i ] = new CEGUI::colour( red, green, blue ); 136 assert( this->text_colors[ i ] ); 150 { this->text_colors[ i ] = CEGUI::colour( red, green, blue ); 137 151 red += 0.2f, blue += 0.2f; 138 152 } … … 141 155 red = 0.5, green = 0.5, blue = 1; 142 156 for( ; i < NumberOfColors; ++i ) 143 { this->text_colors[ i ] = new CEGUI::colour( red, green, blue ); 144 assert( this->text_colors[ i ] ); 157 { this->text_colors[ i ] = CEGUI::colour( red, green, blue ); 145 158 red += 0.2f, green += 0.2f; 146 159 } … … 196 209 197 210 /* set the color according to the hash */ 198 tocolor->setTextColours( *(this->text_colors[ hash ]));211 tocolor->setTextColours( this->text_colors[ hash ] ); 199 212 } 200 213 -
code/trunk/src/orxonox/ChatInputHandler.h
r7163 r8079 30 30 #define _ChatInputHandler_H__ 31 31 32 /* std includes */ 33 #include <deque> 32 #include <OrxonoxPrereqs.h> 33 34 34 #include <string> 35 #include <fstream>36 #include <iostream>37 #include <cassert>38 35 #include <CEGUIForwardRefs.h> 36 #include <CEGUIcolour.h> 39 37 40 /* project includes */ 41 #include <OrxonoxPrereqs.h> 42 #include <core/BaseObject.h> 43 #include <core/PathConfig.h> 44 45 #include "core/input/InputBuffer.h" 46 #include "core/input/InputManager.h" 47 #include "core/input/InputState.h" 48 49 #include <network/ChatListener.h> 50 #include <PlayerManager.h> 51 #include <infos/PlayerInfo.h> 52 53 #include "../libraries/network/Host.h" 54 #include <util/Singleton.h> 38 #include "util/Singleton.h" 39 #include "network/ChatListener.h" 55 40 56 41 namespace orxonox // tolua_export … … 70 55 /* colors for nickname coloring */ 71 56 static const int NumberOfColors = 10; 72 CEGUI::colour *text_colors[ NumberOfColors ];57 CEGUI::colour text_colors[ NumberOfColors ]; 73 58 74 59 /** input state */ … … 110 95 /** constructor */ 111 96 ChatInputHandler(); 97 ~ChatInputHandler(); 112 98 friend class Singleton<ChatInputHandler>; 113 99 -
code/trunk/src/orxonox/LevelInfo.h
r7804 r8079 109 109 @return Returns the XML-filename (including *.oxw extension) of the Level. 110 110 */ 111 inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export111 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 112 112 113 113 protected: … … 212 212 { 213 213 bool operator() (const LevelInfoItem* lhs, const LevelInfoItem* rhs) const 214 { return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0; } 214 { 215 if(getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) == 0) 216 return getLowercase(lhs->getXMLFilename()).compare(getLowercase(rhs->getXMLFilename())) < 0; 217 return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0; 218 } 215 219 }; 216 220 -
code/trunk/src/orxonox/LevelManager.cc
r7839 r8079 75 75 LevelManager::~LevelManager() 76 76 { 77 // Delete all the LevelInfoItem objects because the LevelManager created them 78 std::set<LevelInfoItem*, LevelInfoCompare>::iterator it = availableLevels_.begin(); 79 for (; it != availableLevels_.end(); ++it) 80 delete *it; 77 81 } 78 82 … … 237 241 void LevelManager::compileAvailableLevelList() 238 242 { 243 // Get all files matching the level criteria 239 244 Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw"); 240 // Iterate over all *.oxw level files. 245 246 // We only want to load as little as possible 247 ClassTreeMask mask; 248 mask.exclude(Class(BaseObject)); 249 mask.include(Class(LevelInfo)); 250 251 // Iterate over all the found *.oxw files 241 252 COUT(3) << "Loading LevelInfos..." << std::endl; 253 std::set<std::string> names; 242 254 for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it) 243 255 { 244 // TODO: Replace with tag?256 // TODO: Replace with tag? 245 257 if (it->find("old/") != 0) 246 258 { 247 size_t pos = it->find(".oxw");259 LevelInfoItem* info = NULL; 248 260 249 261 // Load the LevelInfo object from the level file. 250 bool infoExists = false;251 262 XMLFile file = XMLFile(*it); 252 ClassTreeMask mask = ClassTreeMask(); 253 mask.exclude(ClassIdentifier<BaseObject>::getIdentifier()); 254 mask.include(ClassIdentifier<LevelInfo>::getIdentifier()); 255 Loader::load(&file, mask, false); 256 // Iterate over all LevelInfos. 263 Loader::load(&file, mask, false, true); 264 265 // Find the LevelInfo object we've just loaded (if there was one) 257 266 for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item) 267 if(item->getXMLFilename() == *it) 268 info = item->copy(); 269 270 // We don't need the loaded stuff anymore 271 Loader::unload(&file); 272 273 if(info == NULL) 258 274 { 259 LevelInfoItem* info = item->copy(); 260 if(info->getXMLFilename() == *it) // If the LevelInfo for this level exists we insert it into the list of available levels. 261 { 262 this->availableLevels_.insert(info); 263 infoExists = true; 264 } 275 // Create a default LevelInfoItem object that merely contains the name 276 std::string filenameWOExtension = it->substr(0, it->find(".oxw")); 277 info = new LevelInfoItem(filenameWOExtension, *it); 265 278 } 266 Loader::unload(&file, mask); 267 if(!infoExists) // If the LevelInfo for this level doesn't exist, we create a new one and insert it into the list of available levels. 268 this->availableLevels_.insert(new LevelInfoItem(it->substr(0, pos), *it)); 279 280 // Warn about levels with the same name. 281 if(!names.insert(info->getName()).second) 282 COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl; 283 284 // Warn about multiple items so that it gets fixed quickly 285 if(availableLevels_.find(info) != availableLevels_.end()) 286 { 287 COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl; 288 // Delete LevelInfoItem to avoid a dangling pointer 289 delete info; 290 } 291 else 292 this->availableLevels_.insert(info); 269 293 } 270 294 } -
code/trunk/src/orxonox/LevelManager.h
r7804 r8079 112 112 // Helpers to allow fast access to the availableLevels list. 113 113 unsigned int nextIndex_; //! The next expected index to be accessed. 114 std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The nex expected Level to be accessed.114 std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The next expected Level to be accessed. 115 115 116 116 // config values -
code/trunk/src/orxonox/controllers/HumanController.cc
r7863 r8079 61 61 SetConsoleCommand("HumanController", "cycleNavigationFocus", &HumanController::cycleNavigationFocus).addShortcut(); 62 62 SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut(); 63 SetConsoleCommand("HumanController", "myposition", &HumanController::myposition ).addShortcut(); 63 64 64 65 CreateUnloadableFactory(HumanController); … … 200 201 void HumanController::toggleGodMode() 201 202 { 202 HumanController::getLocalControllerSingleton()->setGodMode( !HumanController::getLocalControllerSingleton()->getGodMode() ); 203 if (HumanController::localController_s) 204 HumanController::localController_s->setGodMode(!HumanController::localController_s->getGodMode()); 205 } 206 207 void HumanController::myposition() 208 { 209 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 210 { 211 const Vector3& position = HumanController::localController_s->controllableEntity_->getPosition(); 212 const Quaternion& orientation = HumanController::localController_s->controllableEntity_->getOrientation(); 213 214 COUT(0) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" "; 215 COUT(0) << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << std::endl; 216 } 203 217 } 204 218 -
code/trunk/src/orxonox/controllers/HumanController.h
r7533 r8079 73 73 static void suicide(); 74 74 static void toggleGodMode(); 75 static void myposition(); 75 76 76 77 static void addBots(unsigned int amount); -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r7879 r8079 46 46 #include "LevelManager.h" 47 47 #include "PlayerManager.h" 48 #include "GSRoot.h" 48 49 49 50 namespace orxonox … … 55 56 56 57 SetConsoleCommand(__CC_startMainMenu_name, &GSLevel::startMainMenu).deactivate(); 57 SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues( BLANKSTRING).deactivate();58 SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues("").deactivate(); 58 59 59 60 GSLevel::GSLevel(const GameStateInfo& info) … … 156 157 COUT(0) << "Loading level..." << std::endl; 157 158 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 158 Loader::open(startFile_);159 bool loaded = Loader::open(startFile_); 159 160 160 161 Core::getInstance().updateLastLevelTimestamp(); 162 if(!loaded) 163 GSRoot::delayedStartMainMenu(); 161 164 } 162 165 … … 202 205 /*static*/ void GSLevel::changeGame(const std::string& level) 203 206 { 204 if(level != BLANKSTRING)207 if(level != "") 205 208 LevelManager::getInstance().setDefaultLevel(level); 206 209 -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r7876 r8079 57 57 static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath"; 58 58 59 SetConsoleCommand(__CC_startStandalone_name, &GSMainMenu::startStandalone).defaultValues( BLANKSTRING).deactivate();60 SetConsoleCommand(__CC_startServer_name, &GSMainMenu::startServer ).defaultValues( BLANKSTRING).deactivate();61 SetConsoleCommand(__CC_startClient_name, &GSMainMenu::startClient ).defaultValues( BLANKSTRING).deactivate();62 SetConsoleCommand(__CC_startDedicated_name, &GSMainMenu::startDedicated ).defaultValues( BLANKSTRING).deactivate();59 SetConsoleCommand(__CC_startStandalone_name, &GSMainMenu::startStandalone).defaultValues("").deactivate(); 60 SetConsoleCommand(__CC_startServer_name, &GSMainMenu::startServer ).defaultValues("").deactivate(); 61 SetConsoleCommand(__CC_startClient_name, &GSMainMenu::startClient ).defaultValues("").deactivate(); 62 SetConsoleCommand(__CC_startDedicated_name, &GSMainMenu::startDedicated ).defaultValues("").deactivate(); 63 63 SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide(); 64 64 … … 96 96 { 97 97 // show main menu 98 GraphicsManager::getInstance().setCamera(this->camera_); 98 99 GUIManager::getInstance().showGUI("MainMenu", true); 99 GUIManager::getInstance().setCamera(this->camera_);100 100 GUIManager::getInstance().setBackgroundImage("MainMenuBackground", "Background"); 101 GraphicsManager::getInstance().setCamera(this->camera_);102 101 103 102 InputManager::getInstance().enterState("MainMenuHackery"); … … 129 128 InputManager::getInstance().leaveState("MainMenuHackery"); 130 129 131 G UIManager::getInstance().setCamera(0);130 GraphicsManager::getInstance().setCamera(0); 132 131 GUIManager::getInstance().setBackgroundImage(""); 133 132 GUIManager::hideGUI("MainMenu"); 134 GraphicsManager::getInstance().setCamera(0);135 133 136 134 ModifyConsoleCommand(__CC_startStandalone_name).deactivate(); … … 178 176 void GSMainMenu::startStandalone(const std::string& level) 179 177 { 180 if(level != BLANKSTRING)178 if(level != "") 181 179 LevelManager::getInstance().setDefaultLevel(level); 182 180 … … 194 192 void GSMainMenu::startServer(const std::string& level) 195 193 { 196 if(level != BLANKSTRING)194 if(level != "") 197 195 LevelManager::getInstance().setDefaultLevel(level); 198 196 … … 210 208 void GSMainMenu::startClient(const std::string& destination) 211 209 { 212 if(destination != BLANKSTRING)210 if(destination != "") 213 211 Client::getInstance()->setDestination(destination, NETWORK_PORT); 214 212 … … 226 224 void GSMainMenu::startDedicated(const std::string& level) 227 225 { 228 if(level != BLANKSTRING)226 if(level != "") 229 227 LevelManager::getInstance().setDefaultLevel(level); 230 228 -
code/trunk/src/orxonox/gamestates/GSMainMenu.h
r7876 r8079 53 53 void setMainMenuSoundPath(const std::string& path); 54 54 55 static void startStandalone(const std::string& level = BLANKSTRING); //!< Start a level in standalone mode.56 static void startServer(const std::string& level = BLANKSTRING); //!< Start a level in server mode.57 static void startClient(const std::string& destination = BLANKSTRING); //!< Connect to a game as client.58 static void startDedicated(const std::string& level = BLANKSTRING); //!< Start a level in dedicated mode.55 static void startStandalone(const std::string& level = ""); //!< Start a level in standalone mode. 56 static void startServer(const std::string& level = ""); //!< Start a level in server mode. 57 static void startClient(const std::string& destination = ""); //!< Connect to a game as client. 58 static void startDedicated(const std::string& level = ""); //!< Start a level in dedicated mode. 59 59 static void startIOConsole(); 60 60 -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r7284 r8079 38 38 #include "tools/interfaces/Tickable.h" 39 39 40 #include "GSLevel.h" 41 40 42 namespace orxonox 41 43 { … … 43 45 44 46 static const std::string __CC_setTimeFactor_name = "setTimeFactor"; 47 static const std::string __CC_setPause_name = "setPause"; 45 48 static const std::string __CC_pause_name = "pause"; 49 50 /*static*/ bool GSRoot::startMainMenu_s = false; 46 51 47 52 SetConsoleCommand("printObjects", &GSRoot::printObjects).hide(); 48 53 SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0); 54 SetConsoleCommand(__CC_setPause_name, &GSRoot::setPause ).accessLevel(AccessLevel::Master).hide(); 49 55 SetConsoleCommand(__CC_pause_name, &GSRoot::pause ).accessLevel(AccessLevel::Master); 50 56 … … 83 89 84 90 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this); 91 ModifyConsoleCommand(__CC_setPause_name).setObject(this); 85 92 ModifyConsoleCommand(__CC_pause_name).setObject(this); 86 93 } … … 89 96 { 90 97 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0); 98 ModifyConsoleCommand(__CC_setPause_name).setObject(0); 91 99 ModifyConsoleCommand(__CC_pause_name).setObject(0); 92 100 } … … 94 102 void GSRoot::update(const Clock& time) 95 103 { 104 if(startMainMenu_s) 105 { 106 delayedStartMainMenu(); 107 startMainMenu_s = false; 108 } 109 96 110 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; ) 97 111 { … … 157 171 } 158 172 173 void GSRoot::setPause(bool pause) 174 { 175 if (GameMode::isMaster()) 176 { 177 if (pause != this->bPaused_) 178 this->pause(); 179 } 180 } 181 159 182 void GSRoot::changedTimeFactor(float factor_new, float factor_old) 160 183 { … … 162 185 callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new); 163 186 } 187 188 /*static*/ void GSRoot::delayedStartMainMenu(void) 189 { 190 if(!startMainMenu_s) 191 startMainMenu_s = true; 192 else 193 GSLevel::startMainMenu(); 194 } 195 164 196 } -
code/trunk/src/orxonox/gamestates/GSRoot.h
r7172 r8079 51 51 // when taking the function address. 52 52 void setTimeFactor(float factor); 53 void setPause(bool pause); 53 54 void pause(); 55 56 static void delayedStartMainMenu(void); 54 57 55 58 protected: … … 59 62 bool bPaused_; 60 63 float timeFactorPauseBackup_; 64 static bool startMainMenu_s; 61 65 }; 62 66 } -
code/trunk/src/orxonox/gametypes/Gametype.cc
r7801 r8079 30 30 31 31 #include "util/Math.h" 32 #include "core/Core.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/ConfigValueIncludes.h" … … 386 387 if (allplayersready && hashumanplayers) 387 388 { 388 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 389 // If in developer's mode, there is no start countdown. 390 if(Core::getInstance().inDevMode()) 391 this->gtinfo_->startCountdown_ = 0; 392 else 393 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 389 394 this->gtinfo_->bStartCountdownRunning_ = true; 390 395 } -
code/trunk/src/orxonox/graphics/Camera.cc
r7163 r8079 69 69 this->bHasFocus_ = false; 70 70 this->bDrag_ = false; 71 this->nearClipDistance_ = 1;72 71 this->lastDtLagged_ = false; 73 72 … … 75 74 76 75 this->setConfigValues(); 76 77 this->configvaluecallback_changedFovAndAspectRatio(); 77 78 this->configvaluecallback_changedNearClipDistance(); 78 79 } … … 82 83 if (this->isInitialized()) 83 84 { 84 if (GUIManager::getInstance().getCamera() == this->camera_)85 GUIManager::getInstance().setCamera(NULL);86 85 this->releaseFocus(); 87 86 … … 99 98 void Camera::setConfigValues() 100 99 { 101 SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance); 100 SetConfigValue(fov_, 80.0f) 101 .description("Horizontal field of view in degrees") 102 .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio); 103 SetConfigValue(aspectRatio_, 1.0f) 104 .description("Aspect ratio of pixels (width / height)") 105 .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio); 106 SetConfigValue(nearClipDistance_, 1.0f) 107 .description("Distance from the camera where close objects will be clipped") 108 .callback(this, &Camera::configvaluecallback_changedNearClipDistance); 109 } 110 111 /** 112 @brief Update FOV and the aspect ratio of the camera after the config values or the window's size have changed. 113 */ 114 void Camera::configvaluecallback_changedFovAndAspectRatio() 115 { 116 // the aspect ratio of the window (width / height) has to be multiplied with the pixels aspect ratio (this->aspectRatio_) 117 float aspectRatio = this->aspectRatio_ * this->getWindowWidth() / this->getWindowHeight(); 118 this->camera_->setAspectRatio(aspectRatio); 119 120 // Since we use horizontal FOV, we have to calculate FOVy by dividing by the aspect ratio and using some tangents 121 Radian fovy(2 * atan(tan(Degree(this->fov_).valueRadians() / 2) / aspectRatio)); 122 this->camera_->setFOVy(fovy); 102 123 } 103 124 … … 105 126 { 106 127 this->camera_->setNearClipDistance(this->nearClipDistance_); 128 } 129 130 /** 131 @brief Inherited from WindowEventListener. 132 */ 133 void Camera::windowResized(unsigned int newWidth, unsigned int newHeight) 134 { 135 this->configvaluecallback_changedFovAndAspectRatio(); 107 136 } 108 137 -
code/trunk/src/orxonox/graphics/Camera.h
r6417 r8079 33 33 34 34 #include "util/OgreForwardRefs.h" 35 #include "core/WindowEventListener.h" 35 36 #include "tools/interfaces/Tickable.h" 36 37 #include "tools/interfaces/TimeFactorListener.h" … … 39 40 namespace orxonox 40 41 { 41 class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener 42 class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener 42 43 { 43 44 friend class CameraManager; … … 66 67 void removeFocus(); 67 68 void setFocus(); 69 70 void configvaluecallback_changedFovAndAspectRatio(); 68 71 void configvaluecallback_changedNearClipDistance(); 72 73 void windowResized(unsigned int newWidth, unsigned int newHeight); 69 74 70 75 Ogre::Camera* camera_; … … 74 79 bool bDrag_; 75 80 bool lastDtLagged_; 81 float fov_; 82 float aspectRatio_; 76 83 }; 77 84 } -
code/trunk/src/orxonox/graphics/GlobalShader.cc
r5781 r8079 61 61 SUPER(GlobalShader, XMLPort, xmlelement, mode); 62 62 63 XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositor , getCompositor, xmlelement, mode);63 XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositorName, getCompositorName, xmlelement, mode); 64 64 } 65 65 … … 67 67 { 68 68 registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility)); 69 registerVariable(const_cast<std::string&>(this->shader_.getCompositor ()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));69 registerVariable(const_cast<std::string&>(this->shader_.getCompositorName()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositorName)); 70 70 } 71 71 -
code/trunk/src/orxonox/graphics/GlobalShader.h
r7163 r8079 53 53 private: 54 54 void registerVariables(); 55 void changedCompositor();56 55 57 56 Shader shader_; -
code/trunk/src/orxonox/graphics/Model.cc
r7183 r8079 60 60 void Model::setConfigValues() 61 61 { 62 SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableM odelLoD", true)62 SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableMeshLoD", true) 63 63 .description("Enable level of detail for models"); 64 64 } -
code/trunk/src/orxonox/items/Engine.cc
r7547 r8079 102 102 void Engine::setConfigValues() 103 103 { 104 SetConfigValue(blurStrength_, 3.0f); 104 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true) 105 .description("Enable or disable the motion blur effect when moving very fast") 106 .callback(this, &Engine::changedEnableMotionBlur); 107 SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f) 108 .description("Defines the strength of the motion blur effect"); 105 109 } 106 110 … … 204 208 this->ship_->setSteeringDirection(Vector3::ZERO); 205 209 206 if ( !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())210 if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController()) 207 211 { 208 212 this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager()); 209 this->boostBlur_->setCompositor ("Radial Blur");213 this->boostBlur_->setCompositorName("Radial Blur"); 210 214 } 211 215 212 216 if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 213 this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f)); 217 { 218 float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f); 219 220 this->boostBlur_->setVisible(blur > 0); 221 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur); 222 } 214 223 } 215 224 … … 257 266 return this->ship_->getWorldPosition(); 258 267 } 268 269 void Engine::changedEnableMotionBlur() 270 { 271 if (!this->bEnableMotionBlur_) 272 { 273 this->boostBlur_->destroy(); 274 this->boostBlur_ = 0; 275 } 276 } 259 277 } -
code/trunk/src/orxonox/items/Engine.h
r7552 r8079 127 127 void registerVariables(); 128 128 void networkcallback_shipID(); 129 void changedEnableMotionBlur(); 129 130 130 131 SpaceShip* ship_; … … 150 151 Shader* boostBlur_; 151 152 float blurStrength_; 153 bool bEnableMotionBlur_; 152 154 }; 153 155 } -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r7689 r8079 60 60 const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically 61 61 62 SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole) .addShortcut();63 SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole) .addShortcut();62 SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole); 63 SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole); 64 64 65 65 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); -
code/trunk/src/orxonox/sound/AmbientSound.cc
r7856 r8079 29 29 #include "AmbientSound.h" 30 30 31 #include "core/CoreIncludes.h" 31 32 #include "core/GameMode.h" 32 33 #include "core/Resource.h" … … 38 39 : bPlayOnLoad_(false) 39 40 { 41 RegisterObject(AmbientSound); 42 40 43 // Ambient sounds always fade in 41 44 this->setVolume(0);
Note: See TracChangeset
for help on using the changeset viewer.