Index: orxonox/trunk/src/util/animation/animation.cc
===================================================================
--- orxonox/trunk/src/util/animation/animation.cc	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation.cc	(revision 3868)
@@ -0,0 +1,130 @@
+/* 
+   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: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
+
+#include "animation.h"
+#include "debug.h"
+#include "animation_player.h"
+
+/**
+   \brief creates a new Animation
+   
+   This also adds the Animation automatically to the AnimationPlayer's list
+*/
+Animation::Animation(void)
+{  
+  // initialize a beginning KeyFrame, that will be deleted afterwards
+  this->bHasKeys = false;
+  this->bHandled = true;
+  this->bDelete = false;
+  this->baseObject = NULL;
+
+  // setting default values
+  this->localTime = 0.0;
+  this->bRunning = true;
+
+  AnimationPlayer::getInstance()->addAnimation(this);
+}
+
+/**
+   \brief destructs the Animation
+   
+   this also takes the animation out of the AnimationPlayer's list (if it is there)
+*/
+Animation::~Animation(void)
+{
+  this->doNotHandle();
+}
+
+/**
+   \brief tells the AnimationPlayer, that we do not wish to  handle this animation
+   automatically.
+   
+   This means that it will not be ticked, and not be deleted with the AnimationPlayer
+*/
+void Animation::doNotHandle(void)
+{
+  if (this->bHandled)
+    AnimationPlayer::getInstance()->removeAnimation(this);
+}
+
+/**
+   \brief Sets the infinitymode
+   \param postInfinity How the Animation should advance after the last Keyframe
+*/
+void Animation::setInfinity(ANIM_INFINITY postInfinity)
+{
+  this->postInfinity = postInfinity;
+}
+
+/**
+   \brief handles the Animation if it gets out of boundraries eg. if animation is finished.
+*/
+void Animation::handleInfinity(void)
+{
+  switch (this->postInfinity)
+    {
+    case ANIM_INF_CONSTANT:
+      this->localTime = 0.0;
+      this->bRunning = false;
+      break;
+    case ANIM_INF_REPLAY:
+      this->replay();
+      break;
+    case ANIM_INF_REWIND:
+      this->stop();
+      break;
+    case ANIM_INF_DELETE: // this will possibly never be made
+      this->bDelete = true;
+      break;
+    }
+}
+
+/**
+   \brief plays the animation back from the current Time forward
+*/
+void Animation::play()
+{
+  this->bRunning = true;
+}
+
+/**
+   \brief Stops the animation. eg. pause(); rewind();
+*/
+void Animation::stop()
+{
+  this->rewind();
+  this->bRunning = true;
+  this->tick(0.0);
+  this->bRunning = false;
+}
+
+/**
+   \brief Pauses the animation. Stays at the current Time
+*/
+void Animation::pause()
+{
+  this->bRunning = false;
+}
+
+/**
+   \brief replays the animation, eg. rewind();play();
+*/
+void Animation::replay()
+{
+  this->rewind();
+  this->bRunning = true;
+}
Index: orxonox/trunk/src/util/animation/animation.h
===================================================================
--- orxonox/trunk/src/util/animation/animation.h	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation.h	(revision 3868)
@@ -0,0 +1,123 @@
+/*! 
+    \file animation.h
+    A Subclass for all animations in orxonox
+*/
+
+#ifndef _ANIMATION_H
+#define _ANIMATION_H
+
+#include "list.h"
+#include "base_object.h"
+#include "confincl.h"  // must be here to determin the DEBUG-level
+
+// FORWARD DEFINITION
+
+//! An enumerator of Functions to describe the flow of the Animation
+/**
+   \todo check with Patrick it of
+
+   description in speed to the next keyframe:
+   ANIM_CONSTANT: 0, infinity.
+   ANIM_LINEAR: equal
+   ANIM_SINE: fast, slow, fast
+   ANIM_COSINE: slow, fast, slow
+   ANIM_EXP: slow, fast
+   ANIM_NEG_EXP: fast, slow
+   ANIM_RANDOM: eratic
+   
+   deprecated QUADRATIC
+*/
+typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
+			    ANIM_LINEAR,
+			    ANIM_SINE,
+			    ANIM_COSINE,
+			    ANIM_EXP,
+			    ANIM_NEG_EXP,
+			    ANIM_QUADRATIC,
+			    ANIM_RANDOM};
+
+//! An enumerator describing what the animation should do after the last keyframe.
+/**
+   ANIM_INF_CONSTANT stays at the end of the animation
+   ANIM_INF_REPLAY loops back to the beginning and replays the animation
+   ANIM_INF_REWIND loops back to the beginning and then stops the animation
+   ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables
+*/
+typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
+			    ANIM_INF_REPLAY,
+			    ANIM_INF_REWIND,
+			    ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
+
+//! A Superclass for describing an animation (all animations will be derived from this one)
+/** implement in subclasses:
+ * 
+ * De-/Constructor
+ * Animation Functions
+ * virtual tick
+ * addKeyFrame
+ * List of keyFrames
+ * currentKeyFrame/nextKeyFrame
+ * virtual rewind, to go to the first Keyframe. (other functions will call this one)
+*/
+class Animation
+{
+ public:
+  virtual ~Animation(void);
+  void doNotHandle(void);
+
+  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
+
+  void play(); // equals resume();
+  void stop();
+  void pause();
+  void replay();
+  //! A virtual function that should change to the first keyframe.
+  virtual void rewind() = 0;
+  /** \brief A virtual function that ticks the animation \param dt the time passed */
+  virtual void tick(float dt) = 0;
+
+  /**
+     \returns the BaseObject, this animation operates on
+  */
+  BaseObject* getBaseObject(void) const {return baseObject;}
+
+  /** \returns if the Animation should be deleted */
+  inline bool ifDelete(void) {return bDelete;}
+
+ protected:
+  Animation(void);
+
+  void handleInfinity(void);
+  // variables
+  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
+  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
+
+  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
+  bool bHasKeys;                  //!< If the animation has any keys at all. Needed to add the first keyframe (and delete the dummy).
+  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
+  bool bRunning;                  //!< If the animation is running
+  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
+};
+
+
+/**********************TEST*******************************/
+class aTest
+{
+ public:
+  aTest() { last = 0.0;}
+  ~aTest() {}
+  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
+ private:
+  float diff;
+  float last;
+};
+
+//aTest::aTest() {}
+//aTest::~aTest() {}
+
+//void aTest::littleDebug(float f)
+
+/**********************TEST*******************************/
+
+
+#endif /* _ANIMATION_H */
Index: orxonox/trunk/src/util/animation/animation3d.cc
===================================================================
--- orxonox/trunk/src/util/animation/animation3d.cc	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation3d.cc	(revision 3868)
@@ -0,0 +1,307 @@
+/*
+   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: Benjamin Grauer
+
+   2005-04-17: Benjamin Grauer
+          Rewritte all functions, so it will fit into the Animation-class
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
+
+#include "animation3d.h"
+
+#include "p_node.h"
+
+using namespace std;
+
+/**
+   \brief standard constructor
+*/
+Animation3D::Animation3D(PNode* object)
+{
+  this->object = object;
+
+  // create a new List
+  this->keyFrameList = new tList<KeyFrame3D>();
+  KeyFrame3D* tmpKeyFrame = new KeyFrame3D;
+  tmpKeyFrame->position = Vector();
+  tmpKeyFrame->direction = Quaternion();
+  keyFrameList->add(tmpKeyFrame);
+
+  this->currentKeyFrame = tmpKeyFrame;
+  this->nextKeyFrame = tmpKeyFrame;
+
+  this->animFunc = &Animation3D::linear;
+}
+
+/**
+   \brief standard deconstructor
+   
+   deletes all the Keyframes
+*/
+Animation3D::~Animation3D(void)
+{
+  // delete all the KeyFrames
+  tIterator<KeyFrame3D>* itKF = keyFrameList->getIterator();
+  KeyFrame3D*  enumKF = itKF->nextElement();
+  while (enumKF)
+    {
+      delete enumKF;
+      enumKF = itKF->nextElement();
+    }
+  delete itKF;
+  delete this->keyFrameList;
+}
+
+/**
+   \brief rewinds the Animation to the beginning (first KeyFrame and time == 0)
+*/
+void Animation3D::rewind(void)
+{
+  this->currentKeyFrame = keyFrameList->firstElement();
+  this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());
+  this->localTime = 0.0;
+}
+
+/**
+   \brief Appends a new Keyframe
+   \param position The position of the new Keyframe
+   \param direction The direction of the new Keyframe.
+   \param duration The duration from the new KeyFrame to the next one
+   \param animFunc The function to animate between this keyFrame and the next one
+*/
+void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, ANIM_FUNCTION animFunc)
+{
+  // some small check
+  if (duration <= 0.0)
+    duration = 1.0;
+
+  KeyFrame3D* tmpKeyFrame;
+    
+  if (bHasKeys)
+    {
+      tmpKeyFrame = new KeyFrame3D;
+      if (this->currentKeyFrame == this->nextKeyFrame)
+	this->nextKeyFrame = tmpKeyFrame;
+      this->keyFrameList->add(tmpKeyFrame);
+
+    }
+  else
+    {
+      tmpKeyFrame = this->keyFrameList->firstElement();
+      bHasKeys = true;
+      this->setAnimFunc(animFunc);
+    }
+
+  tmpKeyFrame->position = position;
+  tmpKeyFrame->direction = direction;
+  tmpKeyFrame->duration = duration;
+  tmpKeyFrame->animFunc = animFunc;
+
+}
+
+/**
+   \brief ticks the Animation
+   \param dt how much time to tick
+*/
+void Animation3D::tick(float dt)
+{
+  if (this->bRunning)
+    { 
+      this->localTime += dt;
+      if (localTime >= this->currentKeyFrame->duration)
+	{
+	  // switching to the next Key-Frame
+	  this->localTime -= this->currentKeyFrame->duration;
+	  this->currentKeyFrame = this->nextKeyFrame;
+	  // checking, if we should still Play the animation
+	  if (this->currentKeyFrame == this->keyFrameList->lastElement())
+	    this->handleInfinity();
+	  this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
+	  this->setAnimFunc(this->currentKeyFrame->animFunc);	  
+	  
+	  if( this->currentKeyFrame->animFunc == ANIM_NEG_EXP)
+	    {
+	      this->tmpVect = this->nextKeyFrame->position - this->currentKeyFrame->position;
+	      this->deltaT = 1/this->currentKeyFrame->duration * logf(1.0 + 600.0/this->tmpVect.len());
+	    }
+	}
+
+      /* now animate it */
+      (this->*animFunc)(this->localTime);
+      /*
+      switch( this->movMode)
+	{
+	case LINEAR:
+	  *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
+	  *this->tmpVect = *this->tmpVect * this->localTime / this->currentFrame->time;
+	  this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
+	  *this->lastPosition = *this->tmpVect;
+	  break;
+	case EXP:
+	      
+	  break;
+	case NEG_EXP:
+	  *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
+	  *this->tmpVect = *this->tmpVect * (1 - expf(- this->localTime * this->deltaT));     
+	  this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
+	  *this->lastPosition = *this->tmpVect;
+	  break;
+	case SIN:
+	  *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
+	  *this->tmpVect = *this->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / this->currentFrame->time));     
+	  this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
+	  *this->lastPosition = *this->tmpVect;
+	  break;
+	case COS:
+	      
+	  break;
+	case QUADRATIC:
+	  *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
+	  *this->tmpVect = *this->tmpVect * 1/3 * ldexpf(this->localTime, 3);
+	  break;
+	default:
+	  break;
+	}
+      */
+    }
+}
+
+
+/**
+   \brief Sets The kind of Animation between this keyframe and the next one
+   \param animFunc The Type of Animation to set
+*/
+void Animation3D::setAnimFunc(ANIM_FUNCTION animFunc)
+{
+  switch (animFunc)
+    {
+    default:
+    case ANIM_CONSTANT:
+      this->animFunc = &Animation3D::constant;
+      break;
+    case ANIM_LINEAR:
+      this->animFunc = &Animation3D::linear;
+      break;
+    case ANIM_SINE:
+      this->animFunc = &Animation3D::sine;
+      break;
+    case ANIM_COSINE:
+      this->animFunc = &Animation3D::cosine;
+      break;
+    case ANIM_EXP:
+      this->animFunc = &Animation3D::exp;
+      break;
+    case ANIM_NEG_EXP:
+      this->animFunc = &Animation3D::negExp;
+      break;
+    case ANIM_QUADRATIC:
+      this->animFunc = &Animation3D::quadratic;
+      break;
+    case ANIM_RANDOM:
+      this->animFunc = &Animation3D::random;
+      break;
+    }
+}
+
+/**
+   \brief stays at the value of the currentKeyFrame
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::constant(float timePassed) const
+{
+  this->object->setRelCoor(this->currentKeyFrame->position);
+
+  /*
+    this->tmpVect = this->nextKeyFrame->position - this->currentKeyFrame->position;
+    this->tmpVect = this->tmpVect * this->localTime / this->currentKeyFrame->duration;
+    this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
+    this->lastPosition = this->tmpVect;
+  */
+}
+
+/**
+   \brief linear interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement also do this for direction
+*/
+void Animation3D::linear(float timePassed) const
+{
+  this->object->setRelCoor(this->currentKeyFrame->position +
+			  (this->nextKeyFrame->position - this->currentKeyFrame->position) * 
+			  (timePassed/this->currentKeyFrame->duration));
+}
+
+/**
+   \brief a Sinusodial Interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::sine(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief a cosine interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::cosine(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief an exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::exp(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief a negative exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::negExp(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief a quadratic interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::quadratic(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief some random animation (fluctuating)
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::random(float timePassed) const
+{
+  this->object->setRelCoor(this->currentKeyFrame->position * (float)rand()/(float)RAND_MAX);
+  this->object->setRelDir(this->currentKeyFrame->direction * (float)rand()/(float)RAND_MAX);
+}
Index: orxonox/trunk/src/util/animation/animation3d.h
===================================================================
--- orxonox/trunk/src/util/animation/animation3d.h	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation3d.h	(revision 3868)
@@ -0,0 +1,62 @@
+/*! 
+    \file animation3d.h
+*/
+
+
+#include "animation.h"
+
+#include "vector.h"
+class PNode;
+
+//! KeyFrame3D Struct
+/**
+   This represents one point with direction of the animation
+*/
+typedef struct KeyFrame3D {
+  float duration;                   //!< The duration of this KeyFrame
+  Vector position;                  //!< The position of this KeyFrame
+  Quaternion direction;             //!< The direction of this KeyFrame
+  ANIM_FUNCTION animFunc;           //!< with whitch function to iterate to the next KeyFrame3D
+};
+
+//! Animation Struct
+/**
+   This represents an animation for a object
+*/
+class Animation3D : public Animation
+{
+ public:
+  Animation3D(PNode* object);
+  virtual ~Animation3D(void);
+    
+  virtual void rewind(void);
+
+  void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFunc = ANIM_LINEAR);
+  //  void addKeyFrame(KeyFrame3D* frame);
+
+  virtual void tick(float dt);
+
+ private:
+  // animation functions
+  void setAnimFunc(ANIM_FUNCTION animFunc);
+  void constant(float timePassed) const;
+  void linear(float timePassed) const;
+  void sine(float timePassed) const;
+  void cosine(float timePassed) const;
+  void exp(float timePassed) const;
+  void negExp(float timePassed) const;
+  void quadratic(float timePassed) const;
+  void random(float timePassed) const;
+  //  ANIM_FUNCTION animFunc;
+  void (Animation3D::*animFunc)(float) const;      //!< A Function for the AnimationType
+
+  KeyFrame3D* currentKeyFrame;                     //!< The current KeyFrame
+  KeyFrame3D* nextKeyFrame;                        //!< The KeyFrame we iterate to
+  tList<KeyFrame3D>* keyFrameList;                 //!< The KeyFrameList
+
+  // more class-local description
+  PNode* object;                                   //!< The Object from which to Animate something
+  Vector lastPosition;   //!< ??
+  Vector tmpVect;        //!< what for??
+  float deltaT;          //!< ??
+};
Index: orxonox/trunk/src/util/animation/animation_player.cc
===================================================================
--- orxonox/trunk/src/util/animation/animation_player.cc	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation_player.cc	(revision 3868)
@@ -0,0 +1,192 @@
+/* 
+   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: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
+
+#include "animation_player.h"
+
+#include "compiler.h"
+
+using namespace std;
+
+
+/**
+   \brief standard constructor
+*/
+AnimationPlayer::AnimationPlayer () 
+{
+   this->setClassName ("AnimationPlayer");
+
+   this->animationList = new tList<Animation>();
+   this->play();
+}
+
+/**
+   \brief the singleton reference to this class
+*/
+AnimationPlayer* AnimationPlayer::singletonRef = NULL;
+
+/**
+   \returns a Pointer to this Class
+*/
+AnimationPlayer* AnimationPlayer::getInstance(void)
+{
+  if (!AnimationPlayer::singletonRef)
+    AnimationPlayer::singletonRef = new AnimationPlayer();
+  return AnimationPlayer::singletonRef;
+}
+
+/**
+   \brief standard deconstructor
+
+   !! DANGER !! when unloading the AnimationPlayer no other Function
+   should reference any Animations, from the animationList because it 
+   automatically deletes them. 
+   This usually happens when unloading a World.
+*/
+AnimationPlayer::~AnimationPlayer () 
+{
+  // deleting the Animation List AND all the elements of the List
+  this->flush();
+  delete this->animationList;
+
+  AnimationPlayer::singletonRef = NULL;
+}
+
+/**
+   \brief adds an Animation to the AnimationList.
+   \param animation the Animation to handle
+
+   when adding a Animation the Animation will too be deleted when
+   the AnimationPlayer gets deleted. Consider not adding it, or 
+   unadding it with animation->notHandled();
+*/
+void AnimationPlayer::addAnimation(Animation* animation)
+{
+  this->animationList->add(animation);
+}
+
+/**
+   \brief removes an Animation from the Animation List, WITHOUT deleting it.
+   \param animation the Anmination to remove from the List
+*/
+void AnimationPlayer::removeAnimation(Animation* animation)
+{
+  this->animationList->remove(animation);
+}
+
+/**
+   \brief empties the list AND deletes all the Animations
+*/ 
+void AnimationPlayer::flush(void)
+{
+  // deleting the Animation List AND all the elements of the List
+  tIterator<Animation>* animIt = this->animationList->getIterator();
+  Animation* anim = animIt->nextElement();
+  while( anim != NULL)
+    {
+      delete anim;
+      this->animationList->remove(anim);
+      anim = animIt->nextElement();
+    }
+  delete animIt;
+
+  delete this->animationList;
+  this->animationList = new tList<Animation>();
+}
+
+/**
+   \brief Ticks all the animations in animationList 
+   \param timePassed the time passed since the last tick.
+*/
+void AnimationPlayer::tick(float timePassed)
+{
+  if (this->bRunning)
+    {
+      // iterate through all the animations and tick them.
+      tIterator<Animation>* animIt = this->animationList->getIterator();
+      Animation* anim = animIt->nextElement();
+      while( anim != NULL)
+	{
+	  anim->tick(timePassed);
+	  if(unlikely(anim->ifDelete()))
+	  {
+	    this->animationList->remove(anim);
+	    delete anim;
+	  }
+	  anim = animIt->nextElement();
+	}
+      delete animIt;
+    }
+}
+/**
+   \brief starts playing the AnimationPlayer
+*/
+void AnimationPlayer::play(void)
+{
+  this->bRunning = true;
+}
+
+/**
+   \brief pauses playing of the AnimationPlayer
+*/
+void AnimationPlayer::pause(void)
+{
+  this->bRunning = false;
+}
+
+
+Animation* AnimationPlayer::getObjectFromBaseObject(const BaseObject* baseObject) const
+{
+  tIterator<Animation>* animIt = this->animationList->getIterator();
+  Animation* anim = animIt->nextElement();
+  while( anim != NULL)
+    {
+      if(anim->getBaseObject() == baseObject)
+	{
+	  delete animIt;
+	  return anim;
+	}
+      anim = animIt->nextElement();
+    }
+  delete animIt;
+
+}
+
+
+
+/**
+   \brief Outputs some nice debug-information
+*/
+void AnimationPlayer::debug(void)
+{
+  PRINT(0)("+------------------------------------+\n");
+  PRINT(0)("+ ANIMATION PLAYER DEBUG INFORMATION +\n");
+  PRINT(0)("+------------------------------------+\n");
+  PRINT(0)("| Reference: %p\n", this);
+  PRINT(0)("| CountOfAnims %d\n", this->animationList->getSize());
+  PRINT(0)("-Animation Information---------------+\n");
+  // Per ANIMATION DEBUG
+  tIterator<Animation>* animIt = this->animationList->getIterator();
+  Animation* anim = animIt->nextElement();
+  while( anim != NULL)
+    {
+      //      anim->debug();
+      anim = animIt->nextElement();
+    }
+  delete animIt;
+
+  PRINT(0)("+--------------------------------AP--+\n");
+}
Index: orxonox/trunk/src/util/animation/animation_player.h
===================================================================
--- orxonox/trunk/src/util/animation/animation_player.h	(revision 3868)
+++ orxonox/trunk/src/util/animation/animation_player.h	(revision 3868)
@@ -0,0 +1,59 @@
+/*! 
+    \file animation_player.h
+*/
+
+#ifndef _ANIMATION_PLAYER_H
+#define _ANIMATION_PLAYER_H
+
+#include "base_object.h"
+#include "animation.h"
+
+/* FORWARD DEFINITION */
+
+//! A AnimationPlayer, that handles the animation of all the Animations in the scene.
+/**
+   <b>AnimationPlayer usage:</b> \n
+
+   <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is 
+   usually done when initializing a world \n
+   <b>Adding Animations</b>: create an Animation the following Way:
+   \li Anim* animation = new Anim(); // also use any other Subclass of Animation to initialize this
+   \li set some parameters: also see the specific classes for more info
+   \n
+   if you do not want a specific Animation to be handled by the AnimationPlayer, you have to 
+   unload it explicitely with animation->doNotHandle();
+   \n
+   eveything else will be done by the AnimationPlayer itself.\n
+*/
+class AnimationPlayer : public BaseObject {
+
+ public:
+  static AnimationPlayer* getInstance(void);
+  virtual ~AnimationPlayer(void);
+
+  // animation handling
+  void addAnimation(Animation* animation);
+  void removeAnimation(Animation* animation);
+  void flush(void);
+
+  // time functions
+  void tick(float timePassed);
+  void play(void);
+  void pause(void);
+
+  Animation* getObjectFromBaseObject(const BaseObject* baseObject) const;
+
+  void debug(void);
+
+ private:
+  /* singleton */
+  AnimationPlayer(void);
+  static AnimationPlayer* singletonRef;
+
+  /* class specific */
+  tList<Animation>* animationList;         //!< A List of Animations to be handled.
+  bool bRunning;                           //!< If the AnimationPlayer is running.
+};
+
+
+#endif /* _ANIMATION_PLAYER_H */
Index: orxonox/trunk/src/util/animation/t_animation.h
===================================================================
--- orxonox/trunk/src/util/animation/t_animation.h	(revision 3868)
+++ orxonox/trunk/src/util/animation/t_animation.h	(revision 3868)
@@ -0,0 +1,346 @@
+/*
+   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: ...
+*/
+
+/*! 
+    \file t_animation.h
+*/
+
+#ifndef _T_ANIMATION_H
+#define _T_ANIMATION_H
+
+
+#include "animation.h"
+
+#define DELTA_X 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
+
+//! A Struct for Keyframes that simply hold a float
+typedef struct KeyFrameF
+{
+  float duration;             //!< duration of this keyframe
+  float value;                //!< value of this keyframe
+  ANIM_FUNCTION animFunc;     //!< with whitch function to iterate to the next KeyFrameF
+};
+
+
+//! A Class to handle some animation for single floated values.
+template<class T> class tAnimation : public Animation
+{
+ public:
+  tAnimation(T* object = NULL, void (T::*funcToAnim)(float) = NULL);
+  virtual ~tAnimation();
+
+  void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
+
+  void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR);
+
+  virtual void rewind();
+  virtual void tick(float dt);
+
+ private:
+  // animation functions
+  void setAnimFunc(ANIM_FUNCTION animFunc);
+  float constant(float timePassed) const;
+  float linear(float timePassed) const;
+  float sine(float timePassed) const;
+  float cosine(float timePassed) const;
+  float exp(float timePassed) const;
+  float negExp(float timePassed) const;
+  float quadratic(float timePassed) const;
+  float random(float timePassed) const;
+
+
+  //  ANIM_FUNCTION animFunc;
+  float (tAnimation<T>::*animFunc)(float) const;  //!< A Function for the AnimationType
+
+  KeyFrameF* currentKeyFrame;                     //!< The current KeyFrame
+  KeyFrameF* nextKeyFrame;                        //!< The KeyFrame we iterate to
+  tList<KeyFrameF>* keyFrameList;                 //!< The KeyFrameList
+
+  T* object;                                      //!< The Object from which to Animate something
+  void (T::*funcToAnim)(float);                   //!< The function to Animate
+
+  float expFactor;                                //!< some factors
+};
+
+
+
+/**
+   \brief standard constructor
+*/
+template<class T>
+tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 
+{
+  // create a new List
+  this->keyFrameList = new tList<KeyFrameF>();
+  KeyFrameF* tmpKeyFrame = new KeyFrameF;
+  tmpKeyFrame->value = 0.0;
+  tmpKeyFrame->duration = 1.0;
+  keyFrameList->add(tmpKeyFrame);
+
+  this->currentKeyFrame = tmpKeyFrame;
+  this->nextKeyFrame = tmpKeyFrame;
+
+  this->animFunc = &tAnimation<T>::linear;
+
+  this->setFuncToAnim(object, funcToAnim);
+}
+
+
+/**
+   \brief standard deconstructor
+   
+   deletes all the Keyframes
+*/
+template<class T>
+tAnimation<T>::~tAnimation () 
+{
+  // delete all the KeyFrames
+  tIterator<KeyFrameF>* itKF = keyFrameList->getIterator();
+  KeyFrameF*  enumKF = itKF->nextElement();
+  while (enumKF)
+    {
+      delete enumKF;
+      enumKF = itKF->nextElement();
+    }
+  delete itKF;
+  delete this->keyFrameList;
+}
+
+/**
+   \brief rewinds the Animation to the beginning (first KeyFrame and time == 0)
+*/
+template<class T>
+void tAnimation<T>::rewind(void)
+{
+  this->currentKeyFrame = keyFrameList->firstElement();
+  this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());
+  this->localTime = 0.0;
+}
+
+/**
+   \brief sets the Function we want to animate
+   \param object from what object do we want to animate
+   \param funcToAnim which function
+*/
+template<class T>
+void tAnimation<T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float))
+{
+  this->baseObject = this->object = object;
+  this->funcToAnim = funcToAnim;
+}
+
+/**
+   \brief Appends a new Keyframe
+   \param value the value of the new KeyFrame
+   \param duration The duration from the new KeyFrame to the next one
+   \param animFunc The function to animate between this keyFrame and the next one
+*/
+template<class T>
+void tAnimation<T>::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc)
+{
+  // some small check
+  if (duration <= 0.0)
+    duration = 1.0;
+
+  KeyFrameF* tmpKeyFrame;
+    
+  if (bHasKeys)
+    {
+      tmpKeyFrame = new KeyFrameF;
+      if (this->currentKeyFrame == this->nextKeyFrame)
+	this->nextKeyFrame = tmpKeyFrame;
+      this->keyFrameList->add(tmpKeyFrame);
+
+    }
+  else
+    {
+      tmpKeyFrame = this->keyFrameList->firstElement();
+      bHasKeys = true;
+      this->setAnimFunc(animFunc);
+    }
+  tmpKeyFrame->value = value;
+  tmpKeyFrame->duration = duration;
+  tmpKeyFrame->animFunc = animFunc;
+}
+
+/**
+   \brief ticks the Animation
+   \param dt how much time to tick
+*/
+template<class T>
+void tAnimation<T>::tick(float dt)
+{
+  if (this->bRunning)
+    {
+      this->localTime += dt;
+      if (localTime >= this->currentKeyFrame->duration)
+	{
+	  // switching to the next Key-Frame
+	  this->localTime -= this->currentKeyFrame->duration;
+
+	  this->currentKeyFrame = this->nextKeyFrame;
+	  // checking, if we should still Play the animation
+	  if (this->currentKeyFrame == this->keyFrameList->lastElement())
+	    this->handleInfinity();
+	  this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
+	  printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
+	  this->setAnimFunc(this->currentKeyFrame->animFunc);	  
+	}
+      
+      (this->object->*(funcToAnim))((this->*animFunc)(this->localTime));
+    }
+}
+
+/**
+   \brief Sets The kind of Animation between this keyframe and the next one
+   \param animFunc The Type of Animation to set
+*/
+template<class T>
+void tAnimation<T>::setAnimFunc(ANIM_FUNCTION animFunc)
+{
+  switch (animFunc)
+    {
+    default:
+    case ANIM_CONSTANT:
+      this->animFunc = &tAnimation<T>::constant;
+      break;
+    case ANIM_LINEAR:
+      this->animFunc = &tAnimation<T>::linear;
+      break;
+    case ANIM_SINE:
+      this->animFunc = &tAnimation<T>::sine;
+      break;
+    case ANIM_COSINE:
+      this->animFunc = &tAnimation<T>::cosine;
+      break;
+    case ANIM_EXP:
+      this->animFunc = &tAnimation<T>::exp;
+      break;
+    case ANIM_NEG_EXP:
+      {
+	this->animFunc = &tAnimation<T>::negExp;
+	float d = fabs(this->currentKeyFrame->value - this->nextKeyFrame->value);
+	expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
+	break;
+      }
+    case ANIM_QUADRATIC:
+      this->animFunc = &tAnimation<T>::quadratic;
+      break;
+    case ANIM_RANDOM:
+      this->animFunc = &tAnimation<T>::random;
+      break;
+    }
+}
+
+
+// animation functions
+/**
+   \brief stays at the value of the currentKeyFrame
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::constant(float timePassed) const
+{
+  return this->currentKeyFrame->value;
+}
+
+/**
+   \brief linear interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::linear(float timePassed) const 
+{
+  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 
+    * (timePassed / this->currentKeyFrame->duration);
+  //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
+  //  return val;
+}
+
+/**
+   \brief a Sinusodial Interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::sine(float timePassed) const
+{
+  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
+  float e = 0.5 * d * (1 - cos(M_PI * timePassed / this->currentKeyFrame->duration));
+  return this->currentKeyFrame->value - e;
+  /*
+  return his->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
+    * sin(timePassed / this->currentKeyFrame->duration * M_PI);
+  */
+}
+
+/**
+   \brief a cosine interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::cosine(float timePassed) const
+{
+  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
+  float e = 0.5 * d * (sin(M_PI * timePassed / this->currentKeyFrame->duration));
+  if( timePassed > 0.5*this->currentKeyFrame->duration) e = (d - e);
+  return this->currentKeyFrame->value - e;
+  /*
+  return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
+    * cos(timePassed / this->currentKeyFrame->duration * M_PI);
+  */
+}
+
+/**
+   \brief an exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::exp(float timePassed) const
+{
+}
+
+/**
+   \brief a negative exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::negExp(float timePassed) const
+{
+  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
+  float e = d * (1.0 - expf(- timePassed * expFactor));
+  return  this->currentKeyFrame->value - e;
+}
+
+/**
+   \brief a quadratic interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::quadratic(float timePassed) const
+{
+  this->linear(timePassed);
+}
+
+/**
+   \brief some random animation (fluctuating)
+   \param timePassed The time passed since this Keyframe began
+*/
+template<class T>
+float tAnimation<T>::random(float timePassed) const
+{
+  return this->currentKeyFrame->value * (float)rand()/(float)RAND_MAX;
+}
+
+#endif /* _T_ANIMATION_H */
