Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/Camera.cc @ 618

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