- Timestamp:
- Dec 10, 2008, 6:37:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/CameraManager.cc
r2369 r2396 29 29 #include "CameraManager.h" 30 30 31 #include <OgreSceneManager.h> 31 32 #include <OgreViewport.h> 32 #include <OgreSceneManager.h>33 33 #include <OgreCamera.h> 34 #include <OgreCompositorManager.h> 35 #include <OgreResource.h> 34 36 35 37 #include "core/Core.h" 38 #include "core/Iterator.h" 36 39 #include "objects/worldentities/Camera.h" 37 40 #include "objects/Scene.h" 41 #include "tools/Shader.h" 38 42 #include "util/String.h" 39 43 … … 57 61 58 62 if (this->fallbackCamera_) 59 {60 63 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 61 COUT(0) << "remove camera-manager" << std::endl;62 }63 64 } 64 65 … … 83 84 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 84 85 this->fallbackCamera_ = 0; 85 COUT(0) << "remove fallback camera" << std::endl;86 86 } 87 87 88 camera->setFocus( this->viewport_);88 camera->setFocus(); 89 89 90 90 // make sure we don't add it twice … … 110 110 // set new focus if possible 111 111 if (this->cameraList_.size() > 0) 112 this->cameraList_.front()->setFocus( this->viewport_);112 this->cameraList_.front()->setFocus(); 113 113 else 114 114 { 115 115 // there are no more cameras, create a fallback 116 116 if (!this->fallbackCamera_) 117 {118 COUT(0) << "create fallback camera" << std::endl;119 117 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 120 } 121 this->viewport_->setCamera(this->fallbackCamera_); 122 COUT(0) << "use fallback camera" << std::endl; 118 this->useCamera(this->fallbackCamera_); 123 119 } 124 120 } … … 128 124 } 129 125 } 126 127 void CameraManager::useCamera(Ogre::Camera* camera) 128 { 129 // This workaround is needed to avoid weird behaviour with active compositors while 130 // switching the camera (like freezing the image) 131 // 132 // Last known Ogre version needing this workaround: 133 // 1.4.8 134 135 // deactivate all compositors 136 { 137 Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator(); 138 while (iterator.hasMoreElements()) 139 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false); 140 } 141 142 this->viewport_->setCamera(camera); 143 144 // reactivate all visible compositors 145 { 146 for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it) 147 it->updateVisibility(); 148 } 149 } 130 150 }
Note: See TracChangeset
for help on using the changeset viewer.