Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/orxonox_tutorial/src/orxonox/objects/CameraHandler.cc @ 1833

Last change on this file since 1833 was 1755, checked in by rgrieder, 16 years ago

merged gui back to trunk.
update the media repository!

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