Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/SpaceshipSteeringObject.cc @ 920

Last change on this file since 920 was 871, checked in by landauf, 17 years ago

merged core branch to trunk

File size: 3.2 KB
RevLine 
[732]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
[786]28#include "OrxonoxStableHeaders.h"
[784]29
[515]30#include <OgreSceneManager.h>
31#include <OgreSceneNode.h>
32#include <OgreRoot.h>
33#include <OgreRenderWindow.h>
34
35#include <string>
36
[614]37#include "../Orxonox.h"
38#include "../GraphicsEngine.h"
[742]39#include "util/tinyxml/tinyxml.h"
40#include "util/Tokenizer.h"
41#include "util/String2Number.h"
[871]42#include "core/CoreIncludes.h"
[515]43#include "SpaceshipSteeringObject.h"
44
[612]45#include "../SpaceshipSteering.h"
[515]46
47namespace 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    {
[663]62      SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer();
[560]63
[663]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");
[515]71
[663]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);
[560]77
[663]78        steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft);
[560]79
[663]80        Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
81        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr);
[560]82
[663]83        steering->addNode(sceneNode);
[560]84
85
86
87
[663]88        COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl;
89      }
[515]90   }
91}
Note: See TracBrowser for help on using the repository browser.