[515] | 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 | |
---|
| 14 | #include "SpaceshipSteeringObject.h" |
---|
| 15 | |
---|
| 16 | #include "../spaceship_steering.h" |
---|
| 17 | |
---|
| 18 | namespace orxonox |
---|
| 19 | { |
---|
| 20 | CreateFactory(SpaceshipSteeringObject); |
---|
| 21 | |
---|
| 22 | SpaceshipSteeringObject::SpaceshipSteeringObject() |
---|
| 23 | { |
---|
| 24 | RegisterObject(SpaceshipSteeringObject); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | SpaceshipSteeringObject::~SpaceshipSteeringObject() |
---|
| 28 | { |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem) |
---|
| 32 | { |
---|
| 33 | SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer(); |
---|
| 34 | |
---|
| 35 | if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) |
---|
| 36 | { |
---|
| 37 | std::string nodeStr = xmlElem->Attribute("node"); |
---|
| 38 | std::string forwardStr = xmlElem->Attribute("forward"); |
---|
| 39 | std::string rotateupdownStr = xmlElem->Attribute("rotateupdown"); |
---|
| 40 | std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft"); |
---|
| 41 | std::string looprightleftStr = xmlElem->Attribute("looprightleft"); |
---|
| 42 | |
---|
| 43 | float forward, rotateupdown, rotaterightleft, looprightleft; |
---|
| 44 | String2Number<float>(forward, forwardStr); |
---|
| 45 | String2Number<float>(rotateupdown, rotateupdownStr); |
---|
| 46 | String2Number<float>(rotaterightleft, rotaterightleftStr); |
---|
| 47 | String2Number<float>(looprightleft, looprightleftStr); |
---|
| 48 | |
---|
| 49 | steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft); |
---|
| 50 | |
---|
| 51 | Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); |
---|
| 52 | Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr); |
---|
| 53 | |
---|
| 54 | steering->addNode(sceneNode); |
---|
| 55 | |
---|
| 56 | std::cout << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl; |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | } |
---|