Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 28, 2006, 2:57:27 PM (19 years ago)
Author:
bensch
Message:

trunk: hover optimize

Location:
trunk/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/camera.cc

    r6780 r6807  
    111111    case VIEW_NORMAL:
    112112      this->toFovy = 60.0;
    113       /*      this->setParentSoft("TrackNode");
    114             this->target->setParentSoft("TrackNode"); */
    115113      this->setRelCoorSoft(-10, 5, 0);
    116114      this->target->setRelCoorSoft(0,0,0);
    117115      break;
    118116    case VIEW_BEHIND:
    119       //      this->toFovy = 120.0;
    120       //      this->setRelCoorSoft(Vector(3.5, 0, 0));
    121       //    this->target->setRelCoorSoft(Vector(10,0,0));
    122 
    123       //       if (!strcmp(this->target->getParent()->getName(), "Player"))
    124       //         this->target->setParentSoft("TrackNode");
    125       //       else
    126       //         this->target->setParentSoft("Player");
    127       //       this->getParent()->debugNode(0);
    128 
    129       //      this->setParent("main-Turret");
    130       //      this->setParentMode(PNODE_ALL);
    131       //      this->target->setParentSoft("Player");
    132 
    133117      break;
    134118    case VIEW_FRONT:
    135119      this->toFovy = 120.0;
    136       /*       this->setParentSoft("Player");
    137              this->target->setParentSoft("Player");*/
    138120      this->setRelCoorSoft(4, 0, 0, 5);
    139121      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    140       //      this->target->setRelDirSoft(Quaternion(M_PI/4.0, Vector(0,1,0)));
    141122      break;
    142123    case VIEW_LEFT:
    143124      this->toFovy = 90;
    144       /*      this->setParentSoft("TrackNode");
    145             this->target->setParentSoft("TrackNode");*/
    146125      this->setRelCoorSoft(0, 1, -10, .5);
    147126      this->target->setRelCoorSoft(0,0,0);
     
    149128    case VIEW_RIGHT:
    150129      this->toFovy = 90;
    151       /*      this->setParentSoft("TrackNode");
    152             this->target->setParentSoft("TrackNode");*/
    153130      this->setRelCoorSoft(Vector(0, 1, 10));
    154131      this->target->setRelCoorSoft(0,0,0);
     
    156133    case VIEW_TOP:
    157134      this->toFovy= 120;
    158       /*      this->setParentSoft("TrackNode");
    159             this->target->setParentSoft("TrackNode");*/
    160135      this->setRelCoorSoft(Vector(30, 50, 0));
    161136      this->target->setRelCoorSoft(35,0,0);
  • trunk/src/world_entities/space_ships/hover.cc

    r6806 r6807  
    9999  this->setClassID(CL_HOVER, "Hover");
    100100
    101   PRINTF(4)("HOVER INIT\n");
    102 
    103   this->loadModel("models/ships/hover_#.obj", 1.0);
    104 
    105   EventHandler::getInstance()->grabEvents(true);
     101  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
     102  this->loadModel("models/ships/hoverglider_rotor.obj", 1.0f, 4);
     103  this->loadModel("models/ships/rotor.obj", .45f, 5);
    106104
    107105  bForward = bBackward = bLeft = bRight = bAscend = bDescend = false;
    108   xMouse = yMouse = 0;
    109   mouseSensitivity = 0.05;
    110   controlVelocityX = 100;
    111   controlVelocityY = 100;
     106  mouseSensitivity = 0.005;
    112107
    113108  this->rotorSpeed = 1000.0f;
    114109  this->rotorCycle = 0.0f;
     110  this->cameraLook = 0.0f;
     111  this->rotation = 0.0f;
    115112
    116113  // camera - issue
     
    138135  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    139136
    140   this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
    141   this->loadModel("models/ships/hoverglider_rotor.obj", 1.0f, 4);
    142   this->loadModel("models/ships/rotor.obj", .45f, 5);
    143137
    144138  //add events to the eventlist
     
    177171  this->getWeaponManager()->setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
    178172
    179   this->getWeaponManager()->getFixedTarget()->setParent(&(this->cameraNode));
     173  this->cameraNode.setRelCoor(1,5,0);
     174  this->getWeaponManager()->getFixedTarget()->setParent(&this->cameraNode);
     175  this->getWeaponManager()->getFixedTarget()->setRelCoor(1000,0,0);
    180176}
    181177
     
    192188{
    193189  State::getCamera()->setParentSoft(&this->cameraNode);
    194   State::getCameraTarget()->setParentSoft(this->getWeaponManager()->getFixedTarget());
    195 
     190  State::getCamera()->setRelCoorSoft(-10, 0,0);
     191  State::getCameraTarget()->setParentSoft(&this->cameraNode);
    196192}
    197193
     
    234230 */
    235231void Hover::collidesWith(WorldEntity* entity, const Vector& location)
    236 {
    237 }
     232{}
    238233
    239234
     
    246241{
    247242  Playable::tick(dt);
    248 
    249   if( xMouse != 0 || yMouse != 0)
    250   {
    251     if (xMouse > controlVelocityX) xMouse = controlVelocityX;
    252     else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
    253     if (yMouse > controlVelocityY) yMouse = controlVelocityY;
    254     else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
    255   }
    256243
    257244  // spaceship controlled movement
     
    262249
    263250  // this is the air friction (necessary for a smooth control)
    264   if(velocity.len() != 0) velocity -= velocity*0.1;
    265     this->shiftCoor (move);
    266 
     251  if(velocity.len() != 0)
     252    velocity -= velocity*0.1;
     253  this->shiftCoor (move);
     254
     255  this->rotation = 0.0f;
    267256}
    268257
     
    276265  float rotVal = .3;
    277266
    278   if( this->bForward )  {
     267  if( this->bForward ) {
    279268    accel += Vector(rotVal, 0, 0);
    280269  }
    281270
    282271  if( this->bBackward ) {
    283       accel -= Vector(rotVal,0,0);
     272    accel -= Vector(rotVal,0,0);
    284273  }
    285274  if( this->bLeft) {
    286275    accel -= Vector(0,0,rotVal);
    287276  }
     277
    288278  if( this->bRight) {
    289279    accel += Vector(0,0,rotVal);
     
    293283    accel += Vector(0,rotVal,0);
    294284  }
    295   if (this->bDescend )
    296     accel -= Vector(0,rotVal,0);
     285  if (this->bDescend ) {
     286       accel -= Vector(0,rotVal,0);
     287  }
    297288
    298289  velocity += accel * 3.0;
     
    300291  this->setRelDirSoft(this->direction * Quaternion(-accel.x, Vector(0,0,1)) * Quaternion(accel.z, Vector(1,0,0)), 5);
    301292
    302   this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z, Vector(1,0,0)), 10);
    303   this->rotorNodeLeft.setRelDirSoft(Quaternion(-2.0*accel.x, Vector(0,0,1)), 10);
    304 
    305   this->wingNodeRight.setRelDirSoft(Quaternion(accel.z, Vector(1,0,0)), 10);
    306   this->rotorNodeRight.setRelDirSoft(Quaternion(-2.0*accel.x, Vector(0,0,1)), 10);
     293  this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 10);
     294  this->rotorNodeLeft.setRelDirSoft(Quaternion(-2.0*accel.x+this->rotation, Vector(0,0,1)), 10);
     295
     296  this->wingNodeRight.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 10);
     297  this->rotorNodeRight.setRelDirSoft(Quaternion(-2.0*accel.x-this->rotation, Vector(0,0,1)), 10);
    307298}
    308299
     
    381372  else if( event.type == EV_MOUSE_MOTION)
    382373  {
    383     this->xMouse = event.xRel*mouseSensitivity;
    384     this->yMouse = event.yRel*mouseSensitivity;
     374    float xMouse, yMouse;
     375    xMouse = event.xRel*mouseSensitivity;
     376    yMouse = event.yRel*mouseSensitivity;
    385377
    386378    // rotate the Player around the y-axis
    387     this->direction *= Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0));
    388 
     379    this->direction *= Quaternion(-M_PI/4.0*xMouse, Vector(0,1,0));
     380    this->rotation += xMouse;
     381
     382    this->cameraLook += yMouse;
    389383    // rotate the Camera around the z-axis
    390     Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1));
    391     if ((this->cameraNode.getAbsDirY()).y < 0.5)
    392     {
    393       if((this->cameraNode.getAbsDirX()).y > 0)
    394       {
    395         if(yMouse > 0) this->cameraNode.shiftDir(yDir);
    396       }
    397       else
    398       {
    399         if(yMouse < 0) this->cameraNode.shiftDir(yDir);
    400       }
    401     }
    402     else this->cameraNode.shiftDir(yDir);
    403   }
    404 }
     384    if (cameraLook > M_PI_4)
     385      cameraLook = M_PI_4;
     386    else if (cameraLook < -M_PI_2)
     387      cameraLook = -M_PI_2;
     388    this->cameraNode.setRelDirSoft(Quaternion(-cameraLook, Vector(0,0,1)),5);
     389  }
     390}
  • trunk/src/world_entities/space_ships/hover.h

    r6806 r6807  
    4545    bool                  bDescend;           //!< descend button presses.
    4646
    47     float                 xMouse;             //!< mouse moved in x-Direction
    48     float                 yMouse;             //!< mouse moved in y-Direction
    4947    int                   yInvert;
    5048    float                 mouseSensitivity;   //!< the mouse sensitivity
    51     int                   controlVelocityX;
    52     int                   controlVelocityY;
    53     //float                 cycle;              //!< hovercycle
    5449
    5550    PNode                 wingNodeLeft;
     
    5954
    6055    PNode                 cameraNode;
     56    float                 cameraLook;
     57    float                 rotation;
    6158
    6259    Vector                velocity;           //!< the velocity of the Hover.
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6804 r6807  
    5656CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
    5757
    58 /**
    59  *  creates the controlable Spaceship
    60  */
    61 SpaceShip::SpaceShip()
    62 {
    63   this->init();
    64 }
    6558
    6659/**
  • trunk/src/world_entities/space_ships/space_ship.h

    r6804 r6807  
    2121
    2222  public:
    23 
    24     SpaceShip();
    2523    SpaceShip(const char* fileName);
    26     SpaceShip(const TiXmlElement* root);
     24    SpaceShip(const TiXmlElement* root = NULL);
    2725    virtual ~SpaceShip();
    2826
  • trunk/src/world_entities/weapons/crosshair.cc

    r6512 r6807  
    135135  this->shiftDir2D(dt * rotationSpeed);
    136136
    137 
     137/*
    138138  float z = 0.0f;
    139139  glReadPixels ((int)this->getAbsCoor2D().x,
     
    155155               &objX,
    156156               &objY,
    157                &objZ );
     157               &objZ );*/
    158158
    159159  //this->setAbsCoor(objX, objY, objZ);
     
    181181  glEnd();
    182182  glPopMatrix();
    183 
    184183}
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6803 r6807  
    104104  // CROSSHAIR INITIALISATION
    105105  this->crosshair = new Crosshair();
    106 
     106  //this->crosshair->setRelCoor(1000,0,0);
    107107  this->crossHairSizeAnim = new tAnimation<Crosshair>(this->crosshair, &Crosshair::setSize);
    108108  this->crossHairSizeAnim->setInfinity(ANIM_INF_REWIND);
Note: See TracChangeset for help on using the changeset viewer.