[Orxonox-commit 1203] r5924 - in code/branches/core5/src: libraries/core modules/objects orxonox orxonox/graphics
scheusso at orxonox.net
scheusso at orxonox.net
Fri Oct 9 18:04:16 CEST 2009
Author: scheusso
Date: 2009-10-09 18:04:16 +0200 (Fri, 09 Oct 2009)
New Revision: 5924
Modified:
code/branches/core5/src/libraries/core/GUIManager.h
code/branches/core5/src/libraries/core/GraphicsManager.cc
code/branches/core5/src/modules/objects/Planet.cc
code/branches/core5/src/orxonox/CameraManager.cc
code/branches/core5/src/orxonox/CameraManager.h
code/branches/core5/src/orxonox/Scene.cc
code/branches/core5/src/orxonox/Scene.h
code/branches/core5/src/orxonox/graphics/Camera.cc
Log:
reverted r5911 partially and removed fallbackcamera
level scene now gets deleted after all when changing from level to mainmenu
Modified: code/branches/core5/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/core5/src/libraries/core/GUIManager.h 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/libraries/core/GUIManager.h 2009-10-09 16:04:16 UTC (rev 5924)
@@ -101,7 +101,7 @@
CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui
- Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI
+ Ogre::Camera* camera_; //!< Camera used to render the scene with the
static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
Modified: code/branches/core5/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/GraphicsManager.cc 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/libraries/core/GraphicsManager.cc 2009-10-09 16:04:16 UTC (rev 5924)
@@ -360,7 +360,8 @@
uint64_t timeBeforeTick = time.getRealMicroseconds();
// Render frame
- ogreRoot_->_updateAllRenderTargets();
+ if( this->viewport_->getCamera() )
+ ogreRoot_->_updateAllRenderTargets();
uint64_t timeAfterTick = time.getRealMicroseconds();
// Subtract the time used for rendering from the tick time counter
Modified: code/branches/core5/src/modules/objects/Planet.cc
===================================================================
--- code/branches/core5/src/modules/objects/Planet.cc 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/modules/objects/Planet.cc 2009-10-09 16:04:16 UTC (rev 5924)
@@ -46,7 +46,7 @@
/**
* @brief Constructor
*/
- Planet::Planet(BaseObject* creator) : MovableEntity(creator)
+ Planet::Planet(BaseObject* creator): MovableEntity(creator)
{
RegisterObject(Planet);
this->registerVariables();
@@ -63,13 +63,13 @@
void Planet::tick(float dt)
{
- if (!this->isVisible())
+ if(!this->isVisible())
return;
if (GameMode::showsGraphics())
{
- Camera* activeCamera = this->getScene()->getCameraManager()->getActiveCamera();
- if (activeCamera)
+ Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
+ if(activeCamera)
{
float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
// COUT(2) << distance << std::endl;
Modified: code/branches/core5/src/orxonox/CameraManager.cc
===================================================================
--- code/branches/core5/src/orxonox/CameraManager.cc 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/orxonox/CameraManager.cc 2009-10-09 16:04:16 UTC (rev 5924)
@@ -37,33 +37,29 @@
#include "core/GraphicsManager.h"
#include "core/GUIManager.h"
#include "core/ObjectList.h"
+#include "core/ScopedSingletonManager.h"
#include "tools/Shader.h"
#include "graphics/Camera.h"
#include "Scene.h"
namespace orxonox
{
- CameraManager::CameraManager(BaseObject* creator)
- : BaseObject(creator)
- , viewport_(GraphicsManager::getInstance().getViewport())
- , fallbackCamera_(NULL)
+ CameraManager* CameraManager::singletonPtr_s = 0;
+ ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
+
+ CameraManager::CameraManager()
+ : viewport_(GraphicsManager::getInstance().getViewport())
{
- assert(GameMode::showsGraphics());
}
CameraManager::~CameraManager()
{
- for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
- if ((*it)->camera_ == GUIManager::getInstance().getCamera())
- GUIManager::getInstance().setCamera(NULL);
-
- if (this->fallbackCamera_)
- this->getScene()->getSceneManager()->destroyCamera(this->fallbackCamera_);
+ GUIManager::getInstance().setCamera(0);
}
Camera* CameraManager::getActiveCamera() const
{
- if (!this->cameraList_.empty())
+ if (this->cameraList_.size() > 0)
return this->cameraList_.front();
else
return 0;
@@ -71,18 +67,19 @@
void CameraManager::requestFocus(Camera* camera)
{
+ if (!GameMode::showsGraphics())
+ assert(0);
+
// notify old camera (if it exists)
- if (!this->cameraList_.empty())
+ if (this->cameraList_.size() > 0)
this->cameraList_.front()->removeFocus();
camera->setFocus();
// make sure we don't add it twice
- for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
+ for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
if ((*it) == camera)
- this->cameraList_.erase(it++);
- else
- ++it;
+ return;
// add to list
this->cameraList_.push_front(camera);
@@ -90,6 +87,9 @@
void CameraManager::releaseFocus(Camera* camera)
{
+ if (!GameMode::showsGraphics())
+ assert(0);
+
// notify the cam of releasing the focus
if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
{
@@ -97,15 +97,8 @@
this->cameraList_.pop_front();
// set new focus if possible
- if (!this->cameraList_.empty())
+ if (this->cameraList_.size() > 0)
this->cameraList_.front()->setFocus();
- else
- {
- // there are no more cameras, create a fallback
- if (!this->fallbackCamera_)
- this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
- this->useCamera(this->fallbackCamera_);
- }
}
else
this->cameraList_.remove(camera);
Modified: code/branches/core5/src/orxonox/CameraManager.h
===================================================================
--- code/branches/core5/src/orxonox/CameraManager.h 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/orxonox/CameraManager.h 2009-10-09 16:04:16 UTC (rev 5924)
@@ -40,14 +40,17 @@
#include <cassert>
#include <list>
#include "util/OgreForwardRefs.h"
-#include "core/BaseObject.h"
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+#include "core/SmartPtr.h"
namespace orxonox
{
- class _OrxonoxExport CameraManager : public BaseObject
+ class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass
{
+ friend class Singleton<CameraManager>;
public:
- CameraManager(BaseObject* creator);
+ CameraManager();
~CameraManager();
Camera* getActiveCamera() const;
@@ -57,12 +60,15 @@
void useCamera(Ogre::Camera* camera);
+ static CameraManager* getInstancePtr() { return singletonPtr_s; }
+
private:
CameraManager(const CameraManager&); // don't use
std::list<Camera*> cameraList_;
Ogre::Viewport* viewport_;
- Ogre::Camera* fallbackCamera_;
+
+ static CameraManager* singletonPtr_s;
};
}
Modified: code/branches/core5/src/orxonox/Scene.cc
===================================================================
--- code/branches/core5/src/orxonox/Scene.cc 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/orxonox/Scene.cc 2009-10-09 16:04:16 UTC (rev 5924)
@@ -45,7 +45,6 @@
#include "core/XMLPort.h"
#include "tools/BulletConversions.h"
#include "Radar.h"
-#include "CameraManager.h"
#include "worldentities/WorldEntity.h"
namespace orxonox
@@ -66,7 +65,6 @@
this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
this->radar_ = new Radar();
- this->cameraManager_ = new CameraManager(this);
}
else
{
@@ -75,7 +73,6 @@
this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
this->radar_ = 0;
- this->cameraManager_ = 0;
}
// No physics yet, XMLPort will do that.
@@ -97,21 +94,13 @@
if (this->isInitialized())
{
if (GameMode::showsGraphics())
- {
- // Check whether we're still using this scene manager for the GUI
- if (GUIManager::getInstance().getCamera() && GUIManager::getInstance().getCamera()->getSceneManager() == this->sceneManager_)
- GUIManager::getInstance().setCamera(NULL);
Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
- }
else
delete this->sceneManager_;
if (this->radar_)
this->radar_->destroy();
- if (this->cameraManager_)
- this->cameraManager_->destroy();
-
this->setPhysicalWorld(false);
}
}
Modified: code/branches/core5/src/orxonox/Scene.h
===================================================================
--- code/branches/core5/src/orxonox/Scene.h 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/orxonox/Scene.h 2009-10-09 16:04:16 UTC (rev 5924)
@@ -72,9 +72,6 @@
inline Radar* getRadar()
{ return this->radar_; }
-
- inline CameraManager* getCameraManager()
- { return this->cameraManager_.get(); }
inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
@@ -99,7 +96,6 @@
std::list<BaseObject*> objects_;
bool bShadows_;
Radar* radar_;
- SmartPtr<CameraManager> cameraManager_;
/////////////
Modified: code/branches/core5/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/core5/src/orxonox/graphics/Camera.cc 2009-10-09 15:47:46 UTC (rev 5923)
+++ code/branches/core5/src/orxonox/graphics/Camera.cc 2009-10-09 16:04:16 UTC (rev 5924)
@@ -37,7 +37,7 @@
#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
-#include "core/GameMode.h"
+#include "core/GUIManager.h"
#include "Scene.h"
#include "CameraManager.h"
@@ -49,8 +49,6 @@
{
RegisterObject(Camera);
- if (!GameMode::showsGraphics())
- ThrowException(AbortLoading, "Can't create Camera, no graphics.");
if (!this->getScene())
ThrowException(AbortLoading, "Can't create Camera, no scene.");
if (!this->getScene()->getSceneManager())
@@ -77,6 +75,8 @@
{
if (this->isInitialized())
{
+ if( GUIManager::getInstance().getCamera() == this->camera_ )
+ GUIManager::getInstance().setCamera( NULL );
this->releaseFocus();
this->cameraNode_->detachAllObjects();
@@ -119,12 +119,12 @@
void Camera::requestFocus()
{
- this->getScene()->getCameraManager()->requestFocus(this);
+ CameraManager::getInstance().requestFocus(this);
}
void Camera::releaseFocus()
{
- this->getScene()->getCameraManager()->releaseFocus(this);
+ CameraManager::getInstance().releaseFocus(this);
}
/**
@@ -139,7 +139,7 @@
void Camera::setFocus()
{
this->bHasFocus_ = true;
- this->getScene()->getCameraManager()->useCamera(this->camera_);
+ CameraManager::getInstance().useCamera(this->camera_);
}
void Camera::setDrag(bool bDrag)
More information about the Orxonox-commit
mailing list