Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2537 was 2261, checked in by landauf, 16 years ago

merged questsystem2 back to trunk

  • Property svn:eol-style set to native
  • Property svn:mergeinfo set to (toggle deleted branches)
    /code/branches/questsystem2/src/orxonox/CameraManager.ccmergedeligible
    /code/branches/ceguilua/src/orxonox/objects/CameraHandler.cc1802-1808
    /code/branches/core3/src/orxonox/objects/CameraHandler.cc1572-1739
    /code/branches/gcc43/src/orxonox/objects/CameraHandler.cc1580
    /code/branches/gui/src/orxonox/objects/CameraHandler.cc1635-1723
    /code/branches/input/src/orxonox/objects/CameraHandler.cc1629-1636
    /code/branches/objecthierarchy/src/orxonox/CameraManager.cc2100,​2110-2169
    /code/branches/script_trigger/src/orxonox/objects/CameraHandler.cc1295-1953,​1955
File size: 2.8 KB
Line 
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:
25 *      Fabian 'x3n' Landau
26 *
27 */
28#include "OrxonoxStableHeaders.h"
29#include "CameraManager.h"
30
31#include <OgreViewport.h>
32
33#include "core/Core.h"
34#include "objects/worldentities/Camera.h"
35
36
37namespace orxonox
38{
39    CameraManager* CameraManager::singletonRef_s = 0;
40
41    CameraManager::CameraManager(Ogre::Viewport* viewport)
42        : viewport_(viewport)
43    {
44        assert(singletonRef_s == 0);
45        singletonRef_s = this;
46    }
47
48    CameraManager::~CameraManager()
49    {
50        assert(singletonRef_s != 0);
51        singletonRef_s = 0;
52    }
53
54    Camera* CameraManager::getActiveCamera() const
55    {
56        if (this->cameraList_.size() > 0)
57            return this->cameraList_.front();
58        else
59            return 0;
60    }
61
62    void CameraManager::requestFocus(Camera* camera)
63    {
64        if (!Core::showsGraphics())
65            return;
66
67        // notify old camera (if it exists)
68        if (this->cameraList_.size() > 0)
69            this->cameraList_.front()->removeFocus();
70
71        camera->setFocus(this->viewport_);
72
73        // add to list
74        std::list<Camera*>::iterator it;
75        for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
76        {
77            if ((*it) == camera)
78                return; // make sure we don't add it twice
79        }
80        this->cameraList_.push_front(camera);
81    }
82
83    void CameraManager::releaseFocus(Camera* camera)
84    {
85        if (!Core::showsGraphics())
86            return;
87
88        // notify the cam of releasing the focus
89        if (this->cameraList_.front() == camera)
90        {
91            camera->removeFocus();
92            this->cameraList_.pop_front();
93
94            // set new focus if necessary
95            if (cameraList_.size() > 0)
96                cameraList_.front()->setFocus(this->viewport_);
97        }
98        else
99        {
100            this->cameraList_.remove(camera);
101        }
102    }
103}
Note: See TracBrowser for help on using the repository browser.