Changeset 5911
- Timestamp:
- Oct 8, 2009, 10:56:29 PM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/GUIManager.cc
r5855 r5911 101 101 : renderWindow_(renderWindow) 102 102 , resourceProvider_(0) 103 , camera_(NULL) 103 104 { 104 105 using namespace CEGUI; … … 174 175 void GUIManager::setCamera(Ogre::Camera* camera) 175 176 { 177 this->camera_ = camera; 176 178 if (camera == NULL) 177 179 this->guiRenderer_->setTargetSceneManager(0); -
code/branches/core5/src/libraries/core/GUIManager.h
r5738 r5911 71 71 72 72 void setCamera(Ogre::Camera* camera); 73 Ogre::Camera* getCamera() { return this->camera_; } 73 74 74 75 static GUIManager* getInstancePtr() { return singletonPtr_s; } … … 101 102 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 102 103 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui 104 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI 103 105 104 106 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager -
code/branches/core5/src/modules/objects/Planet.cc
r5738 r5911 47 47 * @brief Constructor 48 48 */ 49 Planet::Planet(BaseObject* creator) : MovableEntity(creator)49 Planet::Planet(BaseObject* creator) : MovableEntity(creator) 50 50 { 51 51 RegisterObject(Planet); … … 64 64 void Planet::tick(float dt) 65 65 { 66 if (!this->isVisible())66 if (!this->isVisible()) 67 67 return; 68 68 69 69 if (GameMode::showsGraphics()) 70 70 { 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera();72 if (activeCamera)71 Camera* activeCamera = this->getScene()->getCameraManager()->getActiveCamera(); 72 if (activeCamera) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); -
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 -
code/branches/core5/src/orxonox/CameraManager.h
r5867 r5911 41 41 #include <list> 42 42 #include "util/OgreForwardRefs.h" 43 #include "util/Singleton.h" 44 #include "core/OrxonoxClass.h" 45 #include "core/SmartPtr.h" 43 #include "core/BaseObject.h" 46 44 47 45 namespace orxonox 48 46 { 49 class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass47 class _OrxonoxExport CameraManager : public BaseObject 50 48 { 51 friend class Singleton<CameraManager>;52 49 public: 53 CameraManager( );50 CameraManager(BaseObject* creator); 54 51 ~CameraManager(); 55 52 … … 61 58 void useCamera(Ogre::Camera* camera); 62 59 63 static CameraManager* getInstancePtr() { return singletonPtr_s; }64 65 60 private: 66 61 CameraManager(const CameraManager&); // don't use … … 69 64 Ogre::Viewport* viewport_; 70 65 Ogre::Camera* fallbackCamera_; 71 SmartPtr<Scene> fallbackCameraScene_;72 73 static CameraManager* singletonPtr_s;74 66 }; 75 67 } -
code/branches/core5/src/orxonox/Scene.cc
r5839 r5911 45 45 #include "tools/BulletConversions.h" 46 46 #include "Radar.h" 47 #include "CameraManager.h" 47 48 #include "worldentities/WorldEntity.h" 48 49 … … 65 66 66 67 this->radar_ = new Radar(); 68 this->cameraManager_ = new CameraManager(this); 67 69 } 68 70 else … … 73 75 74 76 this->radar_ = 0; 77 this->cameraManager_ = 0; 75 78 } 76 79 … … 94 97 { 95 98 if (GameMode::showsGraphics()) 99 { 100 // Check whether we're still using this scene manager for the GUI 101 if (GUIManager::getInstance().getCamera() && GUIManager::getInstance().getCamera()->getSceneManager() == this->sceneManager_) 102 GUIManager::getInstance().setCamera(NULL); 96 103 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 104 } 97 105 else 98 106 delete this->sceneManager_; … … 100 108 if (this->radar_) 101 109 this->radar_->destroy(); 110 111 if (this->cameraManager_) 112 this->cameraManager_->destroy(); 102 113 103 114 this->setPhysicalWorld(false); -
code/branches/core5/src/orxonox/Scene.h
r5839 r5911 73 73 inline Radar* getRadar() 74 74 { return this->radar_; } 75 76 inline CameraManager* getCameraManager() 77 { return this->cameraManager_.get(); } 75 78 76 79 inline virtual uint32_t getSceneID() const { return this->getObjectID(); } … … 97 100 bool bShadows_; 98 101 Radar* radar_; 102 SmartPtr<CameraManager> cameraManager_; 99 103 100 104 -
code/branches/core5/src/orxonox/graphics/Camera.cc
r5738 r5911 38 38 #include "core/CoreIncludes.h" 39 39 #include "core/ConfigValueIncludes.h" 40 #include "core/GameMode.h" 40 41 #include "Scene.h" 41 42 #include "CameraManager.h" … … 49 50 RegisterObject(Camera); 50 51 52 if (!GameMode::showsGraphics()) 53 ThrowException(AbortLoading, "Can't create Camera, no graphics."); 51 54 if (!this->getScene()) 52 55 ThrowException(AbortLoading, "Can't create Camera, no scene."); … … 117 120 void Camera::requestFocus() 118 121 { 119 CameraManager::getInstance().requestFocus(this);122 this->getScene()->getCameraManager()->requestFocus(this); 120 123 } 121 124 122 125 void Camera::releaseFocus() 123 126 { 124 CameraManager::getInstance().releaseFocus(this);127 this->getScene()->getCameraManager()->releaseFocus(this); 125 128 } 126 129 … … 137 140 { 138 141 this->bHasFocus_ = true; 139 CameraManager::getInstance().useCamera(this->camera_);142 this->getScene()->getCameraManager()->useCamera(this->camera_); 140 143 } 141 144
Note: See TracChangeset
for help on using the changeset viewer.