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