Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc @ 2019

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

many changes, most important: BaseObject takes now a pointer to it's creator which is needed to build a level hierarchy (with different scenes)

  • Property svn:eol-style set to native
File size: 2.6 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 *      ...
26 *
27 */
28#include "OrxonoxStableHeaders.h"
29#include "CameraHandler.h"
30
31#include <OgreSceneManager.h>
32#include <OgreRenderWindow.h>
33
34#include "core/ObjectList.h"
35#include "core/Core.h"
36#include "Camera.h"
37#include "GraphicsEngine.h"
38
39#include <OgreCamera.h>
40
41namespace orxonox
42{
43    CameraHandler::CameraHandler()
44    {
45//        GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
46    }
47
48    CameraHandler& CameraHandler::getInstance()
49    {
50        static CameraHandler instance;
51        return instance;
52    }
53
54    Camera* CameraHandler::getActiveCamera() const
55    {
56        if (this->cameraList_.size() > 0)
57            return this->cameraList_.front();
58        else
59            return 0;
60    }
61
62    void CameraHandler::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        // add to list
72        this->cameraList_.push_front(camera);
73        camera->setFocus(GraphicsEngine::getInstance().getViewport());
74    }
75
76    void CameraHandler::releaseFocus(Camera* camera)
77    {
78        if (!Core::showsGraphics())
79            return;
80
81        // notify the cam of releasing the focus
82        if (this->cameraList_.front() == camera)
83        {
84            camera->removeFocus();
85            this->cameraList_.pop_front();
86
87            // set new focus if necessary
88            if (cameraList_.size() > 0)
89                cameraList_.front()->setFocus(GraphicsEngine::getInstance().getViewport());
90        }
91        else
92        {
93            this->cameraList_.remove(camera);
94        }
95    }
96}
Note: See TracBrowser for help on using the repository browser.