Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/SpaceshipSteeringObject.cc @ 786

Last change on this file since 786 was 786, checked in by rgrieder, 17 years ago
  • renamed StableHeaders.h to OrxonoxStableHeaders.h
File size: 3.2 KB
Line 
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/Debug.h"
43
44#include "SpaceshipSteeringObject.h"
45
46#include "../SpaceshipSteering.h"
47
48namespace orxonox
49{
50    CreateFactory(SpaceshipSteeringObject);
51
52    SpaceshipSteeringObject::SpaceshipSteeringObject()
53    {
54        RegisterObject(SpaceshipSteeringObject);
55    }
56
57    SpaceshipSteeringObject::~SpaceshipSteeringObject()
58    {
59    }
60
61    void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem)
62    {
63      SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer();
64
65      if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
66      {
67        std::string nodeStr = xmlElem->Attribute("node");
68        std::string forwardStr = xmlElem->Attribute("forward");
69        std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
70        std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
71        std::string looprightleftStr = xmlElem->Attribute("looprightleft");
72
73        float forward, rotateupdown, rotaterightleft, looprightleft;
74        String2Number<float>(forward, forwardStr);
75        String2Number<float>(rotateupdown, rotateupdownStr);
76        String2Number<float>(rotaterightleft, rotaterightleftStr);
77        String2Number<float>(looprightleft, looprightleftStr);
78
79        steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft);
80
81        Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
82        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr);
83
84        steering->addNode(sceneNode);
85
86
87
88
89        COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl;
90      }
91   }
92}
Note: See TracBrowser for help on using the repository browser.