Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/environments/rotor.cc

Last change on this file was 10643, checked in by bknecht, 17 years ago

improvements by landauf on bsp, rotor and wireframe (does build, should work)

File size: 1.8 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
21
22
23ObjectListDefinition(Rotor);
24CREATE_FACTORY(Rotor);
25
26/**
27 *  initializes a rotating element from a XmlElement
28*/
29Rotor::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 */
46void 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 */
56void Rotor::initRotation(float x, float y, float z)
57{
58     this->updateNode(0.001);
59     this->mainDir = this->getAbsDir();
60     this->rotation = Vector(x,y,z);
61/*     this->rotation = this->rotation.getNormalized();*/
62}
63
64/**
65 * tick function
66 */
67void Rotor::tick(float dt)
68{
69
70  this->totalTime += dt;
71
72
73
74     this->setAbsDir(this->mainDir*Quaternion(rotation.x*this->totalTime, Vector(1,0,0)) *
75                    Quaternion(rotation.y*this->totalTime, Vector(0,1,0)) *
76                    Quaternion(rotation.z*this->totalTime, Vector(0,0,1)));
77
78}
79
80
81/**
82 *  default destructor
83*/
84Rotor::~Rotor()
85{
86}
87
88
Note: See TracBrowser for help on using the repository browser.