1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * |
---|
4 | * |
---|
5 | * License notice: |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License |
---|
9 | * as published by the Free Software Foundation; either version 2 |
---|
10 | * of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | * |
---|
21 | * Author: |
---|
22 | * ... |
---|
23 | * Co-authors: |
---|
24 | * ... |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | #include "OrxonoxStableHeaders.h" |
---|
29 | |
---|
30 | #include <OgreSceneManager.h> |
---|
31 | #include <OgreSceneNode.h> |
---|
32 | #include <OgreRoot.h> |
---|
33 | #include <OgreRenderWindow.h> |
---|
34 | |
---|
35 | #include <string> |
---|
36 | |
---|
37 | #include "../Orxonox.h" |
---|
38 | #include "../GraphicsEngine.h" |
---|
39 | #include "util/tinyxml/tinyxml.h" |
---|
40 | #include "util/Tokenizer.h" |
---|
41 | #include "util/String2Number.h" |
---|
42 | #include "core/CoreIncludes.h" |
---|
43 | #include "SpaceshipSteeringObject.h" |
---|
44 | |
---|
45 | #include "../SpaceshipSteering.h" |
---|
46 | |
---|
47 | namespace orxonox |
---|
48 | { |
---|
49 | CreateFactory(SpaceshipSteeringObject); |
---|
50 | |
---|
51 | SpaceshipSteeringObject::SpaceshipSteeringObject() |
---|
52 | { |
---|
53 | RegisterObject(SpaceshipSteeringObject); |
---|
54 | } |
---|
55 | |
---|
56 | SpaceshipSteeringObject::~SpaceshipSteeringObject() |
---|
57 | { |
---|
58 | } |
---|
59 | |
---|
60 | void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem) |
---|
61 | { |
---|
62 | SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer(); |
---|
63 | |
---|
64 | if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) |
---|
65 | { |
---|
66 | std::string nodeStr = xmlElem->Attribute("node"); |
---|
67 | std::string forwardStr = xmlElem->Attribute("forward"); |
---|
68 | std::string rotateupdownStr = xmlElem->Attribute("rotateupdown"); |
---|
69 | std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft"); |
---|
70 | std::string looprightleftStr = xmlElem->Attribute("looprightleft"); |
---|
71 | |
---|
72 | float forward, rotateupdown, rotaterightleft, looprightleft; |
---|
73 | String2Number<float>(forward, forwardStr); |
---|
74 | String2Number<float>(rotateupdown, rotateupdownStr); |
---|
75 | String2Number<float>(rotaterightleft, rotaterightleftStr); |
---|
76 | String2Number<float>(looprightleft, looprightleftStr); |
---|
77 | |
---|
78 | steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft); |
---|
79 | |
---|
80 | Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); |
---|
81 | Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr); |
---|
82 | |
---|
83 | steering->addNode(sceneNode); |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl; |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|