Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10454 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 28, 2007, 6:35:43 PM (18 years ago)
Author:
patrick
Message:

track now got constant speed

Location:
trunk/src/util/track
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/track/track.cc

    r10449 r10454  
    132132{
    133133     this->duration = this->duration/speed;
    134 
     134     this->speed = speed;
    135135}
    136136
     
    206206//     this->jumpTo(this->localTime);
    207207//   if (this->localTime <= this->maxTime)
    208      if(this->mode == 0)
    209      {
    210           if(this->localTime < this->duration)
    211              this->localTime += dt;
    212      }
    213      else
    214      {
    215          this->localTime += dt;
    216          if(this->localTime >= this->duration)
    217             this->localTime = 0;
    218      }
     208
    219209
    220210//   if (this->localTime > this->currentTrackElem->endTime
     
    235225   if (this->trackNode)
    236226     {
     227       // tmp save
     228        float oldTime = this->localTime;
     229
     230        if(this->mode == 0)
     231        {
     232              if(this->localTime < this->duration)
     233                this->localTime += dt;
     234        }
     235        else
     236        {
     237            this->localTime += dt;
     238            if(this->localTime >= this->duration)
     239                this->localTime = 0;
     240        }
     241
    237242       Vector tmp = this->calcPos();
    238        //Quaternion quat = Quaternion(this->calcDir(), Vector(this->curve->calcAcc(this->localTime/this->duration).x,1,this->curve->calcAcc(this->localTime/this->duration).z));
    239 
     243
     244
     245       Vector dV = tmp - this->trackNode->getAbsCoor();
     246       float dx = speed * dt;
     247       float ratio = dx / dV.len();
     248
     249       if( dt > 0.0f)
     250       {
     251          float newDt = dt * ratio;
     252          this->localTime = oldTime += newDt;
     253       }
     254       tmp = this->calcPos();
    240255
    241256       Vector v(0.0, 1.0, 0.0);
  • trunk/src/util/track/track.h

    r10410 r10454  
    3838
    3939   //float                 startingTime;         //!< The time at which this Track begins.
     40   float                 speed;
    4041   float                 duration;             //!< The time used to cross this Track (curve).
    4142   float                 endTime;              //!< The time at which this Track ends.
Note: See TracChangeset for help on using the changeset viewer.