Changeset 8079 for code/trunk/src/orxonox
- Timestamp:
- Mar 15, 2011, 9:47:11 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
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.