Changeset 6426 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 7, 2006, 11:17:51 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/camera.cc
r6424 r6426 199 199 Vector up = this->getAbsDirV(); 200 200 Vector delay = Vector(0,0,0); 201 if( currentMode != VIEW_FRONT) delay = (this->target->get AbsDirX() * this->target->getSpeed())/30;201 if( currentMode != VIEW_FRONT) delay = (this->target->getVelocity())/25; 202 202 203 203 // Setting the Camera Eye, lookAt and up Vectors -
trunk/src/world_entities/space_ships/helicopter.cc
r6281 r6426 27 27 #include "key_mapper.h" 28 28 #include "event_handler.h" 29 #include "state.h" 29 30 30 31 #include "graphics_engine.h" … … 117 118 xMouse = yMouse = 0; 118 119 mouseSensitivity = 0.001; 120 rotorspeed = 1; 121 tailrotorspeed = 0; 119 122 120 123 cycle = 0.0; … … 137 140 registerEvent(SDLK_q); 138 141 registerEvent(SDLK_e); 142 registerEvent(SDLK_c); 139 143 registerEvent(KeyMapper::PEV_FIRE1); 140 144 registerEvent(KeyMapper::PEV_NEXT_WEAPON); … … 172 176 // this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 173 177 // this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 178 179 this->getWeaponManager()->getFixedTarget()->setParent(this); 180 this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0); 181 182 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 174 183 175 184 } … … 190 199 { 191 200 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true); 201 this->attachCamera(); 192 202 193 203 … … 197 207 { 198 208 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 199 209 this->detachCamera(); 200 210 201 211 } … … 257 267 */ 258 268 void Helicopter::tick (float time) 259 { 269 { 270 tailrotorspeed += xMouse/20; 271 if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07; 272 else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07; 273 274 if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001; 275 else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001; 276 if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0; 277 260 278 // spaceship controlled movement 261 279 this->calculateVelocity(time); 262 280 263 Vector move = (velocity) *time;281 Vector move = (velocity); 264 282 265 283 // this is the air friction (necessary for a smooth control) 266 284 if(velocity.len() != 0) velocity -= velocity*0.1; 267 285 286 //physics: Gravity 287 this->shiftCoor(Vector(0,-1,0)); 288 289 this->shiftCoor(getAbsDirY()*rotorspeed); 268 290 269 291 //hoover effect … … 278 300 279 301 this->shiftCoor (move); 302 this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0))); 280 303 281 304 this->getWeaponManager()->tick(time); … … 299 322 { 300 323 //this->shiftCoor(this->getAbsDirX()); 301 302 accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 303 if((this->getAbsDirX()).y > -.2) 304 { 305 rot += Vector (0,0,1); 306 rotVal -= time/5; 307 } 324 //accel -= this->getAbsDirY(); 325 rot += Vector (0,0,1); 326 rotVal -= time/5; 308 327 } 309 328 else 310 329 { 311 if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/ 5, Vector(0,0,1)));330 if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/8, Vector(0,0,1))); 312 331 } 313 332 … … 315 334 { 316 335 //this->shiftCoor((this->getAbsDirX())*-1); 317 accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 318 if((this->getAbsDirX()).y < .2) 319 { 320 rot += Vector (0,0,1); 321 rotVal += time/5; 322 } 336 //accel -= this->getAbsDirY(); 337 rot += Vector (0,0,1); 338 rotVal += time/5; 323 339 } 324 340 else 325 341 { 326 if(this->getAbsDir Z().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1)));342 if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time/8, Vector(0,0,1))); 327 343 } 328 344 … … 330 346 { 331 347 //this->shiftDir(Quaternion(time, Vector(0,1,0))); 332 accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;348 //accel -= this->getAbsDirY(); 333 349 //velocityDir.normalize(); 334 if((this->getAbsDirZ()).y < .2) 335 { 336 rot +=Vector(1,0,0); 337 rotVal -= time/5; 338 } 350 rot += Vector(1,0,0); 351 rotVal -= time/5; 339 352 } 340 353 else … … 346 359 { 347 360 //this->shiftDir(Quaternion(-time, Vector(0,1,0))); 348 349 accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2; 361 accel += this->getAbsDirY(); 350 362 //velocityDir.normalize(); 351 if((this->getAbsDirZ()).y > -.2) 352 { 353 rot += Vector(1,0,0); 354 rotVal += time/5; 355 } 363 rot += Vector(1,0,0); 364 rotVal += time/5; 356 365 } 357 366 else … … 381 390 //this->shiftDir(Quaternion(time, Vector(0,0,1))); 382 391 383 accel += (this->getAbsDirY())*2; 392 rotorspeed += 0.05; 393 if (rotorspeed >= 2) rotorspeed = 2; 384 394 //velocityDir.normalize(); 385 395 //rot += Vector(0,0,1); 386 396 //rotVal += .4; 387 397 } 398 else 399 { 400 if(rotorspeed >= 1.05) rotorspeed -= 0.05; 401 } 402 388 403 if (this->bDescend ) 389 404 { 390 405 //this->shiftDir(Quaternion(-time, Vector(0,0,1))); 391 406 392 accel -= (this->getAbsDirY())*2; 407 rotorspeed -= 0.05; 408 if (rotorspeed <= 0) rotorspeed = 0; 393 409 //velocityDir.normalize(); 394 410 //rot += Vector(0,0,1); 395 411 //rotVal -= .4; 396 412 } 397 398 velocity += accel; 413 else 414 { 415 if(rotorspeed <= 0.05) rotorspeed += 0.05; 416 } 417 418 //velocity += accel; 399 419 rot.normalize(); 400 420 this->shiftDir(Quaternion(rotVal, rot)); … … 448 468 else if( event.type == EV_MOUSE_MOTION) 449 469 { 450 this->xMouse = event.xRel ;451 this->yMouse = event.yRel ;452 if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;453 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));470 this->xMouse = event.xRel*mouseSensitivity; 471 this->yMouse = event.yRel*mouseSensitivity; 472 473 //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 454 474 } 455 475 } -
trunk/src/world_entities/space_ships/helicopter.h
r6222 r6426 67 67 float travelSpeed; //!< the current speed of the player (to make soft movement) 68 68 float acceleration; //!< the acceleration of the player. 69 float rotorspeed; //!< the speed of the rotor. 70 float tailrotorspeed; //!< the relativ speed ot the tail rotor 69 71 70 72 float airViscosity; -
trunk/src/world_entities/space_ships/space_ship.cc
r6424 r6426 123 123 PRINTF(4)("SPACESHIP INIT\n"); 124 124 125 125 EventHandler::getInstance()->grabEvents(true); 126 126 127 127 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; … … 315 315 316 316 //readjust 317 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 317 318 /* 319 In the game "Yager" the spaceship gets readjusted when the player moves the mouse. 320 I (bknecht) go and check it out how they do it, we could probably use this also in Orxonox. 321 */ 322 //if (xMouse != 0 && yMouse != 0) 323 324 //if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 318 325 //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0))); 319 326 … … 505 512 //if (this->getWeaponManager()->hasFreeSlot(3)) 506 513 { 507 turret = new AimingTurret(); 514 turret = dynamic_cast<Weapon*>(Factory::fabricate(CL_TARGETING_TURRET)); 515 if (turret != NULL) 508 516 this->getWeaponManager()->addWeapon(turret, 3); 509 517 -
trunk/src/world_entities/space_ships/space_ship.h
r6424 r6426 73 73 Vector velocity; //!< the velocity of the player. 74 74 Quaternion mouseDir; //!< the direction where the player wants to fly 75 Quaternion rotQuat;75 Quaternion rotQuat; 76 76 float travelSpeed; //!< the current speed of the player (to make soft movement) 77 77 float acceleration; //!< the acceleration of the player. -
trunk/src/world_entities/weapons/aiming_turret.cc
r6074 r6426 90 90 91 91 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 92 this->setProjectileType(CL_ GUIDED_MISSILE);92 this->setProjectileType(CL_ROCKET); 93 93 94 94 … … 142 142 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 143 143 144 pj->setTarget(this->target->getParent());145 144 pj->setParent(PNode::getNullParent()); 146 145 pj->setAbsCoor(this->getEmissionPoint()); -
trunk/src/world_entities/weapons/guided_missile.cc
r6241 r6426 44 44 this->energyMax = 10; 45 45 this->lifeSpan = 10.0; 46 this->agility = 4;46 this->agility = 500; 47 47 this->maxVelocity = 75; 48 48 … … 156 156 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility; 157 157 158 if(velocity.dot(diffVector) > 0) 158 if( (diffVector * (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility ) 159 velocity = ((diffVector * (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility; 160 else if(velocity.dot(diffVector) > 0) 159 161 velocity += correctionVector; 160 162 else if (velocity.dot(diffVector) < 0)
Note: See TracChangeset
for help on using the changeset viewer.