Changeset 6162 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Dec 19, 2005, 4:52:01 PM (19 years ago)
- Location:
- trunk/src/world_entities/space_ships
- Files:
-
- 4 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 } -
trunk/src/world_entities/space_ships/helicopter.h
r6005 r6162 65 65 float travelSpeed; //!< the current speed of the player (to make soft movement) 66 66 float acceleration; //!< the acceleration of the player. 67 68 float airViscosity; 67 69 68 70 }; -
trunk/src/world_entities/space_ships/space_ship.cc
r6078 r6162 119 119 mouseSensitivity = 0.001; 120 120 airViscosity = 1.0; 121 122 121 cycle = 0.0; 123 122 … … 125 124 travelSpeed = 15.0; 126 125 this->velocity = Vector(0.0,0.0,0.0); 127 this-> velocityDir = Vector(1.0,0.0,0.0);126 this->mouseDir = this->getAbsDir(); 128 127 129 128 // GLGuiButton* button = new GLGuiPushButton(); … … 175 174 // this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 176 175 176 this->getWeaponManager()->getFixedTarget()->setParent(this); 177 this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0); 178 177 179 } 178 180 … … 265 267 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 266 268 velocity = (velocity.getNormalized())*travelSpeed; 267 269 270 //orient the spaceship in direction of the mouse 271 rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3); 272 if (this->getAbsDir().distance(rotQuat) > 0.001) 273 this->setAbsDir( rotQuat); 274 //this->setAbsDirSoft(mouseDir,5); 275 268 276 // this is the air friction (necessary for a smooth control) 269 277 if(velocity.len() != 0) velocity -= velocity*0.01; … … 293 301 { 294 302 Vector accel(0.0, 0.0, 0.0); 295 //Vector rot(0.0, 0.0, 0.0); 303 /* 304 Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter 305 */ 296 306 //float rotVal = 0.0; 297 307 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ … … 302 312 //this->shiftCoor(this->getAbsDirX()); 303 313 accel += (this->getAbsDirX())*2; 314 315 /* Heli-Steuerung 316 accel += (this->getAbsDirX()*2; 317 if( 318 */ 304 319 } 305 320 … … 331 346 if( this->bRollL /* > -this->getRelCoor().z*2*/) 332 347 { 333 this->shiftDir(Quaternion(-time, Vector(1,0,0)));348 mouseDir *= Quaternion(-time, Vector(1,0,0)); 334 349 // accel -= rightDirection; 335 350 //velocityDir.normalize(); … … 339 354 if( this->bRollR /* > this->getRelCoor().z*2*/) 340 355 { 341 this->shiftDir(Quaternion(time, Vector(1,0,0)));356 mouseDir *= Quaternion(time, Vector(1,0,0)); 342 357 343 358 // accel += rightDirection; … … 407 422 this->xMouse = event.xRel; 408 423 this->yMouse = event.yRel; 409 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 424 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 425 if( xMouse*xMouse + yMouse*yMouse < 0.9) 426 this->setAbsDir(mouseDir); 410 427 } 411 428 } -
trunk/src/world_entities/space_ships/space_ship.h
r6034 r6162 8 8 9 9 #include "playable.h" 10 10 11 11 12 template<class T> class tList; … … 64 65 65 66 Vector velocity; //!< the velocity of the player. 66 Vector velocityDir; //!< the direction of the velocity of the spaceship 67 Quaternion mouseDir; //!< the direction where the player wants to fly 68 Quaternion rotQuat; 67 69 float travelSpeed; //!< the current speed of the player (to make soft movement) 68 70 float acceleration; //!< the acceleration of the player.
Note: See TracChangeset
for help on using the changeset viewer.