Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3355 in orxonox.OLD for orxonox/branches/parenting


Ignore:
Timestamp:
Jan 6, 2005, 1:52:47 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: :Curve: bezierCurve now can have 0,1,2,3 points. instead of only more than 3

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

Legend:

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

    r3351 r3355  
    164164   \param t The position on the Curve (0<=t<=1)
    165165   \return the Position on the Path
    166    \todo implement nodeCount 0,1,2,3
    167166*/
    168167Vector BezierCurve::calcPos(float t)
    169168{
    170   if (nodeCount < 4)
    171     {
    172       //    if (verbose >= 1)
    173       //      printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);
    174       return Vector(0,0,0);
    175     }
    176   PathNode* tmpNode = firstNode;
    177169  Vector ret = Vector(0.0,0.0,0.0);
    178   double factor = pow(1.0-t,nodeCount-1);
    179   while(tmpNode)
    180     {
    181       ret.x += tmpNode->factor * factor * tmpNode->position.x;
    182       ret.y += tmpNode->factor * factor * tmpNode->position.y;
    183       ret.z += tmpNode->factor * factor * tmpNode->position.z;
    184       factor *= t/(1.0-t); // same as pow but much faster.
    185 
    186       tmpNode = tmpNode->next;
    187     }
     170  if (this->nodeCount >= 3)
     171    {
     172      PathNode* tmpNode = this->firstNode;
     173      double factor = pow(1.0-t,nodeCount-1);
     174      while(tmpNode)
     175        {
     176          ret.x += tmpNode->factor * factor * tmpNode->position.x;
     177          ret.y += tmpNode->factor * factor * tmpNode->position.y;
     178          ret.z += tmpNode->factor * factor * tmpNode->position.z;
     179          factor *= t/(1.0-t); // same as pow but much faster.
     180         
     181          tmpNode = tmpNode->next;
     182        }
     183    }
     184  else if (nodeCount == 2)
     185    {
     186      ret = this->firstNode->position *(1.0-t);
     187      ret = ret + this->firstNode->next->position * t;
     188    }
     189  else if (nodeCount == 1)
     190    ret = this->firstNode->position;
    188191  return ret;
    189192}
  • orxonox/branches/parenting/src/track_manager.cc

    r3354 r3355  
    180180void TrackManager::workOn(unsigned int trackID)
    181181{
    182   this->currentTrackElem = findTrackElementByID(trackID);
    183   printf("now Working on %d\n", trackID);
     182  TrackElement* tmpElem = findTrackElementByID(trackID);
     183  if (tmpElem)
     184    this->currentTrackElem = tmpElem;
     185  else
     186    printf("TrackElement not Found, leaving unchanged\n");
     187  printf("now Working on %d\n", this->currentTrackElem->ID);
     188
    184189}
    185190
  • orxonox/branches/parenting/src/world.cc

    r3354 r3355  
    244244      trackManager->addPoint(Vector(150,0,-10));
    245245      trackManager->setDuration(.5);
    246       int fork11, fork12;
    247       trackManager->fork(2, &fork11, &fork12);
     246      int fork11, fork12, fork13;
     247      trackManager->fork(3, &fork11, &fork12, &fork13);
    248248      trackManager->workOn(fork11);
    249249      trackManager->addPoint(Vector(170, 0, -15));
     
    254254      trackManager->addPoint(Vector(190,2,5));
    255255      trackManager->addPoint(Vector(200,2,5));
    256       trackManager->setSavePoint();
     256      int fork21, fork22;
     257      trackManager->fork(2, &fork21, &fork22);
     258      trackManager->workOn(fork21);
    257259      trackManager->addPoint(Vector(220, 10,-10));
    258260      trackManager->addPoint(Vector(230, 0,-10));
    259261      trackManager->addPoint(Vector(240, 0, 2));
    260262      trackManager->addPoint(Vector(250, 0, 0));
     263      trackManager->addPoint(Vector(260, 0, 5));
    261264      trackManager->join(2, fork12, fork11);
    262      
     265      trackManager->workOn(fork22);
     266      trackManager->addPoint(Vector(220, -10,10));
     267      trackManager->addPoint(Vector(230, 0, 10));
     268      trackManager->addPoint(Vector(240, 0, 10));
     269      trackManager->addPoint(Vector(250, 0, 5));
     270      trackManager->workOn(fork13);
     271      trackManager->addPoint(Vector(200,-10,5));
     272      trackManager->addPoint(Vector(250,-10,5));
     273      trackManager->join(3, fork21, fork22, fork13);
    263274      /*
    264275      tmpCurve->addNode(Vector(10,0,-10));
    265       tmpCurve->addNode(Vector(10,2,5));
    266       tmpCurve->addNode(Vector(10,3,-5));
    267       tmpCurve->addNode(Vector(10,1,5));
     276      //tmpCurve->addNode(Vector(10,2,5));
     277      //tmpCurve->addNode(Vector(10,3,-5));
     278      //      tmpCurve->addNode(Vector(10,1,5));
    268279      tmpCurve->addNode(Vector(10,0,5));
    269280      */
     
    563574    }
    564575  glEnd();
    565 
     576 
    566577  /*
    567578  glBegin(GL_LINE_STRIP);
     
    576587  trackManager->drawGraph(.01);
    577588  trackManager->debug(2);
     589  //  delete trackManager;
     590 
    578591  /*
    579592  glBegin(GL_LINES);
     
    584597      glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z);
    585598    }
     599  glEnd();
    586600  */
    587   glEnd();
    588601  glEndList();
    589602}
Note: See TracChangeset for help on using the changeset viewer.