Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 717 was 716, checked in by rgrieder, 17 years ago
  • merged all Vector3, etc. (incl. ColourValue) to misc/Math.h
File size: 2.2 KB
RevLine 
[715]1#include <string>
2
[515]3#include <OgreSceneManager.h>
4#include <OgreSceneNode.h>
5#include <OgreRoot.h>
6#include <OgreRenderWindow.h>
[708]7#include <OgreViewport.h>
[515]8
[708]9#include "tinyxml/tinyxml.h"
10#include "misc/Tokenizer.h"
11#include "misc/String2Number.h"
[716]12#include "misc/Math.h"
[708]13#include "../core/Debug.h"
14#include "../core/CoreIncludes.h"
[614]15#include "../Orxonox.h"
16#include "../GraphicsEngine.h"
[515]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    {
[618]35      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
[560]36
[618]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" />
[560]40
[715]41        std::string name = xmlElem->Attribute("name");
42        std::string pos = xmlElem->Attribute("pos");
43        std::string lookat = xmlElem->Attribute("lookat");
[515]44
[618]45        Ogre::Camera *cam = mgr->createCamera(name);
[515]46
[618]47        float x, y, z;
[715]48        std::vector<std::string> posVec = tokenize(xmlElem->Attribute("pos"),",");
[708]49        String2Number<float>(x, posVec[0]);
[618]50        String2Number<float>(y, posVec[1]);
51        String2Number<float>(z, posVec[2]);
[515]52
[618]53        cam->setPosition(Vector3(x,y,z));
[515]54
[618]55        posVec = tokenize(xmlElem->Attribute("lookat"),",");
56        String2Number<float>(x, posVec[0]);
57        String2Number<float>(y, posVec[1]);
58        String2Number<float>(z, posVec[2]);
[515]59
[618]60        cam->lookAt(Vector3(x,y,z));
[515]61
[715]62        std::string node = xmlElem->Attribute("node");
[560]63
[618]64        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
65        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]66
[660]67        // FIXME: unused var
[618]68        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
[515]69
[560]70
[618]71        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
72      }
[515]73   }
74}
Note: See TracBrowser for help on using the repository browser.