Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 638 was 618, checked in by nicolasc, 17 years ago
  • changed comments to doxygen tags in flocking
  • reduced ogre depency in HUD and ParticleInterface
  • various
File size: 2.1 KB
RevLine 
[515]1#include <OgreSceneManager.h>
2#include <OgreSceneNode.h>
3#include <OgreRoot.h>
4#include <OgreRenderWindow.h>
5
6#include <string>
7
[614]8#include "../Orxonox.h"
9#include "../GraphicsEngine.h"
[515]10#include "../../tinyxml/tinyxml.h"
11#include "../../misc/Tokenizer.h"
12#include "../../misc/String2Number.h"
[560]13#include "../core/Debug.h"
[515]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    {
[618]32      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
[560]33
[618]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" />
[560]37
[618]38        std::string name = xmlElem->Attribute("name");
39        std::string pos = xmlElem->Attribute("pos");
40        std::string lookat = xmlElem->Attribute("lookat");
[515]41
[618]42        Ogre::Camera *cam = mgr->createCamera(name);
[515]43
[618]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]);
[515]49
[618]50        cam->setPosition(Vector3(x,y,z));
[515]51
[618]52        posVec = tokenize(xmlElem->Attribute("lookat"),",");
53        String2Number<float>(x, posVec[0]);
54        String2Number<float>(y, posVec[1]);
55        String2Number<float>(z, posVec[2]);
[515]56
[618]57        cam->lookAt(Vector3(x,y,z));
[515]58
[618]59        std::string node = xmlElem->Attribute("node");
[560]60
[618]61        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
62        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]63
64
[618]65        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
[515]66
[560]67
[618]68        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
69      }
[515]70   }
71}
Note: See TracBrowser for help on using the repository browser.