Index: orxonox/trunk/src/lib/base_entity.cc
===================================================================
--- orxonox/trunk/src/lib/base_entity.cc	(revision 3483)
+++ orxonox/trunk/src/lib/base_entity.cc	(revision 3483)
@@ -0,0 +1,32 @@
+
+
+/* 
+   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: Patrick Boenzli
+   co-programmer: ...
+*/
+
+
+#include "base_entity.h"
+
+
+using namespace std;
+
+
+
+BaseEntity::BaseEntity () {}
+
+
+
+BaseEntity::~BaseEntity () {}
+
+
Index: orxonox/trunk/src/lib/base_entity.h
===================================================================
--- orxonox/trunk/src/lib/base_entity.h	(revision 3483)
+++ orxonox/trunk/src/lib/base_entity.h	(revision 3483)
@@ -0,0 +1,20 @@
+/*! 
+  \file base_entity.h
+  \brief This includes the default values every entity should have.						\
+*/
+
+#ifndef _BASE_ENTITY_H
+#define _BASE_ENTITY_H
+
+#include "stdincl.h"
+
+//! The Base of each entity-Class
+class BaseEntity {
+
+ public:
+  BaseEntity ();
+  ~BaseEntity ();
+
+};
+
+#endif /* _BASE_ENTITY_H */
Index: orxonox/trunk/src/lib/base_object.cc
===================================================================
--- orxonox/trunk/src/lib/base_object.cc	(revision 3483)
+++ orxonox/trunk/src/lib/base_object.cc	(revision 3483)
@@ -0,0 +1,52 @@
+
+
+/* 
+   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: Patrick Boenzli
+   co-programmer: ...
+*/
+
+
+#include "base_object.h"
+
+
+using namespace std;
+
+
+/**
+   \brief standard constructor
+*/
+BaseObject::BaseObject () {}
+
+
+/**
+   \brief standard deconstructor
+*/
+BaseObject::~BaseObject () {}
+
+
+void BaseObject::setClassName (char* className)
+{
+  this->className = className;
+}
+
+char* BaseObject::getClassName(void) const
+{
+  return className;
+}
+
+bool BaseObject::isA (char* className)
+{
+  if( this->className == className)
+    return false;
+  return true;
+}
Index: orxonox/trunk/src/lib/base_object.h
===================================================================
--- orxonox/trunk/src/lib/base_object.h	(revision 3483)
+++ orxonox/trunk/src/lib/base_object.h	(revision 3483)
@@ -0,0 +1,28 @@
+/*! 
+    \file proto_class.h
+    \brief Definition of the proto class template, used quickly start work
+*/
+
+
+#ifndef _BASE_OBJECT_H
+#define _BASE_OBJECT_H
+
+#include "stdincl.h"
+
+
+class BaseObject {
+
+ public:
+  BaseObject ();
+  ~BaseObject ();
+
+  void setClassName (char* className);
+  char* getClassName(void) const;
+  bool isA (char* className);
+
+ private:
+  char* className;
+
+};
+
+#endif /* _BASE_OBJECT_H */
Index: orxonox/trunk/src/lib/list.cc
===================================================================
--- orxonox/trunk/src/lib/list.cc	(revision 3481)
+++ 	(revision )
@@ -1,148 +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: Patrick Boenzli
-   co-programmer: ...
-*/
-
-
-#include "list.h"
-#include "world_entity.h"
-
-using namespace std;
-
-
-
-List::List () 
-{
-  this->first = NULL;
-  this->last = NULL;
-  this->size = 0;
-}
-
-List::~List () 
-{}
-
-
-void List::add(WorldEntity* entity)
-{
-  printf("List::add() \n");
-  listElement* el = new listElement;
-  el->prev = this->last;
-  el->curr = entity;
-  el->next = NULL;
-
-  this->last = el;
-
-  if(this->size == 0) this->first = el;
-  else el->prev->next = el;
-  this->size++;
-}
-
-
-void List::remove(WorldEntity* entity)
-{
-  this->currentEl = this->first;
-  listElement* te;
-  while( this->currentEl != NULL)
-    {
-      if( this->currentEl->curr == entity)
-	{
-	  printf("List::remove() - object found\n");
-	  
-	  if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
-	  else this->currentEl->prev->next = this->currentEl->next;
-
-	  if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
-	  else this->currentEl->next->prev = this->currentEl->prev;
-
-	  te = this->currentEl->next;
-	  delete this->currentEl;
-	  this->currentEl = te;
-	  return;
-	}
-      this->currentEl = this->currentEl->next;
-    }
-}
-
-
-void List::destroy()
-{
-  printf("List::clear() - clearing all world objects, releasing mem\n");
-  this->currentEl = this->first;
-  listElement* le = NULL;
-  while(this->currentEl != NULL)
-    {
-      le = this->currentEl->next;
-      delete this->currentEl->curr;
-      delete this->currentEl;
-      this->currentEl = le;
-    }
-  this->first = NULL;
-  this->last = NULL;
-  this->size = 0;
-}
-
-
-WorldEntity* List::firstElement()
-{
-  return this->first->curr;
-}
-
-
-bool List::isEmpty()
-{
-  return (this->size==0)?true:false;
-}
-
-
-int List::getSize()
-{
-  return this->size;
-}
-
-
-WorldEntity* List::enumerate()
-{
-  if(this->size == 0) return NULL;
-  this->currentEl = this->first;
-  return this->currentEl->curr;
-}
-
-
-WorldEntity* List::nextElement()
-{
-  if(this->size == 0) return NULL;
-  this->currentEl = this->currentEl->next;
-  if(this->currentEl == NULL) return NULL;
-  return this->currentEl->curr;
-}
-
-
-WorldEntity* List::toArray()
-{}
-
-
-void List::debug()
-{
-  int counter = 1;
-  this->currentEl = this->first;
-  printf("List:debug() =====================\n");
-  while(this->currentEl != NULL)
-    {
-      printf("element: nr %d/%d\n", counter, size);
-      this->currentEl = this->currentEl->next;
-      counter++;
-    }
-  printf("List:debug()END =====================\n");
-}
Index: orxonox/trunk/src/lib/list.h
===================================================================
--- orxonox/trunk/src/lib/list.h	(revision 3481)
+++ 	(revision )
@@ -1,207 +1,0 @@
-
-#ifndef _LIST_H
-#define _LIST_H
-
-#include "stdincl.h"
-
-//! An enum to list all the modes available when adding an object to a List
-//enum ADDMODE {LIST_ADD_FIRST, LIST_ADD_LAST};
-//! An enum to list the two searching directions available when removing an object from a List
-//enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
-
-
-
-class WorldEntity;
-
-class List {
-
- public:
-  List ();
-  ~List ();
-
-  void add(WorldEntity* entity);
-  void remove(WorldEntity* entity);
-  void destroy();
-  WorldEntity* firstElement();
-  bool isEmpty();
-  int getSize();
-  WorldEntity* enumerate();
-  WorldEntity* nextElement();
-  WorldEntity* toArray();
-  void debug();
-
- private:
-  struct listElement
-  {
-    listElement* prev;
-    WorldEntity* curr;
-    listElement* next;
-  };
-  Uint32 size;
-  listElement* first;
-  listElement* last;
-  listElement* currentEl;
-
-
-};
-
-class Iterator
-{
-
- public:
-  bool hasNext();
-  WorldEntity* next();
-
- private:
-
-};
-
-
-template<class T> class tList 
-{
- private:
-  struct listElement
-  {
-    listElement* prev;
-    T* curr;
-    listElement* next;
-  };
-
-  Uint32 size;
-  listElement* first;
-  listElement* last;
-  listElement* currentEl;
-  
- public:
-  tList ();
-  ~tList ();
-  
-
-  void add(T* entity);
-  void remove(T* entity);
-  void destroy();
-  T* firstElement();
-  bool isEmpty();
-  int getSize();
-  T* enumerate();
-  T* nextElement();
-  T* toArray();
-  void debug();
-};
-
-
-template<class T>
-tList<T>::tList () 
-{
-  this->first = NULL;
-  this->last = NULL;
-  this->size = 0;
-}
-
-template<class T>
-tList<T>::~tList () 
-{}
-
-template<class T>
-void tList<T>::add(T* entity)
-{
-  listElement* el = new listElement;
-  el->prev = this->last;
-  el->curr = entity;
-  el->next = NULL;
-
-  this->last = el;
-
-  if(this->size == 0) this->first = el;
-  else el->prev->next = el;
-  this->size++;
-}
-
-
-template<class T>
-void tList<T>::remove(T* entity)
-{
-  this->currentEl = this->first;
-  listElement* te;
-  while( this->currentEl != NULL)
-    {
-      if( this->currentEl->curr == entity)
-	{ 
-	  if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
-	  else this->currentEl->prev->next = this->currentEl->next;
-
-	  if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
-	  else this->currentEl->next->prev = this->currentEl->prev;
-
-	  te = this->currentEl->next;
-	  delete this->currentEl;
-	  this->currentEl = te;
-	  return;
-	}
-      this->currentEl = this->currentEl->next;
-    }
-}
-
-
-template<class T>
-void tList<T>::destroy()
-{
-  this->currentEl = this->first;
-  while(this->currentEl != NULL)
-    {
-      listElement* le = this->currentEl->next;
-      delete this->currentEl->curr;
-      delete this->currentEl;
-      this->currentEl = le;
-    }
-  this->first = NULL;
-  this->last = NULL;
-  this->size = 0;
-}
-
-
-template<class T>
-T* tList<T>::firstElement()
-{
-  return this->first->curr;
-}
-
-
-template<class T>
-bool tList<T>::isEmpty()
-{
-  return (this->size==0)?true:false;
-}
-
-
-template<class T>
-int tList<T>::getSize()
-{
-  return this->size;
-}
-
-
-template<class T>
-T* tList<T>::enumerate()
-{
-  if(this->size == 0) return NULL;
-  this->currentEl = this->first;
-  return this->currentEl->curr;
-}
-
-
-template<class T>
-T* tList<T>::nextElement()
-{
-  if(this->size == 0) return NULL;
-  this->currentEl = this->currentEl->next;
-  if(this->currentEl == NULL) return NULL;
-  return this->currentEl->curr;
-}
-
-
-template<class T>
-T* tList<T>::toArray()
-{}
-
-#endif /* _LIST_H */
Index: orxonox/trunk/src/lib/list_template.h
===================================================================
--- orxonox/trunk/src/lib/list_template.h	(revision 3481)
+++ 	(revision )
@@ -1,308 +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
-
-   ADDONS/FIXES:
-  
-   Patrick Boenzli     :          Implemented getSize() function
-*/
-
-
-/*!
-  \file list.h
-  \brief Contains a template for a doubly linked list
-*/
-
-#ifndef _LIST_TEMPLATE_H
-#define _LIST_TEMPLATE_H
-
-#include "stdincl.h"
-
-//! An enum to list all the modes available when adding an object to a List
-enum ADDMODE {LIST_ADD_NEXT, LIST_ADD_PREV, LIST_ADD_FIRST, LIST_ADD_LAST};
-//! An enum to list the two searching directions available when removing an object from a List
-enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
-
-//! A generic doubly linked list
-template<class T> class ListTemplate 
-{
-  T* object;
-  ListTemplate<T>* next;
-  ListTemplate<T>* prev;
-  bool bReference;
-  int size;
-  
- public:
-  ListTemplate (T* obj, ListTemplate<T>* n, ListTemplate<T>* p, bool bRef);
-  ~ListTemplate ();
-  
-  int add(T* obj, ADDMODE mode, bool bRef);
-  T* getObject();
-  ListTemplate<T>* getNext();
-  ListTemplate<T>* getPrevious();
-  ListTemplate<T>* getLast();
-  ListTemplate<T>* getFirst();
-  void setNext(ListTemplate<T>* ptr);
-  void setPrev(ListTemplate<T>* ptr);
-  int remove (T* obj, FINDMODE mode);
-  int getSize();
-  void destroy();
-};
-
-
-/**
-  \brief Standard constructor
-  
-  Call this without any parameters to generate a new ListTemplate which can be filled with content.
-  DO NOT create a ListTemplate element that contains an object on your own, you'll lose the data
-  contained in that object and will have trouble removing the list from your memory.
-*/
-template<class T>
-ListTemplate<T>::ListTemplate (T* obj = NULL, ListTemplate<T>* n = NULL, ListTemplate<T>* p = NULL, bool bRef = false)
-{
-  object = obj;
-  next = n;
-  prev = p;
-  bReference = bRef;
-  if(obj != NULL)
-    ++size;
-}
-
-/**
-  \brief Standard destructor
-  
-  Call this on the initially generated base ListTemplate element to remove the whole ListTemplate from the memory.
-  You can safely do this to any ListTemplate element you want without messing up the rest of the ListTemplate, but keep in mind
-  that the contained object will be deleted as well when bRef had been set to false.
-*/
-template<class T>
-ListTemplate<T>::~ListTemplate ()
-{
-  if (object == NULL) // deleted foot node => disband the list
-  {
-    while( next != NULL)
-    {
-      delete next;
-    }
-    while( prev != NULL)
-    {
-      delete prev;
-    }
-  }
-  else
-  {
-    if (prev != NULL) prev->setNext (next);
-    if (next != NULL) next->setPrev (prev);
-    if (!bReference) delete object;
-  }
-}
- 
-/**
-  \brief Add an object to the ListTemplate
-  \param obj: A pointer to an allocated object
-  \param mode: A Value of ADDMODE (default: LIST_ADD_NEXT)
-  \param bRef: Sets whether the element is serving as a storage point or a simple listing (default: false)
-  \return 0 if the operation succeded, -1 if the element could not be added
-  
-  This adds a new ListTemplate element to the chain. The mode parameter can be used to specify
-  the location where the element should be added. LIST_ADD_NEXT will add the new element directly
-  after the base element. LIST_ADD_PREV will add the new element directly before the base element.
-  LIST_ADD_FIRST will add the element at the beginning of the ListTemplate whereas LIST_ADD_LAST will add
-  it to the end of the chain. If the bRef parameter is set to true, the object pointer will not be deleted
-  when the element containing that object is deleted, thus the ListTemplate can be used for temporary listings as
-  well as permanent data storage.
-*/
-template<class T> 
-int ListTemplate<T>::add (T* obj, ADDMODE mode = LIST_ADD_NEXT, bool bRef = false)
-{
-  ListTemplate<T>* p;
-  if( obj == NULL) return -1;
-  switch (mode)
-  {
-    case LIST_ADD_NEXT:
-      p = new ListTemplate<T>( obj, next, this, bRef);
-      if( next != NULL) next->setPrev (p);
-      next = p;
-      break;
-    case LIST_ADD_PREV:
-      p = new ListTemplate<T>( obj, this, prev, bRef);
-      if( prev != NULL) prev->setNext (p);
-      prev = p;
-      break;
-    case LIST_ADD_FIRST:
-      if (prev == NULL) prev = new ListTemplate<T> (obj, this, NULL, bRef);
-      else return prev->add (obj, mode, bRef);
-      break;
-    case LIST_ADD_LAST:
-      if (next == NULL) next = new ListTemplate<T> (obj, NULL, this, bRef);
-      else return next->add (obj, mode, bRef);
-      break;
-    default:
-        return -1;
-      break;
-  }
-  ++size;
-  return 0;
-}
-
-/**
-  \brief Get the next element of the ListTemplate
-  \return The ListTemplate element after the current ListTemplate element
-*/
-template<class T>
-ListTemplate<T>* ListTemplate<T>::getNext ()
-{
-  return next;
-}
- 
-/**
-  \brief Get the previous element of the ListTemplate
-  \return The ListTemplate element before the current ListTemplate element
-*/
-template<class T>
-ListTemplate<T>* ListTemplate<T>::getPrevious ()
-{
-  return prev;
-}
-
-/**
-  \brief Get the last element of the ListTemplate
-  \return The last ListTemplate element
-*/
-template<class T>
-ListTemplate<T>* ListTemplate<T>::getLast ()
-{
-  if (next == NULL) return this;
-  else return next->getLast();
-}
-
-/**
-  \brief Get the first element of the ListTemplate
-  \return The first ListTemplate element
-*/
-template<class T>
-ListTemplate<T>* ListTemplate<T>::getFirst ()
-{
-  if (prev == NULL) return this;
-  else return prev->getFirst();
-}
-
-/**
-  \brief Removes a certain element from the ListTemplate
-  \param obj: A pointer to the object that should be removed
-  \param mode: A value of FINDMODE
-  \return 0 if the element was found and removed, -1 if the element was not found
-  
-  This searches the part of the ListTemplate specified with mode for the object in question.
-  When the object is found it is deleted and the ListTemplate element is removed from the chain.
-  If mode is LIST_FIND_FW all elements AFTER the base element are searched, if mode is
-  LIST_FIND_BW all elements BEFORE the base element are searched. Note that the object
-  contained within the ListTemplate element is NOT deleted when bRef was set to true.
-*/
-template<class T>
-int ListTemplate<T>::remove (T* obj, FINDMODE mode = LIST_FIND_FW)
-{
-  if (obj == NULL) return -1;
-  else
-  {
-    switch (mode)
-    {
-      case LIST_FIND_BW:
-        if (prev == NULL) return -1;
-        else
-        {
-          if( prev->getObject() == obj)
-          {
-            delete prev;
-          }
-          else
-          {
-            return prev->remove( obj, mode);
-          }
-        }
-        break;
-      case LIST_FIND_FW:
-        if (next == NULL) return -1;
-        else
-        {
-          if( next->getObject() == obj)
-          {
-            delete next;
-          }
-          else
-          {
-            return next->remove( obj, mode);
-          }
-        }
-        break;
-      default:
-        return -1;
-    }
-  }
-  --size;
-  return 0;
-}
-
-/**
-  \brief Set the next element of a ListTemplate element
-  \param ptr: A pointer to the new next element
-    
-  Sets the next element of a ListTemplate element... Better not touch this, it can really mess up a ListTemplate.
-*/
-template<class T>
-void ListTemplate<T>::setNext (ListTemplate<T>* ptr)
-{
-  next = ptr;
-}
-
-/**
-  \brief Set the prev element of a ListTemplate element
-  \param ptr: A pointer to the new previous element
-    
-  Sets the previous element of a ListTemplate element... Better not touch this, it can really mess up a ListTemplate.
-*/
-template<class T>
-void ListTemplate<T>::setPrev (ListTemplate<T>* ptr)
-{
-  prev = ptr;
-}
-
-/**
-  \brief Get the pointer to the object the element is containing
-  \return The contained object (will be NULL if called on the base element).
-*/
-template<class T>
-T* ListTemplate<T>::getObject()
-{
-  return object;
-}
-
-
-/**
-  \brief Returns the current size of the ListTemplate
-  \return Size of ListTemplate
-*/
-template<class T>
-int ListTemplate<T>::getSize()
-{
-  return this->size;
-}
-
-
-template<class T>
-void ListTemplate<T>::destroy()
-{
-  /* \todo at the moment - doing nothing. should delete everything */
-}
-
-#endif /* _LIST_TENMPLATE_H */
-
Index: orxonox/trunk/src/lib/math/curve.cc
===================================================================
--- orxonox/trunk/src/lib/math/curve.cc	(revision 3483)
+++ orxonox/trunk/src/lib/math/curve.cc	(revision 3483)
@@ -0,0 +1,462 @@
+/* 
+   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: Benjamin Grauer
+   co-programmer: Patrick Boenzli
+
+   ADD: Patrick Boenzli           B-Spline 
+
+
+   TODO: 
+     local-Time implementation
+     NURBS
+     
+*/
+
+#include "curve.h"
+#include "matrix.h"
+#include "debug.h"
+
+#include <math.h>
+#include <stdio.h>
+
+/**
+   \brief adds a new Node to the bezier Curve
+   \param newNode a Vector to the position of the new node
+*/
+void Curve::addNode(const Vector& newNode)
+{
+  if (nodeCount != 0 )
+    {
+      currentNode = currentNode->next = new PathNode;
+    }
+  currentNode->position = newNode;
+  currentNode->next = 0;
+  currentNode->number = (++nodeCount);
+  this->rebuild();
+  return;
+}
+
+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
+   \param nodeToFind the n'th node in the List of nodes
+   \returns A Vector to the Position of the Node.
+*/
+Vector Curve::getNode(unsigned int nodeToFind)
+{
+  if (nodeToFind > this->nodeCount || nodeToFind < 0)
+    return Vector(0,0,0);
+  PathNode* tmpNode = this->firstNode;
+  for (int i = 1; i < nodeToFind; i++)
+    tmpNode = tmpNode->next;
+  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");
+}
+
+
+///////////////////////////////////
+/// Bezier Curve //////////////////
+///////////////////////////////////
+
+/**
+   \brief Creates a new BezierCurve
+*/
+BezierCurve::BezierCurve (void)
+{
+  this->derivation = 0;
+  dirCurve = new BezierCurve(1);
+  this->init();
+}
+
+/**
+   \brief Creates a new BezierCurve-Derivation-Curve
+*/
+BezierCurve::BezierCurve (int derivation)
+{
+  this->derivation = derivation;
+  dirCurve=NULL;
+  this->init();
+}
+
+/**
+   \brief Deletes a BezierCurve.
+
+   It does this by freeing all the space taken over from the nodes
+*/
+BezierCurve::~BezierCurve(void)
+{
+  PathNode* tmpNode;
+  currentNode = firstNode;
+  while (tmpNode != 0)
+    {
+      tmpNode = currentNode;
+      currentNode = currentNode->next;
+      delete tmpNode;
+    }
+  if (dirCurve)
+    delete dirCurve;
+}
+
+/**
+   \brief Initializes a BezierCurve
+*/
+void BezierCurve::init(void)
+{
+  nodeCount = 0;
+  firstNode = new PathNode;
+  currentNode = firstNode;
+
+  firstNode->position = Vector (.0, .0, .0);
+  firstNode->number = 0;
+  firstNode->next = 0; // not sure if this really points to NULL!!
+
+  return;
+}
+
+/**
+   \brief Rebuilds a Curve
+*/
+void BezierCurve::rebuild(void)
+{
+  PathNode* tmpNode = firstNode;
+
+  // rebuilding the Curve itself
+  float k=0;
+  float n = nodeCount -1;
+  float binCoef = 1;
+  while(tmpNode)
+    {
+      tmpNode->factor = binCoef;
+      if (tmpNode =tmpNode->next)
+	{
+	  binCoef *=(n-k)/(k+1);
+	  ++k;
+	}
+    }
+
+  // rebuilding the Derivation curve
+  if(this->derivation <= 1)
+    {
+      tmpNode = firstNode;
+      delete dirCurve;
+      dirCurve = new BezierCurve(1);
+      while(tmpNode->next)
+	{
+	  Vector tmpVector = (tmpNode->next->position)- (tmpNode->position);
+	  tmpVector.x*=(float)nodeCount;
+	  tmpVector.y*=(float)nodeCount;
+	  tmpVector.z*=(float)nodeCount;
+	  tmpVector.normalize();
+	  this->dirCurve->addNode(tmpVector);
+	  tmpNode = tmpNode->next;
+	}
+    }
+}
+
+/**
+   \brief calculates the Position on the curve
+   \param t The position on the Curve (0<=t<=1)
+   \return the Position on the Path
+*/
+Vector BezierCurve::calcPos(float t) 
+{
+  Vector ret = Vector(0.0,0.0,0.0);
+  if (this->nodeCount >= 3)
+    {
+      PathNode* tmpNode = this->firstNode;
+      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;
+	}
+    }
+  else if (nodeCount == 2)
+    {
+      ret = this->firstNode->position *(1.0-t);
+      ret = ret + this->firstNode->next->position * t;
+    }
+  else if (nodeCount == 1)
+    ret = this->firstNode->position;
+  return ret;
+}
+
+/**
+   \brief Calulates the direction of the Curve at time t.
+   \param The time at which to evaluate the curve.
+   \returns The vvaluated Vector.
+*/
+Vector BezierCurve::calcDir (float t)
+{
+  return dirCurve->calcPos(t);
+}
+
+Vector BezierCurve::calcAcc (float t)
+{
+  return dirCurve->dirCurve->calcPos(t);
+}
+
+/**
+   \brief Calculates the Quaternion needed for our rotations
+   \param t The time at which to evaluate the cuve.
+   \returns The evaluated Quaternion.
+*/
+Quaternion BezierCurve::calcQuat (float t)
+{
+  return Quaternion (calcDir(t), Vector(0,0,1));
+}
+
+
+/**
+  \brief returns the Position of the point calculated on the Curve
+  \return a Vector to the calculated position
+*/
+Vector BezierCurve::getPos(void) const
+{
+  return curvePoint;
+}
+
+
+
+///////////////////////////////////
+//// Uniform Point curve  /////////
+///////////////////////////////////
+/**
+   \brief Creates a new UPointCurve
+*/
+UPointCurve::UPointCurve (void)
+{
+  this->derivation = 0;
+  this->init();
+}
+
+/**
+   \brief Creates a new UPointCurve-Derivation-Curve of deriavation'th degree
+*/
+UPointCurve::UPointCurve (int derivation)
+{
+  this->derivation = derivation;
+  dirCurve=NULL;
+  this->init();
+}
+
+/**
+   \brief Deletes a UPointCurve.
+
+   It does this by freeing all the space taken over from the nodes
+*/
+UPointCurve::~UPointCurve(void)
+{
+  PathNode* tmpNode;
+  currentNode = firstNode;
+  while (tmpNode != 0)
+    {
+      tmpNode = currentNode;
+      currentNode = currentNode->next;
+      delete tmpNode;
+    }
+  if (dirCurve)
+    delete dirCurve;
+}
+
+/**
+   \brief Initializes a UPointCurve
+*/
+void UPointCurve::init(void)
+{
+  nodeCount = 0;
+  firstNode = new PathNode;
+  currentNode = firstNode;
+
+  firstNode->position = Vector (.0, .0, .0);
+  firstNode->number = 0;
+  firstNode->next = 0; // not sure if this really points to NULL!!
+
+  return;
+}
+
+/**
+   \brief Rebuilds a UPointCurve
+   
+   \todo very bad algorithm
+*/
+void UPointCurve::rebuild(void)
+{
+  // rebuilding the Curve itself
+  PathNode* tmpNode = this->firstNode;
+  int i=0;
+  Matrix xTmpMat = Matrix(this->nodeCount, this->nodeCount);
+  Matrix yTmpMat = Matrix(this->nodeCount, this->nodeCount);
+  Matrix zTmpMat = Matrix(this->nodeCount, this->nodeCount);
+  Matrix xValMat = Matrix(this->nodeCount, 3);
+  Matrix yValMat = Matrix(this->nodeCount, 3);
+  Matrix zValMat = Matrix(this->nodeCount, 3);
+  while(tmpNode)
+    {
+      Vector fac = Vector(1,1,1);
+      for (int j = 0; j < this->nodeCount; j++)
+	{
+	  xTmpMat(i,j) = fac.x; fac.x *= (float)i/(float)this->nodeCount;//tmpNode->position.x;
+	  yTmpMat(i,j) = fac.y; fac.y *= (float)i/(float)this->nodeCount;//tmpNode->position.y;
+	  zTmpMat(i,j) = fac.z; fac.z *= (float)i/(float)this->nodeCount;//tmpNode->position.z;
+	}
+      xValMat(i,0) = tmpNode->position.x;
+      yValMat(i,0) = tmpNode->position.y;
+      zValMat(i,0) = tmpNode->position.z;
+      ++i;
+      tmpNode = tmpNode->next;
+    }
+  tmpNode = this->firstNode;
+  xValMat = xTmpMat.Inv() *= xValMat;
+  yValMat = yTmpMat.Inv() *= yValMat;
+  zValMat = zTmpMat.Inv() *= zValMat;
+  i = 0;
+  while(tmpNode)
+    {
+      tmpNode->vFactor.x = xValMat(i,0);
+      tmpNode->vFactor.y = yValMat(i,0);
+      tmpNode->vFactor.z = zValMat(i,0);
+
+      i++;
+      tmpNode = tmpNode->next;
+    }
+}
+
+/**
+   \brief calculates the Position on the curve
+   \param t The position on the Curve (0<=t<=1)
+   \return the Position on the Path
+*/
+Vector UPointCurve::calcPos(float t) 
+{
+  PathNode* tmpNode = firstNode;
+  Vector ret = Vector(0.0,0.0,0.0);
+  float factor = 1.0;
+  while(tmpNode)
+    {
+      ret.x += tmpNode->vFactor.x * factor;
+      ret.y += tmpNode->vFactor.y * factor;
+      ret.z += tmpNode->vFactor.z * factor;
+      factor *= t;
+
+      tmpNode = tmpNode->next;
+    }
+  return ret;
+}
+
+/**
+   \brief Calulates the direction of the Curve at time t.
+   \param The time at which to evaluate the curve.
+   \returns The vvaluated Vector.
+*/
+Vector UPointCurve::calcDir (float t)
+{
+  PathNode* tmpNode = firstNode;
+  Vector ret = Vector(0.0,0.0,0.0);
+  float factor = 1.0/t;
+  int k=0;
+  while(tmpNode)
+    {
+      ret.x += tmpNode->vFactor.x * factor *k;
+      ret.y += tmpNode->vFactor.y * factor *k;
+      ret.z += tmpNode->vFactor.z * factor *k;
+      factor *= t;
+      k++;
+      tmpNode = tmpNode->next;
+    }
+  ret.normalize();
+  return ret;
+}
+
+Vector UPointCurve::calcAcc (float t)
+{
+}
+
+/**
+   \brief Calculates the Quaternion needed for our rotations
+   \param t The time at which to evaluate the cuve.
+   \returns The evaluated Quaternion.
+*/
+Quaternion UPointCurve::calcQuat (float t)
+{
+  return Quaternion (calcDir(t), Vector(0,0,1));
+}
+
+
+/**
+  \brief returns the Position of the point calculated on the Curve
+  \return a Vector to the calculated position
+*/
+Vector UPointCurve::getPos(void) const
+{
+  return curvePoint;
+}
Index: orxonox/trunk/src/lib/math/curve.h
===================================================================
--- orxonox/trunk/src/lib/math/curve.h	(revision 3483)
+++ orxonox/trunk/src/lib/math/curve.h	(revision 3483)
@@ -0,0 +1,118 @@
+
+/*! 
+    \file curve.h
+    \brief A basic 3D curve framework
+    
+    Contains classes to handle curves
+*/ 
+
+#ifndef _CURVE_H
+#define _CURVE_H
+
+#include "vector.h"
+
+//! An Enumerator that defines what sort of Curves are availible
+enum CurveType {BEZIERCURVE, UPOINTCURVE};
+
+
+//! An abstract class to handle curves. Needed for the Tracking system in orxonox.
+class Curve
+{
+ protected:
+  int nodeCount;         //!< The count of nodes the Curve has.
+  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.
+  int derivation;        //!< Which derivation of a Curve is this.
+
+  //! Handles the curve-points (dynamic List)
+  struct PathNode
+  {
+    int number;          //!< The N-th node of this curve.
+    float factor;        //!< Curve specific multiplier factor.
+    Vector vFactor;      //!< A Vector-factor for multipliing.
+    Vector position;     //!< Vector Pointung to this curve-point.
+    PathNode* next;      //!< Pointer to the next Node.
+  };
+
+  PathNode* firstNode;   //!< First node of the curve.
+  PathNode* currentNode; //!< The node we are working with (the Last node).
+
+ private:
+  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;}
+
+  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);
+};
+
+//!    Class to handle bezier curves in 3-dimesnsional space
+/**
+   This Curve is good, for Fast Interaction. If you want to change it during the game, go on.
+   !!be aware!! BezierCurves only flow through their first and last Node. Their Tangents at those Points a directed to the second and second-last Point.
+*/
+class BezierCurve : public Curve
+{
+ private:
+  void rebuild(void);
+ public:
+  BezierCurve(void);
+  BezierCurve(int derivation);
+  ~BezierCurve(void);
+  void init(void);
+
+  Vector calcPos(float t);
+  Vector calcDir(float t);
+  Vector calcAcc(float t);
+  Quaternion calcQuat(float t);
+  
+  
+  Vector getPos(void) const;
+};
+
+
+//! B-Spline
+/**
+   class to handle b-spline in 3d space
+*/
+class BSplieCurve : public Curve
+{
+
+
+};
+
+//! Uniform Point Curve-class
+/**
+   A UPoint Curve is a A Curve, that flows through all the nodes given it.
+   The Algorithm to buid the curve is rather slow, but Painting and tracing along the curve has high speed, so do not change this curve during the Game.
+
+   This Curve is very erattic, so i do not recommend to use it.
+*/
+class UPointCurve : public Curve
+{
+ private:
+  void rebuild(void);
+ public:
+  UPointCurve(void);
+  UPointCurve(int derivation);
+  ~UPointCurve(void);
+  void init(void);
+
+  Vector calcPos(float t);
+  Vector calcDir(float t);
+  Vector calcAcc(float t);
+  Quaternion calcQuat(float t);
+  
+  Vector getPos(void) const;
+};
+
+#endif /* _CURVE_H */
Index: orxonox/trunk/src/lib/math/matrix.cc
===================================================================
--- orxonox/trunk/src/lib/math/matrix.cc	(revision 3483)
+++ orxonox/trunk/src/lib/math/matrix.cc	(revision 3483)
@@ -0,0 +1,746 @@
+
+/* 
+   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: Benjamin Grauer
+   co-programmer: ...
+
+   \todo Null-Parent => center of the coord system - singleton
+   \todo Smooth-Parent: delay, speed
+   \todo destroy the stuff again, delete...
+*/
+
+#include "matrix.h"
+
+Matrix::Matrix (size_t row, size_t col)
+{
+  _m = new base_mat( row, col, 0);
+}
+
+// copy constructor
+Matrix::Matrix (const Matrix& m)
+{
+    _m = m._m;
+    _m->Refcnt++;
+}
+
+// Internal copy constructor
+void Matrix::clone ()
+{
+    _m->Refcnt--;
+    _m = new base_mat( _m->Row, _m->Col, _m->Val);
+}
+
+// destructor
+Matrix::~Matrix ()
+{
+   if (--_m->Refcnt == 0) delete _m;
+}
+
+// assignment operator
+Matrix& Matrix::operator = (const Matrix& m) 
+{
+    m._m->Refcnt++;
+    if (--_m->Refcnt == 0) delete _m;
+    _m = m._m;
+    return *this;
+}
+
+//  reallocation method
+void Matrix::realloc (size_t row, size_t col)
+{
+   if (row == _m->RowSiz && col == _m->ColSiz)
+   {
+      _m->Row = _m->RowSiz;
+      _m->Col = _m->ColSiz;
+      return;
+   }
+
+   base_mat *m1 = new base_mat( row, col, NULL);
+   size_t colSize = min(_m->Col,col) * sizeof(float);
+   size_t minRow = min(_m->Row,row);
+
+   for (size_t i=0; i < minRow; i++)
+      memcpy( m1->Val[i], _m->Val[i], colSize);
+
+   if (--_m->Refcnt == 0) 
+       delete _m;
+   _m = m1;
+
+   return;
+}
+
+// public method for resizing Matrix
+void Matrix::SetSize (size_t row, size_t col) 
+{
+   size_t i,j;
+   size_t oldRow = _m->Row;
+   size_t oldCol = _m->Col;
+
+   if (row != _m->RowSiz || col != _m->ColSiz)
+      realloc( row, col);
+
+   for (i=oldRow; i < row; i++)
+      for (j=0; j < col; j++)
+	 _m->Val[i][j] = float(0);
+
+   for (i=0; i < row; i++)                      
+      for (j=oldCol; j < col; j++)
+	 _m->Val[i][j] = float(0);
+
+   return;
+}
+
+// subscript operator to get/set individual elements
+float& Matrix::operator () (size_t row, size_t col) 
+{
+   if (row >= _m->Row || col >= _m->Col)
+      printf( "Matrix::operator(): Index out of range!\n");
+   if (_m->Refcnt > 1) clone();
+   return _m->Val[row][col];
+}
+
+// subscript operator to get/set individual elements
+float Matrix::operator () (size_t row, size_t col) const 
+{
+   if (row >= _m->Row || col >= _m->Col)
+      printf( "Matrix::operator(): Index out of range!\n");
+   return _m->Val[row][col];
+}
+
+// input stream function
+istream& operator >> (istream& istrm, Matrix& m)
+{
+   for (size_t i=0; i < m.RowNo(); i++)
+      for (size_t j=0; j < m.ColNo(); j++)
+      {
+         float x;
+         istrm >> x;
+         m(i,j) = x;
+      }
+   return istrm;
+}
+
+// output stream function
+ostream& operator << (ostream& ostrm, const Matrix& m)
+{
+   for (size_t i=0; i < m.RowNo(); i++)
+   {
+      for (size_t j=0; j < m.ColNo(); j++)
+      {
+         float x = m(i,j);
+         ostrm << x << '\t';
+      }
+      ostrm << endl;
+   }
+   return ostrm;
+}
+
+
+// logical equal-to operator
+bool operator == (const Matrix& m1, const Matrix& m2) 
+{
+   if (m1.RowNo() != m2.RowNo() || m1.ColNo() != m2.ColNo())
+      return false;
+
+   for (size_t i=0; i < m1.RowNo(); i++)
+      for (size_t j=0; j < m1.ColNo(); j++)
+	      if (m1(i,j) != m2(i,j))
+	         return false;
+
+   return true;
+}
+
+// logical no-equal-to operator
+bool operator != (const Matrix& m1, const Matrix& m2) 
+{
+    return (m1 == m2) ? false : true;
+}
+
+// combined addition and assignment operator
+Matrix& Matrix::operator += (const Matrix& m) 
+{
+   if (_m->Row != m._m->Row || _m->Col != m._m->Col)
+     printf("Matrix::operator+= : Inconsistent Matrix sizes in addition!\n");
+   if (_m->Refcnt > 1) clone();
+   for (size_t i=0; i < m._m->Row; i++)
+      for (size_t j=0; j < m._m->Col; j++)
+	 _m->Val[i][j] += m._m->Val[i][j];
+   return *this;
+}
+
+// combined subtraction and assignment operator
+Matrix& Matrix::operator -= (const Matrix& m) 
+{
+   if (_m->Row != m._m->Row || _m->Col != m._m->Col)
+      printf( "Matrix::operator-= : Inconsistent Matrix sizes in subtraction!\n");
+   if (_m->Refcnt > 1) clone();
+   for (size_t i=0; i < m._m->Row; i++)
+      for (size_t j=0; j < m._m->Col; j++)
+	 _m->Val[i][j] -= m._m->Val[i][j];
+   return *this;
+}
+
+// combined scalar multiplication and assignment operator
+ Matrix&
+Matrix::operator *= (const float& c) 
+{
+    if (_m->Refcnt > 1) clone();
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+	    _m->Val[i][j] *= c;
+    return *this;
+}
+
+// combined Matrix multiplication and assignment operator
+ Matrix&
+Matrix::operator *= (const Matrix& m) 
+{
+   if (_m->Col != m._m->Row)
+      printf( "Matrix::operator*= : Inconsistent Matrix sizes in multiplication!\n");
+
+   Matrix temp(_m->Row,m._m->Col);
+
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < m._m->Col; j++)
+      {
+         temp._m->Val[i][j] = float(0);
+         for (size_t k=0; k < _m->Col; k++)
+            temp._m->Val[i][j] += _m->Val[i][k] * m._m->Val[k][j];
+      }
+   *this = temp;
+
+   return *this;
+}
+
+// combined scalar division and assignment operator
+ Matrix&
+Matrix::operator /= (const float& c) 
+{
+    if (_m->Refcnt > 1) clone();
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+	    _m->Val[i][j] /= c;
+
+    return *this;
+}
+
+// combined power and assignment operator
+ Matrix&
+Matrix::operator ^= (const size_t& pow) 
+{
+  Matrix temp(*this);
+
+  for (size_t i=2; i <= pow; i++)
+    *this *=  temp; // changed from *this = *this * temp;
+
+  return *this;
+}
+
+// unary negation operator
+ Matrix
+Matrix::operator - () 
+{
+   Matrix temp(_m->Row,_m->Col);
+
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	 temp._m->Val[i][j] = - _m->Val[i][j];
+
+   return temp;
+}
+
+// binary addition operator
+ Matrix
+operator + (const Matrix& m1, const Matrix& m2) 
+{
+   Matrix temp = m1;
+   temp += m2;
+   return temp;
+}
+
+// binary subtraction operator
+ Matrix
+operator - (const Matrix& m1, const Matrix& m2) 
+{
+   Matrix temp = m1;
+   temp -= m2;
+   return temp;
+}
+
+// binary scalar multiplication operator
+ Matrix
+operator * (const Matrix& m, const float& no) 
+{
+   Matrix temp = m;
+   temp *= no;
+   return temp;
+}
+
+
+// binary scalar multiplication operator
+ Matrix
+operator * (const float& no, const Matrix& m) 
+{
+   return (m * no);
+}
+
+// binary Matrix multiplication operator
+ Matrix
+operator * (const Matrix& m1, const Matrix& m2) 
+{
+   Matrix temp = m1;
+   temp *= m2;
+   return temp;
+}
+
+// binary scalar division operator
+ Matrix
+operator / (const Matrix& m, const float& no) 
+{
+    return (m * (float(1) / no));
+}
+
+
+// binary scalar division operator
+ Matrix
+operator / (const float& no, const Matrix& m) 
+{
+    return (!m * no);
+}
+
+// binary Matrix division operator
+ Matrix
+operator / (const Matrix& m1, const Matrix& m2) 
+{
+    return (m1 * !m2);
+}
+
+// binary power operator
+ Matrix
+operator ^ (const Matrix& m, const size_t& pow) 
+{
+   Matrix temp = m;
+   temp ^= pow;
+   return temp;
+}
+
+// unary transpose operator
+ Matrix
+operator ~ (const Matrix& m) 
+{
+   Matrix temp(m.ColNo(),m.RowNo());
+
+   for (size_t i=0; i < m.RowNo(); i++)
+      for (size_t j=0; j < m.ColNo(); j++)
+      {
+         float x = m(i,j);
+	      temp(j,i) = x;
+      }
+   return temp;
+}
+
+// unary inversion operator
+ Matrix
+operator ! (const Matrix m) 
+{
+   Matrix temp = m;
+   return temp.Inv();
+}
+
+// inversion function
+ Matrix
+Matrix::Inv () 
+{
+   size_t i,j,k;
+   float a1,a2,*rowptr;
+
+   if (_m->Row != _m->Col)
+      printf( "Matrix::operator!: Inversion of a non-square Matrix\n");
+
+   Matrix temp(_m->Row,_m->Col);
+   if (_m->Refcnt > 1) clone();
+
+
+   temp.Unit();
+   for (k=0; k < _m->Row; k++)
+   {
+      int indx = pivot(k);
+      if (indx == -1)
+	      printf( "Matrix::operator!: Inversion of a singular Matrix\n");
+
+      if (indx != 0)
+      {
+	      rowptr = temp._m->Val[k];
+	      temp._m->Val[k] = temp._m->Val[indx];
+	      temp._m->Val[indx] = rowptr;
+      }
+      a1 = _m->Val[k][k];
+      for (j=0; j < _m->Row; j++)
+      {
+	      _m->Val[k][j] /= a1;
+	      temp._m->Val[k][j] /= a1;
+      }
+      for (i=0; i < _m->Row; i++)
+	   if (i != k)
+	   {
+	      a2 = _m->Val[i][k];
+	      for (j=0; j < _m->Row; j++)
+	      {
+	         _m->Val[i][j] -= a2 * _m->Val[k][j];
+	         temp._m->Val[i][j] -= a2 * temp._m->Val[k][j];
+	      }
+	   }
+   }
+   return temp;
+}
+
+// solve simultaneous equation
+ Matrix
+Matrix::Solve (const Matrix& v) const 
+{
+   size_t i,j,k;
+   float a1;
+
+   if (!(_m->Row == _m->Col && _m->Col == v._m->Row))
+      printf( "Matrix::Solve():Inconsistent matrices!\n");
+
+   Matrix temp(_m->Row,_m->Col+v._m->Col);
+   for (i=0; i < _m->Row; i++)
+   {
+      for (j=0; j < _m->Col; j++)
+	 temp._m->Val[i][j] = _m->Val[i][j];
+      for (k=0; k < v._m->Col; k++)
+	 temp._m->Val[i][_m->Col+k] = v._m->Val[i][k];
+   }
+   for (k=0; k < _m->Row; k++)
+   {
+      int indx = temp.pivot(k);
+      if (indx == -1)
+	 printf( "Matrix::Solve(): Singular Matrix!\n");
+
+      a1 = temp._m->Val[k][k];
+      for (j=k; j < temp._m->Col; j++)
+	 temp._m->Val[k][j] /= a1;
+
+      for (i=k+1; i < _m->Row; i++)
+      {
+	 a1 = temp._m->Val[i][k];
+	 for (j=k; j < temp._m->Col; j++)
+	   temp._m->Val[i][j] -= a1 * temp._m->Val[k][j];
+      }
+   }
+   Matrix s(v._m->Row,v._m->Col);
+   for (k=0; k < v._m->Col; k++)
+      for (int m=int(_m->Row)-1; m >= 0; m--)
+      {
+	 s._m->Val[m][k] = temp._m->Val[m][_m->Col+k];
+	 for (j=m+1; j < _m->Col; j++)
+	    s._m->Val[m][k] -= temp._m->Val[m][j] * s._m->Val[j][k];
+      }
+   return s;
+}
+
+// set zero to all elements of this Matrix
+ void
+Matrix::Null (const size_t& row, const size_t& col) 
+{
+    if (row != _m->Row || col != _m->Col)
+	realloc( row,col);
+
+    if (_m->Refcnt > 1) 
+	clone();
+
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+	    _m->Val[i][j] = float(0);
+    return;
+}
+
+// set zero to all elements of this Matrix
+ void
+Matrix::Null() 
+{
+    if (_m->Refcnt > 1) clone();   
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+		_m->Val[i][j] = float(0);
+    return;
+}
+
+// set this Matrix to unity
+ void
+Matrix::Unit (const size_t& row) 
+{
+    if (row != _m->Row || row != _m->Col)
+	realloc( row, row);
+	
+    if (_m->Refcnt > 1) 
+	clone();
+
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+	    _m->Val[i][j] = i == j ? float(1) : float(0);
+    return;
+}
+
+// set this Matrix to unity
+ void
+Matrix::Unit () 
+{
+    if (_m->Refcnt > 1) clone();   
+    size_t row = min(_m->Row,_m->Col);
+    _m->Row = _m->Col = row;
+
+    for (size_t i=0; i < _m->Row; i++)
+	for (size_t j=0; j < _m->Col; j++)
+	    _m->Val[i][j] = i == j ? float(1) : float(0);
+    return;
+}
+
+// private partial pivoting method
+ int
+Matrix::pivot (size_t row)
+{
+  int k = int(row);
+  double amax,temp;
+
+  amax = -1;
+  for (size_t i=row; i < _m->Row; i++)
+    if ( (temp = abs( _m->Val[i][row])) > amax && temp != 0.0)
+     {
+       amax = temp;
+       k = i;
+     }
+  if (_m->Val[k][row] == float(0))
+     return -1;
+  if (k != int(row))
+  {
+     float* rowptr = _m->Val[k];
+     _m->Val[k] = _m->Val[row];
+     _m->Val[row] = rowptr;
+     return k;
+  }
+  return 0;
+}
+
+// calculate the determinant of a Matrix
+ float
+Matrix::Det () const 
+{
+   size_t i,j,k;
+   float piv,detVal = float(1);
+
+   if (_m->Row != _m->Col)
+      printf( "Matrix::Det(): Determinant a non-squareMatrix!\n");
+   
+   Matrix temp(*this);
+   if (temp._m->Refcnt > 1) temp.clone();
+
+   for (k=0; k < _m->Row; k++)
+   {
+      int indx = temp.pivot(k);
+      if (indx == -1)
+	 return 0;
+      if (indx != 0)
+	 detVal = - detVal;
+      detVal = detVal * temp._m->Val[k][k];
+      for (i=k+1; i < _m->Row; i++)
+      {
+	 piv = temp._m->Val[i][k] / temp._m->Val[k][k];
+	 for (j=k+1; j < _m->Row; j++)
+	    temp._m->Val[i][j] -= piv * temp._m->Val[k][j];
+      }
+   }
+   return detVal;
+}
+
+// calculate the norm of a Matrix
+ float
+Matrix::Norm () 
+{
+   float retVal = float(0);
+
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	 retVal += _m->Val[i][j] * _m->Val[i][j];
+   retVal = sqrt( retVal);
+
+   return retVal;
+}
+
+// calculate the condition number of a Matrix
+ float
+Matrix::Cond () 
+{
+   Matrix inv = ! (*this);
+   return (Norm() * inv.Norm());
+}
+
+// calculate the cofactor of a Matrix for a given element
+ float
+Matrix::Cofact (size_t row, size_t col) 
+{
+   size_t i,i1,j,j1;
+
+   if (_m->Row != _m->Col)
+      printf( "Matrix::Cofact(): Cofactor of a non-square Matrix!\n");
+
+   if (row > _m->Row || col > _m->Col)
+      printf( "Matrix::Cofact(): Index out of range!\n");
+
+   Matrix temp (_m->Row-1,_m->Col-1);
+
+   for (i=i1=0; i < _m->Row; i++)
+   {
+      if (i == row)
+	continue;
+      for (j=j1=0; j < _m->Col; j++)
+      {
+	 if (j == col)
+	    continue;
+	 temp._m->Val[i1][j1] = _m->Val[i][j];
+	 j1++;
+      }
+      i1++;
+   }
+   float  cof = temp.Det();
+   if ((row+col)%2 == 1)
+      cof = -cof;
+
+   return cof;
+}
+
+
+// calculate adjoin of a Matrix
+ Matrix
+Matrix::Adj () 
+{
+   if (_m->Row != _m->Col)
+      printf( "Matrix::Adj(): Adjoin of a non-square Matrix.\n");
+
+   Matrix temp(_m->Row,_m->Col);
+
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	  temp._m->Val[j][i] = Cofact(i,j);
+   return temp;
+}
+
+// Determine if the Matrix is singular
+ bool
+Matrix::IsSingular () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+   return (Det() == float(0));
+}
+
+// Determine if the Matrix is diagonal
+ bool
+Matrix::IsDiagonal () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+   for (size_t i=0; i < _m->Row; i++)
+     for (size_t j=0; j < _m->Col; j++)
+	if (i != j && _m->Val[i][j] != float(0))
+	  return false;
+   return true;
+}
+
+// Determine if the Matrix is scalar
+ bool
+Matrix::IsScalar () 
+{
+   if (!IsDiagonal())
+     return false;
+   float v = _m->Val[0][0];
+   for (size_t i=1; i < _m->Row; i++)
+     if (_m->Val[i][i] != v)
+	return false;
+   return true;
+}
+
+// Determine if the Matrix is a unit Matrix
+ bool
+Matrix::IsUnit () 
+{
+   if (IsScalar() && _m->Val[0][0] == float(1))
+     return true;
+   return false;
+}
+
+// Determine if this is a null Matrix
+ bool
+Matrix::IsNull () 
+{
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	 if (_m->Val[i][j] != float(0))
+	    return false;
+   return true;
+}
+
+// Determine if the Matrix is symmetric
+ bool
+Matrix::IsSymmetric () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	 if (_m->Val[i][j] != _m->Val[j][i])
+	    return false;
+   return true;
+}
+	   
+// Determine if the Matrix is skew-symmetric
+ bool
+Matrix::IsSkewSymmetric () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+   for (size_t i=0; i < _m->Row; i++)
+      for (size_t j=0; j < _m->Col; j++)
+	 if (_m->Val[i][j] != -_m->Val[j][i])
+	    return false;
+   return true;
+}
+   
+// Determine if the Matrix is upper triangular
+ bool
+Matrix::IsUpperTriangular () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+   for (size_t i=1; i < _m->Row; i++)
+      for (size_t j=0; j < i-1; j++)
+	 if (_m->Val[i][j] != float(0))
+	    return false;
+   return true;
+}
+
+// Determine if the Matrix is lower triangular
+ bool
+Matrix::IsLowerTriangular () 
+{
+   if (_m->Row != _m->Col)
+      return false;
+
+   for (size_t j=1; j < _m->Col; j++)
+      for (size_t i=0; i < j-1; i++)
+	 if (_m->Val[i][j] != float(0))
+	    return false;
+
+   return true;
+}
+
Index: orxonox/trunk/src/lib/math/matrix.h
===================================================================
--- orxonox/trunk/src/lib/math/matrix.h	(revision 3483)
+++ orxonox/trunk/src/lib/math/matrix.h	(revision 3483)
@@ -0,0 +1,110 @@
+#ifndef _MATRIX_H
+#define _MATRIX_H
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+
+using namespace std;
+
+class Matrix
+{
+public:
+  // Constructors
+  Matrix (const Matrix& m);
+  Matrix (size_t row, size_t col);
+  
+  // Destructor
+  ~Matrix ();
+  
+  // Assignment operators
+  Matrix& operator = (const Matrix& m) ;
+  
+  // Value extraction method
+  size_t RowNo () const { return _m->Row; }
+  size_t ColNo () const { return _m->Col; }
+  
+  // Subscript operator
+  float& operator () (size_t row, size_t col);
+   float  operator () (size_t row, size_t col) const;
+
+   // Unary operators
+   Matrix operator + ()  { return *this; }
+   Matrix operator - () ;
+
+   // Combined assignment - calculation operators
+   Matrix& operator += (const Matrix& m);
+   Matrix& operator -= (const Matrix& m);
+   Matrix& operator *= (const Matrix& m);
+   Matrix& operator *= (const float& c) ;
+   Matrix& operator /= (const float& c) ;
+   Matrix& operator ^= (const size_t& pow);
+
+   // Miscellaneous -methods
+   void Null (const size_t& row, const size_t& col) ;
+   void Null () ;
+   void Unit (const size_t& row) ;
+   void Unit () ;
+   void SetSize (size_t row, size_t col) ;
+
+   // Utility methods
+   Matrix Solve (const Matrix& v) const;
+   Matrix Adj ();
+   Matrix Inv ();
+   float Det () const;
+   float Norm () ;
+   float Cofact (size_t row, size_t col);
+   float Cond () ;
+
+   // Type of matrices
+   bool IsSquare ()  { return (_m->Row == _m->Col); } 
+   bool IsSingular ();
+   bool IsDiagonal ();
+   bool IsScalar ();
+   bool IsUnit ();
+   bool IsNull ();
+   bool IsSymmetric ();
+   bool IsSkewSymmetric ();
+   bool IsUpperTriangular ();
+   bool IsLowerTriangular ();
+
+private:
+   struct base_mat
+    {
+	float **Val;
+	size_t Row, Col, RowSiz, ColSiz;
+	int Refcnt;
+
+	base_mat (size_t row, size_t col, float** v)
+	{
+	    Row = row; RowSiz = row;
+	    Col = col; ColSiz = col;
+	    Refcnt = 1;
+
+	    Val = new float* [row];
+	    size_t rowlen = col * sizeof(float);
+
+	    for (size_t i=0; i < row; i++)
+	    {
+		Val[i] = new float [col];
+		if (v) memcpy( Val[i], v[i], rowlen);
+	    }
+	}
+	~base_mat ()
+	{
+	    for (size_t i=0; i < RowSiz; i++)
+		delete [] Val[i];
+	    delete [] Val;
+	}
+    };
+    base_mat *_m;
+
+    void clone ();
+    void realloc (size_t row, size_t col);
+    int pivot (size_t row);
+};
+
+Matrix operator ! (const Matrix m);
+
+#endif /*_MATRIX_H */
Index: orxonox/trunk/src/lib/math/vector.cc
===================================================================
--- orxonox/trunk/src/lib/math/vector.cc	(revision 3483)
+++ orxonox/trunk/src/lib/math/vector.cc	(revision 3483)
@@ -0,0 +1,856 @@
+
+
+/* 
+   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: Patrick Boenzli : Vector::scale()
+                                    Vector::abs()
+   
+   Quaternion code borrowed from an Gamasutra article by Nick Bobick and Ken Shoemake
+*/
+
+
+#include "vector.h"
+
+
+using namespace std;
+
+/**
+   \brief add two vectors
+   \param v: the other vector
+   \return the sum of both vectors
+*/
+Vector Vector::operator+ (const Vector& v) const
+{
+  Vector r;
+
+  r.x = x + v.x;
+  r.y = y + v.y;
+  r.z = z + v.z;
+  
+  return r;
+}
+
+/**
+   \brief subtract a vector from another
+   \param v: the other vector
+   \return the difference between the vectors
+*/
+Vector Vector::operator- (const Vector& v) const
+{
+  Vector r;
+  
+  r.x = x - v.x;
+  r.y = y - v.y;
+  r.z = z - v.z;
+  
+  return r;
+}
+
+/**
+   \brief calculate the dot product of two vectors
+   \param v: the other vector
+   \return the dot product of the vectors
+*/
+float Vector::operator* (const Vector& v) const
+{
+  return x*v.x+y*v.y+z*v.z;
+}
+
+/**
+   \brief multiply a vector with a float
+   \param f: the factor
+   \return the vector multipied by f
+*/
+Vector Vector::operator* (float f) const
+{  
+  Vector r;
+  
+  r.x = x * f;
+  r.y = y * f;
+  r.z = z * f;
+  
+  return r;
+}
+
+/**
+   \brief divide a vector with a float
+   \param f: the divisor
+   \return the vector divided by f   
+*/
+Vector Vector::operator/ (float f) const
+{
+  Vector r;
+  
+  if( f == 0.0)
+  {
+    // Prevent divide by zero
+    return Vector (0,0,0);
+  }
+  
+  r.x = x / f;
+  r.y = y / f;
+  r.z = z / f;
+  
+  return r;
+}
+
+/**
+   \brief calculate the dot product of two vectors
+   \param v: the other vector
+   \return the dot product of the vectors
+*/
+float Vector::dot (const Vector& v) const
+{
+  return x*v.x+y*v.y+z*v.z;
+}
+
+/**
+  \brief calculate the cross product of two vectors
+  \param v: the other vector
+	\return the cross product of the vectors
+*/
+Vector Vector::cross (const Vector& v) const
+{
+  Vector r;
+  
+  r.x = y * v.z - z * v.y;
+  r.y = z * v.x - x * v.z;
+  r.z = x * v.y - y * v.x;
+  
+  return r;
+}
+  
+/**
+   \brief normalizes the vector to lenght 1.0
+*/
+void Vector::normalize ()
+{
+  float l = len();
+  
+  if( l == 0.0)
+  {
+    // Prevent divide by zero
+    return;
+  }
+  
+  x = x / l;
+  y = y / l;
+  z = z / l;
+}
+
+
+/**
+   \brief returns the voctor normalized to length 1.0
+*/
+
+Vector* Vector::getNormalized()
+{
+  float l = len();
+  if(l != 1.0)
+    {
+      return this;
+    }
+  else if(l == 0.0)
+    {
+      return 0;
+    }
+  
+  Vector *normalizedVector = new Vector(x / l, y /l, z / l);
+  return normalizedVector;
+}
+
+/**
+   \brief scales this Vector with Vector v.
+   \param v the vector to scale this vector with
+*/
+void Vector::scale(const Vector& v)
+{
+  x *= v.x;
+  y *= v.y;
+  z *= v.z;
+}
+
+ 
+/**
+   \brief calculates the lenght of the vector
+   \return the lenght of the vector
+*/
+float Vector::len () const
+{
+  return sqrt (x*x+y*y+z*z);
+}
+
+
+/**
+   \brief Vector is looking in the positive direction on all axes after this
+*/
+Vector Vector::abs() 
+{
+  Vector v(fabs(x), fabs(y), fabs(z));
+  return v;
+}
+
+
+/**
+   \brief calculate the angle between two vectors in radiances
+   \param v1: a vector
+   \param v2: another vector
+   \return the angle between the vectors in radians
+*/
+float angleRad (const Vector& v1, const Vector& v2)
+{
+  return acos( v1 * v2 / (v1.len() * v2.len()));
+}
+
+
+/**
+   \brief calculate the angle between two vectors in degrees
+   \param v1: a vector
+   \param v2: another vector
+   \return the angle between the vectors in degrees
+*/
+float angleDeg (const Vector& v1, const Vector& v2)
+{
+  float f;
+  f = acos( v1 * v2 / (v1.len() * v2.len()));
+  return f * 180 / PI;
+}
+
+/**
+	\brief creates a multiplicational identity Quaternion
+*/
+Quaternion::Quaternion ()
+{
+	w = 1;
+	v = Vector(0,0,0);
+}
+
+/**
+	\brief turns a rotation along an axis into a Quaternion
+	\param angle: the amount of radians to rotate
+	\param axis: the axis to rotate around
+*/
+Quaternion::Quaternion (float angle, const Vector& axis)
+{
+	w = cos(angle/2);
+	v = axis * sin(angle/2);
+}
+
+/**
+   \brief calculates a lookAt rotation
+   \param dir: the direction you want to look
+   \param up: specify what direction up should be
+   
+   Mathematically this determines the rotation a (0,0,1)-Vector has to undergo to point
+   the same way as dir. If you want to use this with cameras, you'll have to reverse the
+   dir Vector (Vector(0,0,0) - your viewing direction) or you'll point the wrong way. You
+   can use this for meshes as well (then you do not have to reverse the vector), but keep 
+   in mind that if you do that, the model's front has to point in +z direction, and left 
+   and right should be -x or +x respectively or the mesh wont rotate correctly.
+*/
+Quaternion::Quaternion (const Vector& dir, const Vector& up)
+{
+  Vector z = dir;
+  z.normalize(); 
+  Vector x = up.cross(z);
+  x.normalize(); 
+  Vector y = z.cross(x);
+  
+  float m[4][4];
+  m[0][0] = x.x;
+  m[0][1] = x.y;
+  m[0][2] = x.z;
+  m[0][3] = 0;
+  m[1][0] = y.x;
+  m[1][1] = y.y;
+  m[1][2] = y.z;
+  m[1][3] = 0;
+  m[2][0] = z.x;
+  m[2][1] = z.y;
+  m[2][2] = z.z;
+  m[2][3] = 0;
+  m[3][0] = 0;
+  m[3][1] = 0;
+  m[3][2] = 0;
+  m[3][3] = 1;
+  
+  *this = Quaternion (m);
+}
+
+/**
+	\brief calculates a rotation from euler angles
+	\param roll: the roll in radians
+	\param pitch: the pitch in radians
+	\param yaw: the yaw in radians
+	
+	I DO HONESTLY NOT EXACTLY KNOW WHICH ANGLE REPRESENTS WHICH ROTATION. And I do not know 
+	in what order they are applied,	I just copy-pasted the code.
+*/
+Quaternion::Quaternion (float roll, float pitch, float yaw)
+{
+	float cr, cp, cy, sr, sp, sy, cpcy, spsy;
+	
+	// calculate trig identities
+	cr = cos(roll/2);
+	cp = cos(pitch/2);
+	cy = cos(yaw/2);
+	
+	sr = sin(roll/2);
+	sp = sin(pitch/2);
+	sy = sin(yaw/2);
+	
+	cpcy = cp * cy;
+	spsy = sp * sy;
+	
+	w = cr * cpcy + sr * spsy;
+	v.x = sr * cpcy - cr * spsy;
+	v.y = cr * sp * cy + sr * cp * sy;
+	v.z = cr * cp * sy - sr * sp * cy;
+}
+
+/**
+	\brief rotates one Quaternion by another
+	\param q: another Quaternion to rotate this by
+	\return a quaternion that represents the first one rotated by the second one (WARUNING: this operation is not commutative! e.g. (A*B) != (B*A))
+*/
+Quaternion Quaternion::operator*(const Quaternion& q) const
+{
+	float A, B, C, D, E, F, G, H;
+	Quaternion r;
+	
+	A = (w   + v.x)*(q.w   + q.v.x);
+	B = (v.z - v.y)*(q.v.y - q.v.z);
+	C = (w   - v.x)*(q.v.y + q.v.z); 
+	D = (v.y + v.z)*(q.w   - q.v.x);
+	E = (v.x + v.z)*(q.v.x + q.v.y);
+	F = (v.x - v.z)*(q.v.x - q.v.y);
+	G = (w   + v.y)*(q.w   - q.v.z);
+	H = (w   - v.y)*(q.w   + q.v.z);
+	
+	r.w = B +  (-E - F + G + H)/2;
+	r.v.x = A - (E + F + G + H)/2; 
+	r.v.y = C + (E - F + G - H)/2; 
+	r.v.z = D + (E - F - G + H)/2;
+	
+	return r;
+}
+
+/**
+	\brief add two Quaternions
+	\param q: another Quaternion
+	\return the sum of both Quaternions
+*/
+Quaternion Quaternion::operator+(const Quaternion& q) const
+{
+	Quaternion r(*this);
+	r.w = r.w + q.w;
+	r.v = r.v + q.v;
+	return r;
+}
+
+/**
+	\brief subtract two Quaternions
+	\param q: another Quaternion
+	\return the difference of both Quaternions
+*/
+Quaternion Quaternion::operator- (const Quaternion& q) const
+{
+	Quaternion r(*this);
+	r.w = r.w - q.w;
+	r.v = r.v - q.v;
+	return r;
+}
+
+/**
+	\brief rotate a Vector by a Quaternion
+	\param v: the Vector
+	\return a new Vector representing v rotated by the Quaternion
+*/
+Vector Quaternion::apply (Vector& v) const
+{
+	Quaternion q;
+	q.v = v;
+	q.w = 0;
+	q = *this * q * conjugate();
+	return q.v;
+}
+
+/**
+	\brief multiply a Quaternion with a real value
+	\param f: a real value
+	\return a new Quaternion containing the product
+*/
+Quaternion Quaternion::operator*(const float& f) const
+{
+	Quaternion r(*this);
+	r.w = r.w*f;
+	r.v = r.v*f;
+	return r;
+}
+
+/**
+	\brief divide a Quaternion by a real value
+	\param f: a real value
+	\return a new Quaternion containing the quotient
+*/
+Quaternion Quaternion::operator/(const float& f) const
+{
+	if( f == 0) return Quaternion();
+	Quaternion r(*this);
+	r.w = r.w/f;
+	r.v = r.v/f;
+	return r;
+}
+
+/**
+	\brief calculate the conjugate value of the Quaternion
+	\return the conjugate Quaternion
+*/
+Quaternion Quaternion::conjugate() const
+{
+	Quaternion r(*this);
+	r.v = Vector() - r.v;
+	return r;
+}
+
+/**
+	\brief calculate the norm of the Quaternion
+	\return the norm of The Quaternion
+*/
+float Quaternion::norm() const
+{
+	return w*w + v.x*v.x + v.y*v.y + v.z*v.z;
+}
+
+/**
+	\brief calculate the inverse value of the Quaternion
+	\return the inverse Quaternion
+	
+	Note that this is equal to conjugate() if the Quaternion's norm is 1
+*/
+Quaternion Quaternion::inverse() const
+{
+	float n = norm();
+	if (n != 0)
+	{
+		return conjugate() / norm();
+	}
+	else return Quaternion();
+}
+
+/**
+	\brief convert the Quaternion to a 4x4 rotational glMatrix
+	\param m: a buffer to store the Matrix in
+*/
+void Quaternion::matrix (float m[4][4]) const
+{
+  float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; 
+  
+  // calculate coefficients
+  x2 = v.x + v.x;
+  y2 = v.y + v.y; 
+  z2 = v.z + v.z;
+  xx = v.x * x2; xy = v.x * y2; xz = v.x * z2;
+  yy = v.y * y2; yz = v.y * z2; zz = v.z * z2;
+  wx = w * x2; wy = w * y2; wz = w * z2;
+  
+  m[0][0] = 1.0 - (yy + zz); m[1][0] = xy - wz;
+  m[2][0] = xz + wy; m[3][0] = 0.0;
+	
+  m[0][1] = xy + wz; m[1][1] = 1.0 - (xx + zz);
+  m[2][1] = yz - wx; m[3][1] = 0.0;
+  
+  m[0][2] = xz - wy; m[1][2] = yz + wx;
+  m[2][2] = 1.0 - (xx + yy); m[3][2] = 0.0;
+  
+  m[0][3] = 0; m[1][3] = 0;
+  m[2][3] = 0; m[3][3] = 1;
+}
+
+/**
+   \brief performs a smooth move.
+   \param from from where
+   \param to to where
+   \param t the time this transformation should take
+   \param res The approximation-density
+*/
+void Quaternion::quatSlerp(const Quaternion* from, const Quaternion* to, float t, Quaternion* res)
+{
+  float tol[4];
+  double omega, cosom, sinom, scale0, scale1;
+  DELTA = 0.2;
+
+  cosom = from->v.x * to->v.x + from->v.y * to->v.y + from->v.z * to->v.z + from->w * to->w;
+
+  if( cosom < 0.0 ) 
+    { 
+      cosom = -cosom; 
+      tol[0] = -to->v.x;
+      tol[1] = -to->v.y;
+      tol[2] = -to->v.z;
+      tol[3] = -to->w;
+    }
+  else
+    {
+      tol[0] = to->v.x;
+      tol[1] = to->v.y;
+      tol[2] = to->v.z;
+      tol[3] = to->w;
+    }
+  
+  //if( (1.0 - cosom) > DELTA )
+  //{
+      omega = acos(cosom);
+      sinom = sin(omega);
+      scale0 = sin((1.0 - t) * omega) / sinom;
+      scale1 = sin(t * omega) / sinom;
+      //}
+      /*
+  else
+    {
+      scale0 = 1.0 - t;
+      scale1 = t;
+    }
+      */
+  res->v.x = scale0 * from->v.x + scale1 * tol[0];
+  res->v.y = scale0 * from->v.y + scale1 * tol[1];
+  res->v.z = scale0 * from->v.z + scale1 * tol[2];
+  res->w = scale0 * from->w + scale1 * tol[3];
+}
+
+
+/**
+   \brief convert a rotational 4x4 glMatrix into a Quaternion
+   \param m: a 4x4 matrix in glMatrix order
+*/
+Quaternion::Quaternion (float m[4][4])
+{
+	
+  float  tr, s, q[4];
+  int    i, j, k;
+
+  int nxt[3] = {1, 2, 0};
+
+  tr = m[0][0] + m[1][1] + m[2][2];
+
+  	// check the diagonal
+  if (tr > 0.0) 
+  {
+    s = sqrt (tr + 1.0);
+    w = s / 2.0;
+    s = 0.5 / s;
+    v.x = (m[1][2] - m[2][1]) * s;
+    v.y = (m[2][0] - m[0][2]) * s;
+    v.z = (m[0][1] - m[1][0]) * s;
+	} 
+	else 
+	{
+ 		// diagonal is negative
+  	i = 0;
+  	if (m[1][1] > m[0][0]) i = 1;
+    if (m[2][2] > m[i][i]) i = 2;
+    j = nxt[i];
+    k = nxt[j];
+
+    s = sqrt ((m[i][i] - (m[j][j] + m[k][k])) + 1.0);
+      
+    q[i] = s * 0.5;
+            
+    if (s != 0.0) s = 0.5 / s;
+	
+	  q[3] = (m[j][k] - m[k][j]) * s;
+    q[j] = (m[i][j] + m[j][i]) * s;
+    q[k] = (m[i][k] + m[k][i]) * s;
+
+  	v.x = q[0];
+  	v.y = q[1];
+  	v.z = q[2];
+  	w = q[3];
+  }
+}
+
+/**
+   \brief create a rotation from a vector
+   \param v: a vector
+*/
+Rotation::Rotation (const Vector& v)
+{
+  Vector x = Vector( 1, 0, 0);
+  Vector axis = x.cross( v);
+  axis.normalize();
+  float angle = angleRad( x, v);
+  float ca = cos(angle);
+  float sa = sin(angle);
+  m[0] = 1.0f+(1.0f-ca)*(axis.x*axis.x-1.0f);
+  m[1] = -axis.z*sa+(1.0f-ca)*axis.x*axis.y;
+  m[2] = axis.y*sa+(1.0f-ca)*axis.x*axis.z;
+  m[3] = axis.z*sa+(1.0f-ca)*axis.x*axis.y;
+  m[4] = 1.0f+(1.0f-ca)*(axis.y*axis.y-1.0f);
+  m[5] = -axis.x*sa+(1.0f-ca)*axis.y*axis.z;
+  m[6] = -axis.y*sa+(1.0f-ca)*axis.x*axis.z;
+  m[7] = axis.x*sa+(1.0f-ca)*axis.y*axis.z;
+  m[8] = 1.0f+(1.0f-ca)*(axis.z*axis.z-1.0f);
+}
+
+/**
+   \brief creates a rotation from an axis and an angle (radians!)
+   \param axis: the rotational axis
+   \param angle: the angle in radians
+*/
+Rotation::Rotation (const Vector& axis, float angle)
+{
+  float ca, sa;
+  ca = cos(angle);
+  sa = sin(angle);
+  m[0] = 1.0f+(1.0f-ca)*(axis.x*axis.x-1.0f);
+  m[1] = -axis.z*sa+(1.0f-ca)*axis.x*axis.y;
+  m[2] = axis.y*sa+(1.0f-ca)*axis.x*axis.z;
+  m[3] = axis.z*sa+(1.0f-ca)*axis.x*axis.y;
+  m[4] = 1.0f+(1.0f-ca)*(axis.y*axis.y-1.0f);
+  m[5] = -axis.x*sa+(1.0f-ca)*axis.y*axis.z;
+  m[6] = -axis.y*sa+(1.0f-ca)*axis.x*axis.z;
+  m[7] = axis.x*sa+(1.0f-ca)*axis.y*axis.z;
+  m[8] = 1.0f+(1.0f-ca)*(axis.z*axis.z-1.0f);
+}
+
+/**
+   \brief creates a rotation from euler angles (pitch/yaw/roll)
+   \param pitch: rotation around z (in radians)
+   \param yaw: rotation around y (in radians)
+   \param roll: rotation around x (in radians)
+*/
+Rotation::Rotation ( float pitch, float yaw, float roll)
+{
+  float cy, sy, cr, sr, cp, sp;
+  cy = cos(yaw);
+  sy = sin(yaw);
+  cr = cos(roll);
+  sr = sin(roll);
+  cp = cos(pitch);
+  sp = sin(pitch);
+  m[0] = cy*cr;
+  m[1] = -cy*sr;
+  m[2] = sy;
+  m[3] = cp*sr+sp*sy*cr;
+  m[4] = cp*cr-sp*sr*sy;
+  m[5] = -sp*cy;
+  m[6] = sp*sr-cp*sy*cr;
+  m[7] = sp*cr+cp*sy*sr;
+  m[8] = cp*cy;
+}
+
+/**
+   \brief creates a nullrotation (an identity rotation)
+*/
+Rotation::Rotation ()
+{
+  m[0] = 1.0f;
+  m[1] = 0.0f;
+  m[2] = 0.0f;
+  m[3] = 0.0f;
+  m[4] = 1.0f;
+  m[5] = 0.0f;
+  m[6] = 0.0f;
+  m[7] = 0.0f;
+  m[8] = 1.0f;
+}
+
+/**
+   \brief fills the specified buffer with a 4x4 glmatrix
+   \param buffer: Pointer to an array of 16 floats
+   
+   Use this to get the rotation in a gl-compatible format
+*/
+void Rotation::glmatrix (float* buffer)
+{
+	buffer[0] = m[0];
+	buffer[1] = m[3];
+	buffer[2] = m[6];
+	buffer[3] = m[0];
+	buffer[4] = m[1];
+	buffer[5] = m[4];
+	buffer[6] = m[7];
+	buffer[7] = m[0];
+	buffer[8] = m[2];
+	buffer[9] = m[5];
+	buffer[10] = m[8];
+	buffer[11] = m[0];
+	buffer[12] = m[0];
+	buffer[13] = m[0];
+	buffer[14] = m[0];
+	buffer[15] = m[1];
+}
+
+/**
+   \brief multiplies two rotational matrices
+   \param r: another Rotation
+   \return the matrix product of the Rotations
+   
+   Use this to rotate one rotation by another
+*/
+Rotation Rotation::operator* (const Rotation& r)
+{
+	Rotation p;
+	
+	p.m[0] = m[0]*r.m[0] + m[1]*r.m[3] + m[2]*r.m[6];
+	p.m[1] = m[0]*r.m[1] + m[1]*r.m[4] + m[2]*r.m[7];
+	p.m[2] = m[0]*r.m[2] + m[1]*r.m[5] + m[2]*r.m[8];
+	
+	p.m[3] = m[3]*r.m[0] + m[4]*r.m[3] + m[5]*r.m[6];
+	p.m[4] = m[3]*r.m[1] + m[4]*r.m[4] + m[5]*r.m[7];
+	p.m[5] = m[3]*r.m[2] + m[4]*r.m[5] + m[5]*r.m[8];
+
+	p.m[6] = m[6]*r.m[0] + m[7]*r.m[3] + m[8]*r.m[6];
+	p.m[7] = m[6]*r.m[1] + m[7]*r.m[4] + m[8]*r.m[7];
+	p.m[8] = m[6]*r.m[2] + m[7]*r.m[5] + m[8]*r.m[8];
+	
+	return p;
+}
+
+
+/**
+   \brief rotates the vector by the given rotation
+   \param v: a vector
+   \param r: a rotation
+   \return the rotated vector
+*/
+Vector rotateVector( const Vector& v, const Rotation& r)
+{
+  Vector t;
+  
+  t.x = v.x * r.m[0] + v.y * r.m[1] + v.z * r.m[2];
+  t.y = v.x * r.m[3] + v.y * r.m[4] + v.z * r.m[5];
+  t.z = v.x * r.m[6] + v.y * r.m[7] + v.z * r.m[8];
+
+  return t;
+}
+
+/**
+   \brief calculate the distance between two lines
+   \param l: the other line
+   \return the distance between the lines
+*/
+float Line::distance (const Line& l) const
+{
+  float q, d;
+  Vector n = a.cross(l.a);
+  q = n.dot(r-l.r);
+  d = n.len();
+  if( d == 0.0) return 0.0;
+  return q/d;
+}
+
+/**
+   \brief calculate the distance between a line and a point
+   \param v: the point
+   \return the distance between the Line and the point
+*/
+float Line::distancePoint (const Vector& v) const
+{
+  Vector d = v-r;
+  Vector u = a * d.dot( a);
+  return (d - u).len();
+}
+
+/**
+   \brief calculate the two points of minimal distance of two lines
+   \param l: the other line
+   \return a Vector[2] (!has to be deleted after use!) containing the two points of minimal distance
+*/
+Vector* Line::footpoints (const Line& l) const
+{
+  Vector* fp = new Vector[2];
+  Plane p = Plane (r + a.cross(l.a), r, r + a);
+  fp[1] = p.intersectLine (l);
+  p = Plane (fp[1], l.a);
+  fp[0] = p.intersectLine (*this);
+  return fp;
+}
+
+/**
+  \brief calculate the length of a line
+  \return the lenght of the line 
+*/
+float Line::len() const
+{
+  return a.len();
+}
+
+/**
+   \brief rotate the line by given rotation
+   \param rot: a rotation
+*/
+void Line::rotate (const Rotation& rot)
+{
+  Vector t = a + r;
+  t = rotateVector( t, rot);
+  r = rotateVector( r, rot),
+  a = t - r;
+}
+
+/**
+   \brief create a plane from three points
+   \param a: first point
+   \param b: second point
+   \param c: third point
+*/
+Plane::Plane (Vector a, Vector b, Vector c)
+{
+  n = (a-b).cross(c-b);
+  k = -(n.x*b.x+n.y*b.y+n.z*b.z);
+}
+
+/**
+   \brief create a plane from anchor point and normal
+   \param norm: normal vector
+   \param p: anchor point
+*/
+Plane::Plane (Vector norm, Vector p)
+{
+  n = norm;
+  k = -(n.x*p.x+n.y*p.y+n.z*p.z);
+}
+
+/**
+   \brief returns the intersection point between the plane and a line
+   \param l: a line
+*/
+Vector Plane::intersectLine (const Line& l) const
+{
+  if (n.x*l.a.x+n.y*l.a.y+n.z*l.a.z == 0.0) return Vector(0,0,0);
+  float t = (n.x*l.r.x+n.y*l.r.y+n.z*l.r.z+k) / (n.x*l.a.x+n.y*l.a.y+n.z*l.a.z);
+  return l.r + (l.a * t);
+}
+
+/**
+   \brief returns the distance between the plane and a point
+   \param p: a Point
+   \return the distance between the plane and the point (can be negative)
+*/
+float Plane::distancePoint (const Vector& p) const
+{
+  float l = n.len();
+  if( l == 0.0) return 0.0;
+  return (n.dot(p) + k) / n.len();
+}
+
+/**
+   \brief returns the side a point is located relative to a Plane
+   \param p: a Point
+   \return 0 if the point is contained within the Plane, positive(negative) if the point is in the positive(negative) semi-space of the Plane
+*/
+float Plane::locatePoint (const Vector& p) const
+{
+  return (n.dot(p) + k);
+}
+
Index: orxonox/trunk/src/lib/math/vector.h
===================================================================
--- orxonox/trunk/src/lib/math/vector.h	(revision 3483)
+++ orxonox/trunk/src/lib/math/vector.h	(revision 3483)
@@ -0,0 +1,154 @@
+/*! 
+    \file vector.h
+    \brief A basic 3D math framework
+    
+    Contains classes to handle vectors, lines, rotations and planes
+*/ 
+
+#ifndef _VECTOR_H
+#define _VECTOR_H
+
+#include <math.h>
+//! PI the circle-constant
+#define PI 3.14159265359f
+
+//! 3D Vector
+/**
+	Class to handle 3D Vectors
+*/
+class Vector {
+
+  public:
+ 
+  float x; //!< The x Coordinate of the Vector.
+  float y; //!< The y Coordinate of the Vector.
+  float z; //!< The z Coordinate of the Vector.
+
+  Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
+  Vector () : x(0), y(0), z(0) {}
+  ~Vector () {}
+
+  Vector operator+ (const Vector& v) const;
+  Vector operator- (const Vector& v) const;
+  float operator* (const Vector& v) const;
+  Vector operator* (float f) const;
+  Vector operator/ (float f) const;
+  float dot (const Vector& v) const;
+  Vector cross (const Vector& v) const;
+  void scale(const Vector& v);
+  float len() const;
+  void normalize();
+  Vector* getNormalized();
+  Vector abs();
+};
+
+float angleDeg (const Vector& v1, const Vector& v2);
+float angleRad (const Vector& v1, const Vector& v2);
+
+//! Quaternion
+/**
+	Class to handle 3-dimensional rotation efficiently
+*/
+class Quaternion
+{
+ public:
+	Vector v;	//!< Imaginary Vector
+	float w;        //!< Real part of the number
+
+ 	Quaternion ();
+ 	Quaternion (float m[4][4]);
+ 	Quaternion (float angle, const Vector& axis);
+ 	Quaternion (const Vector& dir, const Vector& up);
+ 	Quaternion (float roll, float pitch, float yaw);
+ 	
+ 	Quaternion operator/ (const float& f) const;
+ 	Quaternion operator* (const float& f) const;
+ 	Quaternion operator* (const Quaternion& q) const;
+	Quaternion operator+ (const Quaternion& q) const;
+	Quaternion operator- (const Quaternion& q) const;
+	Quaternion conjugate () const;
+	Quaternion inverse () const;
+ 	Vector apply (Vector& f) const;
+	float norm () const;
+	void matrix (float m[4][4]) const;
+	void quatSlerp(const Quaternion* from, const Quaternion* to, const float t, Quaternion* res);
+
+ private:
+	float DELTA;      //!< resolution of calculation
+
+};
+
+//! 3D rotation (OBSOLETE)
+/**
+  Class to handle 3-dimensional rotations.
+  Can create a rotation from several inputs, currently stores rotation using a 3x3 Matrix
+*/
+class Rotation {
+  public:
+  
+  float m[9]; //!< 3x3 Rotation Matrix
+  
+  Rotation ( const Vector& v);
+  Rotation ( const Vector& axis, float angle);
+  Rotation ( float pitch, float yaw, float roll);
+  Rotation ();
+  ~Rotation () {}
+  
+  Rotation operator* (const Rotation& r);
+  
+  void glmatrix (float* buffer);
+};
+
+//!< Apply a rotation to a vector
+Vector rotateVector( const Vector& v, const Rotation& r);
+
+//! 3D line
+/**
+  Class to store Lines in 3-dimensional space
+
+  Supports line-to-line distance measurements and rotation
+*/
+class Line
+{
+  public:
+  
+  Vector r;   //!< Offset
+  Vector a;   //!< Direction
+  
+  Line ( Vector r, Vector a) : r(r), a(a) {}  //!< assignment constructor
+  Line () : r(Vector(0,0,0)), a(Vector (1,1,1)) {}
+  ~Line () {}
+  
+  float distance (const Line& l) const;
+  float distancePoint (const Vector& v) const;
+  Vector* footpoints (const Line& l) const;
+  float len () const;
+  
+  void rotate(const Rotation& rot);
+};
+
+//! 3D plane
+/**
+  Class to handle planes in 3-dimensional space
+  
+  Critical for polygon-based collision detection
+*/
+class Plane
+{
+  public:
+  
+  Vector n;   //!< Normal vector
+  float k;    //!< Offset constant
+  
+  Plane (Vector a, Vector b, Vector c);
+  Plane (Vector norm, Vector p);
+  Plane (Vector n, float k) : n(n), k(k) {} //!< assignment constructor
+  Plane () : n(Vector(1,1,1)), k(0) {}
+  ~Plane () {}
+  
+  Vector intersectLine (const Line& l) const;
+  float distancePoint (const Vector& p) const;
+  float locatePoint (const Vector& p) const;
+};
+
+#endif /* _VECTOR_H */
Index: orxonox/trunk/src/lib/util/list.cc
===================================================================
--- orxonox/trunk/src/lib/util/list.cc	(revision 3483)
+++ orxonox/trunk/src/lib/util/list.cc	(revision 3483)
@@ -0,0 +1,148 @@
+
+
+/* 
+   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: Patrick Boenzli
+   co-programmer: ...
+*/
+
+
+#include "list.h"
+#include "world_entity.h"
+
+using namespace std;
+
+
+
+List::List () 
+{
+  this->first = NULL;
+  this->last = NULL;
+  this->size = 0;
+}
+
+List::~List () 
+{}
+
+
+void List::add(WorldEntity* entity)
+{
+  printf("List::add() \n");
+  listElement* el = new listElement;
+  el->prev = this->last;
+  el->curr = entity;
+  el->next = NULL;
+
+  this->last = el;
+
+  if(this->size == 0) this->first = el;
+  else el->prev->next = el;
+  this->size++;
+}
+
+
+void List::remove(WorldEntity* entity)
+{
+  this->currentEl = this->first;
+  listElement* te;
+  while( this->currentEl != NULL)
+    {
+      if( this->currentEl->curr == entity)
+	{
+	  printf("List::remove() - object found\n");
+	  
+	  if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
+	  else this->currentEl->prev->next = this->currentEl->next;
+
+	  if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
+	  else this->currentEl->next->prev = this->currentEl->prev;
+
+	  te = this->currentEl->next;
+	  delete this->currentEl;
+	  this->currentEl = te;
+	  return;
+	}
+      this->currentEl = this->currentEl->next;
+    }
+}
+
+
+void List::destroy()
+{
+  printf("List::clear() - clearing all world objects, releasing mem\n");
+  this->currentEl = this->first;
+  listElement* le = NULL;
+  while(this->currentEl != NULL)
+    {
+      le = this->currentEl->next;
+      delete this->currentEl->curr;
+      delete this->currentEl;
+      this->currentEl = le;
+    }
+  this->first = NULL;
+  this->last = NULL;
+  this->size = 0;
+}
+
+
+WorldEntity* List::firstElement()
+{
+  return this->first->curr;
+}
+
+
+bool List::isEmpty()
+{
+  return (this->size==0)?true:false;
+}
+
+
+int List::getSize()
+{
+  return this->size;
+}
+
+
+WorldEntity* List::enumerate()
+{
+  if(this->size == 0) return NULL;
+  this->currentEl = this->first;
+  return this->currentEl->curr;
+}
+
+
+WorldEntity* List::nextElement()
+{
+  if(this->size == 0) return NULL;
+  this->currentEl = this->currentEl->next;
+  if(this->currentEl == NULL) return NULL;
+  return this->currentEl->curr;
+}
+
+
+WorldEntity* List::toArray()
+{}
+
+
+void List::debug()
+{
+  int counter = 1;
+  this->currentEl = this->first;
+  printf("List:debug() =====================\n");
+  while(this->currentEl != NULL)
+    {
+      printf("element: nr %d/%d\n", counter, size);
+      this->currentEl = this->currentEl->next;
+      counter++;
+    }
+  printf("List:debug()END =====================\n");
+}
Index: orxonox/trunk/src/lib/util/list.h
===================================================================
--- orxonox/trunk/src/lib/util/list.h	(revision 3483)
+++ orxonox/trunk/src/lib/util/list.h	(revision 3483)
@@ -0,0 +1,207 @@
+
+#ifndef _LIST_H
+#define _LIST_H
+
+#include "stdincl.h"
+
+//! An enum to list all the modes available when adding an object to a List
+//enum ADDMODE {LIST_ADD_FIRST, LIST_ADD_LAST};
+//! An enum to list the two searching directions available when removing an object from a List
+//enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
+
+
+
+class WorldEntity;
+
+class List {
+
+ public:
+  List ();
+  ~List ();
+
+  void add(WorldEntity* entity);
+  void remove(WorldEntity* entity);
+  void destroy();
+  WorldEntity* firstElement();
+  bool isEmpty();
+  int getSize();
+  WorldEntity* enumerate();
+  WorldEntity* nextElement();
+  WorldEntity* toArray();
+  void debug();
+
+ private:
+  struct listElement
+  {
+    listElement* prev;
+    WorldEntity* curr;
+    listElement* next;
+  };
+  Uint32 size;
+  listElement* first;
+  listElement* last;
+  listElement* currentEl;
+
+
+};
+
+class Iterator
+{
+
+ public:
+  bool hasNext();
+  WorldEntity* next();
+
+ private:
+
+};
+
+
+template<class T> class tList 
+{
+ private:
+  struct listElement
+  {
+    listElement* prev;
+    T* curr;
+    listElement* next;
+  };
+
+  Uint32 size;
+  listElement* first;
+  listElement* last;
+  listElement* currentEl;
+  
+ public:
+  tList ();
+  ~tList ();
+  
+
+  void add(T* entity);
+  void remove(T* entity);
+  void destroy();
+  T* firstElement();
+  bool isEmpty();
+  int getSize();
+  T* enumerate();
+  T* nextElement();
+  T* toArray();
+  void debug();
+};
+
+
+template<class T>
+tList<T>::tList () 
+{
+  this->first = NULL;
+  this->last = NULL;
+  this->size = 0;
+}
+
+template<class T>
+tList<T>::~tList () 
+{}
+
+template<class T>
+void tList<T>::add(T* entity)
+{
+  listElement* el = new listElement;
+  el->prev = this->last;
+  el->curr = entity;
+  el->next = NULL;
+
+  this->last = el;
+
+  if(this->size == 0) this->first = el;
+  else el->prev->next = el;
+  this->size++;
+}
+
+
+template<class T>
+void tList<T>::remove(T* entity)
+{
+  this->currentEl = this->first;
+  listElement* te;
+  while( this->currentEl != NULL)
+    {
+      if( this->currentEl->curr == entity)
+	{ 
+	  if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
+	  else this->currentEl->prev->next = this->currentEl->next;
+
+	  if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
+	  else this->currentEl->next->prev = this->currentEl->prev;
+
+	  te = this->currentEl->next;
+	  delete this->currentEl;
+	  this->currentEl = te;
+	  return;
+	}
+      this->currentEl = this->currentEl->next;
+    }
+}
+
+
+template<class T>
+void tList<T>::destroy()
+{
+  this->currentEl = this->first;
+  while(this->currentEl != NULL)
+    {
+      listElement* le = this->currentEl->next;
+      delete this->currentEl->curr;
+      delete this->currentEl;
+      this->currentEl = le;
+    }
+  this->first = NULL;
+  this->last = NULL;
+  this->size = 0;
+}
+
+
+template<class T>
+T* tList<T>::firstElement()
+{
+  return this->first->curr;
+}
+
+
+template<class T>
+bool tList<T>::isEmpty()
+{
+  return (this->size==0)?true:false;
+}
+
+
+template<class T>
+int tList<T>::getSize()
+{
+  return this->size;
+}
+
+
+template<class T>
+T* tList<T>::enumerate()
+{
+  if(this->size == 0) return NULL;
+  this->currentEl = this->first;
+  return this->currentEl->curr;
+}
+
+
+template<class T>
+T* tList<T>::nextElement()
+{
+  if(this->size == 0) return NULL;
+  this->currentEl = this->currentEl->next;
+  if(this->currentEl == NULL) return NULL;
+  return this->currentEl->curr;
+}
+
+
+template<class T>
+T* tList<T>::toArray()
+{}
+
+#endif /* _LIST_H */
Index: orxonox/trunk/src/lib/util/list_template.h
===================================================================
--- orxonox/trunk/src/lib/util/list_template.h	(revision 3483)
+++ orxonox/trunk/src/lib/util/list_template.h	(revision 3483)
@@ -0,0 +1,308 @@
+/* 
+   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
+
+   ADDONS/FIXES:
+  
+   Patrick Boenzli     :          Implemented getSize() function
+*/
+
+
+/*!
+  \file list.h
+  \brief Contains a template for a doubly linked list
+*/
+
+#ifndef _LIST_TEMPLATE_H
+#define _LIST_TEMPLATE_H
+
+#include "stdincl.h"
+
+//! An enum to list all the modes available when adding an object to a List
+enum ADDMODE {LIST_ADD_NEXT, LIST_ADD_PREV, LIST_ADD_FIRST, LIST_ADD_LAST};
+//! An enum to list the two searching directions available when removing an object from a List
+enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};
+
+//! A generic doubly linked list
+template<class T> class ListTemplate 
+{
+  T* object;
+  ListTemplate<T>* next;
+  ListTemplate<T>* prev;
+  bool bReference;
+  int size;
+  
+ public:
+  ListTemplate (T* obj, ListTemplate<T>* n, ListTemplate<T>* p, bool bRef);
+  ~ListTemplate ();
+  
+  int add(T* obj, ADDMODE mode, bool bRef);
+  T* getObject();
+  ListTemplate<T>* getNext();
+  ListTemplate<T>* getPrevious();
+  ListTemplate<T>* getLast();
+  ListTemplate<T>* getFirst();
+  void setNext(ListTemplate<T>* ptr);
+  void setPrev(ListTemplate<T>* ptr);
+  int remove (T* obj, FINDMODE mode);
+  int getSize();
+  void destroy();
+};
+
+
+/**
+  \brief Standard constructor
+  
+  Call this without any parameters to generate a new ListTemplate which can be filled with content.
+  DO NOT create a ListTemplate element that contains an object on your own, you'll lose the data
+  contained in that object and will have trouble removing the list from your memory.
+*/
+template<class T>
+ListTemplate<T>::ListTemplate (T* obj = NULL, ListTemplate<T>* n = NULL, ListTemplate<T>* p = NULL, bool bRef = false)
+{
+  object = obj;
+  next = n;
+  prev = p;
+  bReference = bRef;
+  if(obj != NULL)
+    ++size;
+}
+
+/**
+  \brief Standard destructor
+  
+  Call this on the initially generated base ListTemplate element to remove the whole ListTemplate from the memory.
+  You can safely do this to any ListTemplate element you want without messing up the rest of the ListTemplate, but keep in mind
+  that the contained object will be deleted as well when bRef had been set to false.
+*/
+template<class T>
+ListTemplate<T>::~ListTemplate ()
+{
+  if (object == NULL) // deleted foot node => disband the list
+  {
+    while( next != NULL)
+    {
+      delete next;
+    }
+    while( prev != NULL)
+    {
+      delete prev;
+    }
+  }
+  else
+  {
+    if (prev != NULL) prev->setNext (next);
+    if (next != NULL) next->setPrev (prev);
+    if (!bReference) delete object;
+  }
+}
+ 
+/**
+  \brief Add an object to the ListTemplate
+  \param obj: A pointer to an allocated object
+  \param mode: A Value of ADDMODE (default: LIST_ADD_NEXT)
+  \param bRef: Sets whether the element is serving as a storage point or a simple listing (default: false)
+  \return 0 if the operation succeded, -1 if the element could not be added
+  
+  This adds a new ListTemplate element to the chain. The mode parameter can be used to specify
+  the location where the element should be added. LIST_ADD_NEXT will add the new element directly
+  after the base element. LIST_ADD_PREV will add the new element directly before the base element.
+  LIST_ADD_FIRST will add the element at the beginning of the ListTemplate whereas LIST_ADD_LAST will add
+  it to the end of the chain. If the bRef parameter is set to true, the object pointer will not be deleted
+  when the element containing that object is deleted, thus the ListTemplate can be used for temporary listings as
+  well as permanent data storage.
+*/
+template<class T> 
+int ListTemplate<T>::add (T* obj, ADDMODE mode = LIST_ADD_NEXT, bool bRef = false)
+{
+  ListTemplate<T>* p;
+  if( obj == NULL) return -1;
+  switch (mode)
+  {
+    case LIST_ADD_NEXT:
+      p = new ListTemplate<T>( obj, next, this, bRef);
+      if( next != NULL) next->setPrev (p);
+      next = p;
+      break;
+    case LIST_ADD_PREV:
+      p = new ListTemplate<T>( obj, this, prev, bRef);
+      if( prev != NULL) prev->setNext (p);
+      prev = p;
+      break;
+    case LIST_ADD_FIRST:
+      if (prev == NULL) prev = new ListTemplate<T> (obj, this, NULL, bRef);
+      else return prev->add (obj, mode, bRef);
+      break;
+    case LIST_ADD_LAST:
+      if (next == NULL) next = new ListTemplate<T> (obj, NULL, this, bRef);
+      else return next->add (obj, mode, bRef);
+      break;
+    default:
+        return -1;
+      break;
+  }
+  ++size;
+  return 0;
+}
+
+/**
+  \brief Get the next element of the ListTemplate
+  \return The ListTemplate element after the current ListTemplate element
+*/
+template<class T>
+ListTemplate<T>* ListTemplate<T>::getNext ()
+{
+  return next;
+}
+ 
+/**
+  \brief Get the previous element of the ListTemplate
+  \return The ListTemplate element before the current ListTemplate element
+*/
+template<class T>
+ListTemplate<T>* ListTemplate<T>::getPrevious ()
+{
+  return prev;
+}
+
+/**
+  \brief Get the last element of the ListTemplate
+  \return The last ListTemplate element
+*/
+template<class T>
+ListTemplate<T>* ListTemplate<T>::getLast ()
+{
+  if (next == NULL) return this;
+  else return next->getLast();
+}
+
+/**
+  \brief Get the first element of the ListTemplate
+  \return The first ListTemplate element
+*/
+template<class T>
+ListTemplate<T>* ListTemplate<T>::getFirst ()
+{
+  if (prev == NULL) return this;
+  else return prev->getFirst();
+}
+
+/**
+  \brief Removes a certain element from the ListTemplate
+  \param obj: A pointer to the object that should be removed
+  \param mode: A value of FINDMODE
+  \return 0 if the element was found and removed, -1 if the element was not found
+  
+  This searches the part of the ListTemplate specified with mode for the object in question.
+  When the object is found it is deleted and the ListTemplate element is removed from the chain.
+  If mode is LIST_FIND_FW all elements AFTER the base element are searched, if mode is
+  LIST_FIND_BW all elements BEFORE the base element are searched. Note that the object
+  contained within the ListTemplate element is NOT deleted when bRef was set to true.
+*/
+template<class T>
+int ListTemplate<T>::remove (T* obj, FINDMODE mode = LIST_FIND_FW)
+{
+  if (obj == NULL) return -1;
+  else
+  {
+    switch (mode)
+    {
+      case LIST_FIND_BW:
+        if (prev == NULL) return -1;
+        else
+        {
+          if( prev->getObject() == obj)
+          {
+            delete prev;
+          }
+          else
+          {
+            return prev->remove( obj, mode);
+          }
+        }
+        break;
+      case LIST_FIND_FW:
+        if (next == NULL) return -1;
+        else
+        {
+          if( next->getObject() == obj)
+          {
+            delete next;
+          }
+          else
+          {
+            return next->remove( obj, mode);
+          }
+        }
+        break;
+      default:
+        return -1;
+    }
+  }
+  --size;
+  return 0;
+}
+
+/**
+  \brief Set the next element of a ListTemplate element
+  \param ptr: A pointer to the new next element
+    
+  Sets the next element of a ListTemplate element... Better not touch this, it can really mess up a ListTemplate.
+*/
+template<class T>
+void ListTemplate<T>::setNext (ListTemplate<T>* ptr)
+{
+  next = ptr;
+}
+
+/**
+  \brief Set the prev element of a ListTemplate element
+  \param ptr: A pointer to the new previous element
+    
+  Sets the previous element of a ListTemplate element... Better not touch this, it can really mess up a ListTemplate.
+*/
+template<class T>
+void ListTemplate<T>::setPrev (ListTemplate<T>* ptr)
+{
+  prev = ptr;
+}
+
+/**
+  \brief Get the pointer to the object the element is containing
+  \return The contained object (will be NULL if called on the base element).
+*/
+template<class T>
+T* ListTemplate<T>::getObject()
+{
+  return object;
+}
+
+
+/**
+  \brief Returns the current size of the ListTemplate
+  \return Size of ListTemplate
+*/
+template<class T>
+int ListTemplate<T>::getSize()
+{
+  return this->size;
+}
+
+
+template<class T>
+void ListTemplate<T>::destroy()
+{
+  /* \todo at the moment - doing nothing. should delete everything */
+}
+
+#endif /* _LIST_TENMPLATE_H */
+
