Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/Camera.cc @ 1039

Last change on this file since 1039 was 1039, checked in by rgrieder, 16 years ago
  • train riding doesn't have to be boring
  • added some license notes
  • removed certain header dependencies in audio
  • changed order of header file inclusion in orxonox and audio (coding style guide will be updated)
File size: 3.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "OrxonoxStableHeaders.h"
29#include "Camera.h"
30
31#include <string>
32
33#include <OgreSceneManager.h>
34#include <OgreSceneNode.h>
35#include <OgreRenderWindow.h>
36#include <OgreViewport.h>
37
38#include "util/tinyxml/tinyxml.h"
39#include "util/Tokenizer.h"
40#include "util/String2Number.h"
41#include "util/Math.h"
42#include "core/Debug.h"
43#include "core/CoreIncludes.h"
44#include "GraphicsEngine.h"
45
46namespace orxonox
47{
48    CreateFactory(Camera);
49
50    Camera::Camera()
51    {
52        RegisterObject(Camera);
53    }
54
55    Camera::~Camera()
56    {
57    }
58
59    void Camera::loadParams(TiXmlElement* xmlElem)
60    {
61      Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
62
63      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
64      {
65        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
66
67        std::string name = xmlElem->Attribute("name");
68        std::string pos = xmlElem->Attribute("pos");
69        std::string lookat = xmlElem->Attribute("lookat");
70
71        Ogre::Camera *cam = mgr->createCamera(name);
72
73        float x, y, z;
74        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
75        String2Number<float>(x, posVec[0]);
76        String2Number<float>(y, posVec[1]);
77        String2Number<float>(z, posVec[2]);
78
79        cam->setPosition(Vector3(x,y,z));
80
81        posVec = tokenize(xmlElem->Attribute("lookat"),",");
82        String2Number<float>(x, posVec[0]);
83        String2Number<float>(y, posVec[1]);
84        String2Number<float>(z, posVec[2]);
85
86        cam->lookAt(Vector3(x,y,z));
87
88        std::string node = xmlElem->Attribute("node");
89
90        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
91        sceneNode->attachObject((Ogre::MovableObject*)cam);
92
93        // FIXME: unused var
94        Ogre::Viewport* vp = GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
95
96
97        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
98      }
99   }
100}
Note: See TracBrowser for help on using the repository browser.