Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 920 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 2.2 KB
RevLine 
[784]1
[786]2#include "OrxonoxStableHeaders.h"
[784]3
[715]4#include <string>
5
[515]6#include <OgreSceneManager.h>
7#include <OgreSceneNode.h>
8#include <OgreRoot.h>
9#include <OgreRenderWindow.h>
[708]10#include <OgreViewport.h>
[515]11
[742]12#include "util/tinyxml/tinyxml.h"
13#include "util/Tokenizer.h"
14#include "util/String2Number.h"
15#include "util/Math.h"
[708]16#include "../core/Debug.h"
17#include "../core/CoreIncludes.h"
[614]18#include "../Orxonox.h"
19#include "../GraphicsEngine.h"
[515]20
21#include "Camera.h"
22
23namespace orxonox
24{
25    CreateFactory(Camera);
26
27    Camera::Camera()
28    {
29        RegisterObject(Camera);
30    }
31
32    Camera::~Camera()
33    {
34    }
35
36    void Camera::loadParams(TiXmlElement* xmlElem)
37    {
[618]38      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
[560]39
[618]40      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
41      {
42        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
[560]43
[715]44        std::string name = xmlElem->Attribute("name");
45        std::string pos = xmlElem->Attribute("pos");
46        std::string lookat = xmlElem->Attribute("lookat");
[515]47
[618]48        Ogre::Camera *cam = mgr->createCamera(name);
[515]49
[618]50        float x, y, z;
[715]51        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
[708]52        String2Number<float>(x, posVec[0]);
[618]53        String2Number<float>(y, posVec[1]);
54        String2Number<float>(z, posVec[2]);
[515]55
[618]56        cam->setPosition(Vector3(x,y,z));
[515]57
[618]58        posVec = tokenize(xmlElem->Attribute("lookat"),",");
59        String2Number<float>(x, posVec[0]);
60        String2Number<float>(y, posVec[1]);
61        String2Number<float>(z, posVec[2]);
[515]62
[618]63        cam->lookAt(Vector3(x,y,z));
[515]64
[715]65        std::string node = xmlElem->Attribute("node");
[560]66
[618]67        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
68        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]69
[660]70        // FIXME: unused var
[618]71        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
[515]72
[560]73
[618]74        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
75      }
[515]76   }
77}
Note: See TracBrowser for help on using the repository browser.