1 | #include <OgreSceneManager.h> |
---|
2 | #include <OgreSceneNode.h> |
---|
3 | #include <OgreRoot.h> |
---|
4 | #include <OgreRenderWindow.h> |
---|
5 | |
---|
6 | #include <string> |
---|
7 | |
---|
8 | #include "../orxonox.h" |
---|
9 | #include "../graphicsEngine.h" |
---|
10 | #include "../../tinyxml/tinyxml.h" |
---|
11 | #include "../../misc/Tokenizer.h" |
---|
12 | #include "../../misc/String2Number.h" |
---|
13 | #include "../core/Debug.h" |
---|
14 | |
---|
15 | #include "SpaceshipSteeringObject.h" |
---|
16 | |
---|
17 | #include "../spaceship_steering.h" |
---|
18 | |
---|
19 | namespace orxonox |
---|
20 | { |
---|
21 | CreateFactory(SpaceshipSteeringObject); |
---|
22 | |
---|
23 | SpaceshipSteeringObject::SpaceshipSteeringObject() |
---|
24 | { |
---|
25 | RegisterObject(SpaceshipSteeringObject); |
---|
26 | } |
---|
27 | |
---|
28 | SpaceshipSteeringObject::~SpaceshipSteeringObject() |
---|
29 | { |
---|
30 | } |
---|
31 | |
---|
32 | void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem) |
---|
33 | { |
---|
34 | SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer(); |
---|
35 | |
---|
36 | if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) |
---|
37 | { |
---|
38 | std::string nodeStr = xmlElem->Attribute("node"); |
---|
39 | std::string forwardStr = xmlElem->Attribute("forward"); |
---|
40 | std::string rotateupdownStr = xmlElem->Attribute("rotateupdown"); |
---|
41 | std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft"); |
---|
42 | std::string looprightleftStr = xmlElem->Attribute("looprightleft"); |
---|
43 | |
---|
44 | float forward, rotateupdown, rotaterightleft, looprightleft; |
---|
45 | String2Number<float>(forward, forwardStr); |
---|
46 | String2Number<float>(rotateupdown, rotateupdownStr); |
---|
47 | String2Number<float>(rotaterightleft, rotaterightleftStr); |
---|
48 | String2Number<float>(looprightleft, looprightleftStr); |
---|
49 | |
---|
50 | steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft); |
---|
51 | |
---|
52 | Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); |
---|
53 | Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr); |
---|
54 | |
---|
55 | steering->addNode(sceneNode); |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl; |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|