Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 990 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
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 <OgreRenderWindow.h>
[708]9#include <OgreViewport.h>
[515]10
[742]11#include "util/tinyxml/tinyxml.h"
12#include "util/Tokenizer.h"
13#include "util/String2Number.h"
14#include "util/Math.h"
[708]15#include "../core/Debug.h"
16#include "../core/CoreIncludes.h"
[614]17#include "../Orxonox.h"
18#include "../GraphicsEngine.h"
[515]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    {
[618]37      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
[560]38
[618]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" />
[560]42
[715]43        std::string name = xmlElem->Attribute("name");
44        std::string pos = xmlElem->Attribute("pos");
45        std::string lookat = xmlElem->Attribute("lookat");
[515]46
[618]47        Ogre::Camera *cam = mgr->createCamera(name);
[515]48
[618]49        float x, y, z;
[715]50        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
[708]51        String2Number<float>(x, posVec[0]);
[618]52        String2Number<float>(y, posVec[1]);
53        String2Number<float>(z, posVec[2]);
[515]54
[618]55        cam->setPosition(Vector3(x,y,z));
[515]56
[618]57        posVec = tokenize(xmlElem->Attribute("lookat"),",");
58        String2Number<float>(x, posVec[0]);
59        String2Number<float>(y, posVec[1]);
60        String2Number<float>(z, posVec[2]);
[515]61
[618]62        cam->lookAt(Vector3(x,y,z));
[515]63
[715]64        std::string node = xmlElem->Attribute("node");
[560]65
[618]66        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
67        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]68
[660]69        // FIXME: unused var
[929]70        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRenderWindow()->addViewport(cam);
[515]71
[560]72
[618]73        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
74      }
[515]75   }
76}
Note: See TracBrowser for help on using the repository browser.