Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2006, 7:00:44 PM (17 years ago)
Author:
nicolasc
Message:

updated swarm_projectile, model included in data
TE2 tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/projectiles/projectile.cc

    r10020 r10035  
    167167 *  @return normalized (new) direction vector
    168168*/
    169 Vector Projectile::newDirection(Vector curDirection, Vector estTargetDir, float angle)
    170 {
    171   float tmp = angleDeg ( curDirection, estTargetDir);
    172   if (tmp == 0) { return curDirection; }
    173 
    174   if( angle >  tmp ) { angle = tmp; }
    175 
    176   //Vector n = curDirection.cross(estTargetDir);
    177   //Vector d = n.cross(curDirection);
    178   Vector d = curDirection.cross(estTargetDir).cross(curDirection);
    179   d.normalize();
    180   if( angle == 90) { return d; }
    181 
    182   Vector newDir = curDirection + d *  curDirection.len() * tan (angle);
    183   newDir.normalize();
    184   return newDir;
    185 }
     169// Vector Projectile::newDirection(Vector curDirection, Vector estTargetDir, float angle)
     170// {
     171//   float tmp = angleDeg ( curDirection, estTargetDir);
     172//   if ( unlikely(tmp == 0) ) { return curDirection; }
     173//
     174//   if( fabsf(angle) >  fabsf(tmp) ) { angle = tmp; }
     175//
     176//   Vector d = curDirection.cross(estTargetDir).cross(curDirection);
     177//   d.normalize();
     178//   if( unlikely( angle == 90)) { return d; }
     179//
     180//   Vector newDir = curDirection + d *  curDirection.len() * tan (angle);
     181//   newDir.normalize();
     182//   return newDir;
     183// }
    186184
    187185
     
    192190void Projectile::tick (float dt)
    193191{
    194   float tti = 0;  //!< time to impact
    195   Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity());
    196   this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * dt ) * this->velocity.len();
    197   Vector v = this->velocity * (dt);
    198   this->shiftCoor(v);
     192/*
     193  if (target != NULL){
     194    float tti = this->target->getRelCoor().len() / this->getVelocity().len();
     195    Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti;
     196    this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * dt ) * this->velocity.len();
     197    Vector v = this->velocity * (dt);
     198    this->shiftCoor(v);
     199  }*/
    199200
    200201  if (this->tickLifeCycle(dt))
Note: See TracChangeset for help on using the changeset viewer.