Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6426 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 7, 2006, 11:17:51 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the spaceshipcontrol branche back to the trunk

merged with command
svn merge https://svn.orxonox.net/orxonox/branches/spaceshipcontrol . -r6224:HEAD
small conflict in space_ship.cc fixed in favor of the control

Location:
trunk/src/world_entities
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/camera.cc

    r6424 r6426  
    199199  Vector up = this->getAbsDirV();
    200200  Vector delay = Vector(0,0,0);
    201   if( currentMode != VIEW_FRONT) delay = (this->target->getAbsDirX() * this->target->getSpeed())/30;
     201  if( currentMode != VIEW_FRONT) delay = (this->target->getVelocity())/25;
    202202
    203203  // Setting the Camera Eye, lookAt and up Vectors
  • trunk/src/world_entities/space_ships/helicopter.cc

    r6281 r6426  
    2727#include "key_mapper.h"
    2828#include "event_handler.h"
     29#include "state.h"
    2930
    3031#include "graphics_engine.h"
     
    117118  xMouse = yMouse = 0;
    118119  mouseSensitivity = 0.001;
     120  rotorspeed = 1;
     121  tailrotorspeed = 0;
    119122
    120123  cycle = 0.0;
     
    137140  registerEvent(SDLK_q);
    138141  registerEvent(SDLK_e);
     142  registerEvent(SDLK_c);
    139143  registerEvent(KeyMapper::PEV_FIRE1);
    140144  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    172176//   this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    173177//   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);
    174183
    175184}
     
    190199{
    191200  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
     201  this->attachCamera();
    192202
    193203
     
    197207{
    198208  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    199 
     209  this->detachCamera();
    200210
    201211}
     
    257267*/
    258268void 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 
    260278  // spaceship controlled movement
    261279  this->calculateVelocity(time);
    262280
    263   Vector move = (velocity)*time;
     281  Vector move = (velocity);
    264282
    265283  // this is the air friction (necessary for a smooth control)
    266284  if(velocity.len() != 0) velocity -= velocity*0.1;
    267285
     286  //physics: Gravity
     287  this->shiftCoor(Vector(0,-1,0));
     288 
     289  this->shiftCoor(getAbsDirY()*rotorspeed);
    268290
    269291  //hoover effect
     
    278300
    279301  this->shiftCoor (move);
     302  this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
    280303
    281304  this->getWeaponManager()->tick(time);
     
    299322   {
    300323     //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;
    308327   }
    309328   else
    310329   {
    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)));
    312331   }
    313332
     
    315334   {
    316335     //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;
    323339   }
    324340   else
    325341   {
    326          if(this->getAbsDirZ().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)));
    327343   }
    328344
     
    330346  {
    331347    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
    332     accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     348    //accel -= this->getAbsDirY();
    333349    //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;
    339352  }
    340353  else
     
    346359  {
    347360    //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();
    350362    //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;
    356365  }
    357366  else
     
    381390    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
    382391
    383     accel += (this->getAbsDirY())*2;
     392    rotorspeed += 0.05;
     393    if (rotorspeed >= 2) rotorspeed = 2;
    384394    //velocityDir.normalize();
    385395    //rot += Vector(0,0,1);
    386396    //rotVal += .4;
    387397  }
     398  else
     399  {
     400    if(rotorspeed >= 1.05) rotorspeed -= 0.05;
     401  }
     402 
    388403  if (this->bDescend )
    389404  {
    390405    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    391406
    392     accel -= (this->getAbsDirY())*2;
     407    rotorspeed -= 0.05;
     408    if (rotorspeed <= 0) rotorspeed = 0;
    393409    //velocityDir.normalize();
    394410    //rot += Vector(0,0,1);
    395411    //rotVal -= .4;
    396412  }
    397 
    398   velocity += accel;
     413  else
     414  {
     415    if(rotorspeed <= 0.05) rotorspeed += 0.05;
     416  }
     417
     418  //velocity += accel;
    399419  rot.normalize();
    400420  this->shiftDir(Quaternion(rotVal, rot));
     
    448468  else if( event.type == EV_MOUSE_MOTION)
    449469  {
    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)));
    454474  }
    455475}
  • trunk/src/world_entities/space_ships/helicopter.h

    r6222 r6426  
    6767    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6868    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
    6971
    7072    float                 airViscosity;
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6424 r6426  
    123123  PRINTF(4)("SPACESHIP INIT\n");
    124124
    125     EventHandler::getInstance()->grabEvents(true);
     125  EventHandler::getInstance()->grabEvents(true);
    126126
    127127  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     
    315315
    316316  //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)));
    318325  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    319326
     
    505512    //if (this->getWeaponManager()->hasFreeSlot(3))
    506513    {
    507       turret = new AimingTurret();
     514      turret = dynamic_cast<Weapon*>(Factory::fabricate(CL_TARGETING_TURRET));
     515      if (turret != NULL)
    508516      this->getWeaponManager()->addWeapon(turret, 3);
    509517
  • trunk/src/world_entities/space_ships/space_ship.h

    r6424 r6426  
    7373    Vector                velocity;           //!< the velocity of the player.
    7474    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    75     Quaternion rotQuat;
     75    Quaternion            rotQuat;
    7676    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    7777    float                 acceleration;       //!< the acceleration of the player.
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r6074 r6426  
    9090
    9191  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    92   this->setProjectileType(CL_GUIDED_MISSILE);
     92  this->setProjectileType(CL_ROCKET);
    9393
    9494
     
    142142            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    143143
    144   pj->setTarget(this->target->getParent());
    145144  pj->setParent(PNode::getNullParent());
    146145  pj->setAbsCoor(this->getEmissionPoint());
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6241 r6426  
    4444  this->energyMax = 10;
    4545  this->lifeSpan = 10.0;
    46   this->agility = 4;
     46  this->agility = 500;
    4747  this->maxVelocity = 75;
    4848
     
    156156     correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
    157157
    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)
    159161        velocity += correctionVector;
    160162      else if (velocity.dot(diffVector) < 0)
Note: See TracChangeset for help on using the changeset viewer.