Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 6, 2005, 3:03:54 AM (21 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: fixed major flaw in BezierCurve-calculation. before all BezierCurves started in the Origin. Now they are realy bezier-curves.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/track_manager.cc

    r3335 r3348  
    3535  this->ID = -1;
    3636  this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
    37   this->duration =0;
     37  this->duration = 1;
    3838  this->curveType = BEZIERCURVE;
    3939  this->nodeCount = 0;
    40   childCount = 0;
     40  this->childCount = 0;
    4141  this->name = NULL;
    4242  this->curve = NULL;
     
    102102
    103103  PRINTF(3)("Initializing the TrackManager\n");
    104   this->firstTrackElem = new TrackElement;
     104  this->firstTrackElem = new TrackElement();
     105  this->firstTrackElem->ID = 1;
    105106  this->currentTrackElem = firstTrackElem;
    106107  this->localTime = 0;
    107108  this->maxTime = 0;
    108   this->trackElemCount = 0;
     109  this->trackElemCount = 1;
    109110}
    110111
     
    146147void TrackManager::initChildren(unsigned int childCount)
    147148{
    148   trackElemCount = 0;
    149149  this->currentTrackElem->childCount = childCount;
    150150  this->currentTrackElem->children = new TrackElement*[childCount];
    151151  for (int i=0; i<childCount; i++)
    152     this->currentTrackElem->children[i] = new TrackElement();
     152    {
     153      this->currentTrackElem->children[i] = new TrackElement();
     154      this->currentTrackElem->children[i]->ID = ++trackElemCount;
     155      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration;
     156    }
    153157}
    154158
     
    252256
    253257  this->initChildren(1);
     258  this->currentTrackElem = this->currentTrackElem->children[0];
    254259}
    255260
     
    344349Vector TrackManager::calcPos() const
    345350{
    346   return this->currentTrackElem->curve->calcPos(this->localTime);
     351  //  PRINTF(0)("TrackElement:%d, localTime: %f\n",this->currentTrackElem->ID, this->localTime);
     352  return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
    347353}
    348354
     
    353359Vector TrackManager::calcDir() const
    354360{
    355   return this->currentTrackElem->curve->calcDir(this->localTime);
     361  return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
    356362}
    357363
     
    364370void TrackManager::tick(float dt)
    365371{
     372  if (this->localTime <= this->firstTrackElem->duration)
     373    this->jumpTo(this->localTime);
    366374  this->localTime += dt;
     375  if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0)
     376    this->currentTrackElem = this->currentTrackElem->children[0];
    367377}
    368378
     
    376386void TrackManager::jumpTo(float time)
    377387{
    378   localTime = time;
     388  if (time == 0)
     389    this->currentTrackElem = this->firstTrackElem;
     390  this->localTime = time;
    379391}
    380392
Note: See TracChangeset for help on using the changeset viewer.