- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/CameraManager.cc
r2171 r2369 30 30 31 31 #include <OgreViewport.h> 32 #include <OgreSceneManager.h> 33 #include <OgreCamera.h> 32 34 33 35 #include "core/Core.h" 34 36 #include "objects/worldentities/Camera.h" 35 37 #include "objects/Scene.h" 38 #include "util/String.h" 36 39 37 40 namespace orxonox … … 44 47 assert(singletonRef_s == 0); 45 48 singletonRef_s = this; 49 50 this->fallbackCamera_ = 0; 46 51 } 47 52 … … 50 55 assert(singletonRef_s != 0); 51 56 singletonRef_s = 0; 57 58 if (this->fallbackCamera_) 59 { 60 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 61 COUT(0) << "remove camera-manager" << std::endl; 62 } 52 63 } 53 64 … … 68 79 if (this->cameraList_.size() > 0) 69 80 this->cameraList_.front()->removeFocus(); 81 else if (this->fallbackCamera_) 82 { 83 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 84 this->fallbackCamera_ = 0; 85 COUT(0) << "remove fallback camera" << std::endl; 86 } 70 87 71 88 camera->setFocus(this->viewport_); 72 89 90 // make sure we don't add it twice 91 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it) 92 if ((*it) == camera) 93 return; 94 73 95 // add to list 74 std::list<Camera*>::iterator it;75 for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)76 {77 if ((*it) == camera)78 return; // make sure we don't add it twice79 }80 96 this->cameraList_.push_front(camera); 81 97 } … … 92 108 this->cameraList_.pop_front(); 93 109 94 // set new focus if necessary 95 if (cameraList_.size() > 0) 96 cameraList_.front()->setFocus(this->viewport_); 110 // set new focus if possible 111 if (this->cameraList_.size() > 0) 112 this->cameraList_.front()->setFocus(this->viewport_); 113 else 114 { 115 // there are no more cameras, create a fallback 116 if (!this->fallbackCamera_) 117 { 118 COUT(0) << "create fallback camera" << std::endl; 119 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 120 } 121 this->viewport_->setCamera(this->fallbackCamera_); 122 COUT(0) << "use fallback camera" << std::endl; 123 } 97 124 } 98 125 else
Note: See TracChangeset
for help on using the changeset viewer.