Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 1, 2006, 2:12:08 PM (19 years ago)
Author:
bknecht
Message:

Control: helicopter stuff

Location:
branches/spaceshipcontrol/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.cc

    r6871 r6936  
    1010
    1111### File Specific:
    12    main-programmer: Benjamin Grauer
     12   main-programmer: Benjamin Knecht
    1313   co-programmer: ...
    1414
     
    9393  this->addWeapon(cannon, 0, 6);
    9494
    95   //this->addWeapon(turret, 3, 0);
    96 
    9795  this->getWeaponManager()->changeWeaponConfig(1);
    9896  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     
    105103void Helicopter::init()
    106104{
    107 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    108105  this->setClassID(CL_HELICOPTER, "Helicopter");
    109106
     
    120117  controlVelocityX = 100;
    121118  controlVelocityY = 100;
    122   //rotorspeed = 1;
    123   //tailrotorspeed = 0;
    124 
    125   //cycle = 0.0;
    126 
    127   // cameraissue
     119
     120
     121  // initialization of cameraNode
    128122  this->cameraNode.setParent(this);
    129123  this->cameraNode.setParentMode(PNODE_ALL);
    130 
    131 
     124  this->cameraNode.setRelCoor(Vector(0,1,0));
     125 
    132126  // rotors
    133127  this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     
    145139
    146140
    147   //travelSpeed = 15.0;
    148141  this->velocity = Vector(0.0,0.0,0.0);
    149142  this->velocityDir = Vector(1.0,0.0,0.0);
    150 //   GLGuiButton* button = new GLGuiPushButton();
    151 //   button->show();
    152 //   button->setLabel("orxonox");
    153 //   button->setBindNode(this);
     143 
     144  // very, very old stuff
     145  //  GLGuiButton* button = new GLGuiPushButton();
     146  //  button->show();
     147  //  button->setLabel("orxonox");
     148  //  button->setBindNode(this);
    154149
    155150  //add events to the eventlist
     
    158153  registerEvent(KeyMapper::PEV_LEFT);
    159154  registerEvent(KeyMapper::PEV_RIGHT);
    160   //registerEvent(SDLK_q);
    161155  registerEvent(SDLK_e);
    162156  registerEvent(SDLK_c);
     
    164158  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
    165159  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
    166   //registerEvent(SDLK_PAGEUP);
    167   //registerEvent(SDLK_PAGEDOWN);
    168160  registerEvent(EV_MOUSE_MOTION);
    169161
     
    187179  this->getWeaponManager()->setSlotPosition(5, Vector(-1.5, -.5, -.5));
    188180  this->getWeaponManager()->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    189 //
    190    this->getWeaponManager()->setSlotPosition(6, Vector(-1, 0.0, 0));
    191    this->getWeaponManager()->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    192    //
    193 //   this->getWeaponManager()->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    194 //   this->getWeaponManager()->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    195 //
    196 //   this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    197 //   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
     181
     182  this->getWeaponManager()->setSlotPosition(6, Vector(-1, 0.0, 0));
     183  this->getWeaponManager()->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    198184
    199185  this->getWeaponManager()->getFixedTarget()->setParent(&(this->cameraNode));
     
    282268  if(velocity.len() != 0) velocity -= velocity*0.1;
    283269
    284   //travelSpeed = velocity.len();
    285 
    286   //physics: Gravity
    287   /*this->shiftCoor(Vector(0,-1,0));
    288 
    289   this->shiftCoor(getAbsDirY()*rotorspeed);
    290   */
    291 
    292   /*
    293   //hoover effect
    294   cycle += time;
    295   this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    296   */
    297270
    298271  //readjust
    299  // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
    300   //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    301 
    302   //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     272  // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
     273  // else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
     274
    303275
    304276  this->shiftCoor (move);
    305   //this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
    306277}
    307278
     
    344315   }
    345316
    346   if( this->bLeft /* > -this->getRelCoor().z*2*/)
     317  if( this->bLeft )
    347318  {
    348319    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
     
    358329   }
    359330
    360   if( this->bRight /* > this->getRelCoor().z*2*/)
     331  if( this->bRight )
    361332  {
    362333    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
     
    372343   }
    373344
    374   if( this->bRollL /* > -this->getRelCoor().z*2*/)
     345  if( this->bRollL )
    375346  {
    376347    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    377     //accel -= rightDirection;
    378     //velocityDir.normalize();
    379     //rot +=Vector(1,0,0);
    380     //rotVal -= .4;
    381   }
    382   if( this->bRollR /* > this->getRelCoor().z*2*/)
     348  }
     349  if( this->bRollR )
    383350  {
    384351    this->shiftDir(Quaternion(time, Vector(1,0,0)));
    385 
    386     //accel += rightDirection;
    387     //velocityDir.normalize();
    388     //rot += Vector(1,0,0);
    389     //rotVal += .4;
    390352  }
    391353  if (this->bAscend )
    392354  {
    393     //this->shiftDir(Quaternion(time, Vector(0,0,1)));
    394 
    395355    accel += this->getAbsDirY();
    396     //rotorspeed += 0.05;
    397     //if (rotorspeed >= 2) rotorspeed = 2;
    398     //velocityDir.normalize();
    399     //rot += Vector(0,0,1);
    400     //rotVal += .4;
    401   }
    402   else
    403   {
    404     //if(rotorspeed >= 1.05) rotorspeed -= 0.05;
    405356  }
    406357
    407358  if (this->bDescend )
    408359  {
    409     //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    410 
    411360    accel -= this->getAbsDirY();
    412     //rotorspeed -= 0.05;
    413     //if (rotorspeed <= 0) rotorspeed = 0;
    414     //velocityDir.normalize();
    415     //rot += Vector(0,0,1);
    416     //rotVal -= .4;
    417   }
    418   else
    419   {
    420     //if(rotorspeed <= 0.05) rotorspeed += 0.05;
    421361  }
    422362
     
    468408      this->bRight = event.bPressed;
    469409  else if( event.type == SDLK_e)
    470     this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
     410    this->bAscend = event.bPressed;
    471411  else if( event.type == SDLK_c)
    472     this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
     412    this->bDescend = event.bPressed;
    473413  else if( event.type == KeyMapper::PEV_UP)
    474     this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     414    this->bUp = event.bPressed;
    475415  else if( event.type == KeyMapper::PEV_DOWN)
    476     this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
     416    this->bDown = event.bPressed;
    477417  else if( event.type == EV_MOUSE_MOTION)
    478418  {
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h

    r6871 r6936  
    5555    int                   yInvert;
    5656    float                 mouseSensitivity;   //!< the mouse sensitivity
    57     int                   controlVelocityX;
    58     int                   controlVelocityY;
    59     //float                 cycle;              //!< hovercycle
     57    int                   controlVelocityX;   //!< defines max velocity of Xaxis of mousecontrol
     58    int                   controlVelocityY;   //!< defines max velocity of Yaxis of mousecontrol
    6059
    61     PNode                 topRotor;
    62     PNode                 tailRotor;
     60    PNode                 topRotor;           //!< the position of the toprotor
     61    PNode                 tailRotor;          //!< the position of the tailrotor
    6362
    64     PNode                 cameraNode;
     63    PNode                 cameraNode;         //!< the position the camera is locked at (used to look up and down without turning the helicopter)
    6564
    6665    Vector                velocity;           //!< the velocity of the player.
     
    6867    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6968    float                 acceleration;       //!< the acceleration of the player.
    70     //float                 rotorspeed;         //!< the speed of the rotor.
    71     //float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
    7269
    7370    float                 airViscosity;
Note: See TracChangeset for help on using the changeset viewer.