Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 737 was 732, checked in by nicolasc, 17 years ago
  • added copyrightnotice to spaceshipsteeringobject
  • added OPTION to build networktools
  • minor cleanups
File size: 3.1 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 <OgreSceneManager.h>
29#include <OgreSceneNode.h>
30#include <OgreRoot.h>
31#include <OgreRenderWindow.h>
32
33#include <string>
34
35#include "../Orxonox.h"
36#include "../GraphicsEngine.h"
37#include "../../tinyxml/tinyxml.h"
38#include "../../misc/Tokenizer.h"
39#include "../../misc/String2Number.h"
40#include "../core/Debug.h"
41
42#include "SpaceshipSteeringObject.h"
43
44#include "../SpaceshipSteering.h"
45
46namespace orxonox
47{
48    CreateFactory(SpaceshipSteeringObject);
49
50    SpaceshipSteeringObject::SpaceshipSteeringObject()
51    {
52        RegisterObject(SpaceshipSteeringObject);
53    }
54
55    SpaceshipSteeringObject::~SpaceshipSteeringObject()
56    {
57    }
58
59    void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem)
60    {
61      SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer();
62
63      if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
64      {
65        std::string nodeStr = xmlElem->Attribute("node");
66        std::string forwardStr = xmlElem->Attribute("forward");
67        std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
68        std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
69        std::string looprightleftStr = xmlElem->Attribute("looprightleft");
70
71        float forward, rotateupdown, rotaterightleft, looprightleft;
72        String2Number<float>(forward, forwardStr);
73        String2Number<float>(rotateupdown, rotateupdownStr);
74        String2Number<float>(rotaterightleft, rotaterightleftStr);
75        String2Number<float>(looprightleft, looprightleftStr);
76
77        steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft);
78
79        Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
80        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr);
81
82        steering->addNode(sceneNode);
83
84
85
86
87        COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl;
88      }
89   }
90}
Note: See TracBrowser for help on using the repository browser.