Changeset 5924 for code/branches/core5/src/orxonox/CameraManager.cc
- Timestamp:
- Oct 9, 2009, 6:04:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/orxonox/CameraManager.cc
r5911 r5924 38 38 #include "core/GUIManager.h" 39 39 #include "core/ObjectList.h" 40 #include "core/ScopedSingletonManager.h" 40 41 #include "tools/Shader.h" 41 42 #include "graphics/Camera.h" … … 44 45 namespace orxonox 45 46 { 46 CameraManager::CameraManager(BaseObject* creator) 47 : BaseObject(creator) 48 , viewport_(GraphicsManager::getInstance().getViewport()) 49 , fallbackCamera_(NULL) 47 CameraManager* CameraManager::singletonPtr_s = 0; 48 ManageScopedSingleton(CameraManager, ScopeID::Graphics, false); 49 50 CameraManager::CameraManager() 51 : viewport_(GraphicsManager::getInstance().getViewport()) 50 52 { 51 assert(GameMode::showsGraphics());52 53 } 53 54 54 55 CameraManager::~CameraManager() 55 56 { 56 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();) 57 if ((*it)->camera_ == GUIManager::getInstance().getCamera()) 58 GUIManager::getInstance().setCamera(NULL); 59 60 if (this->fallbackCamera_) 61 this->getScene()->getSceneManager()->destroyCamera(this->fallbackCamera_); 57 GUIManager::getInstance().setCamera(0); 62 58 } 63 59 64 60 Camera* CameraManager::getActiveCamera() const 65 61 { 66 if ( !this->cameraList_.empty())62 if (this->cameraList_.size() > 0) 67 63 return this->cameraList_.front(); 68 64 else … … 72 68 void CameraManager::requestFocus(Camera* camera) 73 69 { 70 if (!GameMode::showsGraphics()) 71 assert(0); 72 74 73 // notify old camera (if it exists) 75 if ( !this->cameraList_.empty())74 if (this->cameraList_.size() > 0) 76 75 this->cameraList_.front()->removeFocus(); 77 76 … … 79 78 80 79 // make sure we don't add it twice 81 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); )80 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it) 82 81 if ((*it) == camera) 83 this->cameraList_.erase(it++); 84 else 85 ++it; 82 return; 86 83 87 84 // add to list … … 91 88 void CameraManager::releaseFocus(Camera* camera) 92 89 { 90 if (!GameMode::showsGraphics()) 91 assert(0); 92 93 93 // notify the cam of releasing the focus 94 94 if (!this->cameraList_.empty() && this->cameraList_.front() == camera) … … 98 98 99 99 // set new focus if possible 100 if ( !this->cameraList_.empty())100 if (this->cameraList_.size() > 0) 101 101 this->cameraList_.front()->setFocus(); 102 else103 {104 // there are no more cameras, create a fallback105 if (!this->fallbackCamera_)106 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());107 this->useCamera(this->fallbackCamera_);108 }109 102 } 110 103 else
Note: See TracChangeset
for help on using the changeset viewer.