Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1287 was 1209, checked in by rgrieder, 17 years ago
  • moved tinyxml and tolua folders
File size: 3.1 KB
RevLine 
[1039]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1056]3 *                    > www.orxonox.net <
[1039]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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
[784]28
[786]29#include "OrxonoxStableHeaders.h"
[1039]30#include "Camera.h"
[784]31
[715]32#include <string>
33
[515]34#include <OgreSceneManager.h>
35#include <OgreSceneNode.h>
36#include <OgreRenderWindow.h>
[708]37#include <OgreViewport.h>
[515]38
[1209]39#include "tinyxml/tinyxml.h"
[1067]40#include "util/SubString.h"
[1064]41#include "util/Convert.h"
[742]42#include "util/Math.h"
[1032]43#include "core/Debug.h"
44#include "core/CoreIncludes.h"
45#include "GraphicsEngine.h"
[515]46
47namespace orxonox
48{
49    CreateFactory(Camera);
50
51    Camera::Camera()
52    {
53        RegisterObject(Camera);
54    }
55
56    Camera::~Camera()
57    {
58    }
59
60    void Camera::loadParams(TiXmlElement* xmlElem)
61    {
[1032]62      Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
[560]63
[618]64      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
65      {
66        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
[560]67
[715]68        std::string name = xmlElem->Attribute("name");
69        std::string pos = xmlElem->Attribute("pos");
70        std::string lookat = xmlElem->Attribute("lookat");
[515]71
[618]72        Ogre::Camera *cam = mgr->createCamera(name);
[515]73
[618]74        float x, y, z;
[1064]75        SubString posVec(xmlElem->Attribute("pos"), ',');
76        convertValue<std::string, float>(&x, posVec[0]);
77        convertValue<std::string, float>(&y, posVec[1]);
78        convertValue<std::string, float>(&z, posVec[2]);
[515]79
[618]80        cam->setPosition(Vector3(x,y,z));
[515]81
[1064]82        posVec = SubString(xmlElem->Attribute("lookat"), ',');
83        convertValue<std::string, float>(&x, posVec[0]);
84        convertValue<std::string, float>(&y, posVec[1]);
85        convertValue<std::string, float>(&z, posVec[2]);
[515]86
[618]87        cam->lookAt(Vector3(x,y,z));
[515]88
[715]89        std::string node = xmlElem->Attribute("node");
[560]90
[618]91        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
92        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]93
[660]94        // FIXME: unused var
[1064]95        //Ogre::Viewport* vp =
96        GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
[515]97
[560]98
[618]99        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
100      }
[515]101   }
102}
Note: See TracBrowser for help on using the repository browser.