Index: orxonox/trunk/src/simple_animation.cc
===================================================================
--- orxonox/trunk/src/simple_animation.cc	(revision 3739)
+++ orxonox/trunk/src/simple_animation.cc	(revision 3743)
@@ -97,4 +97,5 @@
 {
   this->workingObject = NULL;
+  this->workingAnimator = NULL;
   this->bDescriptive = false;
 }
@@ -117,4 +118,5 @@
 void SimpleAnimation::selectObject(WorldEntity* entity)
 {
+  printf("SimpleAnimation::selectObject() - selecing active object\n");
   Animation* anim = getAnimationFromWorldEntity(entity);
   if( anim == NULL)
@@ -125,10 +127,13 @@
       anim->lastPosition = new Vector();
       anim->tmpVect = new Vector();
-      frames = new tList<KeyFrame>();
+      anim->frames = new tList<KeyFrame>();
       bRunning = false;
       deltaT = 0.0;
       this->animators->add(anim);
     }
+  else 
+    printf("SimpleAnimation::selectObject() - animation already existent, using it\n");
   this->workingAnimator = anim;
+  printf("SimpleAnimation::selectObject() - selection completed\n");
 }
 
@@ -143,5 +148,5 @@
 void SimpleAnimation::addKeyFrame(Vector* point, Quaternion* direction, float time)
 {
-  if( !this->bDescriptive)
+  if( !this->bDescriptive || this->workingAnimator == NULL)
     {
       PRINTF(1)("SimpleAnimation: executing animation code outside a AnimationBegin()/AnimationEnd() - ignoring\n");
@@ -153,6 +158,6 @@
   frame->time = time;
   frame->mode = DEFAULT_ANIMATION_MODE;
-  frame->object = this->workingObject;
-  this->frames->add(frame);
+  frame->object = this->workingAnimator->object;
+  this->workingAnimator->frames->add(frame);
 }
 
@@ -167,5 +172,5 @@
 void SimpleAnimation::addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode)
 {
-  if( !this->bDescriptive)
+  if( !this->bDescriptive || this->workingAnimator == NULL)
     {
       PRINTF(1)("SimpleAnimation: executing animation code outside a AnimationBegin()/AnimationEnd() - ignoring\n");
@@ -177,6 +182,6 @@
   frame->time = time;
   frame->mode = mode;
-  frame->object = this->workingObject;
-  this->frames->add(frame);
+  frame->object = this->workingAnimator->object;
+  this->workingAnimator->frames->add(frame);
 }
 
@@ -187,11 +192,13 @@
 void SimpleAnimation::addKeyFrame(KeyFrame* frame)
 {
-  if( !this->bDescriptive)
+  printf("SimpleAnimation::addKeyFrame() - adding frame\n");
+  if( !this->bDescriptive || this->workingAnimator == NULL)
     {
       PRINTF(1)("SimpleAnimation: executing animation code outside a AnimationBegin()/AnimationEnd() - ignoring\n");
       return;
     }
-  frame->object = this->workingObject;
-  this->frames->add(frame);
+  frame->object = this->workingAnimator->object;
+  this->workingAnimator->frames->add(frame);
+  printf("SimpleAnimation::addKeyFrame() - addition completed\n");
 }
 
@@ -202,4 +209,5 @@
 void SimpleAnimation::reset()
 {
+  /*
   tIterator<KeyFrame>* iterator = this->frames->getIterator();
   KeyFrame* frame = iterator->nextElement(); 
@@ -218,4 +226,5 @@
   this->currentFrame = NULL;
   this->lastFrame = NULL;
+  */
 }
 
@@ -232,6 +241,17 @@
   
   this->localTime = 0;
-  this->lastFrame = this->frames->firstElement();
-  this->currentFrame = this->frames->nextElement(this->currentFrame);
+
+  /*
+  tIterator<Animation>* iterator = this->animators->getIterator();
+  Animation* anim = iterator->nextElement();
+  while( anim != NULL)
+    {
+      printf("SimpleAnimation::start() - initializing an animaion\n");
+      anim->currentFrame = anim->frames->firstElement();
+      anim->lastFrame = anim->frames->nextElement(anim->currentFrame);
+      anim = iterator->nextElement();
+    }
+  */
+
   this->bRunning = true;
 }
@@ -252,6 +272,6 @@
 {
   this->localTime = 0;
-  this->lastFrame = this->frames->firstElement();
-  this->currentFrame = this->frames->nextElement(this->currentFrame);
+  //this->lastFrame = this->frames->firstElement();
+  //this->currentFrame = this->frames->nextElement(this->currentFrame);
   this->bRunning = true;
 }
@@ -285,6 +305,5 @@
     {
       if( anim->bRunning)
-	{
-	  
+	{ 
 	  
 	  /* first get the current frame via time-stamps */ 
