Changeset 6162 in orxonox.OLD for trunk/src/world_entities/space_ships/helicopter.cc
- Timestamp:
- Dec 19, 2005, 4:52:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/helicopter.cc
r6005 r6162 99 99 100 100 /** 101 * initializes a Spaceship101 * initializes a Helicopter 102 102 */ 103 103 void Helicopter::init() … … 240 240 void Helicopter::tick (float time) 241 241 { 242 cycle += time;243 242 // spaceship controlled movement 244 243 this->calculateVelocity(time); … … 246 245 Vector move = (velocity)*time; 247 246 248 //orient the spaceship model in the direction of movement.249 250 247 // this is the air friction (necessary for a smooth control) 251 if(velocity.len() != 0) velocity -= velocity*0.01; 252 248 if(velocity.len() != 0) velocity -= velocity*0.1; 249 250 251 //hoover effect 252 cycle += time; 253 253 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 254 255 //readjust 256 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 257 //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0))); 254 258 255 259 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); … … 269 273 { 270 274 Vector accel(0.0, 0.0, 0.0); 271 //Vector rot(0.0, 0.0, 0.0);272 //float rotVal = 0.0;275 Vector rot(0.0, 0.0, 0.0); 276 float rotVal = 0.0; 273 277 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 274 278 /* calculate the direction in which the craft is heading */ … … 277 281 { 278 282 //this->shiftCoor(this->getAbsDirX()); 279 accel += (this->getAbsDirX())*2; 283 284 accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 285 if((this->getAbsDirX()).y > -.2) 286 { 287 rot += Vector (0,0,1); 288 rotVal -= time/5; 289 } 290 } 291 else 292 { 293 if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/5, Vector(0,0,1))); 280 294 } 281 295 … … 283 297 { 284 298 //this->shiftCoor((this->getAbsDirX())*-1); 285 accel -= (this->getAbsDirX())*2; 299 accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 300 if((this->getAbsDirX()).y < .2) 301 { 302 rot += Vector (0,0,1); 303 rotVal += time/5; 304 } 305 } 306 else 307 { 308 if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1))); 286 309 } 287 310 288 311 if( this->bLeft /* > -this->getRelCoor().z*2*/) 289 312 { 290 this->shiftDir(Quaternion(time, Vector(0,1,0))); 291 // accel -= rightDirection; 313 //this->shiftDir(Quaternion(time, Vector(0,1,0))); 314 accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2; 315 //velocityDir.normalize(); 316 if((this->getAbsDirZ()).y < .2) 317 { 318 rot +=Vector(1,0,0); 319 rotVal -= time/5; 320 } 321 } 322 else 323 { 324 if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0))); 325 } 326 327 if( this->bRight /* > this->getRelCoor().z*2*/) 328 { 329 //this->shiftDir(Quaternion(-time, Vector(0,1,0))); 330 331 accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2; 332 //velocityDir.normalize(); 333 if((this->getAbsDirZ()).y > -.2) 334 { 335 rot += Vector(1,0,0); 336 rotVal += time/5; 337 } 338 } 339 else 340 { 341 if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0))); 342 } 343 344 if( this->bRollL /* > -this->getRelCoor().z*2*/) 345 { 346 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 347 //accel -= rightDirection; 292 348 //velocityDir.normalize(); 293 349 //rot +=Vector(1,0,0); 294 350 //rotVal -= .4; 295 351 } 296 if( this->bR ight/* > this->getRelCoor().z*2*/)297 { 298 this->shiftDir(Quaternion( -time, Vector(0,1,0)));299 300 // 352 if( this->bRollR /* > this->getRelCoor().z*2*/) 353 { 354 this->shiftDir(Quaternion(time, Vector(1,0,0))); 355 356 //accel += rightDirection; 301 357 //velocityDir.normalize(); 302 358 //rot += Vector(1,0,0); 303 359 //rotVal += .4; 304 360 } 305 306 if( this->bRollL /* > -this->getRelCoor().z*2*/)307 {308 this->shiftDir(Quaternion(-time, Vector(1,0,0)));309 // accel -= rightDirection;310 //velocityDir.normalize();311 //rot +=Vector(1,0,0);312 //rotVal -= .4;313 }314 if( this->bRollR /* > this->getRelCoor().z*2*/)315 {316 this->shiftDir(Quaternion(time, Vector(1,0,0)));317 318 // accel += rightDirection;319 //velocityDir.normalize();320 //rot += Vector(1,0,0);321 //rotVal += .4;322 }323 361 if (this->bAscend ) 324 362 { 325 this->shiftDir(Quaternion(time, Vector(0,0,1)));326 327 // accel += upDirection;363 //this->shiftDir(Quaternion(time, Vector(0,0,1))); 364 365 accel += (this->getAbsDirY())*2; 328 366 //velocityDir.normalize(); 329 367 //rot += Vector(0,0,1); … … 332 370 if (this->bDescend ) 333 371 { 334 this->shiftDir(Quaternion(-time, Vector(0,0,1)));335 336 // accel -= upDirection;372 //this->shiftDir(Quaternion(-time, Vector(0,0,1))); 373 374 accel -= (this->getAbsDirY())*2; 337 375 //velocityDir.normalize(); 338 376 //rot += Vector(0,0,1); … … 341 379 342 380 velocity += accel; 343 //rot.normalize();344 //this->setRelDirSoft(Quaternion(rotVal, rot), 5);381 rot.normalize(); 382 this->shiftDir(Quaternion(rotVal, rot)); 345 383 } 346 384 … … 373 411 374 412 if( event.type == SDLK_a) 375 this->b RollL= event.bPressed;413 this->bLeft = event.bPressed; 376 414 else if( event.type == SDLK_d) 377 this->bR ollR= event.bPressed;415 this->bRight = event.bPressed; 378 416 else if( event.type == KeyMapper::PEV_FIRE1) 379 417 this->bFire = event.bPressed; … … 382 420 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed) 383 421 this->getWeaponManager()->previousWeaponConfig(); 384 422 else if( event.type == SDLK_e) 423 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); 424 else if( event.type == SDLK_c) 425 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); 385 426 else if( event.type == SDLK_w) 386 427 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); … … 391 432 this->xMouse = event.xRel; 392 433 this->yMouse = event.yRel; 434 if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0; 393 435 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 394 436 }
Note: See TracChangeset
for help on using the changeset viewer.