Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/space_ships/turbine_hover.cc @ 10235

Last change on this file since 10235 was 10114, checked in by patrick, 17 years ago

merged network back to trunk

File size: 18.5 KB
RevLine 
[6443]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 Grauer
13   co-programmer: ...
14
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
[7000]19#include "turbine_hover.h"
[6443]20
21#include "weapons/weapon_manager.h"
22#include "weapons/test_gun.h"
23#include "weapons/turret.h"
24#include "weapons/cannon.h"
25
[7193]26#include "util/loading/factory.h"
[6443]27#include "key_mapper.h"
28#include "state.h"
29
30#include "graphics_engine.h"
[9869]31#include "particles/dot_emitter.h"
32#include "particles/sprite_particles.h"
[6443]33
[8362]34#include "debug.h"
35
[10114]36
37ObjectListDefinition(TurbineHover);
[9869]38CREATE_FACTORY(TurbineHover);
[6443]39
40/**
[7000]41 *  destructs the turbine_hover, deletes alocated memory
[6443]42 */
[7000]43TurbineHover::~TurbineHover ()
[6986]44{
45  this->setPlayer(NULL);
46}
[6443]47
48/**
[7339]49 * @brief loads a TurbineHover information from a specified file.
[7000]50 * @param fileName the name of the File to load the turbine_hover from (absolute path)
[6443]51 */
[7221]52TurbineHover::TurbineHover(const std::string& fileName)
[6443]53{
54  this->init();
55  TiXmlDocument doc(fileName);
56
57  if(!doc.LoadFile())
58  {
[7221]59    PRINTF(2)("Loading file %s failed for TurbineHover.\n", fileName.c_str());
[6443]60    return;
61  }
62
63  this->loadParams(doc.RootElement());
64}
65
66/**
[7339]67 * @brief creates a new Spaceship from Xml Data
[6443]68 * @param root the xml element containing spaceship data
69
70   @todo add more parameters to load
71*/
[7000]72TurbineHover::TurbineHover(const TiXmlElement* root)
[6443]73{
74  this->init();
75  if (root != NULL)
76    this->loadParams(root);
77
78  //weapons:
79  Weapon* wpRight = new TestGun(0);
80  wpRight->setName("testGun Right");
81  Weapon* wpLeft = new TestGun(1);
82  wpLeft->setName("testGun Left");
[7126]83  //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_HYPERBLASTER));
[6443]84
[7126]85  //  cannon->setName("BFG");
[6443]86
87  this->addWeapon(wpLeft, 1, 0);
88  this->addWeapon(wpRight,1 ,1);
[7126]89  //this->addWeapon(cannon, 0, 2);
[6443]90
[7337]91  this->getWeaponManager().changeWeaponConfig(1);
92  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
[6800]93
94  this->loadModel("models/ships/hoverglider_mainbody.obj");
[9656]95
[6443]96}
97
98
99/**
[7339]100 * @brief initializes a TurbineHover
[6443]101 */
[7000]102void TurbineHover::init()
[6443]103{
[6805]104  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
[9869]105  this->registerObject(this, TurbineHover::_objectList);
[6443]106
[7346]107  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal | Playable::Vertical);
[7339]108
[6807]109  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
[7000]110  this->loadModel("models/ships/hoverglider_turbine.obj", 1.0f, 4);
111  this->loadModel("models/ships/hoverglider_turbine_rotors.obj", 1.0f, 5);
[6443]112
[6805]113  bForward = bBackward = bLeft = bRight = bAscend = bDescend = false;
[6807]114  mouseSensitivity = 0.005;
[6443]115
[6806]116  this->rotorSpeed = 1000.0f;
117  this->rotorCycle = 0.0f;
[6807]118  this->cameraLook = 0.0f;
119  this->rotation = 0.0f;
[7001]120  this->acceleration = 10.0f;
121  this->airFriction = 2.0f;
[6799]122
[7072]123  this->setHealthMax(100);
124  this->setHealth(100);
125
126
[6806]127  // camera - issue
[6800]128  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
[6806]129  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
[6880]130  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
[9494]131  this->cameraNode.setParent(this);
132  this->cameraNode.setRelCoor(0,5,0);
[6799]133
[6724]134  // rotors
[6803]135  this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT );
136  this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
[6801]137  this->wingNodeLeft.setParent(this);
138  this->wingNodeLeft.setRelCoor(-1.5, -.3, -1.0);
[6800]139  this->rotorNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
[6801]140  this->rotorNodeLeft.setParent(&this->wingNodeLeft);
141  this->rotorNodeLeft.setRelCoor(0, 1.0, -2.3);
[6799]142
[6801]143  this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
[6803]144  this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
[6800]145  this->wingNodeRight.setParent(this);
[6801]146  this->wingNodeRight.setRelCoor(-1.5, -0.3, 1.0);
147  this->rotorNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
[6800]148  this->rotorNodeRight.setParent(&this->wingNodeRight);
[6801]149  this->rotorNodeRight.setRelCoor(0, 1.0, 2.3);
[6443]150
[7001]151  // PARTICLES
152  this->burstEmitter[0] = new DotEmitter(200, 5.0, .01);
153  this->burstEmitter[0]->setParent(&this->rotorNodeLeft);
154  this->burstEmitter[0]->setRelCoor(0, -0.7, 0);
155  this->burstEmitter[0]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
156  this->burstEmitter[0]->setName("TurbineHover_Burst_emitter_Left");
[6803]157
[7001]158  this->burstEmitter[1] = new DotEmitter(200, 5.0, .01);
159  this->burstEmitter[1]->setParent(&this->rotorNodeRight);
160  this->burstEmitter[1]->setRelCoor(0, -0.7, 0);
161  this->burstEmitter[1]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
162  this->burstEmitter[1]->setName("TurbineHover_Burst_emitter_Right");
[6800]163
[7001]164
165  this->burstSystem = new SpriteParticles(1000);
166  this->burstSystem->addEmitter(this->burstEmitter[0]);
167  this->burstSystem->addEmitter(this->burstEmitter[1]);
168  this->burstSystem->setName("SpaceShip_Burst_System");
169  ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
170  this->burstSystem->setLifeSpan(1.0, .3);
171  this->burstSystem->setRadius(0.0, 1.5);
172  this->burstSystem->setRadius(0.05, 1.8);
173  this->burstSystem->setRadius(.5, .8);
174  this->burstSystem->setRadius(1.0, 0);
175  this->burstSystem->setColor(0.0, .7,.7,1,.5);
176  this->burstSystem->setColor(0.2, 0,0,0.8,.5);
177  this->burstSystem->setColor(0.5, .5,.5,.8,.3);
178  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
179
180
[7868]181  //add events to the eventlist of the Playable
182  this->registerEvent(KeyMapper::PEV_FORWARD);
183  this->registerEvent(KeyMapper::PEV_BACKWARD);
184  this->registerEvent(KeyMapper::PEV_LEFT);
185  this->registerEvent(KeyMapper::PEV_RIGHT);
186  this->registerEvent(KeyMapper::PEV_UP);
187  this->registerEvent(KeyMapper::PEV_DOWN);
188  this->registerEvent(KeyMapper::PEV_FIRE1);
189  this->registerEvent(KeyMapper::PEV_NEXT_WEAPON);
190  this->registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
191  this->registerEvent(EV_MOUSE_MOTION);
[6443]192
[7337]193  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
[6443]194
[6803]195  // WEAPON_MANAGER configuration
[7337]196  this->getWeaponManager().setSlotCount(5);
[6803]197
[7337]198  this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750), &this->wingNodeLeft);
199  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[6443]200
[7337]201  this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750), &this->wingNodeRight);
202  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[6443]203
[7337]204  this->getWeaponManager().setSlotPosition(2, Vector(-1.63, .809, -.003));
205  this->getWeaponManager().setSlotCapability(2, WTYPE_HEAVY);
[6443]206
[6803]207  /// TODO: THESE ARE TOO MUCH
[7337]208  this->getWeaponManager().setSlotPosition(3, Vector(-1.63, .678, -.652));
209  this->getWeaponManager().setSlotDirection(3, Quaternion(-24/180 * M_PI, Vector(1,0,0)));
[6443]210
[7337]211  this->getWeaponManager().setSlotPosition(4, Vector(-1.63, .678, .652));
212  this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
[6443]213
[6807]214  this->cameraNode.setRelCoor(1,5,0);
[7337]215  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
216  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
[9494]217
[8623]218  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
219  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
220  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
221  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
222  registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
223  registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
[9494]224  registerVar( new SynchronizeableQuaternion( &direction, &direction, "direction", PERMISSION_OWNER ) );
[8623]225  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
226  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
[9656]227
228  if( State::isOnline())
229    toList( OM_PLAYERS );
[6443]230}
231
232/**
[7345]233 * @brief loads the Settings of a TurbineHover from an XML-element.
[6443]234 * @param root the XML-element to load the Spaceship's properties from
235 */
[7000]236void TurbineHover::loadParams(const TiXmlElement* root)
[6443]237{
[7348]238  Playable::loadParams(root);
[6443]239}
240
[9656]241
242void TurbineHover::setBoostColor(const Color& color)
243{
244  this->burstSystem->setColor(0.0, color);
245  this->burstSystem->setColor(0.2, color * 0.6);
246  this->burstSystem->setColor(0.5, color * .3 + Color(0.5, 0.5, 0.8, 0.3));
247  this->burstSystem->setColor(1.0, 0.8, 0.8, 0.8, 0.0);
248
249  printf(":::::::::::::::::::::::\n");
250  this->burstSystem->debug();
251}
252
[7348]253void TurbineHover::setPlayDirection(const Quaternion& rot, float speed)
254{
255  this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
256}
[6443]257
[7000]258void TurbineHover::enter()
[6443]259{
[7337]260  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
[6443]261
[7125]262  if (State::getCameraNode != NULL)
263  {
264    State::getCameraNode()->setParentSoft(&this->cameraNode);
265    State::getCameraNode()->setRelCoorSoft(-10, 0,0);
266    State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
267  }
[6443]268}
269
[7000]270void TurbineHover::leave()
[6443]271{
[7337]272  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
[6443]273  this->detachCamera();
274
275}
276
[9656]277void TurbineHover::setTeam(int teamID)
278{
279  printf("::::::::::::::::: TEAM ::: %d\n", teamID);
280  if (teamID == 0)
281  {
282    this->setBoostColor(Color::blue);
283  }
284  else if (teamID == 1)
285  {
286    this->setBoostColor(Color::red);
287  }
[6443]288
[9656]289  ///HACK this is very much hard coded.set the owner of the weapons
290  this->getWeaponManager().getWeapon(0)->setOwner(this->getOwner());
291  this->getWeaponManager().getWeapon(1)->setOwner(this->getOwner());
292
293  //choose collision list
294  if( State::isOnline())
295  {
296    if( teamID == 0)
297      toList( OM_GROUP_00 );
298    else if(teamID == 1)
299      toList( OM_GROUP_01);
300  }
301
302
303  // set the local team id, very important
304  this->setTeamId(teamID);
305}
306
307
308
[6443]309/**
[7345]310 * @brief effect that occurs after the TurbineHover is spawned
[6443]311*/
[7000]312void TurbineHover::postSpawn ()
[6443]313{
314  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
315}
316
317/**
[7345]318 * @brief the action occuring if the turbine_hover left the game
[6443]319*/
[7000]320void TurbineHover::leftWorld ()
[6443]321{}
322
323/**
[7345]324 * @brief this function is called, when two entities collide
[6443]325 * @param entity: the world entity with whom it collides
326 *
327 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
328 */
[7000]329void TurbineHover::collidesWith(WorldEntity* entity, const Vector& location)
[7072]330{
331  Playable::collidesWith(entity, location);
332}
[6443]333
334
335
336/**
[7345]337 * @brief the function called for each passing timeSnap
[6443]338 * @param time The timespan passed since last update
339*/
[7000]340void TurbineHover::tick (float dt)
[6443]341{
[7339]342  //  this->debugNode(1);
[6804]343  Playable::tick(dt);
344
[6443]345  // spaceship controlled movement
[9494]346
347  // TRYING TO FIX PNode.
348  //this->cameraNode.setRelCoor(Vector(0.0f, 5.0f, 0.0f));//, 30.0f);
349  //this->cameraNode.setRelDir(Quaternion(this->smoothRotator  *10.0, Vector(0,1,0)));
350
[6805]351  this->movement(dt);
[6806]352  this->rotorCycle += this->rotorSpeed * dt;
[6443]353}
354
[9494]355
356#include "shared_network_data.h"
357
[6443]358/**
[7345]359 * @brief calculate the velocity
[6443]360 * @param time the timeslice since the last frame
361*/
[7000]362void TurbineHover::movement (float dt)
[6443]363{
364  Vector accel(0.0, 0.0, 0.0);
365
[6814]366  if( this->bForward )
367  {
[6879]368    accel += Vector(this->acceleration, 0, 0);
[6443]369  }
370
[6814]371  if( this->bBackward )
372  {
[6879]373    accel -= Vector(this->acceleration, 0, 0);
[6443]374  }
[6814]375  if( this->bLeft)
376  {
[6879]377    accel -= Vector(0, 0, this->acceleration);
[6443]378  }
[6807]379
[6814]380  if( this->bRight)
381  {
[6879]382    accel += Vector(0, 0, this->acceleration);
[6443]383  }
384
[6814]385  if (this->bAscend )
386  {
[6879]387    accel += Vector(0, this->acceleration, 0);
[6443]388  }
[6814]389  if (this->bDescend )
390  {
[6879]391    accel -= Vector(0, this->acceleration, 0);
[6807]392  }
[6443]393
[7339]394  switch(this->getPlaymode())
395  {
396    case Playable::Full3D:
397      {
398        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
[6814]399
[7339]400        // this is the air friction (necessary for a smooth control)
401        Vector damping = (this->velocity * this->airFriction);
[6999]402
403
[7339]404        this->velocity += (accelerationDir - damping)* dt;
[9494]405        //if (this->getOwner() != SharedNetworkData::getInstance()->getHostID())
406          this->shiftCoor (this->velocity * dt);
[6879]407
[7339]408        // limit the maximum rotation speed.
409        if (this->rotation != 0.0f)
410        {
411          float maxRot = 10.0 * dt;
412          if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
413          if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
414          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
[7326]415
[7339]416          this->rotation = 0.0f;
417        }
[7326]418
[9494]419        //if (this->getOwner() != SharedNetworkData::getInstance()->getHostID())
420          this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
[6805]421
[7339]422        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
423        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
[6805]424
[7339]425        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
426        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
427      }
428      break;
429
430    case Playable::Horizontal:
431      {
[7345]432        accel.y = 0.0;
[7339]433        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
[7345]434        accelerationDir.y = 0.0;
[7339]435
436        // this is the air friction (necessary for a smooth control)
437        Vector damping = (this->velocity * this->airFriction);
438
439
440        this->velocity += (accelerationDir - damping)* dt;
441        this->shiftCoor (this->velocity * dt);
442
443        // limit the maximum rotation speed.
444        if (this->rotation != 0.0f)
445        {
446          float maxRot = 10.0 * dt;
447          if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
448          if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
449          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
450
451          this->rotation = 0.0f;
452        }
453
454        this->setRelDirSoft(this->direction, 5);
455
456        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
457        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation, Vector(0,0,1)), 5);
458
459        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
460        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation, Vector(0,0,1)), 5);
461      }
462      break;
[7346]463
464    case Playable::Vertical:
[9494]465      {
466        accel.z = 0;
467        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
468        accelerationDir.z=0;
[7346]469
470        // this is the air friction (necessary for a smooth control)
[9494]471        Vector damping = (this->velocity * this->airFriction);
[7346]472
[9494]473        this->velocity += (accelerationDir - damping)* dt;
474        this->shiftCoor (this->velocity * dt);
[7346]475
[9494]476        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
[7346]477
[9494]478        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
479        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
[7346]480
[9494]481        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
482        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
483      }
484      break;
[8316]485    default:
486      PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
[7339]487  }
[6443]488}
489
490
[7000]491void TurbineHover::draw() const
[6443]492{
[6801]493  Vector tmpRot;
[6443]494  WorldEntity::draw();
[6799]495
[6801]496  glPushMatrix();
497  /// LEFT SIDE
498  glTranslatef (this->wingNodeLeft.getAbsCoor ().x,
499                this->wingNodeLeft.getAbsCoor ().y,
500                this->wingNodeLeft.getAbsCoor ().z);
501  tmpRot = this->wingNodeLeft.getAbsDir().getSpacialAxis();
502  glRotatef (this->wingNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
503  this->getModel(3)->draw();
504  glPopMatrix ();
[6443]505
[6801]506  glPushMatrix();
507  glTranslatef (this->rotorNodeLeft.getAbsCoor ().x,
508                this->rotorNodeLeft.getAbsCoor ().y,
509                this->rotorNodeLeft.getAbsCoor ().z);
510  tmpRot = this->rotorNodeLeft.getAbsDir().getSpacialAxis();
511  glRotatef (this->rotorNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
512  this->getModel(4)->draw();
[6806]513  glRotatef(this->rotorCycle, 0,1,0);
514  this->getModel(5)->draw();
[6801]515  glPopMatrix ();
[6724]516
[6801]517  /// RIGHT SIDE
518  glPushMatrix();
519  glTranslatef (this->wingNodeRight.getAbsCoor ().x,
520                this->wingNodeRight.getAbsCoor ().y,
521                this->wingNodeRight.getAbsCoor ().z);
522  tmpRot = this->wingNodeRight.getAbsDir().getSpacialAxis();
523  glRotatef (this->wingNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
524  glScalef(1,1,-1);
525  this->getModel(3)->draw();
526  glPopMatrix ();
[6724]527
[6801]528  glPushMatrix();
529  glTranslatef (this->rotorNodeRight.getAbsCoor ().x,
530                this->rotorNodeRight.getAbsCoor ().y,
531                this->rotorNodeRight.getAbsCoor ().z);
532  tmpRot = this->rotorNodeRight.getAbsDir().getSpacialAxis();
533  glRotatef (this->rotorNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
534  glScalef(1,1,-1);
535  this->getModel(4)->draw();
[6806]536  glRotatef(this->rotorCycle, 0,1,0);
537  this->getModel(5)->draw();
[6801]538  glPopMatrix ();
[6443]539}
540
541/**
542 * @todo switch statement ??
543 */
[7000]544void TurbineHover::process(const Event &event)
[6443]545{
[6804]546  Playable::process(event);
[6443]547
[6637]548  if( event.type == KeyMapper::PEV_LEFT)
[6805]549    this->bLeft = event.bPressed;
[6637]550  else if( event.type == KeyMapper::PEV_RIGHT)
[6805]551    this->bRight = event.bPressed;
[6998]552  else if( event.type == KeyMapper::PEV_UP)
[6443]553    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
[6998]554  else if( event.type == KeyMapper::PEV_DOWN)
[6443]555    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
[6997]556  else if( event.type == KeyMapper::PEV_FORWARD)
[6805]557    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
[6997]558  else if( event.type == KeyMapper::PEV_BACKWARD)
[6805]559    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
[6443]560  else if( event.type == EV_MOUSE_MOTION)
561  {
[6807]562    float xMouse, yMouse;
563    xMouse = event.xRel*mouseSensitivity;
564    yMouse = event.yRel*mouseSensitivity;
[6443]565
[6805]566    // rotate the Player around the y-axis
[6807]567    this->rotation += xMouse;
[6799]568
[6807]569    this->cameraLook += yMouse;
[6805]570    // rotate the Camera around the z-axis
[6807]571    if (cameraLook > M_PI_4)
572      cameraLook = M_PI_4;
[6880]573    else if (cameraLook < -M_PI_4)
574      cameraLook = -M_PI_4;
575    //this->cameraNode.setRelDirSoft(this->direction,10);
[6805]576  }
[6443]577}
[9656]578
579
580/**
581 *  respawning function called by the GameRules
582 */
583void TurbineHover::respawn( )
584{
585
586  Playable::respawn();
587}
Note: See TracBrowser for help on using the repository browser.