Changeset 2396 for code/branches
- Timestamp:
- Dec 10, 2008, 6:37:31 PM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox
- Files:
-
- 6 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 } -
code/branches/objecthierarchy2/src/orxonox/CameraManager.h
r2369 r2396 57 57 static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 58 58 59 void useCamera(Ogre::Camera* camera); 60 59 61 private: 60 62 CameraManager(const CameraManager&); -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.cc
r2350 r2396 101 101 } 102 102 103 this->playerManager_ = new PlayerManager(); 104 103 105 if (Core::isMaster()) 104 106 { 105 107 // create the global LevelManager 106 108 this->levelManager_ = new LevelManager(); 107 this->playerManager_ = new PlayerManager();108 109 109 110 // reset game speed to normal -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc
r2369 r2396 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreViewport.h>39 #include <OgreCompositorManager.h>40 #include <OgreResource.h>41 38 42 39 #include "util/Exception.h" … … 44 41 #include "core/ConfigValueIncludes.h" 45 42 #include "objects/Scene.h" 46 #include "tools/Shader.h"47 43 #include "CameraManager.h" 48 44 … … 54 50 { 55 51 RegisterObject(Camera); 56 COUT(0) << this << ": created camera" << std::endl; 52 57 53 if (!this->getScene() || !this->getScene()->getSceneManager()) 58 54 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); … … 80 76 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 81 77 } 82 COUT(0) << this << ": destroyed camera" << std::endl;83 78 } 84 79 … … 123 118 void Camera::removeFocus() 124 119 { 125 COUT(0) << this << ": remove focus" << std::endl;126 120 this->bHasFocus_ = false; 127 121 } 128 122 129 void Camera::setFocus( Ogre::Viewport* viewport)123 void Camera::setFocus() 130 124 { 131 // This workaround is needed to avoid weird behaviour with active compositors while132 // switching the camera (like freezing the image)133 //134 // Last known Ogre version needing this workaround:135 // 1.4.8136 137 // deactivate all compositors138 {139 Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();140 while (iterator.hasMoreElements())141 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, iterator.getNext()->getName(), false);142 }143 144 125 this->bHasFocus_ = true; 145 viewport->setCamera(this->camera_); 146 COUT(0) << this << ": set focus" << std::endl; 147 148 // reactivate all visible compositors 149 { 150 for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it) 151 it->updateVisibility(); 152 } 126 CameraManager::getInstance().useCamera(this->camera_); 153 127 } 154 128 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.h
r2171 r2396 62 62 private: 63 63 void removeFocus(); 64 void setFocus( Ogre::Viewport* viewport);64 void setFocus(); 65 65 void configvaluecallback_changedNearClipDistance(); 66 66 -
code/branches/objecthierarchy2/src/orxonox/tools/Shader.cc
r2361 r2396 83 83 Shader::~Shader() 84 84 { 85 /* 86 if (this-> isInitialized() && this->bLoadCompositor_ && this->compositor_ != "")85 86 if (this->bLoadCompositor_ && this->compositorInstance_) 87 87 { 88 88 Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport(); … … 90 90 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_); 91 91 } 92 */ 92 93 93 } 94 94
Note: See TracChangeset
for help on using the changeset viewer.