Index: orxonox/branches/parenting/src/curve.cc
===================================================================
--- orxonox/branches/parenting/src/curve.cc	(revision 3347)
+++ orxonox/branches/parenting/src/curve.cc	(revision 3348)
@@ -24,4 +24,5 @@
 #include "curve.h"
 #include "matrix.h"
+#include "debug.h"
 
 #include <math.h>
@@ -113,15 +114,17 @@
 
   // rebuilding the Curve itself
-  int k=0;
-  int binCoef = 1;
-  while(tmpNode)
-    {
-      if (k+1 < nodeCount-k)
-	binCoef *=(nodeCount-k)/(k+1);
-      else
-	binCoef /= (k+1)/(nodeCount-k);
-      ++k;
+  float k=0;
+  float n = nodeCount -1;
+  float binCoef = 1;
+  printf("n=%f\n", n);
+  while(tmpNode)
+    {
       tmpNode->factor = binCoef;
-      tmpNode = tmpNode->next;
+      printf("bincoef: %f\n", binCoef);
+      if (tmpNode =tmpNode->next)
+	{
+	  binCoef *=(n-k)/(k+1);
+	  ++k;
+	}
     }
 
@@ -149,8 +152,9 @@
    \param t The position on the Curve (0<=t<=1)
    \return the Position on the Path
+   \todo implement nodeCount 0,1,2,3
 */
 Vector BezierCurve::calcPos(float t) 
 {
-  if (nodeCount <=4)
+  if (nodeCount < 4)
     {
       //    if (verbose >= 1)
@@ -160,11 +164,11 @@
   PathNode* tmpNode = firstNode;
   Vector ret = Vector(0.0,0.0,0.0);
-  float factor = 1.0*pow(1.0-t,nodeCount);
-  while(tmpNode)
-    {
-      factor *= t/(1.0-t); // same as pow but much faster.
+  double factor = pow(1.0-t,nodeCount-1);
+  while(tmpNode)
+    {
       ret.x += tmpNode->factor * factor * tmpNode->position.x;
       ret.y += tmpNode->factor * factor * tmpNode->position.y;
       ret.z += tmpNode->factor * factor * tmpNode->position.z;
+      factor *= t/(1.0-t); // same as pow but much faster.
 
       tmpNode = tmpNode->next;
Index: orxonox/branches/parenting/src/track_manager.cc
===================================================================
--- orxonox/branches/parenting/src/track_manager.cc	(revision 3347)
+++ orxonox/branches/parenting/src/track_manager.cc	(revision 3348)
@@ -35,8 +35,8 @@
   this->ID = -1;
   this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
-  this->duration =0;
+  this->duration = 1;
   this->curveType = BEZIERCURVE;
   this->nodeCount = 0;
-  childCount = 0;
+  this->childCount = 0;
   this->name = NULL;
   this->curve = NULL;
@@ -102,9 +102,10 @@
 
   PRINTF(3)("Initializing the TrackManager\n");
-  this->firstTrackElem = new TrackElement;
+  this->firstTrackElem = new TrackElement();
+  this->firstTrackElem->ID = 1;
   this->currentTrackElem = firstTrackElem;
   this->localTime = 0;
   this->maxTime = 0;
-  this->trackElemCount = 0;
+  this->trackElemCount = 1;
 }
 
@@ -146,9 +147,12 @@
 void TrackManager::initChildren(unsigned int childCount)
 {
-  trackElemCount = 0;
   this->currentTrackElem->childCount = childCount;
   this->currentTrackElem->children = new TrackElement*[childCount];
   for (int i=0; i<childCount; i++)
-    this->currentTrackElem->children[i] = new TrackElement();
+    {
+      this->currentTrackElem->children[i] = new TrackElement();
+      this->currentTrackElem->children[i]->ID = ++trackElemCount;
+      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration;
+    }
 }
 
@@ -252,4 +256,5 @@
 
   this->initChildren(1);
+  this->currentTrackElem = this->currentTrackElem->children[0];
 }
 
@@ -344,5 +349,6 @@
 Vector TrackManager::calcPos() const
 {
-  return this->currentTrackElem->curve->calcPos(this->localTime);
+  //  PRINTF(0)("TrackElement:%d, localTime: %f\n",this->currentTrackElem->ID, this->localTime);
+  return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
 }
 
@@ -353,5 +359,5 @@
 Vector TrackManager::calcDir() const
 {
-  return this->currentTrackElem->curve->calcDir(this->localTime);
+  return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
 }
 
@@ -364,5 +370,9 @@
 void TrackManager::tick(float dt)
 {
+  if (this->localTime <= this->firstTrackElem->duration)
+    this->jumpTo(this->localTime);
   this->localTime += dt;
+  if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0)
+    this->currentTrackElem = this->currentTrackElem->children[0];
 }
 
@@ -376,5 +386,7 @@
 void TrackManager::jumpTo(float time)
 {
-  localTime = time;
+  if (time == 0)
+    this->currentTrackElem = this->firstTrackElem;
+  this->localTime = time;
 }
 
Index: orxonox/branches/parenting/src/world.cc
===================================================================
--- orxonox/branches/parenting/src/world.cc	(revision 3347)
+++ orxonox/branches/parenting/src/world.cc	(revision 3348)
@@ -220,7 +220,29 @@
 void World::load()
 {
+  //  BezierCurve* tmpCurve = new BezierCurve();
   if(this->debugWorldNr != -1)
     {
       trackManager = TrackManager::getInstance();
+      trackManager->addPoint(Vector(0,-5,0));
+      trackManager->addPoint(Vector(10,0,5));
+      trackManager->addPoint(Vector(20,0,-5));
+      trackManager->addPoint(Vector(30,0,5));
+      trackManager->addPoint(Vector(40,0,5));
+      trackManager->setDuration(.5);
+      trackManager->setSavePoint();
+      trackManager->addPoint(Vector(50,10,10));
+      trackManager->addPoint(Vector(60,0, 10));
+      trackManager->addPoint(Vector(70,0, 10));
+      trackManager->addPoint(Vector(80,0,-10));
+      trackManager->addPoint(Vector(90,0,-10));
+      trackManager->setDuration(.5);
+      
+      /*
+      tmpCurve->addNode(Vector(10,0,-10));
+      tmpCurve->addNode(Vector(10,2,5));
+      tmpCurve->addNode(Vector(10,3,-5));
+      tmpCurve->addNode(Vector(10,1,5));
+      tmpCurve->addNode(Vector(10,0,5));
+      */
       switch(this->debugWorldNr)
 	{
@@ -526,5 +548,20 @@
     }
   glEnd();
-
+  float i;
+  glBegin(GL_LINES);
+  for(i = 0.0; i<1; i+=.01)
+    {
+      trackManager->tick (.01);
+      printf("%f, %f, %f\n",trackManager->calcPos().x, trackManager->calcPos().y, trackManager->calcPos().z);
+      glVertex3f(trackManager->calcPos().x, trackManager->calcPos().y, trackManager->calcPos().z);
+    }
+  /*
+  for(i = 0.0; i<1; i+=.01)
+    {
+      printf("%f, %f, %f\n",tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z);
+      glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z);
+    }
+  */
+  glEnd();
   glEndList();
 }
