Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6131 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities


Ignore:
Timestamp:
Dec 16, 2005, 4:18:16 PM (19 years ago)
Author:
snellen
Message:

guided_missile.cc in /world_entities/weapon updated

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

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6114 r6131  
    269269 
    270270  //orient the spaceship in direction of the mouse
    271    Quaternion rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time));
     271   rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    272272   if (this->getAbsDir().distance(rotQuat) > 0.001) 
    273      this->setAbsDir( Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)));
     273    this->setAbsDir( rotQuat);
    274274   //this->setAbsDirSoft(mouseDir,5);
    275275   
     
    423423    this->yMouse = event.yRel;
    424424    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    425    
     425    if( xMouse*xMouse + yMouse*yMouse < 0.9)
     426     this->setAbsDir(mouseDir);
    426427  }
    427428}
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h

    r6114 r6131  
    6666    Vector                velocity;           //!< the velocity of the player.
    6767    Quaternion            mouseDir;           //!< the direction where the player wants to fly
     68    Quaternion rotQuat;
    6869    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6970    float                 acceleration;       //!< the acceleration of the player.
  • branches/spaceshipcontrol/src/world_entities/weapons/guided_missile.cc

    r6044 r6131  
    4949  this->energyMax = 10;
    5050  this->lifeSpan = 5.0;
    51   this->agility = 0.1;
    52   this->maxVelocity = 100;
     51  this->agility = 50;
     52  this->maxVelocity = 300;
    5353
    5454  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     
    150150*/
    151151void GuidedMissile::tick (float time)
    152 {
     152{
     153
     154   
    153155
    154156  if (target != NULL && target->getParent() != NullParent::getInstance())
    155157   {
    156      float speed = velocity.len();
    157 
    158      velocity += (((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*speed - velocity)*agility;
    159      velocity *= (velocity.getNormalized())*speed;
    160 
    161 
    162      velocity *= maxVelocity/speed;
     158    float speed = velocity.len();
     159    Vector diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized());
     160
     161     if (velocity.dot(diffVector) != 0)
     162
     163      if(velocity.dot(diffVector) > 0)
     164       velocity += ( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) ) - velocity).getNormalized()) * agility;
     165      else
     166       velocity -= ( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) ) - velocity).getNormalized()) * agility;
     167
     168     else
     169      velocity += diffVector * agility;
    163170
    164171     this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
    165172   }
    166173
     174  velocity *= maxVelocity/velocity.len();
    167175  Vector v = this->velocity * (time);
    168176  this->shiftCoor(v);
Note: See TracChangeset for help on using the changeset viewer.