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