Changeset 6051 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities/space_ships
- Timestamp:
- Dec 11, 2005, 5:18:43 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src/world_entities/space_ships
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.cc
r6005 r6051 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. 247 //orient the velocity in the direction of the spaceship. 248 travelSpeed = velocity.len(); 249 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 250 velocity = (velocity.getNormalized())*travelSpeed; 249 251 250 252 // this is the air friction (necessary for a smooth control) 251 253 if(velocity.len() != 0) velocity -= velocity*0.01; 252 254 255 //hoover effect 256 cycle += time; 253 257 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 258 259 //readjust 260 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 261 //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0))); 254 262 255 263 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); … … 269 277 { 270 278 Vector accel(0.0, 0.0, 0.0); 271 //Vector rot(0.0, 0.0, 0.0);272 //float rotVal = 0.0;279 Vector rot(0.0, 0.0, 0.0); 280 float rotVal = 0.0; 273 281 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 274 282 /* calculate the direction in which the craft is heading */ … … 278 286 //this->shiftCoor(this->getAbsDirX()); 279 287 accel += (this->getAbsDirX())*2; 288 rot += Vector (0,0,1); 289 rotVal -= .4; 280 290 } 281 291 … … 284 294 //this->shiftCoor((this->getAbsDirX())*-1); 285 295 accel -= (this->getAbsDirX())*2; 296 rot += Vector (0,0,1); 297 rotVal += .4; 286 298 } 287 299 288 300 if( this->bLeft /* > -this->getRelCoor().z*2*/) 289 301 { 290 this->shiftDir(Quaternion(time, Vector(0,1,0))); 291 // accel -= rightDirection; 302 //this->shiftDir(Quaternion(time, Vector(0,1,0))); 303 accel -= (this->getAbsDirZ()); 304 //velocityDir.normalize(); 305 rot +=Vector(1,0,0); 306 rotVal -= .2; 307 } 308 if( this->bRight /* > this->getRelCoor().z*2*/) 309 { 310 //this->shiftDir(Quaternion(-time, Vector(0,1,0))); 311 312 accel += (this->getAbsDirZ()); 313 //velocityDir.normalize(); 314 rot += Vector(1,0,0); 315 rotVal += .2; 316 } 317 318 if( this->bRollL /* > -this->getRelCoor().z*2*/) 319 { 320 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 321 //accel -= rightDirection; 292 322 //velocityDir.normalize(); 293 323 //rot +=Vector(1,0,0); 294 324 //rotVal -= .4; 295 325 } 296 if( this->bR ight/* > this->getRelCoor().z*2*/)297 { 298 this->shiftDir(Quaternion( -time, Vector(0,1,0)));299 300 // 326 if( this->bRollR /* > this->getRelCoor().z*2*/) 327 { 328 this->shiftDir(Quaternion(time, Vector(1,0,0))); 329 330 //accel += rightDirection; 301 331 //velocityDir.normalize(); 302 332 //rot += Vector(1,0,0); 303 333 //rotVal += .4; 304 334 } 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 335 if (this->bAscend ) 324 336 { 325 this->shiftDir(Quaternion(time, Vector(0,0,1)));326 327 // accel += upDirection;337 //this->shiftDir(Quaternion(time, Vector(0,0,1))); 338 339 accel += (this->getAbsDirY())*2; 328 340 //velocityDir.normalize(); 329 341 //rot += Vector(0,0,1); … … 332 344 if (this->bDescend ) 333 345 { 334 this->shiftDir(Quaternion(-time, Vector(0,0,1)));335 336 // accel -= upDirection;346 //this->shiftDir(Quaternion(-time, Vector(0,0,1))); 347 348 accel -= (this->getAbsDirY())*2; 337 349 //velocityDir.normalize(); 338 350 //rot += Vector(0,0,1); … … 341 353 342 354 velocity += accel; 343 //rot.normalize();344 //this->setRelDirSoft(Quaternion(rotVal, rot), 5);355 rot.normalize(); 356 this->setRelDirSoft(Quaternion(rotVal, rot), 5); 345 357 } 346 358 … … 373 385 374 386 if( event.type == SDLK_a) 375 this->b RollL= event.bPressed;387 this->bLeft = event.bPressed; 376 388 else if( event.type == SDLK_d) 377 this->bR ollR= event.bPressed;389 this->bRight = event.bPressed; 378 390 else if( event.type == KeyMapper::PEV_FIRE1) 379 391 this->bFire = event.bPressed; … … 382 394 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed) 383 395 this->getWeaponManager()->previousWeaponConfig(); 384 396 else if( event.type == SDLK_e) 397 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); 398 else if( event.type == SDLK_c) 399 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); 385 400 else if( event.type == SDLK_w) 386 401 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); -
branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h
r6005 r6051 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 }; -
branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc
r6044 r6051 292 292 { 293 293 Vector accel(0.0, 0.0, 0.0); 294 //Vector rot(0.0, 0.0, 0.0); 294 /* 295 Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter 296 */ 295 297 //float rotVal = 0.0; 296 298 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ … … 301 303 //this->shiftCoor(this->getAbsDirX()); 302 304 accel += (this->getAbsDirX())*2; 305 306 /* Heli-Steuerung 307 accel += (this->getAbsDirX()*2; 308 if( 309 */ 303 310 } 304 311
Note: See TracChangeset
for help on using the changeset viewer.