Index: orxonox/branches/heightMap/src/util/animation/animation.cc
===================================================================
--- orxonox/branches/heightMap/src/util/animation/animation.cc	(revision 3918)
+++ orxonox/branches/heightMap/src/util/animation/animation.cc	(revision 4122)
@@ -34,6 +34,7 @@
 
   // setting default values
+  this->keyFramesToPlay = -1;
   this->localTime = 0.0;
-  this->bRunning = true;
+  this->bRunning = false;
 
   AnimationPlayer::getInstance()->addAnimation(this);
@@ -83,5 +84,6 @@
       break;
     case ANIM_INF_REPLAY:
-      this->replay();
+      this->rewind();
+      this->bRunning = true;
       break;
     case ANIM_INF_REWIND:
@@ -99,4 +101,15 @@
 void Animation::play()
 {
+  this->keyFramesToPlay = -1;
+  this->bRunning = true;
+}
+
+/**
+   \brief plays the Next n keyframes
+   \param n the Count of keyFrames to play.
+*/
+void Animation::playNextKeyframes(int n)
+{
+  this->keyFramesToPlay = n-1;
   this->bRunning = true;
 }
@@ -107,4 +120,5 @@
 void Animation::stop()
 {
+  this->keyFramesToPlay = -1;
   this->rewind();
   this->bRunning = true;
@@ -127,4 +141,4 @@
 {
   this->rewind();
-  this->bRunning = true;
+  this->play();
 }
Index: orxonox/branches/heightMap/src/util/animation/animation.h
===================================================================
--- orxonox/branches/heightMap/src/util/animation/animation.h	(revision 3918)
+++ orxonox/branches/heightMap/src/util/animation/animation.h	(revision 4122)
@@ -25,5 +25,7 @@
    ANIM_NEG_EXP: fast, slow
    ANIM_RANDOM: eratic
-   
+
+   ANIM_NULL: !!DO NOT USE THIS!! only for internal handling
+
    deprecated QUADRATIC
 */
@@ -35,5 +37,7 @@
 			    ANIM_NEG_EXP,
 			    ANIM_QUADRATIC,
-			    ANIM_RANDOM};
+			    ANIM_RANDOM,
+			    ANIM_NULL};
+#define ANIM_DEFAULT_FUNCTION ANIM_LINEAR      //!< A default function to choose from the above set
 
 //! An enumerator describing what the animation should do after the last keyframe.
@@ -69,4 +73,5 @@
 
   void play(); // equals resume();
+  void playNextKeyframes(int n = 1);
   void stop();
   void pause();
@@ -95,4 +100,5 @@
   BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
   unsigned int keyFrameCount;     //!< The Count of KeyFrames.
+  int keyFramesToPlay;            //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
   bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
   bool bRunning;                  //!< If the animation is running
Index: orxonox/branches/heightMap/src/util/animation/animation3d.cc
===================================================================
--- orxonox/branches/heightMap/src/util/animation/animation3d.cc	(revision 3918)
+++ orxonox/branches/heightMap/src/util/animation/animation3d.cc	(revision 4122)
@@ -15,4 +15,6 @@
    2005-04-17: Benjamin Grauer
           Rewritte all functions, so it will fit into the Animation-class
+   2005-04-25: Patrick Boenzli
+          Extended the framework to support quatSlerp rotations. Each frame now supports diff mov/rot types. Implemented mov/rot functions
 */
 
@@ -42,5 +44,7 @@
   this->nextKeyFrame = tmpKeyFrame;
 
-  this->animFunc = &Animation3D::linear;
+  this->animFuncMov = &Animation3D::mLinear;
+  this->animFuncRot = &Animation3D::rLinear;
+
 }
 
@@ -72,5 +76,6 @@
   this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());
   this->localTime = 0.0;
-  this->setAnimFunc(this->currentKeyFrame->animFunc);
+  this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
+  this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
 }
 
@@ -80,11 +85,17 @@
    \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)
+   \param animFuncMov The function to animate position between this keyFrame and the next one
+   \param animFuncMov The function to animate rotation between this keyFrame and the next one
+*/
+void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot)
 {
   // some small check
   if (duration <= 0.0)
     duration = 1.0;
+  // if the Rotation-Animation-function is set ANIM_NULL, animFuncRot will match animFuncRot
+  if (animFuncMov == ANIM_NULL)
+    animFuncMov = ANIM_DEFAULT_FUNCTION;
+  if (animFuncRot == ANIM_NULL)
+    animFuncRot = animFuncMov;
 
   KeyFrame3D* tmpKeyFrame;
@@ -94,5 +105,6 @@
     {
       tmpKeyFrame = this->keyFrameList->firstElement();
-      this->setAnimFunc(animFunc);
+      //this->setAnimFuncMov(animFuncMov);
+      //this->setAnimFuncRot(animFuncRot);
     }
   else
@@ -106,9 +118,13 @@
 
   tmpKeyFrame->position = position;
+  //tmpKeyFrame->lastPosition = position;
   tmpKeyFrame->direction = direction;
   tmpKeyFrame->duration = duration;
-  tmpKeyFrame->animFunc = animFunc;
+  tmpKeyFrame->animFuncMov = animFuncMov;
+  tmpKeyFrame->animFuncRot = animFuncRot;
   this->keyFrameCount++;
 }
+
+
 
 /**
@@ -123,96 +139,80 @@
       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)
+	  if (likely(this->keyFramesToPlay != 0))
 	    {
-	      this->tmpVect = this->nextKeyFrame->position - this->currentKeyFrame->position;
-	      this->deltaT = 1/this->currentKeyFrame->duration * logf(1.0 + 600.0/this->tmpVect.len());
+	      if (unlikely(this->keyFramesToPlay > 0))
+		--this->keyFramesToPlay;
+	      // 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->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
+	      this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
 	    }
-	}
-
+	  else
+	    this->pause();
+	}      
       /* 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
+      (this->*animFuncMov)(this->localTime);
+      (this->*animFuncRot)(this->localTime);
+    }
+}
+
+
+/*==Movement Section==========================================================*/
+
+/**
+   \brief Sets The kind of movment Animation between this keyframe and the next one
    \param animFunc The Type of Animation to set
 */
-void Animation3D::setAnimFunc(ANIM_FUNCTION animFunc)
-{
-  switch (animFunc)
+void Animation3D::setAnimFuncMov(ANIM_FUNCTION animFuncMov)
+{
+  switch (animFuncMov)
     {
+    case ANIM_CONSTANT:
+      this->animFuncMov = &Animation3D::mConstant;
+      break;
+    case ANIM_LINEAR:
+      this->animFuncMov = &Animation3D::mLinear;
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->currentKeyFrame->lastPosition = Vector();
+      break;
+    case ANIM_SINE:
+      this->animFuncMov = &Animation3D::mSine;
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->currentKeyFrame->lastPosition = Vector();
+      break;
+    case ANIM_COSINE:
+      this->animFuncMov = &Animation3D::mCosine;
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->currentKeyFrame->lastPosition = Vector();
+      break;
+    case ANIM_EXP:
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->animFuncMov = &Animation3D::mExp;
+      break;
+    case ANIM_NEG_EXP:
+      this->animFuncMov = &Animation3D::mNegExp;
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->expFactorMov = -1.0 / this->currentKeyFrame->duration * logf(DELTA_X_3D);
+      this->currentKeyFrame->lastPosition = Vector();
+      break;
+    case ANIM_QUADRATIC:
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->animFuncMov = &Animation3D::mQuadratic;
+      break;
+    case ANIM_RANDOM:
+      this->object->setRelCoor(this->currentKeyFrame->position);
+      this->animFuncMov = &Animation3D::mRandom;
+      break;
     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;
-    }
-}
+      break;
+    }
+}
+
+
 
 /**
@@ -220,7 +220,7 @@
    \param timePassed The time passed since this Keyframe began
 */
-void Animation3D::constant(float timePassed) const
-{
-  this->object->setRelCoor(this->currentKeyFrame->position);
+void Animation3D::mConstant(float timePassed) const
+{
+  //this->object->setRelCoor(this->currentKeyFrame->position);
 
   /*
@@ -238,9 +238,9 @@
    \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));
+void Animation3D::mLinear(float timePassed) const
+{
+  Vector v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (timePassed/this->currentKeyFrame->duration);
+  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
+  this->currentKeyFrame->lastPosition = v;
 }
 
@@ -251,8 +251,16 @@
    \todo implement
 */
-void Animation3D::sine(float timePassed) const
-{
-  this->linear(timePassed);
-}
+void Animation3D::mSine(float timePassed) const
+{
+  Vector v;
+  if( timePassed  < this->currentKeyFrame->duration/2.0)
+    v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * sin( M_PI * timePassed /this->currentKeyFrame->duration) / 2.0;
+  else
+    v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (2.0 + sin( M_PI * (- timePassed /this->currentKeyFrame->duration)) )/ 2.0;
+  
+  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
+  this->currentKeyFrame->lastPosition = v;
+}
+
 
 /**
@@ -262,8 +270,20 @@
    \todo implement
 */
-void Animation3D::cosine(float timePassed) const
-{
-  this->linear(timePassed);
-}
+void Animation3D::mCosine(float timePassed) const
+{
+  Vector v;
+  v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0;
+  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
+  this->currentKeyFrame->lastPosition = v;
+
+
+  /*
+  this->object->setRelCoor( this->nextKeyFrame->position -
+			    (this->nextKeyFrame->position - this->currentKeyFrame->position) *
+			    (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0);
+  */
+}
+
+
 
 /**
@@ -271,7 +291,8 @@
    \param timePassed The time passed since this Keyframe began
 */
-void Animation3D::exp(float timePassed) const
-{
-  this->linear(timePassed);
+void Animation3D::mExp(float timePassed) const
+{
+  PRINTF(0)("no exp animation3d defined\n");
+  this->mLinear(timePassed);
 }
 
@@ -279,11 +300,19 @@
    \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);
-}
+*/
+void Animation3D::mNegExp(float timePassed) const
+{
+  Vector v;
+  v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (1.0 - expf(- timePassed * expFactorMov));
+  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
+  this->currentKeyFrame->lastPosition = v;
+
+  /*
+  this->object->setRelCoor( this->currentKeyFrame->position +
+			    (this->nextKeyFrame->position - this->currentKeyFrame->position) * 
+			    (1.0 - expf(- timePassed * expFactorMov)) );
+  */
+}
+
 
 /**
@@ -293,7 +322,8 @@
    \todo implement
 */
-void Animation3D::quadratic(float timePassed) const
-{
-  this->linear(timePassed);
+void Animation3D::mQuadratic(float timePassed) const
+{
+  PRINTF(0)("no quadratic animation3d defined\n");
+  this->mLinear(timePassed);
 }
 
@@ -302,9 +332,154 @@
    \param timePassed The time passed since this Keyframe began
 */
-void Animation3D::random(float timePassed) const
-{
+void Animation3D::mRandom(float timePassed) const
+{
+  /*
   this->object->setRelCoor(this->currentKeyFrame->position + 
 			   (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX);
   this->object->setRelDir(this->currentKeyFrame->direction +
 			  (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX);
-}
+  */
+}
+
+
+/*==Rotation Section==========================================================*/
+
+
+/**
+   \brief Sets The kind of rotation Animation between this keyframe and the next one
+   \param animFunc The Type of Animation to set
+*/
+void Animation3D::setAnimFuncRot(ANIM_FUNCTION animFuncRot)
+{
+  switch (animFuncRot)
+    {
+    default:
+    case ANIM_CONSTANT:
+      this->animFuncRot = &Animation3D::rConstant;
+      break;
+    case ANIM_LINEAR:
+      this->animFuncRot = &Animation3D::rLinear;
+      break;
+    case ANIM_SINE:
+      this->animFuncRot = &Animation3D::rSine;
+      break;
+    case ANIM_COSINE:
+      this->animFuncRot = &Animation3D::rCosine;
+      break;
+    case ANIM_EXP:
+      this->animFuncRot = &Animation3D::rExp;
+      break;
+    case ANIM_NEG_EXP:
+      this->animFuncRot = &Animation3D::rNegExp;
+      this->expFactorRot = -1.0 / this->currentKeyFrame->duration * logf(DELTA_X_3D);
+      break;
+    case ANIM_QUADRATIC:
+      this->animFuncRot = &Animation3D::rQuadratic;
+      break;
+    case ANIM_RANDOM:
+      this->animFuncRot = &Animation3D::rRandom;
+      break;
+
+    }
+}
+
+
+/**
+   \brief stays at the value of the currentKeyFrame
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::rConstant(float timePassed) const
+{
+  this->object->setRelDir(this->currentKeyFrame->direction);
+}
+
+/**
+   \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::rLinear(float timePassed) const
+{
+  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
+				     this->currentKeyFrame->direction, 
+				     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::rSine(float timePassed) const
+{
+  float scale;
+  if( timePassed < this->currentKeyFrame->duration / 2.0)
+    scale = sin( M_PI * timePassed / this->currentKeyFrame->duration);
+  else
+    scale = 1.0 - sin( M_PI * timePassed / this->currentKeyFrame->duration);
+
+  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
+				     this->currentKeyFrame->direction, 
+				     scale) );
+}
+
+
+/**
+   \brief a cosine interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::rCosine(float timePassed) const
+{
+  float scale = cos(M_PI * timePassed / this->currentKeyFrame->duration);
+  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
+				     this->currentKeyFrame->direction, 
+				     scale) );
+}
+
+
+
+/**
+   \brief an exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::rExp(float timePassed) const
+{
+  PRINTF(0)("exp rotation function not implemented\n");
+}
+
+/**
+   \brief a negative exponential interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::rNegExp(float timePassed) const
+{
+  float scale = (1.0 - expf(- timePassed * expFactorRot));
+  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
+				     this->currentKeyFrame->direction, 
+				     scale) );
+}
+
+
+/**
+   \brief a quadratic interpolation between this keyframe and the next one
+   \param timePassed The time passed since this Keyframe began
+
+   \todo implement
+*/
+void Animation3D::rQuadratic(float timePassed) const
+{
+  PRINTF(0)("quadratic rotation alg not implemented\n");
+}
+
+/**
+   \brief some random animation (fluctuating)
+   \param timePassed The time passed since this Keyframe began
+*/
+void Animation3D::rRandom(float timePassed) const
+{
+  PRINTF(0)("random rotation alg not implemented\n");
+}
Index: orxonox/branches/heightMap/src/util/animation/animation3d.h
===================================================================
--- orxonox/branches/heightMap/src/util/animation/animation3d.h	(revision 3918)
+++ orxonox/branches/heightMap/src/util/animation/animation3d.h	(revision 4122)
@@ -9,4 +9,6 @@
 class PNode;
 
+#define DELTA_X_3D 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
+
 //! KeyFrame3D Struct
 /**
@@ -16,6 +18,8 @@
   float duration;                   //!< The duration of this KeyFrame
   Vector position;                  //!< The position of this KeyFrame
+  Vector lastPosition;
   Quaternion direction;             //!< The direction of this KeyFrame
-  ANIM_FUNCTION animFunc;           //!< with whitch function to iterate to the next KeyFrame3D
+  ANIM_FUNCTION animFuncMov;        //!< with whitch function to iterate movement to the next KeyFrame3D
+  ANIM_FUNCTION animFuncRot;        //!< with whitch function to iterate rotation to the next KeyFrame3D
 };
 
@@ -32,22 +36,32 @@
   virtual void rewind(void);
 
-  void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFunc = ANIM_LINEAR);
+  void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION, ANIM_FUNCTION animFuncRot = ANIM_NULL);
   //  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;
+  void setAnimFuncMov(ANIM_FUNCTION animFunc);
+  void setAnimFuncRot(ANIM_FUNCTION animFunc);
+  void mConstant(float timePassed) const;
+  void mLinear(float timePassed) const;
+  void mSine(float timePassed) const;
+  void mCosine(float timePassed) const;
+  void mExp(float timePassed) const;
+  void mNegExp(float timePassed) const;
+  void mQuadratic(float timePassed) const;
+  void mRandom(float timePassed) const;
+  void rConstant(float timePassed) const;
+  void rLinear(float timePassed) const;
+  void rSine(float timePassed) const;
+  void rCosine(float timePassed) const;
+  void rExp(float timePassed) const;
+  void rNegExp(float timePassed) const;
+  void rQuadratic(float timePassed) const;
+  void rRandom(float timePassed) const;
   //  ANIM_FUNCTION animFunc;
-  void (Animation3D::*animFunc)(float) const;      //!< A Function for the AnimationType
+  void (Animation3D::*animFuncMov)(float) const;      //!< A Function for the AnimationType
+  void (Animation3D::*animFuncRot)(float) const;      //!< A Function for the AnimationType
 
   KeyFrame3D* currentKeyFrame;                     //!< The current KeyFrame
@@ -60,3 +74,5 @@
   Vector tmpVect;        //!< what for??
   float deltaT;          //!< ??
+  float expFactorMov;
+  float expFactorRot;
 };
Index: orxonox/branches/heightMap/src/util/animation/t_animation.h
===================================================================
--- orxonox/branches/heightMap/src/util/animation/t_animation.h	(revision 3918)
+++ orxonox/branches/heightMap/src/util/animation/t_animation.h	(revision 4122)
@@ -43,5 +43,5 @@
   void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
 
-  void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR);
+  void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_DEFAULT_FUNCTION);
 
   virtual void rewind();
@@ -154,4 +154,6 @@
   if (duration <= 0.0)
     duration = 1.0;
+  if (animFunc == ANIM_NULL)
+    animFunc = ANIM_DEFAULT_FUNCTION;
 
   KeyFrameF* tmpKeyFrame;
@@ -190,15 +192,22 @@
       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);	  
+	  if (likely(this->keyFramesToPlay != 0))
+	    {
+	      if (unlikely(this->keyFramesToPlay > 0))
+		--this->keyFramesToPlay;
+	      // 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);	  
+	    }
+	  else
+	    this->pause();
 	}
       
@@ -235,5 +244,4 @@
       {
 	this->animFunc = &tAnimation<T>::negExp;
-	float d = fabs(this->currentKeyFrame->value - this->nextKeyFrame->value);
 	expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
 	break;
Index: orxonox/branches/heightMap/src/util/resource_manager.cc
===================================================================
--- orxonox/branches/heightMap/src/util/resource_manager.cc	(revision 3918)
+++ orxonox/branches/heightMap/src/util/resource_manager.cc	(revision 4122)
@@ -92,9 +92,31 @@
       this->dataDir = new char[strlen(dataDir)+1];
       strcpy(this->dataDir, dataDir);
+      return true;
     }
   else
     {
       PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir, this->dataDir);
-    }
+      return false;
+    }
+}
+
+/**
+   \brief checks for the DataDirectory, by looking if 
+   \param fileInside is inisde??
+*/
+bool ResourceManager::checkDataDir(const char* fileInside)
+{
+  bool retVal;
+  if (!isDir(this->dataDir))
+    {
+      PRINTF(1)("%s is not a directory\n", this->dataDir);
+      return false;
+    }
+  
+  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
+  sprintf(testFile, "%s%s", this->dataDir, fileInside);
+  retVal = isFile(testFile);
+  delete testFile;
+  return retVal;
 }
 
@@ -180,5 +202,5 @@
   // searching if the resource was loaded before.
   Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2,param3);
-  if (tmpResource) // if the resource was not loaded before.
+  if (tmpResource) // if the resource was loaded before.
     {
       PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
@@ -199,7 +221,6 @@
 
       // creating the full name. (directoryName + FileName)
-      char* fullName = new char[strlen(dataDir)+strlen(fileName)+1];
-      sprintf(fullName, "%s%s", this->dataDir, fileName);
-      
+      char* fullName = new char[strlen(this->getDataDir())+strlen(fileName)+1];
+      sprintf(fullName, "%s%s", this->getDataDir(), fileName);
       // Checking for the type of resource \see ResourceType
       switch(type)
@@ -211,5 +232,5 @@
 	    tmpResource->modelSize = 1.0;
 
-	  if(isFile(fullName))
+	  if(ResourceManager::isFile(fullName))
 	    tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
 	  else
@@ -508,19 +529,23 @@
     }
 
-  stat(tmpDirName, &status);
-  if (status.st_mode & (S_IFDIR
+  if(!stat(tmpDirName, &status))
+    {
+      if (status.st_mode & (S_IFDIR
 #ifndef __WIN32__
-			| S_IFLNK
+			    | S_IFLNK
 #endif
-			))
-    {
-      delete tmpDirName;
-      return true;
+			    ))
+	{
+	  delete tmpDirName;
+	  return true;
+	}
+      else
+	{
+	  delete tmpDirName;
+	  return false;
+	}
     }
   else
-    {
-      delete tmpDirName;
-      return false;
-    }
+    return false;
 }
 
@@ -532,15 +557,76 @@
 bool ResourceManager::isFile(const char* fileName)
 {
+  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
+  // actually checks the File
   struct stat status;
-  stat(fileName, &status);
-  if (status.st_mode & (S_IFREG 
+  if (!stat(tmpFileName, &status))
+    {
+      if (status.st_mode & (S_IFREG 
 #ifndef __WIN32__
-			| S_IFLNK
+			    | S_IFLNK
 #endif
-			))
-    return true;
+			    ))
+	{
+	  delete tmpFileName;
+	  return true;
+	}
+      else
+	{
+	  delete tmpFileName;
+	  return false;
+	}
+    }
+  else 
+    {
+      delete tmpFileName;
+      return false;
+    }
+}
+
+bool ResourceManager::touchFile(const char* fileName)
+{
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+
+  FILE* stream;
+  if( (stream = fopen (tmpName, "w")) == NULL)
+    {
+      PRINTF(1)("could not open %s fro writing\n", fileName);
+      return false;
+    }
+  fclose(stream);
+    
+  delete tmpName; 
+}
+
+bool ResourceManager::deleteFile(const char* fileName)
+{
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+  unlink(tmpName);
+  delete tmpName;
+}
+
+char* ResourceManager::homeDirCheck(const char* name)
+{
+  char* retName;
+  if (!strncmp(name, "~/", 2))
+    {
+      char tmpFileName[500];
+#ifdef __WIN32__
+      strcpy(tmpFileName, getenv("USERPROFILE"));
+#else
+      strcpy(tmpFileName, getenv("HOME"));
+#endif
+      retName = new char[strlen(tmpFileName)+strlen(name)];
+      sprintf(retName, "%s%s", tmpFileName, name+1);
+    }
   else
-    return false;
-}
+    {
+      retName = new char[strlen(name)+1];
+      strcpy(retName, name);
+    }
+  return retName;
+}
+
+
 
 /**
Index: orxonox/branches/heightMap/src/util/resource_manager.h
===================================================================
--- orxonox/branches/heightMap/src/util/resource_manager.h	(revision 3918)
+++ orxonox/branches/heightMap/src/util/resource_manager.h	(revision 4122)
@@ -65,4 +65,7 @@
 
   bool setDataDir(const char* dataDir);
+  /** \returns the Name of the data directory */
+  inline const char*  getDataDir(void) {return this->dataDir;}
+  bool checkDataDir(const char* fileInside);
   bool addImageDir(char* imageDir);
   void* load(const char* fileName, ResourcePriority prio = RP_NO,
@@ -73,5 +76,13 @@
   bool unload(Resource* resource, ResourcePriority = RP_NO);
   bool unloadAllByPriority(ResourcePriority prio);
+
   void debug(void);
+
+  // utility functions of this class
+  static bool isDir(const char* directory);
+  static bool isFile(const char* fileName);
+  static bool touchFile(const char* fileName);
+  static bool deleteFile(const char* fileName);
+  static char* homeDirCheck(const char* name);
 
  private:
@@ -87,7 +98,4 @@
   Resource* locateResourceByPointer(const void* pointer);
   
-  bool isDir(const char* directory);
-  bool isFile(const char* directory);
-
 };
 
