Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN_test/src/orxonox/objects/Camera.cc @ 756

Last change on this file since 756 was 742, checked in by landauf, 17 years ago

moved all files from misc and the tinyxml folder into the new util folder

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