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