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