Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10153 in orxonox.OLD


Ignore:
Timestamp:
Dec 28, 2006, 11:44:44 AM (18 years ago)
Author:
nicolasc
Message:

bump

File:
1 edited

Legend:

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

    r10132 r10153  
    216216  this->shiftCoor(v);*/
    217217
     218
     219/** old  guiding functuion*/
     220
    218221  float projectileVelocity = this->getVelocity().len();
    219222  if (target != NULL){
    220 /*    float tti;  //Time To Impact*/
    221 //     float targetVelocity = this->target->getVelocity().len();
    222 //     if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably
    223 //       tti = 1; // we do have a problem....
    224 //     else
    225 //       tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);
    226223    Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();
    227 //     estTargetDir.slerpTo(this->velocity, 1);
    228224    this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );
    229225  }
     
    235231//   printf("target position: %f, %f, %f\n", this->target->getAbsCoor().x, this->target->getAbsCoor().y, this->target->getAbsCoor().z);
    236232
    237   this->shiftCoor(this->velocity * (time));
     233  this->shiftCoor(this->velocity * time);
     234
     235
     236/*
     237  Vector pjV = this->getVelocity();
     238  Vector tV = this->target->getVelocity();
     239  Vector pT = this->target->getAbsCoor() - this->getAbsCoor(); // vector projectile target
     240
     241  Vector a = tV.getNormalized() * pT.dot(tV.getNormalized());
     242
     243  float A = 2 * pT.len() * pT.len();
     244  float B = 2 * a.len() * tV.len();
     245  float D = 2 * sqrt(B * B - 4 * pT.len() * pT.len() *(tV.len() * tV.len() - pjV.len() * pjV.len()));
     246  float tti;
     247
     248  if (A != 0){
     249    if ( B < D ) tti = ( B + D ) / A;
     250    else tti = ( B + D ) / A;
     251  }
     252  else tti = 0;
     253
     254
     255  Vector estTargetDir;
     256  if (tti == 0)
     257    estTargetDir = pT.getNormalized() * pjV.len();
     258  else
     259    estTargetDir = pT / tti + pjV;
     260
     261  this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );
     262
     263  this->shiftCoor(this->velocity * (this->maxVelocity * time));*/
    238264
    239265  if(this->tickLifeCycle(time))
     
    246272  this->lastDir = this->curDir;
    247273  this->curDir = this->velocity;
     274/*
    248275  if( (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3)   // FIXME  Temp fake workaround for collision :)
    249276  {
    250277    dynamic_cast<WorldEntity*>(target)->destroy( this);
    251278    this->destroy( this);
    252   }
     279  }*/
    253280}
    254281
Note: See TracChangeset for help on using the changeset viewer.