Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10087 in orxonox.OLD for branches/playability/src/world_entities


Ignore:
Timestamp:
Dec 17, 2006, 9:48:31 PM (18 years ago)
Author:
nicolasc
Message:

smoother drawing, or not

Location:
branches/playability/src/world_entities/projectiles
Files:
2 edited

Legend:

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

    r10086 r10087  
    114114  this->rotationSpeed = 360;
    115115  this->angle = 0;
     116
     117  this->curDir = this->lastDir = this->velocity;
    116118}
    117119
     
    210212
    211213  float projectileVelocity = this->getVelocity().len();
    212 //   if (target != NULL){
    213     float tti;  //Time To Impact
    214     float targetVelocity = this->target->getVelocity().len();
    215     if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably
    216       tti = 1; // we do have a problem....
    217     else
    218       tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);
     214  if (target != NULL){
     215/*    float tti;  //Time To Impact*/
     216//     float targetVelocity = this->target->getVelocity().len();
     217//     if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably
     218//       tti = 1; // we do have a problem....
     219//     else
     220//       tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);
    219221    Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized() * maxVelocity;
    220 //     Vector estTargetDir = (this->target->getAbsCoor() - (Vector(2000, 30, 300) + VECTOR_RAND(20))).getNormalized() * projectileVelocity;
    221222    this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );
    222 //   }
    223 //   else
    224 //     if (likely(projectileVelocity != 0))
    225 //       this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max
     223  }
     224  else
     225    if (likely(projectileVelocity != 0))
     226      this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max
    226227
    227228//   printf("position: %f, %f, %f\n", this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
     
    233234    this->deactivate();
    234235
    235   this->updateAngle(time);
    236 
    237236  this->trail->tick(time);
     237
     238  this->angle += this->rotationSpeed * time;
     239
     240  this->lastDir = this->curDir;
     241  this->curDir = this->velocity;
    238242}
    239243
     
    257261}
    258262
    259 void SwarmProjectile::updateAngle(float time)
    260 {
    261   this->angle += this->rotationSpeed * time;
    262 }
    263263
    264264void SwarmProjectile::draw () const
     
    267267  glPushMatrix();
    268268
     269  Vector tmpDir = this->curDir *.5 + this->lastDir * .5;
     270
    269271  float matrix[4][4];
    270272  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    271   Vector tmpRot = this->getAbsCoor().cross(this->velocity);
    272   glRotatef (angleRad ( this->getAbsCoor(), this->velocity), tmpRot.x, tmpRot.y, tmpRot.z );
     273  Vector tmpRot = this->getAbsCoor().cross(tmpDir);
     274  glRotatef (angleDeg ( this->getAbsCoor(), tmpDir), tmpRot.x, tmpRot.y, tmpRot.z );
    273275  glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile
    274276  this->getAbsDir().matrix (matrix);
  • branches/playability/src/world_entities/projectiles/swarm_projectile.h

    r10081 r10087  
    4848    Vector                            correctionVector;
    4949
     50    Vector                            curDir;
     51    Vector                            lastDir;
     52
    5053    WorldEntity* hitEntity; // FIXME TEMPORARY
    5154
     
    5356
    5457    // spinning missle
    55     void updateAngle(float time);
    5658    float                             rotationSpeed;
    5759    float                             angle;
Note: See TracChangeset for help on using the changeset viewer.