Index: /branches/playability/src/util/track/track.cc
===================================================================
--- /branches/playability/src/util/track/track.cc	(revision 10084)
+++ /branches/playability/src/util/track/track.cc	(revision 10085)
@@ -23,4 +23,11 @@
 */
 
+#include "util/loading/load_param.h"
+
+#include "class_id_DEPRECATED.h"
+
+ObjectListDefinition(Track);
+CREATE_FACTORY(Track);
+
 /**
  *  standard constructor
@@ -28,4 +35,143 @@
 Track::Track()
 {
+      this->firstTrackElem = new TrackElement();
+      this->firstTrackElem->ID = 1;
+      this->firstTrackElem->setName("root");
       
+      this->currentTrackElem = firstTrackElem;
+      
+      this->curveType = CURVE_BEZIER;
+      this->trackElemCount = 1;
+      
+      this->trackNode = new PNode(PNode::getNullParent(), PNODE_ALL);
 }
+
+/**
+ *  standard destructor
+*/
+Track::~Track()
+{
+  delete this->firstTrackElem;
+}
+
+void Track::loadParams(const TiXmlElement* root)
+{
+     LOAD_PARAM_START_CYCLE(root, element);
+     {
+           LoadParam_CYCLE(element, "Point", this, Track, addPoint)
+             .describe("Adds a new Point to the currently selected TrackElement");
+           
+     }
+     LOAD_PARAM_END_CYCLE(element);
+}
+
+void Track::addPoint(float x, float y, float z)
+{
+     this->addPoint(Vector (x,y,z));
+}
+
+void Track::addPoint(Vector newPoint)
+{
+  if (this->currentTrackElem->isFresh)
+    {
+      this->setCurveType(CURVE_BEZIER, this->currentTrackElem);
+      this->currentTrackElem->isFresh = false;
+    }
+  trackElem->curve->addNode(newPoint);
+  trackElem->nodeCount++;
+}
+
+void Track::finalize()
+{
+  for (int i = 1; i<= trackElemCount ;i++)
+    {
+      TrackElement* tmpElem = this->firstTrackElem->findByID(i);
+      if( tmpElem->childCount > 0)
+        {
+          tIterator<TrackElement>* iterator = tmpElem->children->getIterator();
+          TrackElement* enumElem = iterator->firstElement();
+          //TrackElement* enumElem = tmpElem->children->enumerate();
+          while (enumElem)
+            {
+
+              // c1-continuity
+              enumElem->curve->addNode(enumElem->curve->getNode(0) +
+                                                   ((enumElem->curve->getNode(0) -
+                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
+                                                    ),2);
+              enumElem->nodeCount++;
+              // c2-continuity
+              enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
+                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
+                                                   tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
+              enumElem->nodeCount++;
+              PRINTF(5)("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,
+                     enumElem->ID, enumElem->nodeCount,
+                     enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z);
+
+              enumElem = iterator->nextElement();
+            }
+          delete iterator;
+        }
+    }
+  /*for (int i = 1; i <= trackElemCount;i++)
+    if (this->firstTrackElem->findByID(i)->endTime > this->maxTime)
+      this->maxTime = this->firstTrackElem->findByID(i)->endTime; // very bad implemented :/
+      */
+}
+
+Vector TrackManager::calcPos() const
+{
+  return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
+}
+
+Vector TrackManager::calcDir() const
+{
+  return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
+}
+
+void Track::tick(float dt)
+{
+  PRINTF(4)("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);
+  if (this->localTime <= this->maxTime)
+    this->localTime += dt;
+  if (this->localTime > this->currentTrackElem->endTime
+      && this->currentTrackElem->children)
+    {
+      if (this->currentTrackElem->jumpTime != 0.0)
+        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
+      // jump to the next TrackElement and also set the history of the new Element to the old one.
+      TrackElement* tmpHistoryElem = this->currentTrackElem;
+      this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
+      this->currentTrackElem->history = tmpHistoryElem;
+      if (this->currentTrackElem->getName())
+        {
+          this->trackText->setText(this->currentTrackElem->getName());
+          this->textAnimation->replay();
+        }
+    }
+  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));
+
+      Vector v(0.0, 1.0, 0.0);
+      Quaternion q(-PI/2, v);
+      quat = quat * q;
+
+      this->bindSlave->setAbsCoor(tmp);
+      this->bindSlave->setAbsDir(quat);
+    }
+}
+
+/**
+ * @returns the main TrackNode
+*/
+PNode* TrackManager::getTrackNode()
+{
+  return this->trackNode;
+}
Index: /branches/playability/src/util/track/track.h
===================================================================
--- /branches/playability/src/util/track/track.h	(revision 10084)
+++ /branches/playability/src/util/track/track.h	(revision 10085)
@@ -9,9 +9,30 @@
 #include "base_object.h"
 
+// Forward Definition
+class PNode;
+class TiXmlElement;
+
 class Track : public BaseObject
 {
+ public:
+      virtual void loadParams(const TiXmlElement* root);
+      void addPoint(float x, float y, float z);
+      void addPoint(Vector newPoint);
       
+      void finalize();
+      inline Vector calcPos() const;
+      inline Vector calcDir() const;
+      void tick(float dt);
       
+      PNode* getTrackNode();
+ 
+ private:
+      TrackElement*        firstTrackElem;         //!< The first TrackElement that exists.
+      TrackElement*        currentTrackElem;       //!< The TrackElement we are working on.
+      CurveType            curveType;              //!< The CurveType the entire TrackSystem will have.
+      int                  trackElemCount;         //!< The count of TrackElements that exist.
       
-      
-}
+      PNode*               trackNode;              //!< The node that is slave to the Track. This node will be moved while update the Track, and must NOT move itself.
+};
+
+#endif /* _TRACK_H */
