Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5924 for code/branches/core5


Ignore:
Timestamp:
Oct 9, 2009, 6:04:16 PM (15 years ago)
Author:
scheusso
Message:

reverted r5911 partially and removed fallbackcamera
level scene now gets deleted after all when changing from level to mainmenu

Location:
code/branches/core5/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/GUIManager.h

    r5911 r5924  
    102102        CEGUI::Logger*                       ceguiLogger_;      //!< CEGUI's logger to be able to log CEGUI errors in our log
    103103        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
     104        Ogre::Camera*                        camera_;           //!< Camera used to render the scene with the
    105105
    106106        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
  • code/branches/core5/src/libraries/core/GraphicsManager.cc

    r5876 r5924  
    361361
    362362        // Render frame
    363         ogreRoot_->_updateAllRenderTargets();
     363        if( this->viewport_->getCamera() )
     364            ogreRoot_->_updateAllRenderTargets();
    364365
    365366        uint64_t timeAfterTick = time.getRealMicroseconds();
  • code/branches/core5/src/modules/objects/Planet.cc

    r5911 r5924  
    4747     * @brief Constructor
    4848     */
    49     Planet::Planet(BaseObject* creator) : MovableEntity(creator)
     49    Planet::Planet(BaseObject* creator): MovableEntity(creator)
    5050    {
    5151        RegisterObject(Planet);
     
    6464    void Planet::tick(float dt)
    6565    {
    66         if (!this->isVisible())
     66        if(!this->isVisible())
    6767            return;
    6868
    6969        if (GameMode::showsGraphics())
    7070        {
    71             Camera* activeCamera = this->getScene()->getCameraManager()->getActiveCamera();
    72             if (activeCamera)
     71            Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
     72            if(activeCamera)
    7373            {
    7474                float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
  • code/branches/core5/src/orxonox/CameraManager.cc

    r5911 r5924  
    3838#include "core/GUIManager.h"
    3939#include "core/ObjectList.h"
     40#include "core/ScopedSingletonManager.h"
    4041#include "tools/Shader.h"
    4142#include "graphics/Camera.h"
     
    4445namespace orxonox
    4546{
    46     CameraManager::CameraManager(BaseObject* creator)
    47         : BaseObject(creator)
    48         , viewport_(GraphicsManager::getInstance().getViewport())
    49         , fallbackCamera_(NULL)
     47    CameraManager* CameraManager::singletonPtr_s = 0;
     48    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
     49
     50    CameraManager::CameraManager()
     51        : viewport_(GraphicsManager::getInstance().getViewport())
    5052    {
    51         assert(GameMode::showsGraphics());
    5253    }
    5354
    5455    CameraManager::~CameraManager()
    5556    {
    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 
    60         if (this->fallbackCamera_)
    61             this->getScene()->getSceneManager()->destroyCamera(this->fallbackCamera_);
     57        GUIManager::getInstance().setCamera(0);
    6258    }
    6359
    6460    Camera* CameraManager::getActiveCamera() const
    6561    {
    66         if (!this->cameraList_.empty())
     62        if (this->cameraList_.size() > 0)
    6763            return this->cameraList_.front();
    6864        else
     
    7268    void CameraManager::requestFocus(Camera* camera)
    7369    {
     70        if (!GameMode::showsGraphics())
     71            assert(0);
     72
    7473        // notify old camera (if it exists)
    75         if (!this->cameraList_.empty())
     74        if (this->cameraList_.size() > 0)
    7675            this->cameraList_.front()->removeFocus();
    7776
     
    7978
    8079        // make sure we don't add it twice
    81         for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
     80        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
    8281            if ((*it) == camera)
    83                 this->cameraList_.erase(it++);
    84             else
    85                 ++it;
     82                return;
    8683
    8784        // add to list
     
    9188    void CameraManager::releaseFocus(Camera* camera)
    9289    {
     90        if (!GameMode::showsGraphics())
     91            assert(0);
     92
    9393        // notify the cam of releasing the focus
    9494        if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
     
    9898
    9999            // set new focus if possible
    100             if (!this->cameraList_.empty())
     100            if (this->cameraList_.size() > 0)
    101101                this->cameraList_.front()->setFocus();
    102             else
    103             {
    104                 // there are no more cameras, create a fallback
    105                 if (!this->fallbackCamera_)
    106                     this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    107                 this->useCamera(this->fallbackCamera_);
    108             }
    109102        }
    110103        else
  • code/branches/core5/src/orxonox/CameraManager.h

    r5911 r5924  
    4141#include <list>
    4242#include "util/OgreForwardRefs.h"
    43 #include "core/BaseObject.h"
     43#include "util/Singleton.h"
     44#include "core/OrxonoxClass.h"
     45#include "core/SmartPtr.h"
    4446
    4547namespace orxonox
    4648{
    47     class _OrxonoxExport CameraManager : public BaseObject
     49    class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass
    4850    {
     51            friend class Singleton<CameraManager>;
    4952        public:
    50             CameraManager(BaseObject* creator);
     53            CameraManager();
    5154            ~CameraManager();
    5255
     
    5861            void useCamera(Ogre::Camera* camera);
    5962
     63            static CameraManager* getInstancePtr() { return singletonPtr_s; }
     64
    6065        private:
    6166            CameraManager(const CameraManager&); // don't use
     
    6368            std::list<Camera*>    cameraList_;
    6469            Ogre::Viewport*       viewport_;
    65             Ogre::Camera*         fallbackCamera_;
     70
     71            static CameraManager* singletonPtr_s;
    6672    };
    6773}
  • code/branches/core5/src/orxonox/Scene.cc

    r5914 r5924  
    4646#include "tools/BulletConversions.h"
    4747#include "Radar.h"
    48 #include "CameraManager.h"
    4948#include "worldentities/WorldEntity.h"
    5049
     
    6766
    6867            this->radar_ = new Radar();
    69             this->cameraManager_ = new CameraManager(this);
    7068        }
    7169        else
     
    7674
    7775            this->radar_ = 0;
    78             this->cameraManager_ = 0;
    7976        }
    8077
     
    9895        {
    9996            if (GameMode::showsGraphics())
    100             {
    101                 // Check whether we're still using this scene manager for the GUI
    102                 if (GUIManager::getInstance().getCamera() && GUIManager::getInstance().getCamera()->getSceneManager() == this->sceneManager_)
    103                     GUIManager::getInstance().setCamera(NULL);
    10497                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    105             }
    10698            else
    10799                delete this->sceneManager_;
     
    109101            if (this->radar_)
    110102                this->radar_->destroy();
    111 
    112             if (this->cameraManager_)
    113                 this->cameraManager_->destroy();
    114103
    115104            this->setPhysicalWorld(false);
  • code/branches/core5/src/orxonox/Scene.h

    r5911 r5924  
    7373            inline Radar* getRadar()
    7474                { return this->radar_; }
    75 
    76             inline CameraManager* getCameraManager()
    77                 { return this->cameraManager_.get(); }
    7875           
    7976            inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
     
    10097            bool                     bShadows_;
    10198            Radar*                   radar_;
    102             SmartPtr<CameraManager>  cameraManager_;
    10399
    104100
  • code/branches/core5/src/orxonox/graphics/Camera.cc

    r5916 r5924  
    3838#include "core/CoreIncludes.h"
    3939#include "core/ConfigValueIncludes.h"
    40 #include "core/GameMode.h"
     40#include "core/GUIManager.h"
    4141#include "Scene.h"
    4242#include "CameraManager.h"
     
    5050        RegisterObject(Camera);
    5151
    52         if (!GameMode::showsGraphics())
    53             ThrowException(AbortLoading, "Can't create Camera, no graphics.");
    5452        if (!this->getScene())
    5553            ThrowException(AbortLoading, "Can't create Camera, no scene.");
     
    7876        if (this->isInitialized())
    7977        {
     78            if( GUIManager::getInstance().getCamera() == this->camera_ )
     79                GUIManager::getInstance().setCamera( NULL );
    8080            this->releaseFocus();
    8181
     
    120120    void Camera::requestFocus()
    121121    {
    122         this->getScene()->getCameraManager()->requestFocus(this);
     122        CameraManager::getInstance().requestFocus(this);
    123123    }
    124124
    125125    void Camera::releaseFocus()
    126126    {
    127         this->getScene()->getCameraManager()->releaseFocus(this);
     127        CameraManager::getInstance().releaseFocus(this);
    128128    }
    129129
     
    140140    {
    141141        this->bHasFocus_ = true;
    142         this->getScene()->getCameraManager()->useCamera(this->camera_);
     142        CameraManager::getInstance().useCamera(this->camera_);
    143143    }
    144144
Note: See TracChangeset for help on using the changeset viewer.