Index: trunk/src/world_entities/weapons/weapon.cc
===================================================================
--- trunk/src/world_entities/weapons/weapon.cc	(revision 9869)
+++ trunk/src/world_entities/weapons/weapon.cc	(revision 10368)
@@ -33,5 +33,5 @@
 #include "resource_sound_buffer.h"
 
-#include "elements/glgui_energywidget.h"
+#include "elements/glgui_energywidgetvertical.h"
 
 ObjectListDefinition(Weapon);
@@ -119,8 +119,20 @@
   }
 
-  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
-  this->emissionPoint.setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
-  this->emissionPoint.setName("EmissionPoint");
-  this->emissionPoint.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource
+
+  this->barrels = 1;
+  this->segs = 1;
+
+  this->shootAnim = new Animation3D**[this->getBarrels()];
+  for (int i = 0; i < this->getBarrels(); i++)
+    this->shootAnim[i] = new Animation3D* [this->getSegs()];
+
+  this->emissionPoint = new PNode*[this->barrels];
+  for(int i = 0; i < this->barrels; i++){
+    this->emissionPoint[i] = new PNode;
+    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
+    this->emissionPoint[i]->setName("EmissionPoint");
+    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+  }
 
   this->defaultTarget = NULL;                      //< Nothing is Targeted by default.
@@ -145,4 +157,44 @@
 
 /**
+ * needed, if there are more than one barrel or segments
+ */
+void Weapon::init2() 
+{
+  if (this->barrels == 1 && this->segs == 1)
+    return;
+
+  delete this->emissionPoint[0];
+  delete this->emissionPoint;
+  delete this->shootAnim[0];
+  delete this->shootAnim;
+
+  this->shootAnim = new Animation3D**[this->barrels];
+  this->emissionPoint = new PNode*[this->barrels];
+  for(int i = 0; i < this->barrels; i++){
+    this->emissionPoint[i] = new PNode;
+    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
+    this->emissionPoint[i]->setName("EmissionPoint");
+    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+    this->shootAnim[i] = new Animation3D* [this->segs];
+  }
+}
+
+/**
+ * deconstructor for init2
+ */
+void Weapon::deconstr()
+{
+  for(int i = 0; i < this->barrels; i++) {
+    delete this->emissionPoint[i];
+    for (int j = 0; j < this->segs; j++)
+      delete this->shootAnim[i][j];
+    delete this->shootAnim[i];
+  }
+
+  delete this->emissionPoint;
+  delete this->shootAnim;
+}
+
+/**
  * loads the Parameters of a Weapon
  * @param root the XML-Element to load the Weapons settings from
@@ -154,7 +206,7 @@
   LoadParam(root, "projectile", this, Weapon, setProjectileTypeC)
   .describe("Sets the name of the Projectile to load onto the Entity");
-
+/*
   LoadParam(root, "emission-point", this, Weapon, setEmissionPoint)
-  .describe("Sets the Point of emission of this weapon");
+  .describe("Sets the Point of emission of this weapon (1: EmmsionVector; 2: EmissionPoint)");*/
 
   LoadParam(root, "state-duration", this, Weapon, setStateDuration)
@@ -253,9 +305,13 @@
  * @param point the Point relative to the mass-point of the Weapon
  */
+void Weapon::setEmissionPoint(const Vector& point, int barrel)
+{
+  this->emissionPoint[barrel]->setRelCoor(point);
+}
+
 void Weapon::setEmissionPoint(const Vector& point)
 {
-  this->emissionPoint.setRelCoor(point);
-}
-
+  this->emissionPoint[0]->setRelCoor(point);
+}
 
 /**
@@ -315,10 +371,29 @@
 }
 
+Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node)
+{
+  if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known
+    return NULL;
+
+  if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it.
+  {
+    if (likely(node != NULL))
+      return this->shootAnim[barrel][seg] = new Animation3D(node);
+    else
+    {
+//       PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state));
+      return NULL;
+    }
+  }
+  else
+    return this->shootAnim[barrel][seg];
+}
+
 OrxGui::GLGuiWidget* Weapon::getEnergyWidget()
 {
-  if (this->energyWidget == NULL)
-  {
-    this->energyWidget = new OrxGui::GLGuiEnergyWidget();
-    this->energyWidget->setDisplayedName(this->getClassCName());
+  if ( this->energyWidget == NULL)
+  {
+    this->energyWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    //this->energyWidget->setDisplayedName(this->getClassCName());
     this->energyWidget->setSize2D( 20, 100);
     this->energyWidget->setMaximum(this->getEnergyMax());
@@ -352,4 +427,5 @@
   if (likely(this->isActive()))
   {
+    /** Disabled for releaseFire() from WM*/
     if (this->requestedAction != WA_NONE)
       return;
@@ -378,4 +454,5 @@
   {
     this->energy += energyToAdd;
+    this->updateWidgets();
     return 0.0;
   }
@@ -383,6 +460,8 @@
   {
     this->energy += maxAddEnergy;
+    this->updateWidgets();
     return energyToAdd - maxAddEnergy;
   }
+  
 }
 
@@ -431,5 +510,5 @@
     break;
     default:
-    PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
+    PRINTF(5)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     return false;
   }
@@ -507,4 +586,5 @@
 bool Weapon::fireW()
 {
+//   printf("fireW Weapon\n");
   //if (likely(this->currentState != WS_INACTIVE))
   if (this->minCharge <= this->energy)
@@ -513,5 +593,4 @@
     if (this->soundBuffers[WA_SHOOT].loaded())
       this->soundSource->play(this->soundBuffers[WA_SHOOT]);
-    this->updateWidgets();
     // fire
     this->energy -= this->minCharge;
@@ -519,4 +598,5 @@
     // setting up for the next state
     this->enterState(WS_SHOOTING);
+    this->updateWidgets();
   }
   else  // reload if we still have the charge
@@ -538,5 +618,5 @@
       unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
   {
-    this->requestAction(WA_DEACTIVATE);
+    //this->requestAction(WA_DEACTIVATE);
     this->execute();
     return false;
