Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3373 in orxonox.OLD for orxonox/branches/trackManager/src


Ignore:
Timestamp:
Jan 7, 2005, 5:17:27 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: patched:
problem with timeTable solved
self-producing start ofChildren in initChildren.

Location:
orxonox/branches/trackManager/src
Files:
3 edited

Legend:

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

    r3372 r3373  
    3838  this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
    3939  this->duration = 1;
     40  this->endTime = 1;
     41  this->jumpTime = 0;
    4042  this->curveType = BEZIERCURVE;
    4143  this->nodeCount = 0;
    4244  this->childCount = 0;
    4345  this->name = NULL;
    44   this->startPoint = Vector(0,0,0);
    45   this->startTangentPoint = Vector(0,0,0);
    4646  this->curve = NULL;
    4747  this->children = NULL;
     
    157157      this->currentTrackElem->children[i] = new TrackElement();
    158158      this->currentTrackElem->children[i]->ID = ++trackElemCount;
    159       this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration;
    160       this->currentTrackElem->children[i]->startPoint = this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount());
    161       this->currentTrackElem->children[i]->startTangentPoint = (this->currentTrackElem->children[i]->startPoint *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1);
     159      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime;
     160      this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]);
     161      this->addPoint((this->currentTrackElem->children[i]->curve->getNode(0) *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1),  this->currentTrackElem->children[i]);
    162162    }
    163163}
     
    194194   \brief curveType The Type to set
    195195*/
    196 void TrackManager::setCurveType(CurveType curveType)
    197 {
    198   if (!this->currentTrackElem->isFresh)
     196void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem)
     197{
     198  if (!trackElem->isFresh)
    199199    {
    200200      PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n");
    201201      return;
    202202    }
    203   this->currentTrackElem->curveType = curveType;
     203  trackElem->curveType = curveType;
    204204  switch (curveType)
    205205    {
    206206    case BEZIERCURVE:
    207       this->currentTrackElem->curve = new BezierCurve();
     207      trackElem->curve = new BezierCurve();
    208208      break;
    209209    case UPOINTCURVE:
    210       this->currentTrackElem->curve = new UPointCurve();
     210      trackElem->curve = new UPointCurve();
    211211      break;
    212212    }
     
    221221{
    222222  this->currentTrackElem->duration = time;
     223  this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time;
    223224}
    224225
     
    241242  if (trackElem->isFresh)
    242243    {
    243       this->setCurveType(BEZIERCURVE);
     244      this->setCurveType(BEZIERCURVE, trackElem);
    244245      trackElem->isFresh = false;
    245       if(trackElem != this->firstTrackElem)
    246         {
    247           this->addPoint(trackElem->startPoint);
    248           this->addPoint(trackElem->startTangentPoint);
    249         }
    250246    }
    251247  trackElem->curve->addNode(newPoint);
     
    380376  int tmpCurrentWorkingID = this->currentTrackElem->ID;
    381377  this->workOn(trackIDs[0]);
     378  float tmpLatestTime = this->currentTrackElem->endTime;
    382379
    383380  TrackElement* firstJoint = this->currentTrackElem;
     
    388385  if(!firstJoint->isHotPoint)
    389386    this->setSavePoint();
    390 
     387  // Timing:
     388  for (int i = 0; i < count; i++)
     389    {
     390      TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]);
     391      if (tmpJoinElem->childCount == 0
     392          && tmpJoinElem->endTime > tmpLatestTime)
     393            tmpLatestTime = tmpJoinElem->endTime;
     394    }
     395  // Joining:
    391396  for (int i = 1; i < count; i++)
    392397    {
     
    398403          this->addPoint(tmpTangentPoint, tmpJoinElem);
    399404          this->addPoint(tmpEndPoint, tmpJoinElem);
     405          tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime;
    400406         
    401407          //Copying Joint-Info
     
    404410          tmpJoinElem->isSavePoint = firstJoint->isSavePoint;
    405411          tmpJoinElem->isFork = firstJoint->isFork;
    406          
     412
    407413          tmpJoinElem->isJoined = true;
    408414        }
    409415    }
     416  if(currentTrackElem->children)
     417    for(int i = 0; i > currentTrackElem->childCount; i++)
     418      currentTrackElem->children[i]->startingTime = tmpLatestTime;
     419
    410420  // returning to the TrackElement we were working on.
    411421  this->workOn(tmpCurrentWorkingID);
     
    430440Vector TrackManager::calcDir() const
    431441{
    432   return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
     442  return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
    433443}
    434444
     
    442452{
    443453  dt /= 1000;
    444   printf("LocalTime is: %f, timestep is: %f\n", this->localTime, dt);
     454  printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    445455  if (this->localTime <= this->firstTrackElem->duration)
    446456    this->jumpTo(this->localTime);
    447457  this->localTime += dt;
    448   if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0)
    449     this->currentTrackElem = this->currentTrackElem->children[0];
     458  if (this->localTime > this->currentTrackElem->endTime
     459      && this->currentTrackElem->children)
     460    {
     461      if (this->currentTrackElem->jumpTime > 0)
     462        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     463      this->currentTrackElem = this->currentTrackElem->children[0];
     464    }
    450465  if (this->bindSlave)
    451466    {
     
    535550          if(tmpElem->isFresh)
    536551            printf("   has not jet eddited in any way\n");
    537           printf("\n   TimeTable: starting at = %f; ends at = %f; duration = %f\n", tmpElem->startingTime, tmpElem->startingTime+tmpElem->duration, tmpElem->duration);
     552          printf("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime);
    538553          printf("   consists of %d Points\n", tmpElem->nodeCount);
    539554          if (tmpElem->childCount == 0)
  • orxonox/branches/trackManager/src/track_manager.h

    r3371 r3373  
    4646  float startingTime;        //!< The time at which this Track begins.
    4747  float duration;            //!< The time used to cross this TrackElement (curve).
     48  float endTime;             //!< The time at which this Track ends.
     49  float jumpTime;            //!< The Time this Track has to jump to its preceding Track (only >0 if Track isJoined==true)
    4850  CurveType curveType;       //!< The CurveType this will have.
    4951  int nodeCount;             //!< The count of points this TrackElement has.
    5052  char* name;                //!< A name for the Trac.
    51   Vector startPoint;         //!< A Vector that Points to the first point of the containing Curve. (for c1-steadiness)
    52   Vector startTangentPoint;  //!< A Vector that points into the direction of the previous Curve. (for c1-steadiness)
    5353  Curve* curve;              //!< The Curve of this TrackElement
    5454  int childCount;            //!< The number of Children This TrackElement has.
     
    117117  // Methods to change the Path (initialisation)
    118118  void workOn(unsigned int trackID);
    119   void setCurveType(CurveType curveType);
     119  inline void setCurveType(CurveType curveType) { this->setCurveType (curveType, this->currentTrackElem);}
     120  void setCurveType(CurveType curveType, TrackElement* trackElem);
    120121  void setDuration(float time);
    121122  bool addPoint(Vector newPoint);
  • orxonox/branches/trackManager/src/world.cc

    r3371 r3373  
    226226      trackManager->addPoint(Vector(210,0,10));
    227227      trackManager->setDuration(1);
    228 
    229 
    230228      trackManager->join(4, fork21, fork22, fork13, fork14);
    231 
     229      trackManager->workOn(10);
     230      trackManager->addPoint(Vector(250,-10,5));
     231     
    232232      /*
    233233      tmpCurve->addNode(Vector(10,0,-10));
Note: See TracChangeset for help on using the changeset viewer.