[612] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1293] | 3 | * > www.orxonox.net < |
---|
[612] | 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
[1349] | 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
[612] | 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[1531] | 23 | * Reto Grieder |
---|
[612] | 24 | * Co-authors: |
---|
[1531] | 25 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess |
---|
[612] | 26 | * |
---|
| 27 | */ |
---|
[1035] | 28 | |
---|
[612] | 29 | /** |
---|
| 30 | @file orxonox.cc |
---|
| 31 | @brief Orxonox class |
---|
| 32 | */ |
---|
| 33 | |
---|
[1021] | 34 | #include "OrxonoxStableHeaders.h" |
---|
[1039] | 35 | #include "GraphicsEngine.h" |
---|
[612] | 36 | |
---|
[1531] | 37 | #include <OgreConfigFile.h> |
---|
[1021] | 38 | #include <OgreException.h> |
---|
[1024] | 39 | #include <OgreLogManager.h> |
---|
[1531] | 40 | #include <OgreRoot.h> |
---|
| 41 | #include <OgreSceneManager.h> |
---|
[612] | 42 | #include <OgreTextureManager.h> |
---|
[1531] | 43 | #include <OgreViewport.h> |
---|
| 44 | |
---|
[1293] | 45 | #include "core/CoreIncludes.h" |
---|
| 46 | #include "core/ConfigValueIncludes.h" |
---|
| 47 | #include "core/Debug.h" |
---|
[1505] | 48 | #include "core/CommandExecutor.h" |
---|
[1531] | 49 | #include "core/ConsoleCommand.h" |
---|
| 50 | #include "core/input/InputManager.h" |
---|
| 51 | |
---|
[1502] | 52 | #include "console/InGameConsole.h" |
---|
[1531] | 53 | #include "Settings.h" |
---|
[1032] | 54 | |
---|
[612] | 55 | |
---|
| 56 | namespace orxonox { |
---|
[1032] | 57 | /** |
---|
| 58 | @brief Returns the singleton instance and creates it the first time. |
---|
| 59 | @return The only instance of GraphicsEngine. |
---|
| 60 | */ |
---|
[1293] | 61 | /*static*/ GraphicsEngine& GraphicsEngine::getSingleton() |
---|
[1032] | 62 | { |
---|
| 63 | static GraphicsEngine theOnlyInstance; |
---|
| 64 | return theOnlyInstance; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | @brief Only use constructor to initialise variables and pointers! |
---|
| 69 | */ |
---|
[1293] | 70 | GraphicsEngine::GraphicsEngine() : |
---|
| 71 | root_(0), |
---|
| 72 | scene_(0), |
---|
[1531] | 73 | renderWindow_(0) |
---|
[612] | 74 | { |
---|
[1021] | 75 | RegisterObject(GraphicsEngine); |
---|
[1293] | 76 | |
---|
[1021] | 77 | this->setConfigValues(); |
---|
[1293] | 78 | CCOUT(4) << "Constructed" << std::endl; |
---|
[612] | 79 | } |
---|
| 80 | |
---|
[1293] | 81 | void GraphicsEngine::setConfigValues() |
---|
| 82 | { |
---|
[1531] | 83 | SetConfigValue(resourceFile_, "resources.cfg").description("Location of the resources file in the data path."); |
---|
| 84 | SetConfigValue(ogreConfigFile_, "ogre.cfg").description("Location of the Ogre config file"); |
---|
| 85 | SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file"); |
---|
| 86 | SetConfigValue(ogreLogFile_, "ogre.log").description("Logfile for messages from Ogre. \ |
---|
| 87 | Use \"\" to suppress log file creation."); |
---|
[1293] | 88 | SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial"); |
---|
| 89 | SetConfigValue(ogreLogLevelNormal_ , 4).description("Corresponding orxonox debug level for ogre Normal"); |
---|
[1505] | 90 | SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); |
---|
[1293] | 91 | } |
---|
| 92 | |
---|
[1032] | 93 | /** |
---|
| 94 | @brief Called after main() --> call destroyObjects()! |
---|
| 95 | */ |
---|
[612] | 96 | GraphicsEngine::~GraphicsEngine() |
---|
| 97 | { |
---|
[1032] | 98 | this->destroy(); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | @brief Destroys all the internal objects. Call this method when you |
---|
| 103 | normally would call the destructor. |
---|
| 104 | */ |
---|
| 105 | void GraphicsEngine::destroy() |
---|
| 106 | { |
---|
[1293] | 107 | CCOUT(4) << "Destroying objects..." << std::endl; |
---|
[1214] | 108 | Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this); |
---|
[1024] | 109 | if (this->root_) |
---|
[1021] | 110 | delete this->root_; |
---|
[1032] | 111 | this->root_ = 0; |
---|
| 112 | this->scene_ = 0; |
---|
| 113 | this->renderWindow_ = 0; |
---|
| 114 | // delete the ogre log and the logManager (since we have created it). |
---|
[1052] | 115 | if (Ogre::LogManager::getSingletonPtr() != 0) |
---|
[1024] | 116 | { |
---|
[1052] | 117 | Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this); |
---|
| 118 | Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); |
---|
| 119 | delete Ogre::LogManager::getSingletonPtr(); |
---|
[1024] | 120 | } |
---|
[1293] | 121 | CCOUT(4) << "Destroying objects done" << std::endl; |
---|
[612] | 122 | } |
---|
| 123 | |
---|
[1024] | 124 | /** |
---|
| 125 | @brief Creates the Ogre Root object and sets up the ogre log. |
---|
| 126 | */ |
---|
[1531] | 127 | bool GraphicsEngine::setup() |
---|
[612] | 128 | { |
---|
[1293] | 129 | CCOUT(3) << "Setting up..." << std::endl; |
---|
| 130 | // temporary overwrite of dataPath, change ini file for permanent change |
---|
| 131 | |
---|
[1502] | 132 | // TODO: LogManager doesn't work on specific systems. The why is unknown yet. |
---|
| 133 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 |
---|
| 134 | // create a logManager |
---|
[1293] | 135 | // note: If there's already a logManager, Ogre will complain by a failed assertation. |
---|
| 136 | // but that shouldn't happen, since this is the first time to create a logManager.. |
---|
| 137 | Ogre::LogManager* logger = new Ogre::LogManager(); |
---|
| 138 | CCOUT(4) << "Ogre LogManager created" << std::endl; |
---|
[1024] | 139 | |
---|
| 140 | // create our own log that we can listen to |
---|
[1062] | 141 | Ogre::Log *myLog; |
---|
[1531] | 142 | if (this->ogreLogFile_ == "") |
---|
[1024] | 143 | myLog = logger->createLog("ogre.log", true, false, true); |
---|
| 144 | else |
---|
[1531] | 145 | myLog = logger->createLog(this->ogreLogFile_, true, false, false); |
---|
[1293] | 146 | CCOUT(4) << "Ogre Log created" << std::endl; |
---|
[1024] | 147 | |
---|
[1062] | 148 | myLog->setLogDetail(Ogre::LL_BOREME); |
---|
[1502] | 149 | myLog->addListener(this); |
---|
| 150 | #endif |
---|
[1024] | 151 | |
---|
| 152 | // Root will detect that we've already created a Log |
---|
[1293] | 153 | CCOUT(4) << "Creating Ogre Root..." << std::endl; |
---|
[1502] | 154 | |
---|
[1531] | 155 | if (ogrePluginsFile_ == "") |
---|
| 156 | { |
---|
| 157 | COUT(1) << "Error: Ogre plugins file set to \"\". Cannot load." << std::endl; |
---|
| 158 | return false; |
---|
| 159 | } |
---|
| 160 | if (ogreConfigFile_ == "") |
---|
| 161 | { |
---|
| 162 | COUT(1) << "Error: Ogre config file set to \"\". Cannot load." << std::endl; |
---|
| 163 | return false; |
---|
| 164 | } |
---|
| 165 | if (ogreLogFile_ == "") |
---|
| 166 | { |
---|
| 167 | COUT(1) << "Error: Ogre log file set to \"\". Cannot load." << std::endl; |
---|
| 168 | return false; |
---|
| 169 | } |
---|
[1502] | 170 | |
---|
[1531] | 171 | try |
---|
| 172 | { |
---|
| 173 | root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_); |
---|
| 174 | } |
---|
| 175 | catch (Ogre::Exception ex) |
---|
| 176 | { |
---|
| 177 | COUT(2) << "Error: There was an exception when creating Ogre Root." << std::endl; |
---|
| 178 | return false; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | if (!root_->getInstalledPlugins().size()) |
---|
| 182 | { |
---|
| 183 | COUT(1) << "Error: No plugins declared. Cannot load Ogre." << std::endl; |
---|
| 184 | COUT(0) << "Is the plugins file correctly declared?" << std::endl; |
---|
| 185 | return false; |
---|
| 186 | } |
---|
| 187 | |
---|
[1507] | 188 | #if 0 |
---|
[1502] | 189 | // tame the ogre ouput so we don't get all the mess in the console |
---|
| 190 | Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog(); |
---|
| 191 | defaultLog->setDebugOutputEnabled(false); |
---|
| 192 | defaultLog->setLogDetail(Ogre::LL_BOREME); |
---|
| 193 | defaultLog->addListener(this); |
---|
| 194 | #endif |
---|
| 195 | |
---|
[1293] | 196 | CCOUT(4) << "Creating Ogre Root done" << std::endl; |
---|
[612] | 197 | |
---|
[1293] | 198 | // specify where Ogre has to look for resources. This call doesn't parse anything yet! |
---|
[1531] | 199 | if (!declareRessourceLocations()) |
---|
| 200 | return false; |
---|
[612] | 201 | |
---|
[1293] | 202 | CCOUT(3) << "Set up done." << std::endl; |
---|
[612] | 203 | return true; |
---|
| 204 | } |
---|
| 205 | |
---|
[1531] | 206 | bool GraphicsEngine::declareRessourceLocations() |
---|
[612] | 207 | { |
---|
[1293] | 208 | CCOUT(4) << "Declaring Resources" << std::endl; |
---|
[612] | 209 | //TODO: Specify layout of data file and maybe use xml-loader |
---|
| 210 | //TODO: Work with ressource groups (should be generated by a special loader) |
---|
[1531] | 211 | |
---|
| 212 | if (resourceFile_ == "") |
---|
| 213 | { |
---|
| 214 | COUT(1) << "Error: Resource file set to \"\". Cannot load." << std::endl; |
---|
| 215 | return false; |
---|
| 216 | } |
---|
| 217 | |
---|
[612] | 218 | // Load resource paths from data file using configfile ressource type |
---|
[1052] | 219 | Ogre::ConfigFile cf; |
---|
[1531] | 220 | try |
---|
| 221 | { |
---|
| 222 | cf.load(Settings::getDataPath() + resourceFile_); |
---|
| 223 | } |
---|
| 224 | catch (Ogre::Exception ex) |
---|
| 225 | { |
---|
| 226 | COUT(1) << "Error: Could not load resources.cfg in path " << Settings::getDataPath() << std::endl; |
---|
| 227 | COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl; |
---|
| 228 | return false; |
---|
| 229 | } |
---|
[612] | 230 | |
---|
| 231 | // Go through all sections & settings in the file |
---|
[1052] | 232 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); |
---|
[612] | 233 | |
---|
[715] | 234 | std::string secName, typeName, archName; |
---|
[612] | 235 | while (seci.hasMoreElements()) |
---|
| 236 | { |
---|
[1531] | 237 | try |
---|
[612] | 238 | { |
---|
[1531] | 239 | secName = seci.peekNextKey(); |
---|
| 240 | Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); |
---|
| 241 | Ogre::ConfigFile::SettingsMultiMap::iterator i; |
---|
| 242 | for (i = settings->begin(); i != settings->end(); ++i) |
---|
| 243 | { |
---|
| 244 | typeName = i->first; // for instance "FileSystem" or "Zip" |
---|
| 245 | archName = i->second; // name (and location) of archive |
---|
[612] | 246 | |
---|
[1531] | 247 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( |
---|
| 248 | std::string(Settings::getDataPath() + archName), typeName, secName); |
---|
| 249 | } |
---|
[612] | 250 | } |
---|
[1531] | 251 | catch (Ogre::Exception ex) |
---|
| 252 | { |
---|
| 253 | COUT(2) << "Exception while reading resources.cfg. Proceeding.." << ex.getDescription() << std::endl; |
---|
| 254 | } |
---|
[612] | 255 | } |
---|
[1531] | 256 | return true; |
---|
[612] | 257 | } |
---|
| 258 | |
---|
[1293] | 259 | bool GraphicsEngine::loadRenderer() |
---|
| 260 | { |
---|
| 261 | CCOUT(4) << "Configuring Renderer" << std::endl; |
---|
| 262 | if (!root_->restoreConfig() && !root_->showConfigDialog()) |
---|
| 263 | return false; |
---|
| 264 | |
---|
| 265 | CCOUT(4) << "Creating render window" << std::endl; |
---|
[1531] | 266 | try |
---|
| 267 | { |
---|
| 268 | this->renderWindow_ = root_->initialise(true, "OrxonoxV2"); |
---|
| 269 | } |
---|
| 270 | catch (Ogre::Exception ex) |
---|
| 271 | { |
---|
| 272 | COUT(2) << "Error: There was an exception when initialising Ogre Root." << std::endl; |
---|
| 273 | return false; |
---|
| 274 | } |
---|
| 275 | |
---|
[1293] | 276 | if (!root_->isInitialised()) |
---|
| 277 | { |
---|
[1531] | 278 | CCOUT(2) << "Error: Initialising Ogre root object failed." << std::endl; |
---|
[1293] | 279 | return false; |
---|
| 280 | } |
---|
| 281 | Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this); |
---|
| 282 | Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); |
---|
| 283 | return true; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | bool GraphicsEngine::initialiseResources() |
---|
| 287 | { |
---|
| 288 | CCOUT(4) << "Initialising resources" << std::endl; |
---|
| 289 | //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load... |
---|
| 290 | try |
---|
| 291 | { |
---|
| 292 | Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); |
---|
| 293 | /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); |
---|
| 294 | for (unsigned int i = 0; i < str.size(); i++) |
---|
| 295 | { |
---|
| 296 | Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]); |
---|
| 297 | }*/ |
---|
| 298 | } |
---|
| 299 | catch (Ogre::Exception e) |
---|
| 300 | { |
---|
| 301 | CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl; |
---|
| 302 | CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl; |
---|
| 303 | return false; |
---|
| 304 | } |
---|
| 305 | return true; |
---|
| 306 | } |
---|
| 307 | |
---|
[1021] | 308 | /** |
---|
[1293] | 309 | * @brief Creates the SceneManager |
---|
| 310 | */ |
---|
| 311 | bool GraphicsEngine::createNewScene() |
---|
| 312 | { |
---|
[1502] | 313 | CCOUT(4) << "Creating new SceneManager..." << std::endl; |
---|
[1293] | 314 | if (scene_) |
---|
| 315 | { |
---|
| 316 | CCOUT(2) << "SceneManager already exists! Skipping." << std::endl; |
---|
| 317 | return false; |
---|
| 318 | } |
---|
| 319 | scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager"); |
---|
| 320 | CCOUT(3) << "Created SceneManager: " << scene_ << std::endl; |
---|
| 321 | return true; |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | /** |
---|
[1021] | 325 | Returns the window handle of the render window. |
---|
| 326 | At least the InputHandler uses this to create the OIS::InputManager |
---|
| 327 | @return The window handle of the render window |
---|
| 328 | */ |
---|
| 329 | size_t GraphicsEngine::getWindowHandle() |
---|
| 330 | { |
---|
| 331 | if (this->renderWindow_) |
---|
| 332 | { |
---|
[1024] | 333 | size_t windowHnd = 0; |
---|
[1032] | 334 | this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd); |
---|
[1024] | 335 | return windowHnd; |
---|
| 336 | } |
---|
[1021] | 337 | else |
---|
| 338 | return 0; |
---|
| 339 | } |
---|
[612] | 340 | |
---|
[1021] | 341 | /** |
---|
| 342 | Get the width of the current render window |
---|
| 343 | @return The width of the current render window |
---|
| 344 | */ |
---|
| 345 | int GraphicsEngine::getWindowWidth() const |
---|
| 346 | { |
---|
| 347 | if (this->renderWindow_) |
---|
| 348 | return this->renderWindow_->getWidth(); |
---|
| 349 | else |
---|
| 350 | return 0; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | /** |
---|
| 354 | Get the height of the current render window |
---|
| 355 | @return The height of the current render window |
---|
| 356 | */ |
---|
| 357 | int GraphicsEngine::getWindowHeight() const |
---|
| 358 | { |
---|
| 359 | if (this->renderWindow_) |
---|
| 360 | return this->renderWindow_->getHeight(); |
---|
| 361 | else |
---|
| 362 | return 0; |
---|
| 363 | } |
---|
| 364 | |
---|
[1024] | 365 | /** |
---|
[1505] | 366 | @brief Returns the window aspect ratio height/width. |
---|
| 367 | @return The ratio |
---|
| 368 | */ |
---|
| 369 | float GraphicsEngine::getWindowAspectRatio() const |
---|
| 370 | { |
---|
| 371 | if (this->renderWindow_) |
---|
| 372 | return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth(); |
---|
| 373 | else |
---|
| 374 | return 1.0f; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | /** |
---|
[1024] | 378 | @brief Method called by the LogListener interface from Ogre. |
---|
| 379 | We use it to capture Ogre log messages and handle it ourselves. |
---|
| 380 | @param message The message to be logged |
---|
| 381 | @param lml The message level the log is using |
---|
| 382 | @param maskDebug If we are printing to the console or not |
---|
| 383 | @param logName the name of this log (so you can have several listeners |
---|
| 384 | for different logs, and identify them) |
---|
| 385 | */ |
---|
| 386 | void GraphicsEngine::messageLogged(const std::string& message, |
---|
[1052] | 387 | Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName) |
---|
[1024] | 388 | { |
---|
| 389 | int orxonoxLevel; |
---|
| 390 | switch (lml) |
---|
| 391 | { |
---|
[1052] | 392 | case Ogre::LML_TRIVIAL: |
---|
[1024] | 393 | orxonoxLevel = this->ogreLogLevelTrivial_; |
---|
| 394 | break; |
---|
[1052] | 395 | case Ogre::LML_NORMAL: |
---|
[1024] | 396 | orxonoxLevel = this->ogreLogLevelNormal_; |
---|
| 397 | break; |
---|
[1052] | 398 | case Ogre::LML_CRITICAL: |
---|
[1024] | 399 | orxonoxLevel = this->ogreLogLevelCritical_; |
---|
| 400 | break; |
---|
| 401 | default: |
---|
| 402 | orxonoxLevel = 0; |
---|
| 403 | } |
---|
| 404 | OutputHandler::getOutStream().setOutputLevel(orxonoxLevel) |
---|
[1293] | 405 | << "Ogre: " << message << std::endl; |
---|
[1024] | 406 | } |
---|
[1214] | 407 | |
---|
[1293] | 408 | /** |
---|
| 409 | * Window has resized. |
---|
| 410 | * @param rw The render window it occured in |
---|
| 411 | */ |
---|
| 412 | void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw) |
---|
| 413 | { |
---|
| 414 | // note: this doesn't change the window extents |
---|
| 415 | } |
---|
[1214] | 416 | |
---|
[1293] | 417 | /** |
---|
| 418 | * Window has resized. |
---|
| 419 | * @param rw The render window it occured in |
---|
| 420 | * @note GraphicsEngine has a render window stored itself. This is the same |
---|
| 421 | * as rw. But we have to be careful when using multiple render windows! |
---|
| 422 | */ |
---|
[1505] | 423 | void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) |
---|
| 424 | { |
---|
[1293] | 425 | // change the mouse clipping size for absolute mouse movements |
---|
| 426 | int w = rw->getWidth(); |
---|
| 427 | int h = rw->getHeight(); |
---|
| 428 | InputManager::setWindowExtents(w, h); |
---|
[1502] | 429 | InGameConsole::getInstance().resize(); |
---|
[1293] | 430 | } |
---|
[1214] | 431 | |
---|
[1293] | 432 | /** |
---|
| 433 | * Window has resized. |
---|
| 434 | * @param rw The render window it occured in |
---|
| 435 | */ |
---|
| 436 | void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw) |
---|
| 437 | { |
---|
| 438 | // note: this doesn't change the window extents |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | /** |
---|
| 442 | * Window has resized. |
---|
| 443 | * @param rw The render window it occured in |
---|
| 444 | */ |
---|
| 445 | void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw) |
---|
| 446 | { |
---|
| 447 | // using CommandExecutor in order to avoid depending on Orxonox class. |
---|
| 448 | CommandExecutor::execute("exit", false); |
---|
| 449 | } |
---|
[1502] | 450 | |
---|
| 451 | //HACK!! |
---|
| 452 | /*SetConsoleCommandShortcut(GraphicsEngine, CompositorBloomOn).setAccessLevel(AccessLevel::User); |
---|
| 453 | SetConsoleCommandShortcut(GraphicsEngine, CompositorMotionBlurOn).setAccessLevel(AccessLevel::User); |
---|
| 454 | SetConsoleCommandShortcut(GraphicsEngine, CompositorBloomOff).setAccessLevel(AccessLevel::User); |
---|
| 455 | SetConsoleCommandShortcut(GraphicsEngine, CompositorMotionBlurOff).setAccessLevel(AccessLevel::User); |
---|
| 456 | void GraphicsEngine::CompositorBloomOn() |
---|
| 457 | { |
---|
| 458 | Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager(); |
---|
| 459 | Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport(); |
---|
| 460 | Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom"); |
---|
| 461 | Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Bloom", true); |
---|
| 462 | } |
---|
| 463 | void GraphicsEngine::CompositorBloomOff() |
---|
| 464 | { |
---|
| 465 | Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager(); |
---|
| 466 | Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport(); |
---|
| 467 | Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Bloom", false); |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | void GraphicsEngine::CompositorMotionBlurOn() |
---|
| 471 | { |
---|
| 472 | Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager(); |
---|
| 473 | Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport(); |
---|
| 474 | Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur"); |
---|
| 475 | Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "MotionBlur", true); |
---|
| 476 | } |
---|
| 477 | void GraphicsEngine::CompositorMotionBlurOff() |
---|
| 478 | { |
---|
| 479 | Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager(); |
---|
| 480 | Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport(); |
---|
| 481 | Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "MotionBlur", false); |
---|
| 482 | }*/ |
---|
[612] | 483 | } |
---|