Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged FICN back into trunk
awaiting release.

File size: 2.2 KB
Line 
1
2#include "OrxonoxStableHeaders.h"
3
4#include <string>
5
6#include <OgreSceneManager.h>
7#include <OgreSceneNode.h>
8#include <OgreRoot.h>
9#include <OgreRenderWindow.h>
10#include <OgreViewport.h>
11
12#include "util/tinyxml/tinyxml.h"
13#include "util/Tokenizer.h"
14#include "util/String2Number.h"
15#include "util/Math.h"
16#include "../core/Debug.h"
17#include "../core/CoreIncludes.h"
18#include "../Orxonox.h"
19#include "../GraphicsEngine.h"
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    {
38      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
39
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" />
43
44        std::string name = xmlElem->Attribute("name");
45        std::string pos = xmlElem->Attribute("pos");
46        std::string lookat = xmlElem->Attribute("lookat");
47
48        Ogre::Camera *cam = mgr->createCamera(name);
49
50        float x, y, z;
51        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
52        String2Number<float>(x, posVec[0]);
53        String2Number<float>(y, posVec[1]);
54        String2Number<float>(z, posVec[2]);
55
56        cam->setPosition(Vector3(x,y,z));
57
58        posVec = tokenize(xmlElem->Attribute("lookat"),",");
59        String2Number<float>(x, posVec[0]);
60        String2Number<float>(y, posVec[1]);
61        String2Number<float>(z, posVec[2]);
62
63        cam->lookAt(Vector3(x,y,z));
64
65        std::string node = xmlElem->Attribute("node");
66
67        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
68        sceneNode->attachObject((Ogre::MovableObject*)cam);
69
70        // FIXME: unused var
71        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
72
73
74        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
75      }
76   }
77}
Note: See TracBrowser for help on using the repository browser.