Changeset 5929 for code/trunk/src/orxonox/CameraManager.cc
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CameraManager.cc
r5781 r5929 26 26 * 27 27 */ 28 28 29 #include "CameraManager.h" 29 30 … … 34 35 #include "util/StringUtils.h" 35 36 #include "core/GameMode.h" 37 #include "core/GraphicsManager.h" 36 38 #include "core/GUIManager.h" 37 39 #include "core/ObjectList.h" 40 #include "core/ScopedSingletonManager.h" 38 41 #include "tools/Shader.h" 39 42 #include "graphics/Camera.h" … … 43 46 { 44 47 CameraManager* CameraManager::singletonPtr_s = 0; 48 ManageScopedSingleton(CameraManager, ScopeID::Graphics, false); 45 49 46 CameraManager::CameraManager( Ogre::Viewport* viewport)47 : viewport_( viewport)50 CameraManager::CameraManager() 51 : viewport_(GraphicsManager::getInstance().getViewport()) 48 52 { 49 this->fallbackCamera_ = 0;53 assert(GameMode::showsGraphics()); 50 54 } 51 55 52 56 CameraManager::~CameraManager() 53 57 { 54 if (this->fallbackCamera_) 55 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 58 GUIManager::getInstance().setCamera(0); 56 59 } 57 60 58 61 Camera* CameraManager::getActiveCamera() const 59 62 { 60 if ( this->cameraList_.size() > 0)63 if (!this->cameraList_.empty()) 61 64 return this->cameraList_.front(); 62 65 else … … 66 69 void CameraManager::requestFocus(Camera* camera) 67 70 { 68 if (!GameMode::showsGraphics())69 return;70 71 71 // notify old camera (if it exists) 72 if ( this->cameraList_.size() > 0)72 if (!this->cameraList_.empty()) 73 73 this->cameraList_.front()->removeFocus(); 74 else if (this->fallbackCamera_)75 {76 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);77 this->fallbackCamera_ = 0;78 }79 74 80 75 camera->setFocus(); 81 76 82 77 // make sure we don't add it twice 83 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)78 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();) 84 79 if ((*it) == camera) 85 return; 86 80 this->cameraList_.erase(it++); 81 else 82 ++it; 87 83 // add to list 88 84 this->cameraList_.push_front(camera); … … 91 87 void CameraManager::releaseFocus(Camera* camera) 92 88 { 93 if (!GameMode::showsGraphics())94 return;95 96 89 // notify the cam of releasing the focus 97 if ( this->cameraList_.front() == camera)90 if (!this->cameraList_.empty() && this->cameraList_.front() == camera) 98 91 { 99 92 camera->removeFocus(); … … 101 94 102 95 // set new focus if possible 103 if ( this->cameraList_.size() > 0)96 if (!this->cameraList_.empty()) 104 97 this->cameraList_.front()->setFocus(); 105 else106 {107 // there are no more cameras, create a fallback108 if (!this->fallbackCamera_)109 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());110 this->useCamera(this->fallbackCamera_);111 }112 98 } 113 99 else 114 {115 100 this->cameraList_.remove(camera); 116 }117 101 } 118 102
Note: See TracChangeset
for help on using the changeset viewer.