Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6699 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities


Ignore:
Timestamp:
Jan 25, 2006, 3:09:58 PM (19 years ago)
Author:
bknecht
Message:

Control: Helicopterrotors set

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

Legend:

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

    r6637 r6699  
    3636
    3737/**
    38  *  creates the controlable Spaceship
     38 *  creates the controlable Helicopter
    3939 */
    4040Helicopter::Helicopter()
     
    4444
    4545/**
    46  *  destructs the spaceship, deletes alocated memory
     46 *  destructs the helicopter, deletes alocated memory
    4747 */
    4848Helicopter::~Helicopter ()
     
    5151
    5252/**
    53  * loads a Spaceships information from a specified file.
    54  * @param fileName the name of the File to load the spaceship from (absolute path)
     53 * loads a Helicopter information from a specified file.
     54 * @param fileName the name of the File to load the helicopter from (absolute path)
    5555 */
    5656Helicopter::Helicopter(const char* fileName)
     
    108108  this->setClassID(CL_HELICOPTER, "Helicopter");
    109109
    110   PRINTF(4)("SPACESHIP INIT\n");
     110  PRINTF(4)("HELICOPTER INIT\n");
    111111
    112112  this->loadModel("models/ships/helicopter_#.obj", 1.0);
     
    118118  xMouse = yMouse = 0;
    119119  mouseSensitivity = 0.05;
     120  controlVelocityX = 100;
     121  controlVelocityY = 100;
    120122  //rotorspeed = 1;
    121123  //tailrotorspeed = 0;
    122124
    123125  //cycle = 0.0;
     126 
     127 
     128  // rotors
     129  this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     130  this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     131 
     132  this->topRotor.setParent(this);
     133  this->tailRotor.setParent(this);
     134 
     135  this->topRotor.setRelCoor(Vector(-0.877,0.627,0));
     136  this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068));
     137  this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0)));
     138 
     139  this->loadModel("models/ships/rotor.obj",1.0,3);
     140  this->loadModel("models/ships/rotor.obj",0.15,4);
    124141
    125142
     
    127144  this->velocity = Vector(0.0,0.0,0.0);
    128145  this->velocityDir = Vector(1.0,0.0,0.0);
    129 
    130146//   GLGuiButton* button = new GLGuiPushButton();
    131147//   button->show();
     
    221237
    222238/**
    223  *  the action occuring if the spaceship left the game
     239 *  the action occuring if the helicopter left the game
    224240*/
    225241void Helicopter::leftWorld ()
     
    249265void Helicopter::tick (float time)
    250266{
    251   /*
    252   tailrotorspeed += xMouse/20;
    253   if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07;
    254   else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07;
    255 
    256   if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001;
    257   else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001;
    258   if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0;
    259   */
     267  if( xMouse != 0 || yMouse != 0)
     268   {
     269    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     270    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     271    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
     272    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
     273  }
     274  // rotorrotation
     275  this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
     276  this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
    260277 
    261278  // spaceship controlled movement
     
    419436{
    420437  WorldEntity::draw();
     438 
     439  glMatrixMode(GL_MODELVIEW);
     440    glPushMatrix();
     441
     442    /* translate */
     443    glTranslatef (this->topRotor.getAbsCoor ().x,
     444                  this->topRotor.getAbsCoor ().y,
     445                  this->topRotor.getAbsCoor ().z);
     446    Vector tmpRot = this->topRotor.getAbsDir().getSpacialAxis();
     447    glRotatef (this->topRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     448    this->getModel(3)->draw();
     449
     450    glPopMatrix ();
     451    glPushMatrix();
     452
     453    /* translate */
     454    glTranslatef (this->tailRotor.getAbsCoor ().x,
     455                  this->tailRotor.getAbsCoor ().y,
     456                  this->tailRotor.getAbsCoor ().z);
     457    tmpRot = this->tailRotor.getAbsDir().getSpacialAxis();
     458    glRotatef (this->tailRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     459    this->getModel(4)->draw();
     460
     461    glPopMatrix ();
    421462
    422463  this->getWeaponManager()->draw();
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h

    r6637 r6699  
    5959    int                   yInvert;
    6060    float                 mouseSensitivity;   //!< the mouse sensitivity
     61    int                   controlVelocityX;
     62    int                   controlVelocityY;
    6163    //float                 cycle;              //!< hovercycle
     64   
     65    PNode                   topRotor;
     66    PNode                   tailRotor;
    6267
    6368    Vector                velocity;           //!< the velocity of the player.
  • branches/spaceshipcontrol/src/world_entities/space_ships/hover.cc

    r6637 r6699  
    110110  PRINTF(4)("HOVER INIT\n");
    111111
    112   this->loadModel("models/ships/fighter.obj", 1.0);
     112  this->loadModel("models/ships/nimrod_#.obj", 1.0);
    113113
    114114  EventHandler::getInstance()->grabEvents(true);
     
    118118  xMouse = yMouse = 0;
    119119  mouseSensitivity = 0.05;
     120  controlVelocityX = 100;
     121  controlVelocityY = 100;
    120122
    121123
     
    241243void Hover::tick (float time)
    242244{
    243  
    244  
     245  if( xMouse != 0 || yMouse != 0)
     246   {
     247    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     248    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     249    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
     250    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
     251   }
     252   
    245253  Quaternion xDir = Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0));
    246254  Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1));
     
    261269  else this->shiftDir(xDir*yDir);
    262270 
    263   if((this->getAbsDirZ()).y > 0.1) this->shiftDir(Quaternion(0.01,Vector(1,0,0)));
    264   else if((this->getAbsDirZ()).y < -0.1) this->shiftDir(Quaternion(-0.01,Vector(1,0,0)));
    265 
     271  if((this->getAbsDirZ()).y > 0.05) this->shiftDir(Quaternion(0.02,Vector(1,0,0)));
     272  else if((this->getAbsDirZ()).y < -0.05) this->shiftDir(Quaternion(-0.02,Vector(1,0,0)));
    266273 
    267274  // spaceship controlled movement
  • branches/spaceshipcontrol/src/world_entities/space_ships/hover.h

    r6637 r6699  
    5858    float                 yMouse;             //!< mouse moved in y-Direction
    5959    float                 mouseSensitivity;   //!< the mouse sensitivity
     60    int                   controlVelocityX;
     61    int                   controlVelocityY;
    6062
    6163    Vector                velocity;           //!< the velocity of the player.
Note: See TracChangeset for help on using the changeset viewer.