Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core3/src/orxonox/objects/CameraHandler.cc @ 1929

Last change on this file since 1929 was 1505, checked in by rgrieder, 16 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
File size: 2.7 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 "Camera.h"
36#include "GraphicsEngine.h"
37
38#include <OgreCamera.h>
39
40namespace orxonox {
41
42  CameraHandler* CameraHandler::singletonRef = NULL;
43
44  CameraHandler::CameraHandler()
45  {
46    this->cam_ = GraphicsEngine::getSingleton().getSceneManager()->createCamera("Cam");
47    GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
48    /*this->activeCamera_ = *ObjectList<Camera>::begin();
49    this->activeCamera_->cam_ = this->cam_;*/
50  }
51
52  void CameraHandler::requestFocus(Camera* requestCam)
53  {
54    // notify old camera (if it exists)
55    if(focusList_.size() > 0)
56      focusList_.back()->removeFocus();
57    // add to list
58    focusList_.push_back(requestCam);
59    // set focus to new camera and update (if necessary)
60    if(!requestCam->hasFocus()) {
61      requestCam->setFocus(this->cam_);
62      requestCam->update();
63    }
64    // delete dublicates
65    focusList_.unique();
66  }
67
68  void CameraHandler::releaseFocus(Camera* cam)
69  {
70    // notify the cam of releasing the focus
71    if(cam->hasFocus())
72      cam->removeFocus();
73    // delete camera from list
74    focusList_.remove(cam);
75    // set new focus if necessary
76    if(focusList_.size() > 0 && !(focusList_.back()->hasFocus()))
77      focusList_.back()->setFocus(this->cam_);
78  }
79/*
80  void CameraHandler::changeActiveCamera(Camera* setCam)
81  {
82    cam_->getParentSceneNode()->detachObject(cam_);
83    //setCam->attachCamera(cam_);
84    activeCamera_ = setCam;
85  }
86*/
87/*  bool isInVector(Camera* cam)
88  {
89    for(std::vector<Camera*>::iterator it = cams_.begin(); it != cams_.end(); it++)
90    {
91      if (*it == cam) return true;
92    }
93    return false;
94  }*/
95}
Note: See TracBrowser for help on using the repository browser.