| 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 |  | 
|---|
| 21 |  | 
|---|
| 22 |  | 
|---|
| 23 | ObjectListDefinition(Rotor); | 
|---|
| 24 | CREATE_FACTORY(Rotor); | 
|---|
| 25 |  | 
|---|
| 26 | /** | 
|---|
| 27 | *  initializes a rotating element from a XmlElement | 
|---|
| 28 | */ | 
|---|
| 29 | Rotor::Rotor(const TiXmlElement* root) | 
|---|
| 30 | { | 
|---|
| 31 | this->registerObject(this, Rotor::_objectList); | 
|---|
| 32 | this->toList(OM_ENVIRON); | 
|---|
| 33 |  | 
|---|
| 34 | //PRINTF(0)("loading Rotor"); | 
|---|
| 35 |  | 
|---|
| 36 | this->totalTime = 0.0; | 
|---|
| 37 |  | 
|---|
| 38 | if (root != NULL) | 
|---|
| 39 | this->loadParams(root); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | /** | 
|---|
| 43 | * loads the Settings of a Rotor from an XML-element. | 
|---|
| 44 | * @param root the XML-element to load the Rotor's properties from | 
|---|
| 45 | */ | 
|---|
| 46 | void Rotor::loadParams(const TiXmlElement* root) | 
|---|
| 47 | { | 
|---|
| 48 | WorldEntity::loadParams(root); | 
|---|
| 49 |  | 
|---|
| 50 | LoadParam(root, "rotation", this, Rotor, initRotation); | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /** | 
|---|
| 54 | * sets the rotation axis | 
|---|
| 55 | */ | 
|---|
| 56 | void Rotor::initRotation(float x, float y, float z) | 
|---|
| 57 | { | 
|---|
| 58 | this->mainDir = this->getAbsDir(); | 
|---|
| 59 | this->rotation = Vector(x,y,z); | 
|---|
| 60 | /*     this->rotation = this->rotation.getNormalized();*/ | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | /** | 
|---|
| 64 | * tick function | 
|---|
| 65 | */ | 
|---|
| 66 | void Rotor::tick(float dt) | 
|---|
| 67 | { | 
|---|
| 68 |  | 
|---|
| 69 | this->totalTime += dt; | 
|---|
| 70 |  | 
|---|
| 71 |  | 
|---|
| 72 |  | 
|---|
| 73 | this->setAbsDir(/*this->mainDir**/Quaternion(rotation.x*this->totalTime, Vector(1,0,0)) * | 
|---|
| 74 | Quaternion(rotation.y*this->totalTime, Vector(0,1,0)) * | 
|---|
| 75 | Quaternion(rotation.z*this->totalTime, Vector(0,0,1))); | 
|---|
| 76 |  | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | /** | 
|---|
| 81 | *  default destructor | 
|---|
| 82 | */ | 
|---|
| 83 | Rotor::~Rotor() | 
|---|
| 84 | { | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 |  | 
|---|