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, 16 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
Line 
1#include <OgreSceneManager.h>
2#include <OgreSceneNode.h>
3#include <OgreRoot.h>
4#include <OgreRenderWindow.h>
5#include <OgreViewport.h>
6
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"
14#include "../Orxonox.h"
15#include "../GraphicsEngine.h"
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    {
34      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
35
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" />
39
40        String name = xmlElem->Attribute("name");
41        String pos = xmlElem->Attribute("pos");
42        String lookat = xmlElem->Attribute("lookat");
43
44        Ogre::Camera *cam = mgr->createCamera(name);
45
46        float x, y, z;
47        std::vector<String> posVec = tokenize(xmlElem->Attribute("pos"),",");
48        String2Number<float>(x, posVec[0]);
49        String2Number<float>(y, posVec[1]);
50        String2Number<float>(z, posVec[2]);
51
52        cam->setPosition(Vector3(x,y,z));
53
54        posVec = tokenize(xmlElem->Attribute("lookat"),",");
55        String2Number<float>(x, posVec[0]);
56        String2Number<float>(y, posVec[1]);
57        String2Number<float>(z, posVec[2]);
58
59        cam->lookAt(Vector3(x,y,z));
60
61        String node = xmlElem->Attribute("node");
62
63        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
64        sceneNode->attachObject((Ogre::MovableObject*)cam);
65
66        // FIXME: unused var
67        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
68
69
70        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
71      }
72   }
73}
Note: See TracBrowser for help on using the repository browser.