Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/CameraManager.cc @ 12284

Last change on this file since 12284 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 2.9 KB
RevLine 
[1202]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht
24 *   Co-authors:
[2073]25 *      Fabian 'x3n' Landau
[1202]26 *
27 */
[5929]28
[2073]29#include "CameraManager.h"
[1502]30
[8079]31#include <cassert>
32
[2662]33#include <OgreSceneManager.h>
[2023]34#include <OgreViewport.h>
[2662]35#include <OgreCompositorManager.h>
[1202]36
[2896]37#include "core/GameMode.h"
[5929]38#include "core/GraphicsManager.h"
[9667]39#include "core/object/ObjectList.h"
[10624]40#include "core/singleton/ScopedSingletonIncludes.h"
[3196]41#include "tools/Shader.h"
[5738]42#include "graphics/Camera.h"
[1202]43
[2019]44namespace orxonox
45{
[10624]46    ManageScopedSingleton(CameraManager, ScopeID::GRAPHICS, false);
[2023]47
[5929]48    CameraManager::CameraManager()
[2019]49    {
[5929]50        assert(GameMode::showsGraphics());
[2019]51    }
[1202]52
[2073]53    CameraManager::~CameraManager()
[2019]54    {
55    }
[1202]56
[2073]57    Camera* CameraManager::getActiveCamera() const
[2019]58    {
[5929]59        if (!this->cameraList_.empty())
[2019]60            return this->cameraList_.front();
61        else
[11071]62            return nullptr;
[2019]63    }
[1202]64
[2073]65    void CameraManager::requestFocus(Camera* camera)
[2019]66    {
67        // notify old camera (if it exists)
[5929]68        if (!this->cameraList_.empty())
[2019]69            this->cameraList_.front()->removeFocus();
70
[2662]71        camera->setFocus();
[2064]72
[2662]73        // make sure we don't add it twice
[5929]74        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
[2662]75            if ((*it) == camera)
[5929]76                this->cameraList_.erase(it++);
77            else
78                ++it;
[2019]79        // add to list
80        this->cameraList_.push_front(camera);
[1202]81    }
82
[2073]83    void CameraManager::releaseFocus(Camera* camera)
[1202]84    {
[2019]85        // notify the cam of releasing the focus
[5929]86        if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
[2019]87        {
88            camera->removeFocus();
89            this->cameraList_.pop_front();
90
[2662]91            // set new focus if possible
[5929]92            if (!this->cameraList_.empty())
[2662]93                this->cameraList_.front()->setFocus();
[8079]94            else
[11071]95                this->useCamera(nullptr);
[2019]96        }
97        else
98            this->cameraList_.remove(camera);
[1202]99    }
[2662]100
101    void CameraManager::useCamera(Ogre::Camera* camera)
102    {
[8079]103        GraphicsManager::getInstance().setCamera(camera);
[2662]104    }
[1202]105}
Note: See TracBrowser for help on using the repository browser.