Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
10 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
  • trunk/src/world_entities/weapons/aim.cc

    r6637 r6724  
    7373  this->source = NULL;
    7474
    75   this->range = 0;
    76   this->angle = 0;
     75  this->range = 10000;
     76  this->angle = M_PI_4;
     77  this->group = OM_GROUP_01;
    7778  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7879  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    106107{
    107108  std::list<WorldEntity*>::iterator entity;
    108   Vector diffVec(0.0, 0.0, 0.0);
    109   diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
    110 
    111 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
    112   if( this == PNode::getNullParent() || diffVec.len() > range  || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    113   for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    114        entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
     109
     110  for (entity = State::getObjectManager()->getObjectList(group).begin();
     111       entity != State::getObjectManager()->getObjectList(group).end();
    115112       entity ++)
    116113  {
     
    119116    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)
    120117    {
    121       if (this->getParent() != (*entity))
     118      //if (this->getParent() != (*entity))
    122119      {
    123120        this->anim->replay();
     
    127124    }
    128125  }
    129 //if no target found:
    130   this->setParent(PNode::getNullParent());
     126
     127   //if no target found:
     128   this->setParent(PNode::getNullParent());
     129
     130
     131
    131132}
    132133
     
    165166
    166167//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     168  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
     169//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
     170   if(this->getParent() == PNode::getNullParent() ||
     171      diffVec.len() > range  ||
     172      ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
     173    {
    167174     this->searchTarget();
     175    }
     176
    168177//   float z = 0.0f;
    169178//   glReadPixels ((int)this->getAbsCoor2D().x,
     
    196205{
    197206
     207 if( this->getParent() != PNode::getNullParent() )
     208  {
    198209  glPushMatrix();
    199210  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     
    212223  glEnd();
    213224  glPopMatrix();
    214 
    215 }
     225  }
     226
     227}
  • trunk/src/world_entities/weapons/aim.h

    r6637 r6724  
    99#include "p_node.h"
    1010#include "element_2d.h"
     11#include "object_manager.h"
    1112
    1213// FORWARD DECLARATION
     
    4243  void setRange(float range){this->range = range;};
    4344  void setAngle(float angle){this->angle = angle;};
     45  void setGroup(OM_LIST group){this->group = group;};
    4446
    4547  void setSize(float size);
     
    5860   float            range;                //!<
    5961   float            angle;                //!<
     62   Vector           diffVec;
     63   OM_LIST          group;
    6064
    6165   PNode*           source;               //!< Where this Shot has come from.
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r6671 r6724  
    9898  this->target = new Aim(this);
    9999  this->target->setVisibility(false);
    100   this->target->setRange(100);
    101   this->target->setAngle(M_PI);
     100  this->target->setRange(1000);
     101  this->target->setAngle(M_PI_4);
    102102}
    103103
     
    148148  pj->setAbsDir(this->getAbsDir());
    149149  pj->activate();
    150   this->target->searchTarget();
    151150}
    152151
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r6695 r6724  
    9494  this->target->setVisibility(false);
    9595  this->target->setRange(100);
    96   this->target->setAngle(M_PI_4/2);
     96  this->target->setAngle(M_PI_4/16);
    9797  this->lockedTime = 0;
    9898  this->neededLockTime = 2;
     
    148148            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    149149
    150   pj->setTarget(this->target->getParent());
     150  pj->setTarget(lockedTarget);
    151151  pj->setParent(PNode::getNullParent());
    152152  pj->setAbsCoor(this->getEmissionPoint());
    153153  pj->setAbsDir(this->getAbsDir());
    154154  pj->activate();
    155   this->target->searchTarget();
     155 
    156156}
    157157
  • trunk/src/world_entities/weapons/turret.cc

    r6671 r6724  
    116116void Turret::tick(float dt)
    117117{
    118 /*
     118
    119119  Quaternion quat;
    120   Vector direction = this->getAbsCoor();/*this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();
     120  Vector direction = this->getAbsCoor();/*this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();*/
    121121
    122122  direction.normalize();
     
    127127    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
    128128
    129   this->setAbsDirSoft(quat, 5);*/
     129  this->setAbsDirSoft(quat, 5);
    130130}
    131131
Note: See TracChangeset for help on using the changeset viewer.