Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Control: Helicopterrotors set

File:
1 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();
Note: See TracChangeset for help on using the changeset viewer.