Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/environments/rotor.cc @ 10761

Last change on this file since 10761 was 10720, checked in by stefalie, 18 years ago


File size: 2.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Knecht
13   co-programmer: ...
14*/
15
16#include "rotor.h"
17
18#include "util/loading/load_param.h"
19#include "util/loading/factory.h"
20
21ObjectListDefinition(Rotor);
22CREATE_FACTORY(Rotor);
23
24#include "script_class.h"
25CREATE_SCRIPTABLE_CLASS(Rotor,
26                        addMethod("pause", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::pauseTrack))
27                       );
28
29
30/**
31 *  initializes a rotating element from a XmlElement
32*/
33Rotor::Rotor(const TiXmlElement* root)
34{
35  this->registerObject(this, Rotor::_objectList);
36  this->toList(OM_ENVIRON);
37
38  //PRINTF(0)("loading Rotor");
39
40  this->totalTime = 0.0;
41
42  if (root != NULL)
43    this->loadParams(root);
44}
45
46/**
47 * loads the Settings of a Rotor from an XML-element.
48 * @param root the XML-element to load the Rotor's properties from
49 */
50void Rotor::loadParams(const TiXmlElement* root)
51{
52  WorldEntity::loadParams(root);
53
54  LoadParam(root, "rotation", this, Rotor, initRotation);
55}
56
57/**
58 * sets the rotation axis
59 */
60void Rotor::initRotation(float x, float y, float z)
61{
62     this->updateNode(0.001);
63     this->mainDir = this->getAbsDir();
64     this->rotation = Vector(x,y,z);
65/*     this->rotation = this->rotation.getNormalized();*/
66}
67
68/**
69 * tick function
70 */
71void Rotor::tick(float dt)
72{
73
74  this->totalTime += dt;
75
76
77
78     this->setAbsDir(this->mainDir*Quaternion(rotation.x*this->totalTime, Vector(1,0,0)) *
79                    Quaternion(rotation.y*this->totalTime, Vector(0,1,0)) *
80                    Quaternion(rotation.z*this->totalTime, Vector(0,0,1)));
81
82}
83
84
85/**
86 *  default destructor
87*/
88Rotor::~Rotor()
89{
90}
91
92
Note: See TracBrowser for help on using the repository browser.