Index: orxonox/trunk/configure
===================================================================
--- orxonox/trunk/configure	(revision 3429)
+++ orxonox/trunk/configure	(revision 3433)
@@ -6442,5 +6442,5 @@
 done
 
- if test xjpegHeader = xno; then
+ if test x$jpegHeader = xno; then
 	echo " not including jpeg."
  else
Index: orxonox/trunk/src/Makefile.am
===================================================================
--- orxonox/trunk/src/Makefile.am	(revision 3429)
+++ orxonox/trunk/src/Makefile.am	(revision 3433)
@@ -18,5 +18,4 @@
 		 ini_parser.cc \
 		 keynames.cc \
-		 track.cc \
 		 base_entity.cc \
 		 game_loader.cc \
@@ -45,4 +44,5 @@
 		 npc.h \
 		 stdincl.h \
+		 glincl.h \
 		 ai.h \
 		 environment.h \
@@ -52,5 +52,4 @@
 		 error.h \
 		 player.h \
-		 track.h \
 		 camera.h \
 		 ini_parser.h \
Index: orxonox/trunk/src/Makefile.in
===================================================================
--- orxonox/trunk/src/Makefile.in	(revision 3429)
+++ orxonox/trunk/src/Makefile.in	(revision 3433)
@@ -57,12 +57,12 @@
 	world_entity.$(OBJEXT) vector.$(OBJEXT) camera.$(OBJEXT) \
 	command_node.$(OBJEXT) ini_parser.$(OBJEXT) keynames.$(OBJEXT) \
-	track.$(OBJEXT) base_entity.$(OBJEXT) game_loader.$(OBJEXT) \
-	campaign.$(OBJEXT) story_entity.$(OBJEXT) \
-	environment.$(OBJEXT) model.$(OBJEXT) objModel.$(OBJEXT) \
-	array.$(OBJEXT) material.$(OBJEXT) texture.$(OBJEXT) \
-	list.$(OBJEXT) p_node.$(OBJEXT) null_parent.$(OBJEXT) \
-	base_object.$(OBJEXT) helper_parent.$(OBJEXT) \
-	track_manager.$(OBJEXT) matrix.$(OBJEXT) curve.$(OBJEXT) \
-	glmenu_imagescreen.$(OBJEXT) skysphere.$(OBJEXT)
+	base_entity.$(OBJEXT) game_loader.$(OBJEXT) campaign.$(OBJEXT) \
+	story_entity.$(OBJEXT) environment.$(OBJEXT) model.$(OBJEXT) \
+	objModel.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \
+	texture.$(OBJEXT) list.$(OBJEXT) p_node.$(OBJEXT) \
+	null_parent.$(OBJEXT) base_object.$(OBJEXT) \
+	helper_parent.$(OBJEXT) track_manager.$(OBJEXT) \
+	matrix.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \
+	skysphere.$(OBJEXT)
 orxonox_OBJECTS = $(am_orxonox_OBJECTS)
 orxonox_LDADD = $(LDADD)
@@ -87,7 +87,6 @@
 @AMDEP_TRUE@	./$(DEPDIR)/player.Po ./$(DEPDIR)/skysphere.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/texture.Po \
-@AMDEP_TRUE@	./$(DEPDIR)/track.Po ./$(DEPDIR)/track_manager.Po \
-@AMDEP_TRUE@	./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \
-@AMDEP_TRUE@	./$(DEPDIR)/world_entity.Po
+@AMDEP_TRUE@	./$(DEPDIR)/track_manager.Po ./$(DEPDIR)/vector.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/world.Po ./$(DEPDIR)/world_entity.Po
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
@@ -228,5 +227,4 @@
 		 ini_parser.cc \
 		 keynames.cc \
-		 track.cc \
 		 base_entity.cc \
 		 game_loader.cc \
@@ -255,4 +253,5 @@
 		 npc.h \
 		 stdincl.h \
+		 glincl.h \
 		 ai.h \
 		 environment.h \
@@ -262,5 +261,4 @@
 		 error.h \
 		 player.h \
-		 track.h \
 		 camera.h \
 		 ini_parser.h \
@@ -318,7 +316,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/Makefile
+	  $(AUTOMAKE) --gnu  src/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@@ -398,5 +396,4 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texture.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track_manager.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector.Po@am__quote@
Index: orxonox/trunk/src/console/Makefile.in
===================================================================
--- orxonox/trunk/src/console/Makefile.in	(revision 3429)
+++ orxonox/trunk/src/console/Makefile.in	(revision 3433)
@@ -203,7 +203,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/console/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/console/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/console/Makefile
+	  $(AUTOMAKE) --gnu  src/console/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/trunk/src/curve.cc
===================================================================
--- orxonox/trunk/src/curve.cc	(revision 3429)
+++ orxonox/trunk/src/curve.cc	(revision 3433)
@@ -40,5 +40,5 @@
     }
   currentNode->position = newNode;
-  currentNode->next = 0; // not sure if this really points to NULL!!
+  currentNode->next = 0;
   currentNode->number = (++nodeCount);
   this->rebuild();
@@ -46,4 +46,45 @@
 }
 
+void Curve::addNode(const Vector& newNode, unsigned int insertPosition)
+{
+
+  if (this->nodeCount == 0 || insertPosition > this->nodeCount)
+    return addNode(newNode);
+
+  if (insertPosition == 0)
+    insertPosition = 1;
+
+  PathNode* insNode = new PathNode;
+
+  // relinking
+  PathNode* tmpNode = this->firstNode;
+  if (insertPosition > 1)
+    {
+      while (tmpNode->next->number != insertPosition)
+	tmpNode= tmpNode->next;
+      insNode->next = tmpNode->next;
+      tmpNode->next = insNode;
+    }
+  else
+    {
+      insNode->next = this->firstNode;
+      this->firstNode = insNode;
+    }
+  // renumbering
+  insNode->number = insertPosition;
+  tmpNode = insNode->next;
+  while (tmpNode)
+    {
+      tmpNode->number++;
+      tmpNode = tmpNode->next;
+    }
+
+    // finished
+  insNode->position = newNode;
+  ++nodeCount;
+  this->rebuild();
+  return;
+}
+
 /**
    \brief Finds a Node by its Number, and returns its Position
@@ -53,5 +94,5 @@
 Vector Curve::getNode(unsigned int nodeToFind)
 {
-  if (nodeToFind > this->nodeCount)
+  if (nodeToFind > this->nodeCount || nodeToFind < 0)
     return Vector(0,0,0);
   PathNode* tmpNode = this->firstNode;
@@ -60,4 +101,22 @@
   return tmpNode->position;
 }
+
+/**
+   \brief Outputs information about the state of this Curve
+*/
+void Curve::debug(void)
+{
+  printf("<<-------------------------------\n");
+  printf("Curve Information:\n");
+  printf("NodeCount: %d\n", this->nodeCount);
+  PathNode* tmpNode = this->firstNode;
+  while (tmpNode)
+    {
+      printf("node #%d: %f, %f, %f\n", tmpNode->number, tmpNode->position.x, tmpNode->position.y, tmpNode->position.z);
+      tmpNode = tmpNode->next;
+    }
+  printf("------------------------------->>\n");
+}
+
 
 ///////////////////////////////////
@@ -142,5 +201,5 @@
 
   // rebuilding the Derivation curve
-  if(this->derivation == 0)
+  if(this->derivation <= 1)
     {
       tmpNode = firstNode;
@@ -202,4 +261,9 @@
 }
 
+Vector BezierCurve::calcAcc (float t)
+{
+  return dirCurve->dirCurve->calcPos(t);
+}
+
 /**
    \brief Calculates the Quaternion needed for our rotations
@@ -374,4 +438,8 @@
 }
 
+Vector UPointCurve::calcAcc (float t)
+{
+}
+
 /**
    \brief Calculates the Quaternion needed for our rotations
Index: orxonox/trunk/src/curve.h
===================================================================
--- orxonox/trunk/src/curve.h	(revision 3429)
+++ orxonox/trunk/src/curve.h	(revision 3433)
@@ -23,5 +23,4 @@
   Vector curvePoint;     //!< The point on the Cureve at a local Time.
   float localTime;       //!< If the time of one point is asked more than once the programm will not calculate it again.
-  Curve* dirCurve;       //!< The derivation-curve of this Curve.
   int derivation;        //!< Which derivation of a Curve is this.
 
@@ -42,5 +41,7 @@
   virtual void rebuild(void) = 0;
  public:
+  Curve* dirCurve;       //!< The derivation-curve of this Curve.
   void addNode(const Vector& newNode);
+  void addNode(const Vector& newNode, unsigned int insertPosition);
   Vector getNode(unsigned int nodeToFind);
   inline int getNodeCount(void) { return this->nodeCount;}
@@ -48,6 +49,9 @@
   virtual Vector calcPos(float t) = 0;
   virtual Vector calcDir(float t) = 0;
+  virtual Vector calcAcc(float t) = 0;
   virtual Quaternion calcQuat(float t) = 0;
  
+  // DEBUG
+  void debug(void);
 };
 
@@ -69,4 +73,5 @@
   Vector calcPos(float t);
   Vector calcDir(float t);
+  Vector calcAcc(float t);
   Quaternion calcQuat(float t);
   
@@ -105,4 +110,5 @@
   Vector calcPos(float t);
   Vector calcDir(float t);
+  Vector calcAcc(float t);
   Quaternion calcQuat(float t);
   
Index: orxonox/trunk/src/debug.h
===================================================================
--- orxonox/trunk/src/debug.h	(revision 3429)
+++ orxonox/trunk/src/debug.h	(revision 3433)
@@ -34,5 +34,5 @@
 ///////////////////////////////////////////////////
 
-#ifdef  DEBUG
+#ifdef DEBUG
 extern int verbose;
 #define PRINTF(x) \
Index: orxonox/trunk/src/environment.cc
===================================================================
--- orxonox/trunk/src/environment.cc	(revision 3429)
+++ orxonox/trunk/src/environment.cc	(revision 3433)
@@ -55,8 +55,7 @@
   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
   //rotate
-  this->getAbsDir ().matrix (matrix);
+  this->getAbsDir().matrix (matrix);
   glMultMatrixf((float*)matrix);
   
-  glMatrixMode(GL_MODELVIEW);
   this->model->draw();
 }
Index: orxonox/trunk/src/game_loader.cc
===================================================================
--- orxonox/trunk/src/game_loader.cc	(revision 3429)
+++ orxonox/trunk/src/game_loader.cc	(revision 3433)
@@ -25,5 +25,4 @@
 #include "command_node.h"
 #include "vector.h"
-#include "track.h"
 
 #include <string.h>
Index: orxonox/trunk/src/gui/Makefile.in
===================================================================
--- orxonox/trunk/src/gui/Makefile.in	(revision 3429)
+++ orxonox/trunk/src/gui/Makefile.in	(revision 3433)
@@ -234,7 +234,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/gui/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gui/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/gui/Makefile
+	  $(AUTOMAKE) --gnu  src/gui/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/trunk/src/importer/Makefile.in
===================================================================
--- orxonox/trunk/src/importer/Makefile.in	(revision 3429)
+++ orxonox/trunk/src/importer/Makefile.in	(revision 3433)
@@ -215,7 +215,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/importer/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/importer/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/importer/Makefile
+	  $(AUTOMAKE) --gnu  src/importer/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/trunk/src/p_node.cc
===================================================================
--- orxonox/trunk/src/p_node.cc	(revision 3429)
+++ orxonox/trunk/src/p_node.cc	(revision 3433)
@@ -214,5 +214,7 @@
 */
 Quaternion PNode::getAbsDir ()
-{}
+{
+  return this->absDirection;
+}
 
 
Index: orxonox/trunk/src/stdincl.h
===================================================================
--- orxonox/trunk/src/stdincl.h	(revision 3429)
+++ orxonox/trunk/src/stdincl.h	(revision 3433)
@@ -22,22 +22,13 @@
 #endif
 
-#ifndef __APPLE__
-#include <SDL/SDL.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
-#else
-#include <SDL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#endif
+#include "glincl.h"
 
+// MATH //
+#include "matrix.h"
 #include "vector.h"
-#include "matrix.h"
 #include "curve.h"
-//#include "coordinates.h"
+
 #include "list.h"
 #include "list_template.h"
-#include "error.h"
-#include "debug.h"
 #include "message_structures.h"
 #include "orxonox.h"
@@ -45,3 +36,6 @@
 #include "base_object.h"
 
+#include "error.h"
+#include "debug.h"
+
 #endif /* _STDINCL_H */
Index: orxonox/trunk/src/track.cc
===================================================================
--- orxonox/trunk/src/track.cc	(revision 3429)
+++ 	(revision )
@@ -1,103 +1,0 @@
-
-
-/* 
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   ### File Specific:
-   main-programmer: Christian Meyer
-   co-programmer: ...
-*/
-
-#include "track.h"
-
-using namespace std;
-
-/**
-   \brief creates a null Track part
-*/
-Track::Track ()
-{
-  this->ID = 0;
-  this->offset = NULL;
-  this->end = NULL;
-  this->nextID = 0;
-  this->setClassName ("Track");
-}
-
-/**
-   \brief creates a functional base Track part
-   \param number: the ID if this Track part
-   \param next: the ID of the next Track part
-   \param start: pointer to an anchor point (Vector) representing the offset of this part
-   \param finish: pointer to an anchor point (Vector) representing the end of this part
-*/
-Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish)
-{
-  this->ID = number;
-  this->offset = start;
-  this->end = finish;
-  this->nextID = next;
-  this->setClassName ("Track");
-}
-
-/**
-   \brief removes the Track part from memory
-*/
-Track::~Track ()
-{
-}
-
-void Track::init()
-{
-  
-}
-
-
-
-
-
-/**
-   \brief this is called when a WorldEntity enters a Track part
-   \param entity: pointer to the WorldEntity in question
-   
-   You can do stuff like add or remove effects, do some coordinate finetuning 
-   or whatever in here.
-*/
-void Track::postEnter (WorldEntity* entity)
-{
-}
-
-
-/**
-   \brief this is called when a WorldEntity leaves a Track part
-   \param entity: pointer to the WorldEntity in question
-   
-   You can do stuff like add or remove effects, do some coordinate finetuning 
-   or whatever in here.
-*/
-void Track::postLeave (WorldEntity* entity)
-{
-}
-
-
-/**
-   \brief this is called every frame
-   \param deltaT: amount of time passed since the last frame in seconds
-   
-   Do time based or polling scripts here. 
-*/
-void Track::tick (float deltaT)
-{
-}
-
-
-
-
-
Index: orxonox/trunk/src/track.h
===================================================================
--- orxonox/trunk/src/track.h	(revision 3429)
+++ 	(revision )
@@ -1,39 +1,0 @@
-/*! 
-    \file track.h
-    \brief Basic level architecture
-*/ 
-
-#ifndef _TRACK_H
-#define _TRACK_H
-
-#include "stdincl.h"
-
-//!	The Red Line through a level
-/**
-   Handles level boundaries, bound movement mapping, camera placement and scripting.
-   To create special levels with special camera movement, rules or whatever, derive from this base class.
-*/
-class Track : public BaseObject
-{
- private:
-  Uint32 ID;
-  Vector* offset;
-  Vector* end;
-  // Vector* direction; // unity direction vector: it is costy to always recalculate it
-  //Vector* up; // direction where up is ment to be - diffuse in space, eh?
-  //Vector* traverse; // right-left 
-  Uint32 nextID;
-  
-  
- public:
-  Track ();
-  Track (Uint32 number, Uint32 next, Vector* start, Vector* finish);
-  ~Track ();
-  virtual void init();
-  
-  virtual void postEnter (WorldEntity* entity);	// handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght)
-  virtual void postLeave (WorldEntity* entity);
-  virtual void tick (float deltaT);
-};
-
-#endif /* _TRACK_H */
Index: orxonox/trunk/src/track_manager.cc
===================================================================
--- orxonox/trunk/src/track_manager.cc	(revision 3429)
+++ orxonox/trunk/src/track_manager.cc	(revision 3433)
@@ -1,4 +1,2 @@
-
-
 /* 
    orxonox - the future of 3D-vertical-scrollers
@@ -12,5 +10,5 @@
 
    ### File Specific:
-   main-programmer: Patrick Boenzli
+   main-programmer: Benjamin Grauer
    co-programmer: ...
 */
@@ -19,5 +17,5 @@
 #include "track_manager.h"
 #include <stdarg.h>
-
+#include "p_node.h"
 
 using namespace std;
@@ -38,10 +36,10 @@
   this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
   this->duration = 1;
+  this->endTime = 1;
+  this->jumpTime = 0;
   this->curveType = BEZIERCURVE;
   this->nodeCount = 0;
   this->childCount = 0;
   this->name = NULL;
-  this->startPoint = Vector(0,0,0);
-  this->startTangentPoint = Vector(0,0,0);
   this->curve = NULL;
   this->children = NULL;
@@ -111,4 +109,5 @@
   this->maxTime = 0;
   this->trackElemCount = 1;
+  this->bindSlave = NULL;
 }
 
@@ -151,4 +150,5 @@
 {
   this->currentTrackElem->childCount = childCount;
+  this->currentTrackElem->mainJoin = true;
   this->currentTrackElem->children = new TrackElement*[childCount];
   for (int i=0; i<childCount; i++)
@@ -156,7 +156,6 @@
       this->currentTrackElem->children[i] = new TrackElement();
       this->currentTrackElem->children[i]->ID = ++trackElemCount;
-      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration;
-      this->currentTrackElem->children[i]->startPoint = this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount());
-      this->currentTrackElem->children[i]->startTangentPoint = (this->currentTrackElem->children[i]->startPoint *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1);
+      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime;
+      this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]);
     }
 }
@@ -193,19 +192,19 @@
    \brief curveType The Type to set
 */
-void TrackManager::setCurveType(CurveType curveType)
-{
-  if (!this->currentTrackElem->isFresh)
+void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem)
+{
+  if (!trackElem->isFresh)
     {
       PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n");
       return;
     }
-  this->currentTrackElem->curveType = curveType;
+  trackElem->curveType = curveType;
   switch (curveType)
     {
     case BEZIERCURVE:
-      this->currentTrackElem->curve = new BezierCurve();
+      trackElem->curve = new BezierCurve();
       break;
     case UPOINTCURVE:
-      this->currentTrackElem->curve = new UPointCurve();
+      trackElem->curve = new UPointCurve();
       break;
     }
@@ -220,4 +219,5 @@
 {
   this->currentTrackElem->duration = time;
+  this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time;
 }
 
@@ -240,11 +240,6 @@
   if (trackElem->isFresh)
     {
-      this->setCurveType(BEZIERCURVE);
+      this->setCurveType(BEZIERCURVE, trackElem);
       trackElem->isFresh = false;
-      if(trackElem != this->firstTrackElem)
-	{
-	  this->addPoint(trackElem->startPoint);
-	  this->addPoint(trackElem->startTangentPoint);
-	}
     }
   trackElem->curve->addNode(newPoint);
@@ -374,18 +369,31 @@
 void TrackManager::joinV(unsigned int count, int* trackIDs)
 {
-  printf("Joining %d tracks to Track %d\n", count, trackIDs[0]);
+  printf("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);
 
   // chanching work-on to temporary value. going back at the end.
   int tmpCurrentWorkingID = this->currentTrackElem->ID;
   this->workOn(trackIDs[0]);
-
   TrackElement* firstJoint = this->currentTrackElem;
+  float tmpLatestTime = firstJoint->endTime;
+
   Vector tmpEndPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount());
-  Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1); 
+  Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1);
+  Vector tmpc2Point = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-2);
   firstJoint->isJoined = true;
-  firstJoint->mainJoin = true;
+  //  firstJoint->mainJoin = true;
   if(!firstJoint->isHotPoint)
     this->setSavePoint();
-
+  // Timing:
+  for (int i = 0; i < count; i++)
+    {
+      TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]);
+      if (tmpJoinElem->childCount == 0
+	  && tmpJoinElem->endTime > tmpLatestTime)
+	tmpLatestTime = tmpJoinElem->endTime;
+    }
+  // time the main Join.
+  firstJoint->jumpTime = tmpLatestTime - firstJoint->endTime;
+  
+  // Joining:
   for (int i = 1; i < count; i++)
     {
@@ -395,6 +403,9 @@
       else
 	{
+	  this->addPoint(tmpc2Point, tmpJoinElem);
 	  this->addPoint(tmpTangentPoint, tmpJoinElem);
 	  this->addPoint(tmpEndPoint, tmpJoinElem);
+	  // time all other Joins
+	  tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime;
 	  
 	  //Copying Joint-Info
@@ -403,12 +414,57 @@
 	  tmpJoinElem->isSavePoint = firstJoint->isSavePoint;
 	  tmpJoinElem->isFork = firstJoint->isFork;
-	  
+
 	  tmpJoinElem->isJoined = true;
 	}
     }
+  if(firstJoint->childCount > 0)
+    for(int i = 0; i < firstJoint->childCount; i++)
+      {
+	printf("Setting startingTime of %d to %f.\n", firstJoint->children[i]->ID, tmpLatestTime);
+	firstJoint->children[i]->startingTime = tmpLatestTime;
+	firstJoint->children[i]->endTime = tmpLatestTime+firstJoint->children[i]->duration;
+      }	
+
   // returning to the TrackElement we were working on.
   this->workOn(tmpCurrentWorkingID);
 }
 
+/**
+   \brief finalizes the TrackSystem. after this it will not be editable anymore
+
+   \todo check for any inconsistencies, output errors
+*/
+void TrackManager::finalize(void)
+{
+  for (int i = 1; i<= trackElemCount ;i++)
+    {
+      TrackElement* tmpElem = findTrackElementByID(i);
+      if (tmpElem->childCount>0 && tmpElem->mainJoin)
+	{
+	  for (int j = 0; j < tmpElem->childCount; j++)
+	    {
+	      
+	      // c1-continuity
+	      tmpElem->children[j]->curve->addNode(tmpElem->children[j]->curve->getNode(0) +
+						   ((tmpElem->children[j]->curve->getNode(0) - 
+						    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
+						    ),2);
+	      tmpElem->children[j]->nodeCount++;
+	      // c2-continuity
+	      tmpElem->children[j]->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
+						    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
+						   tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
+	      tmpElem->children[j]->nodeCount++;						    
+	      printf("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
+		     tmpElem->ID, tmpElem->nodeCount,
+		     tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
+		     tmpElem->children[j]->ID, tmpElem->children[j]->nodeCount,
+		     tmpElem->children[j]->curve->calcAcc(0).x, tmpElem->children[j]->curve->calcAcc(0).y, tmpElem->children[j]->curve->calcAcc(0).z);
+	    }
+	}
+    }
+}
+
+
 // RUNTIME //
 
@@ -429,5 +485,5 @@
 Vector TrackManager::calcDir() const
 {
-  return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
+  return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
 }
 
@@ -440,9 +496,23 @@
 void TrackManager::tick(float dt)
 {
+  dt /= 1000;
+  printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, 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];
+  if (this->localTime > this->currentTrackElem->endTime
+      && this->currentTrackElem->children)
+    {
+      if (this->currentTrackElem->jumpTime > 0) 
+	this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
+      this->currentTrackElem = this->currentTrackElem->children[0];
+    }
+  if (this->bindSlave)
+    {
+      Vector tmp = this->calcPos();
+      Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z)); 
+      this->bindSlave->setAbsCoor(&tmp);
+      this->bindSlave->setAbsDir(&quat);
+    }
 }
 
@@ -471,4 +541,13 @@
 }
 
+/**
+   \brief Sets the PNode, that should be moved along the Tack
+   \param bindSlave the PNode to set
+*/
+void TrackManager::setBindSlave(PNode* bindSlave)
+{
+  if (!this->bindSlave)
+    this->bindSlave = bindSlave;
+}
 
 
@@ -500,4 +579,8 @@
 }
 
+/**
+   \brief outputs debug information about the trackManager
+   \param level how much debug
+*/
 void TrackManager::debug(unsigned int level) const
 {
@@ -516,5 +599,5 @@
 	  if(tmpElem->isFresh)
 	    printf("   has not jet eddited in any way\n");
-	  printf("\n   TimeTable: starting at = %f; ends at = %f; duration = %f\n", tmpElem->startingTime, tmpElem->startingTime+tmpElem->duration, tmpElem->duration);
+	  printf("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime);
 	  printf("   consists of %d Points\n", tmpElem->nodeCount);
 	  if (tmpElem->childCount == 0)
@@ -536,5 +619,5 @@
 	  if(tmpElem->isFork)
 	    {
-	      printf("    is A Fork with with %d children.", tmpElem->childCount);
+	      printf("    is A Fork with with %d children.\n", tmpElem->childCount);
 	    }
 	  if(tmpElem->isJoined)
Index: orxonox/trunk/src/track_manager.h
===================================================================
--- orxonox/trunk/src/track_manager.h	(revision 3429)
+++ orxonox/trunk/src/track_manager.h	(revision 3433)
@@ -14,4 +14,5 @@
 #include "stdincl.h"
 
+class PNode;
 
 //! condition for choosing a certain Path. \todo implement a useful way.
@@ -45,9 +46,9 @@
   float startingTime;        //!< The time at which this Track begins.
   float duration;            //!< The time used to cross this TrackElement (curve).
+  float endTime;             //!< The time at which this Track ends.
+  float jumpTime;            //!< The Time this Track has to jump to its preceding Track (only >0 if Track isJoined==true)
   CurveType curveType;       //!< The CurveType this will have.
   int nodeCount;             //!< The count of points this TrackElement has.
   char* name;                //!< A name for the Trac.
-  Vector startPoint;         //!< A Vector that Points to the first point of the containing Curve. (for c1-steadiness)
-  Vector startTangentPoint;  //!< A Vector that points into the direction of the previous Curve. (for c1-steadiness)
   Curve* curve;              //!< The Curve of this TrackElement
   int childCount;            //!< The number of Children This TrackElement has.
@@ -59,5 +60,4 @@
 //! The TrackManager handles the flow of the Players through the game.
 /**
-   \todo write the methodes
 
    <b>The TrackManager works as followed:</b> \n
@@ -104,4 +104,5 @@
   float maxTime;                      //!< The maximal time the track has.
   int trackElemCount;                 //!< The count of TrackElements that exist.
+  PNode* bindSlave;
   
   void initChildren(unsigned int childCount);
@@ -115,5 +116,6 @@
   // Methods to change the Path (initialisation)
   void workOn(unsigned int trackID);
-  void setCurveType(CurveType curveType);
+  inline void setCurveType(CurveType curveType) { this->setCurveType (curveType, this->currentTrackElem);}
+  void setCurveType(CurveType curveType, TrackElement* trackElem);
   void setDuration(float time);
   bool addPoint(Vector newPoint);
@@ -126,4 +128,5 @@
   void join(unsigned int count, ...);
   void joinV(unsigned int count, int* trackIDs);
+  void finalize(void);
 
   // Methods to calculate the position on the Path (runtime)
@@ -134,4 +137,6 @@
   void choosePath(int graphID);
 
+  void setBindSlave(PNode* bindSlave);
+
   // DEBUG //
   void drawGraph(float dt) const;
Index: orxonox/trunk/src/world.cc
===================================================================
--- orxonox/trunk/src/world.cc	(revision 3429)
+++ orxonox/trunk/src/world.cc	(revision 3433)
@@ -19,5 +19,4 @@
 #include "collision.h"
 #include "track_manager.h"
-#include "track.h"
 #include "player.h"
 #include "command_node.h"
@@ -143,4 +142,5 @@
 void World::destroy()
 {
+  delete trackManager;
 }
 
@@ -180,5 +180,5 @@
       trackManager->addPoint(Vector(30,0,5));
       trackManager->addPoint(Vector(40,0,5));
-      trackManager->setDuration(.5);
+      trackManager->setDuration(2);
       trackManager->setSavePoint();
       trackManager->addPoint(Vector(50,10,10));
@@ -187,5 +187,5 @@
       trackManager->addPoint(Vector(80,0,-10));
       trackManager->addPoint(Vector(90,0,-10));
-      trackManager->setDuration(.5);
+      trackManager->setDuration(5);
       trackManager->setSavePoint();
       trackManager->addPoint(Vector(110,0,5));
@@ -194,5 +194,5 @@
       trackManager->addPoint(Vector(140,0,-10));
       trackManager->addPoint(Vector(150,0,-10));
-      trackManager->setDuration(.5);
+      trackManager->setDuration(3);
       int fork11, fork12, fork13, fork14;
       trackManager->fork(4, &fork11, &fork12, &fork13, &fork14);
@@ -200,4 +200,5 @@
       trackManager->addPoint(Vector(170, 0, -15));
       trackManager->addPoint(Vector(180, 0, -15));
+      trackManager->setDuration(3);
       trackManager->workOn(fork12);
       trackManager->addPoint(Vector(170, 0, 10));
@@ -205,4 +206,5 @@
       trackManager->addPoint(Vector(190,2,5));
       trackManager->addPoint(Vector(200,2,5));
+      trackManager->setDuration(7);
       int fork21, fork22;
       trackManager->fork(2, &fork21, &fork22);
@@ -213,4 +215,5 @@
       trackManager->addPoint(Vector(250, 0, 0));
       trackManager->addPoint(Vector(260, 0, 5));
+      trackManager->setDuration(3);
       trackManager->join(2, fork12, fork11);
       trackManager->workOn(fork22);
@@ -219,25 +222,32 @@
       trackManager->addPoint(Vector(240, 0, 10));
       trackManager->addPoint(Vector(250, 0, 5));
+      trackManager->setDuration(6);
       trackManager->workOn(fork13);
       trackManager->addPoint(Vector(200,-10,5));
       trackManager->addPoint(Vector(250,-10,5));
-      printf("fork14: %d\n", fork14);
+      trackManager->setDuration(3);
       trackManager->workOn(fork14);
       trackManager->addPoint(Vector(200,15,0));
       trackManager->addPoint(Vector(210,0,10));
-
-
-
+      trackManager->setDuration(1);
       trackManager->join(4, fork21, fork22, fork13, fork14);
-
+      trackManager->workOn(10);
+      trackManager->addPoint(Vector(250,-10,5));
+      trackManager->addPoint(Vector(260,-10,5));
+      trackManager->finalize();
+      
       /*monitor progress*/
       this->glmis->step();
 
       /*
-      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));
+	tmpCurve->addNode(Vector(10,  -1,  -1));
+	tmpCurve->addNode(Vector(10,  -2,   2));
+	tmpCurve->addNode(Vector(10,   3,   3));
+	tmpCurve->addNode(Vector(10,   4,  -4), 0);
+	tmpCurve->addNode(Vector(10,  -1,  -1));
+	tmpCurve->addNode(Vector(10,  -2,   2));
+	tmpCurve->addNode(Vector(10,   3,   3));
+	tmpCurve->addNode(Vector(10,   4,  -4), 0);
+	tmpCurve->debug();
       */
       switch(this->debugWorldNr)
@@ -254,20 +264,4 @@
 	    this->nullParent->setName ("NullParent");
 
-	    // create some path nodes
-	    this->pathnodes = new Vector[6];
-	    this->pathnodes[0] = Vector(0, 0, 0);
-	    this->pathnodes[1] = Vector(1000, 0, 0);
-	    //	    this->pathnodes[2] = Vector(-100, 140, 0);
-	    //	    this->pathnodes[3] = Vector(0, 180, 0);
-	    //	    this->pathnodes[4] = Vector(100, 140, 0);
-	    //	    this->pathnodes[5] = Vector(100, 40, 0);
-	    
-	    // create the tracks
-	    this->tracklen = 2;
-	    this->track = new Track[2];
-	    for( int i = 0; i < this->tracklen; i++)
-	      {
-		this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
-	      }
 	    // !\todo old track-system has to be removed
 
@@ -281,5 +275,4 @@
 	    this->spawn (myPlayer);
 	    this->localPlayer = myPlayer;
-
 	    /*monitor progress*/
 	    this->glmis->step();	    
@@ -309,4 +302,6 @@
 	    /*monitor progress*/
 	    this->glmis->step();
+
+	    trackManager->setBindSlave(env);
 
 	    break;
@@ -338,12 +333,4 @@
 
 
-
-	    // create the tracks
-	    this->tracklen = 6;
-	    this->track = new Track[6];
-	    for( int i = 0; i < this->tracklen; i++)
-	      {
-		this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
-	      }
 
 	    // create a player
@@ -543,14 +530,4 @@
     }
   */  
-  //draw track
-  glBegin(GL_LINES);
-  glColor3f(0.0, 1.0, 1.0);
-  for( int i = 0; i < tracklen; i++)
-    {
-      glVertex3f(pathnodes[i].x,pathnodes[i].y,pathnodes[i].z);
-      glVertex3f(pathnodes[(i+1)%tracklen].x,pathnodes[(i+1)%tracklen].y,pathnodes[(i+1)%tracklen].z);
-    }
-  glEnd();
-  
   /*
   glBegin(GL_LINE_STRIP);
@@ -565,7 +542,5 @@
   trackManager->drawGraph(.01);
   trackManager->debug(2);
-  delete trackManager;
-  
-  /*
+  /*  
   glBegin(GL_LINES);
   float i;
@@ -678,5 +653,5 @@
 	  t = loc->part;
 	  
-	  if( t >= tracklen )
+	  if( t >= traclen )
 	    {
 	      printf("An entity is out of the game area\n");
@@ -736,19 +711,6 @@
 void World::unload()
 {
-  if( pathnodes) delete []pathnodes;
-  if( track) delete []pathnodes;
-}
-
-
-void World::setTrackLen(Uint32 len)
-{
-  this->tracklen = len;
-}
-
-int World::getTrackLen()
-{
-  return this->tracklen;
-}
-
+
+}
 
 
@@ -910,4 +872,5 @@
       this->update ();
       this->localCamera->timeSlice(dt);
+      this->trackManager->tick(dt);
     }
   this->lastFrame = currentFrame;
Index: orxonox/trunk/src/world.h
===================================================================
--- orxonox/trunk/src/world.h	(revision 3429)
+++ orxonox/trunk/src/world.h	(revision 3433)
@@ -12,5 +12,4 @@
 
 class TrackManager;
-class Track;
 class WorldEntity;
 class Camera;
@@ -49,6 +48,4 @@
   virtual void releaseLoadScreen();
   
-  void setTrackLen (Uint32 tracklen);
-  int getTrackLen ();
   //bool system_command (Command* cmd);
   Camera* getCamera ();
@@ -61,6 +58,4 @@
   // base level data
   TrackManager* trackManager;
-  Track* track;
-  Uint32 tracklen;   // number of Tracks the World consist of
   Vector* pathnodes;
   Camera* localCamera;  
