Changeset 6804 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Jan 28, 2006, 11:29:03 AM (19 years ago)
- Location:
- trunk/src/world_entities/space_ships
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/helicopter.cc
r6724 r6804 124 124 125 125 //cycle = 0.0; 126 126 127 127 // cameraissue 128 128 this->cameraNode.setParent(this); 129 129 this->cameraNode.setParentMode(PNODE_ALL); 130 131 130 131 132 132 // rotors 133 133 this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 134 134 this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 135 135 136 136 this->topRotor.setParent(this); 137 137 this->tailRotor.setParent(this); 138 138 139 139 this->topRotor.setRelCoor(Vector(-0.877,0.627,0)); 140 140 this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068)); 141 141 this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0))); 142 142 143 143 this->loadModel("models/ships/rotor.obj",1.0,3); 144 144 this->loadModel("models/ships/rotor.obj",0.2,4); … … 274 274 void Helicopter::tick (float time) 275 275 { 276 Playable::tick(time); 277 276 278 if( xMouse != 0 || yMouse != 0) 277 279 { … … 281 283 else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY; 282 284 } 283 285 284 286 // rotorrotation 285 287 this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 286 288 this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 287 289 288 290 // spaceship controlled movement 289 291 this->calculateVelocity(time); … … 293 295 // this is the air friction (necessary for a smooth control) 294 296 if(velocity.len() != 0) velocity -= velocity*0.1; 295 297 296 298 //travelSpeed = velocity.len(); 297 299 … … 301 303 this->shiftCoor(getAbsDirY()*rotorspeed); 302 304 */ 303 305 304 306 /* 305 307 //hoover effect … … 316 318 this->shiftCoor (move); 317 319 //this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0))); 318 319 this->getWeaponManager()->tick(time);320 // weapon system manipulation321 this->weaponAction();322 320 } 323 321 … … 338 336 //this->shiftCoor(this->getAbsDirX()); 339 337 //accel -= this->getAbsDirY(); 340 338 341 339 accel += Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z); 342 340 if((this->getAbsDirX()).y >= -0.1) rotValZ -= time; … … 351 349 //this->shiftCoor((this->getAbsDirX())*-1); 352 350 //accel -= this->getAbsDirY(); 353 351 354 352 accel -= Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z); 355 353 rotValZ += time; … … 365 363 //accel -= this->getAbsDirY(); 366 364 //velocityDir.normalize(); 367 365 368 366 accel -= Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z); 369 367 rotValX -= time; … … 379 377 //accel += this->getAbsDirY(); 380 378 //velocityDir.normalize(); 381 379 382 380 accel += Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z); 383 381 rotValX += time; … … 446 444 { 447 445 WorldEntity::draw(); 448 446 449 447 glMatrixMode(GL_MODELVIEW); 450 448 glPushMatrix(); … … 474 472 } 475 473 476 477 /**478 * weapon manipulation by the player479 */480 void Helicopter::weaponAction()481 {482 if( this->bFire)483 {484 this->getWeaponManager()->fire();485 }486 }487 488 474 /** 489 475 * @todo switch statement ?? … … 491 477 void Helicopter::process(const Event &event) 492 478 { 493 479 Playable::process(event); 494 480 495 481 if( event.type == KeyMapper::PEV_LEFT) … … 497 483 else if( event.type == KeyMapper::PEV_RIGHT) 498 484 this->bRight = event.bPressed; 499 else if( event.type == KeyMapper::PEV_FIRE1)500 this->bFire = event.bPressed;501 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)502 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;503 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)504 this->getWeaponManager()->previousWeaponConfig();505 485 else if( event.type == SDLK_e) 506 486 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); … … 517 497 518 498 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))); 519 499 520 500 Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)); 521 501 522 502 523 503 if ((this->cameraNode.getAbsDirY()).y < 0.5) 524 504 { -
trunk/src/world_entities/space_ships/helicopter.h
r6724 r6804 21 21 virtual ~Helicopter(); 22 22 23 void init();24 23 virtual void loadParams(const TiXmlElement* root); 25 24 … … 40 39 41 40 private: 41 void init(); 42 42 void calculateVelocity(float time); 43 void weaponAction();44 43 45 44 // !! temporary !! … … 63 62 int controlVelocityY; 64 63 //float cycle; //!< hovercycle 65 64 66 65 PNode topRotor; 67 66 PNode tailRotor; 68 67 69 68 PNode cameraNode; 70 69 -
trunk/src/world_entities/space_ships/hover.cc
r6803 r6804 252 252 * @param time The timespan passed since last update 253 253 */ 254 void Hover::tick (float time) 255 { 254 void Hover::tick (float dt) 255 { 256 Playable::tick(dt); 257 256 258 if( xMouse != 0 || yMouse != 0) 257 259 { … … 263 265 264 266 // spaceship controlled movement 265 this->calculateVelocity( time);266 267 Vector move = (velocity)* time;267 this->calculateVelocity(dt); 268 269 Vector move = (velocity)*dt; 268 270 269 271 // this is the air friction (necessary for a smooth control) … … 271 273 this->shiftCoor (move); 272 274 273 this->getWeaponManager()->tick(time);274 // weapon system manipulation275 this->weaponAction();276 275 } 277 276 … … 400 399 { 401 400 Vector tmpRot; 402 403 401 WorldEntity::draw(); 404 402 … … 463 461 void Hover::process(const Event &event) 464 462 { 465 463 Playable::process(event); 466 464 467 465 if( event.type == KeyMapper::PEV_LEFT) … … 469 467 else if( event.type == KeyMapper::PEV_RIGHT) 470 468 this->bRight = event.bPressed; 471 else if( event.type == KeyMapper::PEV_FIRE1)472 this->bFire = event.bPressed;473 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)474 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;475 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)476 this->getWeaponManager()->previousWeaponConfig();477 469 else if( event.type == SDLK_e) 478 470 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); -
trunk/src/world_entities/space_ships/space_ship.cc
r6803 r6804 306 306 void SpaceShip::tick (float time) 307 307 { 308 this->getWeaponManager()->tick(time); 309 // weapon system manipulation 310 this->weaponAction(); 308 Playable::tick(time); 311 309 312 310 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() ) … … 464 462 465 463 /** 466 * weapon manipulation by the player467 */468 void SpaceShip::weaponAction()469 {470 if( this->bFire)471 {472 this->getWeaponManager()->fire();473 }474 }475 476 /**477 464 * @todo switch statement ?? 478 465 */ 479 466 void SpaceShip::process(const Event &event) 480 467 { 468 Playable::process(event); 469 481 470 if( event.type == KeyMapper::PEV_LEFT) 482 471 this->bRollL = event.bPressed; 483 472 else if( event.type == KeyMapper::PEV_RIGHT) 484 473 this->bRollR = event.bPressed; 485 else if( event.type == KeyMapper::PEV_FIRE1)486 this->bFire = event.bPressed;487 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)488 {489 this->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;490 }491 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)492 this->previousWeaponConfig();493 474 else if( event.type == KeyMapper::PEV_UP) 494 475 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); -
trunk/src/world_entities/space_ships/space_ship.h
r6756 r6804 27 27 virtual ~SpaceShip(); 28 28 29 void init();30 29 virtual void loadParams(const TiXmlElement* root); 31 30 … … 47 46 48 47 private: 48 void init(); 49 49 50 50 void calculateVelocity(float time); 51 void weaponAction();52 51 53 52 // !! temporary !!
Note: See TracChangeset
for help on using the changeset viewer.