Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 26, 2011, 5:00:17 PM (13 years ago)
Author:
landauf
Message:

some changes related to camera switching:

  • added ViewportEventListener (currently only listens to camera changes in a viewport)
  • Shader now correctly updates its visibility if the camera changes the scene
  • (the same lines of code also fix the weird Ogre behavior which was originally fixed in CameraManager)
  • GraphicsManager also updates the GUIManager's camera
  • if all cameras are destroyed, CameraManager now officially switches to NULL camera
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/src/orxonox/CameraManager.cc

    r7879 r7966  
    2929#include "CameraManager.h"
    3030
     31#include <cassert>
     32
    3133#include <OgreSceneManager.h>
    3234#include <OgreViewport.h>
    3335#include <OgreCompositorManager.h>
    3436
    35 #include "util/StringUtils.h"
    3637#include "util/ScopedSingletonManager.h"
    3738#include "core/GameMode.h"
    3839#include "core/GraphicsManager.h"
    39 #include "core/GUIManager.h"
    4040#include "core/ObjectList.h"
    4141#include "tools/Shader.h"
    4242#include "graphics/Camera.h"
    43 #include "Scene.h"
    4443
    4544namespace orxonox
     
    4847
    4948    CameraManager::CameraManager()
    50         : viewport_(GraphicsManager::getInstance().getViewport())
    5149    {
    5250        assert(GameMode::showsGraphics());
     
    5553    CameraManager::~CameraManager()
    5654    {
    57         GUIManager::getInstance().setCamera(0);
    5855    }
    5956
     
    9592            if (!this->cameraList_.empty())
    9693                this->cameraList_.front()->setFocus();
     94            else
     95                this->useCamera(NULL);
    9796        }
    9897        else
     
    102101    void CameraManager::useCamera(Ogre::Camera* camera)
    103102    {
    104         // This workaround is needed to avoid weird behaviour with active compositors while
    105         // switching the camera (like freezing the image)
    106         //
    107         // Last known Ogre version needing this workaround:
    108         // 1.4.8
    109         // 1.7.2
    110 
    111         // deactivate all compositors
    112         {
    113             Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
    114             while (iterator.hasMoreElements())
    115                 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false);
    116         }
    117 
    118         this->viewport_->setCamera(camera);
    119         GUIManager::getInstance().setCamera(camera);
    120 
    121         // reactivate all visible compositors
    122         {
    123             for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
    124                 it->updateVisibility();
    125         }
     103        GraphicsManager::getInstance().setCamera(camera);
    126104    }
    127105}
Note: See TracChangeset for help on using the changeset viewer.