Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 708 was 708, checked in by rgrieder, 18 years ago
  • added Vector2, Vector3, Matrix3, ColourValue, Quaternion and String to the misc folder as header files (each of them contains #include <string> … typedef std::string String , etc.)
  • please use String from now on by including <misc/String.h"
  • removed #include <OgreVector3.h", etc. from "CoreIncludes.h" (adjusted all source files)
  • adjusted all the source files (except network, that keeps <string> for the moment) (what a mess..)
  • moved usleep hack to misc/Sleep.h
  • relative include paths for files from other root directories (like misc, network, etc.) (but it stills writes "../Orxonox.h" when in folder orxonox/objects)
  • "OgreSceneManager.h" —> <OgreSceneManager.h>
  • included OrxonoxPrereqs in every file in folder orxonox
  • moved HUD and ParticleInterface to namespace orxonox
  • removed some using namespace Ogre/std when appropriate
  • I hope I haven't forgotten important points..
File size: 2.1 KB
RevLine 
[515]1#include <OgreSceneManager.h>
2#include <OgreSceneNode.h>
3#include <OgreRoot.h>
4#include <OgreRenderWindow.h>
[708]5#include <OgreViewport.h>
[515]6
[708]7#include "tinyxml/tinyxml.h"
8#include "misc/Tokenizer.h"
9#include "misc/String2Number.h"
10#include "misc/Vector3.h"
11#include "misc/String.h"
12#include "../core/Debug.h"
13#include "../core/CoreIncludes.h"
[614]14#include "../Orxonox.h"
15#include "../GraphicsEngine.h"
[515]16
17#include "Camera.h"
18
19namespace orxonox
20{
21    CreateFactory(Camera);
22
23    Camera::Camera()
24    {
25        RegisterObject(Camera);
26    }
27
28    Camera::~Camera()
29    {
30    }
31
32    void Camera::loadParams(TiXmlElement* xmlElem)
33    {
[618]34      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
[560]35
[618]36      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
37      {
38        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
[560]39
[708]40        String name = xmlElem->Attribute("name");
41        String pos = xmlElem->Attribute("pos");
42        String lookat = xmlElem->Attribute("lookat");
[515]43
[618]44        Ogre::Camera *cam = mgr->createCamera(name);
[515]45
[618]46        float x, y, z;
[708]47        std::vector<String> posVec = tokenize(xmlElem->Attribute("pos"),",");
48        String2Number<float>(x, posVec[0]);
[618]49        String2Number<float>(y, posVec[1]);
50        String2Number<float>(z, posVec[2]);
[515]51
[618]52        cam->setPosition(Vector3(x,y,z));
[515]53
[618]54        posVec = tokenize(xmlElem->Attribute("lookat"),",");
55        String2Number<float>(x, posVec[0]);
56        String2Number<float>(y, posVec[1]);
57        String2Number<float>(z, posVec[2]);
[515]58
[618]59        cam->lookAt(Vector3(x,y,z));
[515]60
[708]61        String node = xmlElem->Attribute("node");
[560]62
[618]63        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
64        sceneNode->attachObject((Ogre::MovableObject*)cam);
[560]65
[660]66        // FIXME: unused var
[618]67        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
[515]68
[560]69
[618]70        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
71      }
[515]72   }
73}
Note: See TracBrowser for help on using the repository browser.