Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6114 in orxonox.OLD


Ignore:
Timestamp:
Dec 14, 2005, 5:51:23 PM (18 years ago)
Author:
snellen
Message:

control in space_ship.cc updated

Location:
branches/spaceshipcontrol/src/world_entities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/playable.h

    r5915 r6114  
    3434
    3535    virtual void process(const Event &event) = 0;
     36   
    3637
    3738
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6051 r6114  
    117117  bFire = false;
    118118  xMouse = yMouse = 0;
    119   mouseSensitivity = 0.005;
    120   airViscosity = 0.1;
     119  mouseSensitivity = 0.001;
     120  airViscosity = 1.0;
    121121  cycle = 0.0;
    122122
     
    124124  travelSpeed = 15.0;
    125125  this->velocity = Vector(0.0,0.0,0.0);
    126   this->velocityDir = Vector(1.0,0.0,0.0);
     126  this->mouseDir = this->getAbsDir();
    127127
    128128//   GLGuiButton* button = new GLGuiPushButton();
     
    174174//   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    175175
     176  this->getWeaponManager()->getFixedTarget()->setParent(this);
     177  this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0);
     178
    176179}
    177180
     
    264267  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    265268  velocity = (velocity.getNormalized())*travelSpeed;
    266 
     269 
     270  //orient the spaceship in direction of the mouse
     271   Quaternion rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time));
     272   if (this->getAbsDir().distance(rotQuat) > 0.001) 
     273     this->setAbsDir( Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)));
     274   //this->setAbsDirSoft(mouseDir,5);
     275   
    267276  // this is the air friction (necessary for a smooth control)
    268277  if(velocity.len() != 0) velocity -= velocity*0.01;
     
    337346  if( this->bRollL /* > -this->getRelCoor().z*2*/)
    338347  {
    339     this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     348    mouseDir *= Quaternion(-time, Vector(1,0,0));
    340349//    accel -= rightDirection;
    341350    //velocityDir.normalize();
     
    345354  if( this->bRollR /* > this->getRelCoor().z*2*/)
    346355  {
    347     this->shiftDir(Quaternion(time, Vector(1,0,0)));
     356    mouseDir *= Quaternion(time, Vector(1,0,0));
    348357
    349358    //    accel += rightDirection;
     
    413422    this->xMouse = event.xRel;
    414423    this->yMouse = event.yRel;
    415     this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     424    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     425   
    416426  }
    417427}
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h

    r6034 r6114  
    88
    99#include "playable.h"
     10
    1011
    1112template<class T> class tList;
     
    6465
    6566    Vector                velocity;           //!< the velocity of the player.
    66     Vector                velocityDir;        //!< the direction of the velocity of the spaceship
     67    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    6768    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6869    float                 acceleration;       //!< the acceleration of the player.
  • branches/spaceshipcontrol/src/world_entities/weapons/crosshair.cc

    r5978 r6114  
    6767  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    6868
    69 //  this->setBindNode(this);
     69  this->setBindNode(this);
    7070  this->material = new Material;
    7171
     
    166166{
    167167  glPushMatrix();
    168   glTranslatef(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2, 0);
     168  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    169169
    170170  glRotatef(this->getAbsDir2D(), 0,0,1);
  • branches/spaceshipcontrol/src/world_entities/weapons/laser.cc

    r5994 r6114  
    4545  this->energyMin = 1;
    4646  this->energyMax = 10;
    47   this->lifeSpan = 1.0;
     47  this->lifeSpan = 5.0;
    4848
    4949  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
  • branches/spaceshipcontrol/src/world_entities/weapons/test_gun.cc

    r6022 r6114  
    186186  pj->setParent(NullParent::getInstance());
    187187
    188   pj->setVelocity(this->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*50+VECTOR_RAND(5));
     188  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
    189189
    190190  pj->setAbsCoor(this->getEmissionPoint());
Note: See TracChangeset for help on using the changeset viewer.