Index: orxonox/trunk/src/world_entities/weapons/test_gun.cc
===================================================================
--- orxonox/trunk/src/world_entities/weapons/test_gun.cc	(revision 4892)
+++ orxonox/trunk/src/world_entities/weapons/test_gun.cc	(revision 4893)
@@ -53,26 +53,26 @@
 
   this->objectComponent1 = new PNode();
-  this->animation1 = new Animation3D(this->objectComponent1);
-  this->animation2 = new Animation3D(this);
-  this->animation3 = new Animation3D(this);
+  Animation3D* animation1 = this->createAnimation(WS_SHOOTING, this->objectComponent1);
+  Animation3D* animation2 = this->createAnimation(WS_ACTIVATING, this);
+  Animation3D* animation3 = this->createAnimation(WS_DEACTIVATING, this);
   //parent->addChild(this->objectComponent1, PNODE_ALL);
   this->addChild(this->objectComponent1, PNODE_ALL);
 
-  this->animation1->setInfinity(ANIM_INF_CONSTANT);
-  this->animation2->setInfinity(ANIM_INF_CONSTANT);
-  this->animation3->setInfinity(ANIM_INF_CONSTANT);
+  animation1->setInfinity(ANIM_INF_CONSTANT);
+  animation2->setInfinity(ANIM_INF_CONSTANT);
+  animation3->setInfinity(ANIM_INF_CONSTANT);
   if( this->leftRight == W_LEFT)
     {
       this->projectileOffset = Vector(1.0, 0.0, -0.35);
 
-      this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
-
-      this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-
-      this->animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
+
+      animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+
+      animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     }
   else if( this->leftRight == W_RIGHT)
@@ -81,13 +81,13 @@
 
       this->objectComponent1->setRelCoor(Vector(0,0,0.35));
-      this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
-
-      this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-
-      this->animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
-      this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
+
+      animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+
+      animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
+      animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     }
 /*
@@ -128,5 +128,4 @@
 void TestGun::activate()
 {
-  this->animation2->replay();
 }
 
@@ -141,5 +140,4 @@
 void TestGun::deactivate()
 {
-  this->animation3->replay();
 }
 
@@ -153,5 +151,4 @@
 void TestGun::fire()
 {
-  this->energyLoaded -= this->minCharge;
   Projectile* pj =  new TestBullet(this);//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
 //  weaponSource->play();
@@ -161,6 +158,4 @@
   pj->setVelocity(this->getVelocity());
   State::getWorldEntityList()->add(pj);
-
-  this->animation1->replay();
 }
 
Index: orxonox/trunk/src/world_entities/weapons/test_gun.h
===================================================================
--- orxonox/trunk/src/world_entities/weapons/test_gun.h	(revision 4892)
+++ orxonox/trunk/src/world_entities/weapons/test_gun.h	(revision 4893)
@@ -49,8 +49,4 @@
 
   private:
-    Animation3D* animation1;
-    Animation3D* animation2;
-    Animation3D* animation3;
-
     PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
     PNode* objectComponent2;
Index: orxonox/trunk/src/world_entities/weapons/weapon.cc
===================================================================
--- orxonox/trunk/src/world_entities/weapons/weapon.cc	(revision 4892)
+++ orxonox/trunk/src/world_entities/weapons/weapon.cc	(revision 4893)
@@ -126,4 +126,29 @@
 }
 
+
+/**
+ * creates an Animation3D for a certain State.
+ * @param state what state should the Animation be created for
+ * @param node the node this Animation should apply to.
+ * @returns The created animation.Animation(), NULL on error.
+ *
+ * This function does only generate the Animation Object, and if set it will
+ * automatically be executed, when a certain State is reached.
+ * What this does not do, is set keyframes, you have to operate on the returned animation.
+ */
+Animation3D* Weapon::createAnimation(WeaponState state, PNode* node)
+{
+  if (state >= WS_STATE_COUNT || node == NULL)
+    return NULL;
+
+  if (unlikely(this->animation[state] != NULL))
+  {
+    delete this->animation[state];
+    this->animation[state] = NULL;
+  }
+  return this->animation[state] = new Animation3D(node);
+}
+
+
 /////////////////
 //  EXECUTION  //
@@ -219,6 +244,8 @@
   {
         // play Sound
-    if (this->soundBuffers[WA_ACTIVATE] != NULL)
+    if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
       this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
+    if (likely(this->animation[WS_ACTIVATING] != NULL))
+      this->animation[WS_ACTIVATING]->replay();
         // activate
     PRINTF(5)("Activating the Weapon %s\n", this->getName());
@@ -243,4 +270,6 @@
     if (this->soundBuffers[WA_DEACTIVATE] != NULL)
       this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
+    if (likely(this->animation[WS_DEACTIVATING] != NULL))
+      this->animation[WS_DEACTIVATING]->replay();
         // deactivate
     this->deactivate();
@@ -263,4 +292,7 @@
     if (this->soundBuffers[WA_CHARGE] != NULL)
       this->soundSource->play(this->soundBuffers[WA_CHARGE]);
+    if (likely(this->animation[WS_CHARGING] != NULL))
+      this->animation[WS_CHARGING]->replay();
+
         // charge
     this->charge();
@@ -289,4 +321,6 @@
     if (this->soundBuffers[WA_SHOOT] != NULL)
       this->soundSource->play(this->soundBuffers[WA_SHOOT]);
+    if (likely(this->animation[WS_SHOOTING] != NULL))
+      this->animation[WS_SHOOTING]->replay();
           // fire
     this->fire();
@@ -321,4 +355,6 @@
   if (this->soundBuffers[WA_RELOAD] != NULL)
     this->soundSource->play(this->soundBuffers[WA_RELOAD]);
+  if (likely(this->animation[WS_RELOADING] != NULL))
+    this->animation[WS_RELOADING]->replay();
 
   if (chargeSize > this->energy)
Index: orxonox/trunk/src/world_entities/weapons/weapon.h
===================================================================
--- orxonox/trunk/src/world_entities/weapons/weapon.h	(revision 4892)
+++ orxonox/trunk/src/world_entities/weapons/weapon.h	(revision 4893)
@@ -112,5 +112,5 @@
     void setActionSound(const char* action, const char* soundFile) { this->setActionSound(charToAction(action), soundFile); };
 
-
+    Animation3D* createAnimation(WeaponState state, PNode* node);
 
     // FLOW
