Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6724 in orxonox.OLD for trunk/src/world_entities/space_ships


Ignore:
Timestamp:
Jan 25, 2006, 5:35:49 PM (18 years ago)
Author:
bensch
Message:

merged the Spaceshipcontrol back to the trunk

Location:
trunk/src/world_entities/space_ships
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/helicopter.cc

    r6637 r6724  
    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  // cameraissue
     128  this->cameraNode.setParent(this);
     129  this->cameraNode.setParentMode(PNODE_ALL);
     130 
     131 
     132  // rotors
     133  this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     134  this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     135 
     136  this->topRotor.setParent(this);
     137  this->tailRotor.setParent(this);
     138 
     139  this->topRotor.setRelCoor(Vector(-0.877,0.627,0));
     140  this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068));
     141  this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0)));
     142 
     143  this->loadModel("models/ships/rotor.obj",1.0,3);
     144  this->loadModel("models/ships/rotor.obj",0.2,4);
    124145
    125146
     
    127148  this->velocity = Vector(0.0,0.0,0.0);
    128149  this->velocityDir = Vector(1.0,0.0,0.0);
    129 
    130150//   GLGuiButton* button = new GLGuiPushButton();
    131151//   button->show();
     
    177197//   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    178198
    179   this->getWeaponManager()->getFixedTarget()->setParent(this);
    180   this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0);
     199  this->getWeaponManager()->getFixedTarget()->setParent(&(this->cameraNode));
     200  this->getWeaponManager()->getFixedTarget()->setRelCoor(0,0,0);
    181201
    182202  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     
    193213}
    194214
    195 
     215void  Helicopter::attachCamera()
     216{
     217  State::getCamera()->setParentSoft(this->getWeaponManager()->getFixedTarget());
     218  State::getCameraTarget()->setParentSoft(this->getWeaponManager()->getFixedTarget());
     219
     220}
    196221
    197222
     
    221246
    222247/**
    223  *  the action occuring if the spaceship left the game
     248 *  the action occuring if the helicopter left the game
    224249*/
    225250void Helicopter::leftWorld ()
     
    249274void Helicopter::tick (float time)
    250275{
    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   */
     276  if( xMouse != 0 || yMouse != 0)
     277   {
     278    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     279    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     280    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
     281    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
     282  }
     283 
     284  // rotorrotation
     285  this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
     286  this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
    260287 
    261288  // spaceship controlled movement
     
    419446{
    420447  WorldEntity::draw();
     448 
     449  glMatrixMode(GL_MODELVIEW);
     450    glPushMatrix();
     451
     452    /* translate */
     453    glTranslatef (this->topRotor.getAbsCoor ().x,
     454                  this->topRotor.getAbsCoor ().y,
     455                  this->topRotor.getAbsCoor ().z);
     456    Vector tmpRot = this->topRotor.getAbsDir().getSpacialAxis();
     457    glRotatef (this->topRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     458    this->getModel(3)->draw();
     459
     460    glPopMatrix ();
     461    glPushMatrix();
     462
     463    /* translate */
     464    glTranslatef (this->tailRotor.getAbsCoor ().x,
     465                  this->tailRotor.getAbsCoor ().y,
     466                  this->tailRotor.getAbsCoor ().z);
     467    tmpRot = this->tailRotor.getAbsDir().getSpacialAxis();
     468    glRotatef (this->tailRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     469    this->getModel(4)->draw();
     470
     471    glPopMatrix ();
    421472
    422473  this->getWeaponManager()->draw();
     
    465516    this->yMouse = event.yRel*mouseSensitivity;
    466517
    467     this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))/*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*/);
    468   }
     518    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0)));
     519   
     520    Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1));
     521
     522   
     523    if ((this->cameraNode.getAbsDirY()).y < 0.5)
     524    {
     525     if((this->cameraNode.getAbsDirX()).y > 0)
     526     {
     527        if(yMouse > 0) this->cameraNode.shiftDir(yDir);
     528     }
     529     else
     530     {
     531         if(yMouse < 0) this->cameraNode.shiftDir(yDir);
     532     }
     533    }
     534    else this->cameraNode.shiftDir(yDir);;
     535    }
    469536}
    470537
  • trunk/src/world_entities/space_ships/helicopter.h

    r6637 r6724  
    2626    virtual void enter();
    2727    virtual void leave();
     28    virtual void attachCamera();
    2829
    2930    virtual void postSpawn();
     
    5960    int                   yInvert;
    6061    float                 mouseSensitivity;   //!< the mouse sensitivity
     62    int                   controlVelocityX;
     63    int                   controlVelocityY;
    6164    //float                 cycle;              //!< hovercycle
     65   
     66    PNode                 topRotor;
     67    PNode                 tailRotor;
     68   
     69    PNode                 cameraNode;
    6270
    6371    Vector                velocity;           //!< the velocity of the player.
  • trunk/src/world_entities/space_ships/hover.cc

    r6637 r6724  
    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
  • trunk/src/world_entities/space_ships/hover.h

    r6637 r6724  
    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.
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6710 r6724  
    373373     //this->shiftCoor((this->getAbsDirX())*-1);
    374374     //accel -= (this->getAbsDirX())*2;
     375    //if(velocity.len() > 50)
    375376     accel -= (this->getAbsDirX())*0.5*acceleration;
     377
     378
     379
    376380   }
    377381
Note: See TracChangeset for help on using the changeset viewer.