| 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_GROUP_00); | 
|---|
| 33 |  | 
|---|
| 34 | //PRINTF(0)("loading Rotor"); | 
|---|
| 35 |  | 
|---|
| 36 | if (root != NULL) | 
|---|
| 37 | this->loadParams(root); | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | /** | 
|---|
| 41 | * loads the Settings of a Rotor from an XML-element. | 
|---|
| 42 | * @param root the XML-element to load the Rotor's properties from | 
|---|
| 43 | */ | 
|---|
| 44 | void Rotor::loadParams(const TiXmlElement* root) | 
|---|
| 45 | { | 
|---|
| 46 | WorldEntity::loadParams(root); | 
|---|
| 47 |  | 
|---|
| 48 | LoadParam(root, "rotation", this, Rotor, initRotation); | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | /** | 
|---|
| 52 | * sets the rotation axis | 
|---|
| 53 | */ | 
|---|
| 54 | void Rotor::initRotation(float x, float y, float z) | 
|---|
| 55 | { | 
|---|
| 56 | this->rotation = Vector(x,y,z); | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | /** | 
|---|
| 60 | * tick function | 
|---|
| 61 | */ | 
|---|
| 62 | void Rotor::tick(float dt) | 
|---|
| 63 | { | 
|---|
| 64 | this->shiftDir(Quaternion(rotation.x*dt, Vector(1,0,0)) * Quaternion(rotation.y*dt, Vector(0,1,0)) * Quaternion(rotation.z*dt, Vector(0,0,1))); | 
|---|
| 65 |  | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 |  | 
|---|
| 69 | /** | 
|---|
| 70 | *  default destructor | 
|---|
| 71 | */ | 
|---|
| 72 | Rotor::~Rotor() | 
|---|
| 73 | { | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|