[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 | |
---|
| 26 | #include "factory.h" |
---|
| 27 | #include "key_mapper.h" |
---|
| 28 | #include "event_handler.h" |
---|
| 29 | #include "state.h" |
---|
| 30 | |
---|
| 31 | #include "graphics_engine.h" |
---|
[7001] | 32 | #include "dot_emitter.h" |
---|
| 33 | #include "sprite_particles.h" |
---|
[6443] | 34 | |
---|
| 35 | using namespace std; |
---|
| 36 | |
---|
[7000] | 37 | CREATE_FACTORY(TurbineHover, CL_TURBINE_HOVER); |
---|
[6443] | 38 | |
---|
| 39 | /** |
---|
[7000] | 40 | * destructs the turbine_hover, deletes alocated memory |
---|
[6443] | 41 | */ |
---|
[7000] | 42 | TurbineHover::~TurbineHover () |
---|
[6986] | 43 | { |
---|
| 44 | this->setPlayer(NULL); |
---|
| 45 | } |
---|
[6443] | 46 | |
---|
| 47 | /** |
---|
[7000] | 48 | * loads a TurbineHover information from a specified file. |
---|
| 49 | * @param fileName the name of the File to load the turbine_hover from (absolute path) |
---|
[6443] | 50 | */ |
---|
[7000] | 51 | TurbineHover::TurbineHover(const char* fileName) |
---|
[6443] | 52 | { |
---|
| 53 | this->init(); |
---|
| 54 | TiXmlDocument doc(fileName); |
---|
| 55 | |
---|
| 56 | if(!doc.LoadFile()) |
---|
| 57 | { |
---|
[7000] | 58 | PRINTF(2)("Loading file %s failed for TurbineHover.\n", fileName); |
---|
[6443] | 59 | return; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | this->loadParams(doc.RootElement()); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * creates a new Spaceship from Xml Data |
---|
| 67 | * @param root the xml element containing spaceship data |
---|
| 68 | |
---|
| 69 | @todo add more parameters to load |
---|
| 70 | */ |
---|
[7000] | 71 | TurbineHover::TurbineHover(const TiXmlElement* root) |
---|
[6443] | 72 | { |
---|
| 73 | this->init(); |
---|
| 74 | if (root != NULL) |
---|
| 75 | this->loadParams(root); |
---|
| 76 | |
---|
| 77 | //weapons: |
---|
| 78 | Weapon* wpRight = new TestGun(0); |
---|
| 79 | wpRight->setName("testGun Right"); |
---|
| 80 | Weapon* wpLeft = new TestGun(1); |
---|
| 81 | wpLeft->setName("testGun Left"); |
---|
[6811] | 82 | Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_HYPERBLASTER)); |
---|
[6443] | 83 | |
---|
| 84 | cannon->setName("BFG"); |
---|
| 85 | |
---|
| 86 | this->addWeapon(wpLeft, 1, 0); |
---|
| 87 | this->addWeapon(wpRight,1 ,1); |
---|
[6803] | 88 | this->addWeapon(cannon, 0, 2); |
---|
[6443] | 89 | |
---|
| 90 | this->getWeaponManager()->changeWeaponConfig(1); |
---|
| 91 | dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); |
---|
[6800] | 92 | |
---|
| 93 | this->loadModel("models/ships/hoverglider_mainbody.obj"); |
---|
[6443] | 94 | } |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | /** |
---|
[7000] | 98 | * initializes a TurbineHover |
---|
[6443] | 99 | */ |
---|
[7000] | 100 | void TurbineHover::init() |
---|
[6443] | 101 | { |
---|
[6805] | 102 | // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); |
---|
[7000] | 103 | this->setClassID(CL_TURBINE_HOVER, "TurbineHover"); |
---|
[6443] | 104 | |
---|
[6807] | 105 | this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3); |
---|
[7000] | 106 | this->loadModel("models/ships/hoverglider_turbine.obj", 1.0f, 4); |
---|
| 107 | this->loadModel("models/ships/hoverglider_turbine_rotors.obj", 1.0f, 5); |
---|
[6443] | 108 | |
---|
[6805] | 109 | bForward = bBackward = bLeft = bRight = bAscend = bDescend = false; |
---|
[6807] | 110 | mouseSensitivity = 0.005; |
---|
[6443] | 111 | |
---|
[6806] | 112 | this->rotorSpeed = 1000.0f; |
---|
| 113 | this->rotorCycle = 0.0f; |
---|
[6807] | 114 | this->cameraLook = 0.0f; |
---|
| 115 | this->rotation = 0.0f; |
---|
[7001] | 116 | this->acceleration = 10.0f; |
---|
| 117 | this->airFriction = 2.0f; |
---|
[6799] | 118 | |
---|
[6806] | 119 | // camera - issue |
---|
[6800] | 120 | this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
[6806] | 121 | this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
[6880] | 122 | //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT); |
---|
[6724] | 123 | this->cameraNode.setParent(this); |
---|
[6799] | 124 | |
---|
[6724] | 125 | // rotors |
---|
[6803] | 126 | this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT ); |
---|
| 127 | this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
[6801] | 128 | this->wingNodeLeft.setParent(this); |
---|
| 129 | this->wingNodeLeft.setRelCoor(-1.5, -.3, -1.0); |
---|
[6800] | 130 | this->rotorNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
[6801] | 131 | this->rotorNodeLeft.setParent(&this->wingNodeLeft); |
---|
| 132 | this->rotorNodeLeft.setRelCoor(0, 1.0, -2.3); |
---|
[6799] | 133 | |
---|
[6801] | 134 | this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
[6803] | 135 | this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
[6800] | 136 | this->wingNodeRight.setParent(this); |
---|
[6801] | 137 | this->wingNodeRight.setRelCoor(-1.5, -0.3, 1.0); |
---|
| 138 | this->rotorNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
[6800] | 139 | this->rotorNodeRight.setParent(&this->wingNodeRight); |
---|
[6801] | 140 | this->rotorNodeRight.setRelCoor(0, 1.0, 2.3); |
---|
[6443] | 141 | |
---|
[7001] | 142 | // PARTICLES |
---|
| 143 | this->burstEmitter[0] = new DotEmitter(200, 5.0, .01); |
---|
| 144 | this->burstEmitter[0]->setParent(&this->rotorNodeLeft); |
---|
| 145 | this->burstEmitter[0]->setRelCoor(0, -0.7, 0); |
---|
| 146 | this->burstEmitter[0]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1))); |
---|
| 147 | this->burstEmitter[0]->setName("TurbineHover_Burst_emitter_Left"); |
---|
[6803] | 148 | |
---|
[7001] | 149 | this->burstEmitter[1] = new DotEmitter(200, 5.0, .01); |
---|
| 150 | this->burstEmitter[1]->setParent(&this->rotorNodeRight); |
---|
| 151 | this->burstEmitter[1]->setRelCoor(0, -0.7, 0); |
---|
| 152 | this->burstEmitter[1]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1))); |
---|
| 153 | this->burstEmitter[1]->setName("TurbineHover_Burst_emitter_Right"); |
---|
[6800] | 154 | |
---|
[7001] | 155 | |
---|
| 156 | this->burstSystem = new SpriteParticles(1000); |
---|
| 157 | this->burstSystem->addEmitter(this->burstEmitter[0]); |
---|
| 158 | this->burstSystem->addEmitter(this->burstEmitter[1]); |
---|
| 159 | this->burstSystem->setName("SpaceShip_Burst_System"); |
---|
| 160 | ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png"); |
---|
| 161 | this->burstSystem->setLifeSpan(1.0, .3); |
---|
| 162 | this->burstSystem->setRadius(0.0, 1.5); |
---|
| 163 | this->burstSystem->setRadius(0.05, 1.8); |
---|
| 164 | this->burstSystem->setRadius(.5, .8); |
---|
| 165 | this->burstSystem->setRadius(1.0, 0); |
---|
| 166 | this->burstSystem->setColor(0.0, .7,.7,1,.5); |
---|
| 167 | this->burstSystem->setColor(0.2, 0,0,0.8,.5); |
---|
| 168 | this->burstSystem->setColor(0.5, .5,.5,.8,.3); |
---|
| 169 | this->burstSystem->setColor(1.0, .8,.8,.8,.0); |
---|
| 170 | |
---|
| 171 | |
---|
[6443] | 172 | //add events to the eventlist |
---|
[6997] | 173 | registerEvent(KeyMapper::PEV_FORWARD); |
---|
| 174 | registerEvent(KeyMapper::PEV_BACKWARD); |
---|
[6637] | 175 | registerEvent(KeyMapper::PEV_LEFT); |
---|
| 176 | registerEvent(KeyMapper::PEV_RIGHT); |
---|
[6998] | 177 | registerEvent(KeyMapper::PEV_UP); |
---|
| 178 | registerEvent(KeyMapper::PEV_DOWN); |
---|
[6443] | 179 | registerEvent(KeyMapper::PEV_FIRE1); |
---|
| 180 | registerEvent(KeyMapper::PEV_NEXT_WEAPON); |
---|
| 181 | registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON); |
---|
| 182 | registerEvent(EV_MOUSE_MOTION); |
---|
| 183 | |
---|
[7001] | 184 | dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); |
---|
[6443] | 185 | |
---|
[6803] | 186 | // WEAPON_MANAGER configuration |
---|
| 187 | this->getWeaponManager()->setSlotCount(5); |
---|
| 188 | |
---|
| 189 | this->getWeaponManager()->setSlotPosition(0, Vector(-0.28, 1.186, -2.750), &this->wingNodeLeft); |
---|
[6443] | 190 | this->getWeaponManager()->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); |
---|
| 191 | |
---|
[6803] | 192 | this->getWeaponManager()->setSlotPosition(1, Vector(-0.28, 1.186, 2.750), &this->wingNodeRight); |
---|
[6443] | 193 | this->getWeaponManager()->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); |
---|
| 194 | |
---|
[6803] | 195 | this->getWeaponManager()->setSlotPosition(2, Vector(-1.63, .809, -.003)); |
---|
| 196 | this->getWeaponManager()->setSlotCapability(2, WTYPE_HEAVY); |
---|
[6443] | 197 | |
---|
[6803] | 198 | /// TODO: THESE ARE TOO MUCH |
---|
| 199 | this->getWeaponManager()->setSlotPosition(3, Vector(-1.63, .678, -.652)); |
---|
| 200 | this->getWeaponManager()->setSlotDirection(3, Quaternion(-24/180 * M_PI, Vector(1,0,0))); |
---|
[6443] | 201 | |
---|
[6803] | 202 | this->getWeaponManager()->setSlotPosition(4, Vector(-1.63, .678, .652)); |
---|
| 203 | this->getWeaponManager()->setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0))); |
---|
[6443] | 204 | |
---|
[6807] | 205 | this->cameraNode.setRelCoor(1,5,0); |
---|
| 206 | this->getWeaponManager()->getFixedTarget()->setParent(&this->cameraNode); |
---|
| 207 | this->getWeaponManager()->getFixedTarget()->setRelCoor(1000,0,0); |
---|
[6443] | 208 | } |
---|
| 209 | |
---|
| 210 | /** |
---|
[7000] | 211 | * loads the Settings of a TurbineHover from an XML-element. |
---|
[6443] | 212 | * @param root the XML-element to load the Spaceship's properties from |
---|
| 213 | */ |
---|
[7000] | 214 | void TurbineHover::loadParams(const TiXmlElement* root) |
---|
[6443] | 215 | { |
---|
[6512] | 216 | WorldEntity::loadParams(root); |
---|
[6443] | 217 | } |
---|
| 218 | |
---|
| 219 | |
---|
[7000] | 220 | void TurbineHover::enter() |
---|
[6443] | 221 | { |
---|
| 222 | dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true); |
---|
| 223 | |
---|
[6871] | 224 | State::getCamera()->setParentSoft(&this->cameraNode); |
---|
| 225 | State::getCamera()->setRelCoorSoft(-10, 0,0); |
---|
| 226 | State::getCameraTarget()->setParentSoft(&this->cameraNode); |
---|
[6443] | 227 | } |
---|
| 228 | |
---|
[7000] | 229 | void TurbineHover::leave() |
---|
[6443] | 230 | { |
---|
| 231 | dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); |
---|
| 232 | this->detachCamera(); |
---|
| 233 | |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | /** |
---|
[7000] | 238 | * effect that occurs after the TurbineHover is spawned |
---|
[6443] | 239 | */ |
---|
[7000] | 240 | void TurbineHover::postSpawn () |
---|
[6443] | 241 | { |
---|
| 242 | //setCollision(new CollisionCluster(1.0, Vector(0,0,0))); |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | /** |
---|
[7000] | 246 | * the action occuring if the turbine_hover left the game |
---|
[6443] | 247 | */ |
---|
[7000] | 248 | void TurbineHover::leftWorld () |
---|
[6443] | 249 | {} |
---|
| 250 | |
---|
| 251 | /** |
---|
| 252 | * this function is called, when two entities collide |
---|
| 253 | * @param entity: the world entity with whom it collides |
---|
| 254 | * |
---|
| 255 | * Implement behaviour like damage application or other miscellaneous collision stuff in this function |
---|
| 256 | */ |
---|
[7000] | 257 | void TurbineHover::collidesWith(WorldEntity* entity, const Vector& location) |
---|
[6807] | 258 | {} |
---|
[6443] | 259 | |
---|
| 260 | |
---|
| 261 | |
---|
| 262 | /** |
---|
| 263 | * the function called for each passing timeSnap |
---|
| 264 | * @param time The timespan passed since last update |
---|
| 265 | */ |
---|
[7000] | 266 | void TurbineHover::tick (float dt) |
---|
[6443] | 267 | { |
---|
[6804] | 268 | Playable::tick(dt); |
---|
| 269 | |
---|
[6443] | 270 | // spaceship controlled movement |
---|
[6805] | 271 | this->movement(dt); |
---|
[6806] | 272 | this->rotorCycle += this->rotorSpeed * dt; |
---|
[7001] | 273 | |
---|
| 274 | // TRYING TO FIX PNode. |
---|
| 275 | /* this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0,5,0), 30); |
---|
| 276 | this->cameraNode.setAbsDirSoft(this->getAbsDir(), 30);*/ |
---|
[6443] | 277 | } |
---|
| 278 | |
---|
| 279 | /** |
---|
| 280 | * calculate the velocity |
---|
| 281 | * @param time the timeslice since the last frame |
---|
| 282 | */ |
---|
[7000] | 283 | void TurbineHover::movement (float dt) |
---|
[6443] | 284 | { |
---|
| 285 | Vector accel(0.0, 0.0, 0.0); |
---|
[6879] | 286 | float rotSpeed = .3; |
---|
[6443] | 287 | |
---|
[6814] | 288 | if( this->bForward ) |
---|
| 289 | { |
---|
[6879] | 290 | accel += Vector(this->acceleration, 0, 0); |
---|
[6443] | 291 | } |
---|
| 292 | |
---|
[6814] | 293 | if( this->bBackward ) |
---|
| 294 | { |
---|
[6879] | 295 | accel -= Vector(this->acceleration, 0, 0); |
---|
[6443] | 296 | } |
---|
[6814] | 297 | if( this->bLeft) |
---|
| 298 | { |
---|
[6879] | 299 | accel -= Vector(0, 0, this->acceleration); |
---|
[6443] | 300 | } |
---|
[6807] | 301 | |
---|
[6814] | 302 | if( this->bRight) |
---|
| 303 | { |
---|
[6879] | 304 | accel += Vector(0, 0, this->acceleration); |
---|
[6443] | 305 | } |
---|
| 306 | |
---|
[6814] | 307 | if (this->bAscend ) |
---|
| 308 | { |
---|
[6879] | 309 | accel += Vector(0, this->acceleration, 0); |
---|
[6443] | 310 | } |
---|
[6814] | 311 | if (this->bDescend ) |
---|
| 312 | { |
---|
[6879] | 313 | accel -= Vector(0, this->acceleration, 0); |
---|
[6807] | 314 | } |
---|
[6443] | 315 | |
---|
[6999] | 316 | Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); |
---|
[6814] | 317 | |
---|
[6879] | 318 | // this is the air friction (necessary for a smooth control) |
---|
[6999] | 319 | Vector damping = (this->velocity * this->airFriction); |
---|
| 320 | |
---|
| 321 | |
---|
| 322 | this->velocity += (accelerationDir - damping)* dt; |
---|
| 323 | |
---|
| 324 | this->shiftCoor (this->velocity * dt); |
---|
[6879] | 325 | this->rotation = 0.0f; |
---|
| 326 | |
---|
[6880] | 327 | this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5); |
---|
[6805] | 328 | |
---|
[7001] | 329 | this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); |
---|
| 330 | this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5); |
---|
[6805] | 331 | |
---|
[7001] | 332 | this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); |
---|
| 333 | this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5); |
---|
[6443] | 334 | } |
---|
| 335 | |
---|
| 336 | |
---|
[7000] | 337 | void TurbineHover::draw() const |
---|
[6443] | 338 | { |
---|
[6801] | 339 | Vector tmpRot; |
---|
[6443] | 340 | WorldEntity::draw(); |
---|
[6799] | 341 | |
---|
[6801] | 342 | glPushMatrix(); |
---|
| 343 | /// LEFT SIDE |
---|
| 344 | glTranslatef (this->wingNodeLeft.getAbsCoor ().x, |
---|
| 345 | this->wingNodeLeft.getAbsCoor ().y, |
---|
| 346 | this->wingNodeLeft.getAbsCoor ().z); |
---|
| 347 | tmpRot = this->wingNodeLeft.getAbsDir().getSpacialAxis(); |
---|
| 348 | glRotatef (this->wingNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
| 349 | this->getModel(3)->draw(); |
---|
| 350 | glPopMatrix (); |
---|
[6443] | 351 | |
---|
[6801] | 352 | glPushMatrix(); |
---|
| 353 | glTranslatef (this->rotorNodeLeft.getAbsCoor ().x, |
---|
| 354 | this->rotorNodeLeft.getAbsCoor ().y, |
---|
| 355 | this->rotorNodeLeft.getAbsCoor ().z); |
---|
| 356 | tmpRot = this->rotorNodeLeft.getAbsDir().getSpacialAxis(); |
---|
| 357 | glRotatef (this->rotorNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
| 358 | this->getModel(4)->draw(); |
---|
[6806] | 359 | glRotatef(this->rotorCycle, 0,1,0); |
---|
| 360 | this->getModel(5)->draw(); |
---|
[6801] | 361 | glPopMatrix (); |
---|
[6724] | 362 | |
---|
[6801] | 363 | /// RIGHT SIDE |
---|
| 364 | glPushMatrix(); |
---|
| 365 | glTranslatef (this->wingNodeRight.getAbsCoor ().x, |
---|
| 366 | this->wingNodeRight.getAbsCoor ().y, |
---|
| 367 | this->wingNodeRight.getAbsCoor ().z); |
---|
| 368 | tmpRot = this->wingNodeRight.getAbsDir().getSpacialAxis(); |
---|
| 369 | glRotatef (this->wingNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
| 370 | glScalef(1,1,-1); |
---|
| 371 | this->getModel(3)->draw(); |
---|
| 372 | glPopMatrix (); |
---|
[6724] | 373 | |
---|
[6801] | 374 | glPushMatrix(); |
---|
| 375 | glTranslatef (this->rotorNodeRight.getAbsCoor ().x, |
---|
| 376 | this->rotorNodeRight.getAbsCoor ().y, |
---|
| 377 | this->rotorNodeRight.getAbsCoor ().z); |
---|
| 378 | tmpRot = this->rotorNodeRight.getAbsDir().getSpacialAxis(); |
---|
| 379 | glRotatef (this->rotorNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
| 380 | glScalef(1,1,-1); |
---|
| 381 | this->getModel(4)->draw(); |
---|
[6806] | 382 | glRotatef(this->rotorCycle, 0,1,0); |
---|
| 383 | this->getModel(5)->draw(); |
---|
[6801] | 384 | glPopMatrix (); |
---|
[6443] | 385 | } |
---|
| 386 | |
---|
| 387 | /** |
---|
| 388 | * @todo switch statement ?? |
---|
| 389 | */ |
---|
[7000] | 390 | void TurbineHover::process(const Event &event) |
---|
[6443] | 391 | { |
---|
[6804] | 392 | Playable::process(event); |
---|
[6443] | 393 | |
---|
[6637] | 394 | if( event.type == KeyMapper::PEV_LEFT) |
---|
[6805] | 395 | this->bLeft = event.bPressed; |
---|
[6637] | 396 | else if( event.type == KeyMapper::PEV_RIGHT) |
---|
[6805] | 397 | this->bRight = event.bPressed; |
---|
[6998] | 398 | else if( event.type == KeyMapper::PEV_UP) |
---|
[6443] | 399 | this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); |
---|
[6998] | 400 | else if( event.type == KeyMapper::PEV_DOWN) |
---|
[6443] | 401 | this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); |
---|
[6997] | 402 | else if( event.type == KeyMapper::PEV_FORWARD) |
---|
[6805] | 403 | this->bForward = event.bPressed; //this->shiftCoor(0,.1,0); |
---|
[6997] | 404 | else if( event.type == KeyMapper::PEV_BACKWARD) |
---|
[6805] | 405 | this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0); |
---|
[6443] | 406 | else if( event.type == EV_MOUSE_MOTION) |
---|
| 407 | { |
---|
[6807] | 408 | float xMouse, yMouse; |
---|
| 409 | xMouse = event.xRel*mouseSensitivity; |
---|
| 410 | yMouse = event.yRel*mouseSensitivity; |
---|
[6443] | 411 | |
---|
[6805] | 412 | // rotate the Player around the y-axis |
---|
[6807] | 413 | this->direction *= Quaternion(-M_PI/4.0*xMouse, Vector(0,1,0)); |
---|
| 414 | this->rotation += xMouse; |
---|
[6799] | 415 | |
---|
[6807] | 416 | this->cameraLook += yMouse; |
---|
[6805] | 417 | // rotate the Camera around the z-axis |
---|
[6807] | 418 | if (cameraLook > M_PI_4) |
---|
| 419 | cameraLook = M_PI_4; |
---|
[6880] | 420 | else if (cameraLook < -M_PI_4) |
---|
| 421 | cameraLook = -M_PI_4; |
---|
| 422 | //this->cameraNode.setRelDirSoft(this->direction,10); |
---|
[6805] | 423 | } |
---|
[6443] | 424 | } |
---|