Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/orxonox/objects/Camera.cc @ 940

Last change on this file since 940 was 929, checked in by rgrieder, 17 years ago
  • removed getRoot() from GaphicsEngine —> added getRenderWindow() —> added 3 function to control render loop
  • rearranged the sequence of methods in Orxonox.cc to make it a little bit more logical
  • added deletion code in Orxonox.cc destructor
  • fixed a bug in AudioManger destructor
  • fixed a bug in InputHandler destroy()
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 <OgreRenderWindow.h>
9#include <OgreViewport.h>
10
11#include "util/tinyxml/tinyxml.h"
12#include "util/Tokenizer.h"
13#include "util/String2Number.h"
14#include "util/Math.h"
15#include "../core/Debug.h"
16#include "../core/CoreIncludes.h"
17#include "../Orxonox.h"
18#include "../GraphicsEngine.h"
19
20#include "Camera.h"
21
22namespace orxonox
23{
24    CreateFactory(Camera);
25
26    Camera::Camera()
27    {
28        RegisterObject(Camera);
29    }
30
31    Camera::~Camera()
32    {
33    }
34
35    void Camera::loadParams(TiXmlElement* xmlElem)
36    {
37      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
38
39      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
40      {
41        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
42
43        std::string name = xmlElem->Attribute("name");
44        std::string pos = xmlElem->Attribute("pos");
45        std::string lookat = xmlElem->Attribute("lookat");
46
47        Ogre::Camera *cam = mgr->createCamera(name);
48
49        float x, y, z;
50        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
51        String2Number<float>(x, posVec[0]);
52        String2Number<float>(y, posVec[1]);
53        String2Number<float>(z, posVec[2]);
54
55        cam->setPosition(Vector3(x,y,z));
56
57        posVec = tokenize(xmlElem->Attribute("lookat"),",");
58        String2Number<float>(x, posVec[0]);
59        String2Number<float>(y, posVec[1]);
60        String2Number<float>(z, posVec[2]);
61
62        cam->lookAt(Vector3(x,y,z));
63
64        std::string node = xmlElem->Attribute("node");
65
66        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
67        sceneNode->attachObject((Ogre::MovableObject*)cam);
68
69        // FIXME: unused var
70        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRenderWindow()->addViewport(cam);
71
72
73        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
74      }
75   }
76}
Note: See TracBrowser for help on using the repository browser.