Index: code/branches/hud2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/hud2/src/orxonox/CMakeLists.txt	(revision 1098)
+++ code/branches/hud2/src/orxonox/CMakeLists.txt	(revision 1099)
@@ -5,5 +5,5 @@
 #  SpaceshipSteering.cc
   hud/HUD.cc
-  hud/Bar.cc
+  hud/BarOverlayElement.cc
   particle/ParticleInterface.cc
   tools/BillboardSet.cc
Index: code/branches/hud2/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/hud2/src/orxonox/Orxonox.cc	(revision 1098)
+++ code/branches/hud2/src/orxonox/Orxonox.cc	(revision 1099)
@@ -311,4 +311,6 @@
     //orxonoxHUD_->setEnergyDistr(20,20,60);
     //hudOverlay->show();
+    
+    
 
 	/*
Index: code/branches/hud2/src/orxonox/hud/Bar.cc
===================================================================
--- code/branches/hud2/src/orxonox/hud/Bar.cc	(revision 1098)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
-*   ORXONOX - the hottest 3D action shooter ever to exist
-*
-*
-*   License notice:
-*
-*   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
-*   of the License, or (at your option) any later version.
-*
-*   This program is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with this program; if not, write to the Free Software
-*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*
-*   Author:
-*      Yuning Chai
-*   Co-authors:
-*      ...
-*
-*/
-
-#include <OgreOverlayManager.h>
-#include <OgreOverlayElement.h>
-#include <OgreOverlayContainer.h>
-#include <OgrePanelOverlayElement.h>
-#include <OgreStringConverter.h>
-#include <OgreColourValue.h>
-#include <string.h>
-
-#include "Bar.h"
-
-namespace orxonox
-{
-  using namespace Ogre;
-
-//    typeName_s = "Bar";
-
-    Bar::Bar(const String& name):Ogre::PanelOverlayElement(name){
-    }
-
-
-    Bar::~Bar(){}
-
-//    const Ogre::String& Bar::getTypeName() const { return typeName_s;}
-
-
-
-    void Bar::initialise(){
-	PanelOverlayElement::initialise();
-	setDimensions(100,100);
-	setPosition(10,10);
-	setMaterialName("Orxonox/Green");
-	setMetricsMode(Ogre::GMM_PIXELS);
-    }
-
-
-
-
-/*  Bar::Bar(const Ogre::String& s){}
-  
-  Bar::~Bar(void){}
-  
-  */
-/*  void Bar::setPercentage(float percentage){
-    percentage_=percentage;
-    if(dir_){setWidth(int(percentage_* getWidth()));}
-	else {setHeight(int(percentage_ * getHeight()));}
-    }
-
-
-  void Bar::setPercentage(float percentage){
-    percentage_ = percentage;
-//    setWidth(getWidth());
-  }
-
-
-
-  
-  void Bar::setColor(ColourValue color){
-    color_=color;
-    setColour(color);
-  }
-*/	  
-	
-}
-
-
Index: code/branches/hud2/src/orxonox/hud/Bar.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/Bar.h	(revision 1098)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
-*   ORXONOX - the hottest 3D action shooter ever to exist
-*
-*
-*   License notice:
-*
-*   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
-*   of the License, or (at your option) any later version.
-*
-*   This program is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with this program; if not, write to the Free Software
-*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*
-*   Author:
-*      Yuning Chai
-*   Co-authors:
-*      ...
-*
-*/
-
-
-#ifndef _BAR_H__
-#define _BAR_H__
-
-#include <string>
-#include <OgreColourValue.h>
-#include <OgrePanelOverlayElement.h>
-#include <OgreOverlayManager.h>
-#include <OgreOverlayElement.h>
-#include <OgreOverlayContainer.h>
-#include <OgrePrerequisites.h>
-#include <string.h>
-#include "../OrxonoxPrereqs.h"
-
-
-
-namespace orxonox
-{
-  class _OrxonoxExport Bar : public Ogre::PanelOverlayElement
-  {
-  private:
-    float percentage_;
-    bool dir_;
-    Ogre::ColourValue color_;
-	
-    static Ogre::String& typeName_s;
-	
-  public:
-
-    Bar(const Ogre::String& name);
-
-    virtual void initialise();
-
-    virtual ~Bar();
-    
-//    virtual const Ogre::String& getTypeName() const;
-//    virtual ~Bar();
-
-
-
-
-/*    Bar(const Ogre::String& s);
-    ~Bar(void);
-    void setPercentage(float percentage);
-    void setColor(Ogre::ColourValue color);
-*/  };
-}
-
-#endif
-
-
Index: code/branches/hud2/src/orxonox/hud/BarOverlayElement.cc
===================================================================
--- code/branches/hud2/src/orxonox/hud/BarOverlayElement.cc	(revision 1099)
+++ code/branches/hud2/src/orxonox/hud/BarOverlayElement.cc	(revision 1099)
@@ -0,0 +1,130 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   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
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
+#include <OgreOverlayManager.h>
+#include <OgreOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+
+#include "BarOverlayElement.h"
+
+namespace orxonox
+{
+  using namespace Ogre;
+
+
+    BarOverlayElement::BarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){}
+
+    BarOverlayElement::~BarOverlayElement(){}
+
+    void BarOverlayElement::initialise(){
+	PanelOverlayElement::initialise();
+/*	setDimensions(100,100);
+	setPosition(10,10);
+	setMaterialName("Orxonox/Green");
+	setMetricsMode(Ogre::GMM_PIXELS);
+*/  }
+
+
+    void BarOverlayElement::initBarOverlayElement(Real left, Real top, Real width, Real height,
+       int dir,  int colour){
+	 setMetricsMode(Ogre::GMM_PIXELS);
+	 dir_ = dir;
+	 left_ = left;
+	 top_ = top;
+	 width_ = width;
+	 height_ = height;
+	 setPosition(left_,top_);
+	 setDimensions(width_,height_);
+	 setColour(colour);
+    }
+
+
+   void BarOverlayElement::reset(int percentage){
+      switch(dir_){
+        case 1:
+	  setPosition(left_,top_);
+	  setDimensions(width_,height_*percentage/100);
+	  break;
+	case 2:
+	  setPosition(left_+width_-width_*percentage/100,top_);
+	  setDimensions(width_*percentage/100,height_);
+	  break;
+	case 3:
+	  setPosition(left_,top_+height_-height_*percentage/100);
+	  setDimensions(width_,height_*percentage/100);
+	  break;
+	default:
+	  setPosition(left_,top_);
+	  setDimensions(width_*percentage/100,height_);	
+      }
+    }
+       
+       
+    void BarOverlayElement::setColour(int colour){
+      switch(colour){
+	case 0:
+	  setMaterialName("Orxonox/Red");
+	  break;
+	case 1:
+	  setMaterialName("Orxonox/Yellow");
+	  break;
+	case 2:
+	  setMaterialName("Orxonox/Green");
+      }
+    }
+
+
+    SmartBarOverlayElement::SmartBarOverlayElement(const String& name):BarOverlayElement(name){}
+
+    SmartBarOverlayElement::~SmartBarOverlayElement(void){}
+    
+    
+    void SmartBarOverlayElement::initialise(){
+      PanelOverlayElement::initialise();
+/*	setDimensions(100,100);
+      setPosition(10,10);
+      setMaterialName("Orxonox/Green");
+      setMetricsMode(Ogre::GMM_PIXELS);
+*/  }
+    
+    void SmartBarOverlayElement::initSmartBarOverlayElement(Real left, Real top, Real width, Real height, int dir)
+    {
+      BarOverlayElement::initBarOverlayElement(left, top, width, height, dir, BarOverlayElement::GREEN);
+    }
+
+
+    void SmartBarOverlayElement::reset(int percentage){
+      if (percentage>50) {setColour(BarOverlayElement::GREEN);}
+      else if (percentage>25) {setColour(BarOverlayElement::YELLOW);}
+      else setColour(BarOverlayElement::RED);
+      BarOverlayElement::reset(percentage);
+    }
+
+}
+
+
Index: code/branches/hud2/src/orxonox/hud/BarOverlayElement.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/BarOverlayElement.h	(revision 1099)
+++ code/branches/hud2/src/orxonox/hud/BarOverlayElement.h	(revision 1099)
@@ -0,0 +1,98 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   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
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
+
+#ifndef _BAR_H__
+#define _BAR_H__
+
+#include <OgreOverlayManager.h>
+#include <OgreOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include <OgrePrerequisites.h>
+#include "../OrxonoxPrereqs.h"
+
+
+
+namespace orxonox
+{
+  class _OrxonoxExport BarOverlayElement : public Ogre::PanelOverlayElement
+  {
+  private:
+    int percentage_;
+    int dir_;	
+    int left_;
+    int top_;
+    int width_;
+    int height_;
+	
+    static Ogre::String& typeName_s;
+	
+  public:
+
+    static const int LEFT = 0;
+    static const int UP = 1;
+    static const int RIGHT = 2;
+    static const int DOWN = 3;
+
+    static const int RED = 0;
+    static const int YELLOW = 1;
+    static const int GREEN = 2;
+
+    BarOverlayElement(const Ogre::String& name);
+    virtual ~BarOverlayElement();
+    virtual void initialise();
+
+    void initBarOverlayElement(Real left, Real top, Real width, Real height,
+          int dir,  int colour);
+
+    void reset(int percentage);
+    void setColour(int colour);
+
+  };
+  
+  
+  class _OrxonoxExport SmartBarOverlayElement : public BarOverlayElement
+  {
+    private:
+
+    public:
+      
+      SmartBarOverlayElement(const Ogre::String& name);
+      virtual ~SmartBarOverlayElement(void);
+      virtual void initialise();
+      
+      void initSmartBarOverlayElement(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, int dir);
+      void reset(int percentage);
+  };
+
+  
+}
+
+#endif
+
+
Index: code/branches/hud2/src/orxonox/hud/Factories.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/Factories.h	(revision 1098)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
-*   ORXONOX - the hottest 3D action shooter ever to exist
-*
-*
-*   License notice:
-*
-*   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
-*   of the License, or (at your option) any later version.
-*
-*   This program is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with this program; if not, write to the Free Software
-*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*
-*   Author:
-*      Yuning Chai
-*   Co-authors:
-*      ...
-*
-*/
-
-#ifndef _FACTORIES_H__
-#define _FACTORIES_H__
-
-
-#include <OgreOverlayElement.h>
-#include <OgrePrerequisites.h>
-#include <OgreOverlayElementFactory.h>
-
-#include "Bar.h"
-
-
-namespace orxonox{
-
-  class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{
-  public:
-    Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
-      return new Bar(instanceName);
-    }
-    const Ogre::String& getTypeName(void) const{
-      static Ogre::String name = "Bar";
-      return name;
-    }
-  };
-}
-
-
-
-
-#endif
Index: code/branches/hud2/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud2/src/orxonox/hud/HUD.cc	(revision 1098)
+++ code/branches/hud2/src/orxonox/hud/HUD.cc	(revision 1099)
@@ -30,11 +30,11 @@
 #include <OgreOverlay.h>
 #include <OgreOverlayContainer.h>
-#include <OgreOverlayManager.h>
+#include <OgreOverlayManager.h>ma
 #include <OgreSceneNode.h>
 #include <OgreEntity.h>
 
 #include "HUD.h"
-#include "Bar.h"
-#include "Factories.h"
+#include "BarOverlayElement.h"
+#include "OverlayElementFactories.h"
 // ugly hack
 #include "Orxonox.h"
@@ -45,15 +45,38 @@
   using namespace Ogre;
 
-
-
-
-
   HUD::HUD(int zoom){
 
     Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
-
-//    energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter");
+    
+    BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
+    overlayManager.addOverlayElementFactory(barOverlayElementFactory);
+    
+    SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory();
+    overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory);
+    
+    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 
 
     Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
+    
+    energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter"));
+    energyCounter->show();
+    
+    energyCounterPanel->addChild(energyCounter);
+    energyCounterPanel->show();
+
+    orxonoxOverlay->add2D(energyCounterPanel);
+    orxonoxOverlay->show();
+
+    // important: don't use SceneManager to create the node! but register the creator scene manager.
+/*    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
+    
+    ogreNode_->setPosition(80,-60,-200);
+    ogreNode_->setScale(0.4,0.4,0.4);
+    // ugly hack, but I haven't figured out yet how we could change this, since we really need the
+    // scene manager..
+    ogreNode_->attachObject(Orxonox::getSingleton()->getSceneManager()->createEntity("head", "ogrehead.mesh"));
+//    orxonoxOverlay->add3D(ogreNode_);
+*/
+   
     energyCounterPanel->setLeft(-50);
     energyCounterPanel->setTop(10);
@@ -62,30 +85,12 @@
     energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER);
     energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);	
-    energyCounterPanel->show();
-//    energyCounterPanel->addChild(energyCounter->element);
+        
+    energyCounter->initSmartBarOverlayElement(-100,0,200,20,BarOverlayElement::LEFT);
+    energyCounter->reset(80);
 
-    BarOverlayElementFactory *factory = new BarOverlayElementFactory();
-    overlayManager.addOverlayElementFactory(factory);
-    Ogre::OverlayElement* BarElement = overlayManager.createOverlayElementFromFactory("Bar", "BarElement");
-
-    energyCounterPanel->addChild(BarElement);
-
-    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 
-    orxonoxOverlay->add2D(energyCounterPanel);
-
-    // important: don't use SceneManager to create the node! but register the creator scene manager.
-    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
     
-    ogreNode_->setPosition(80,-60,-200);
-    ogreNode_->setScale(0.4,0.4,0.4);
-    // ugly hack, but I haven't figured out yet how we could change this, since we really need the
-    // scene manager..
-    ogreNode_->attachObject(Orxonox::getSingleton()->getSceneManager()->createEntity("head", "ogrehead.mesh"));
-    orxonoxOverlay->add3D(ogreNode_);
-
-    orxonoxOverlay->show();
   }
 
-  void HUD::tick(float dt)
+/*  void HUD::tick(float dt)
   {
     if (this->ogreNode_)
@@ -96,5 +101,5 @@
     }
   }
-
+*/
   HUD::~HUD(void){}
 
@@ -108,195 +113,2 @@
 
 
-/*#include "OrxonoxStableHeaders.h"
-
-#include <OgreOverlayManager.h>
-#include <OgreOverlayElement.h>
-#include <OgreStringConverter.h>
-
-#include "HUD.h"
-#include "Bar.h"
-
-namespace orxonox
-{
-  using namespace Ogre;
-
-  HUD::HUD(void)
-  {
-    init();
-
-    setTime(99,55);
-
-    setTargetWindowName("HURRA");
-    setTargetWindowDistance(12);
-    setTargetWindowStatus("Dead");
-    setTargetWindowDistance(30);
-
-    setEnergyValue(60);
-
-    setShieldLeftTopValue(true);
-    setShieldRightTopValue(false);
-    setShieldLeftBottomValue(false);
-    setShieldRightBottomValue(true);
-
-    setRocket1(11);
-    setRocket2(22);
-    setRocket3(33);
-    setRocket4(44);
-
-    setEnergyDistr(33,33,34);
-
-    setPrimar(3);
-
-    energyDistrPixelX_ = 100;
-    energyDistrPixelY_ = 86;
-
-
-  }
-
-
-  HUD::~HUD( void ){
-
-  }
-
-  void HUD::setTime(int i, int j){
-    timeMin_=i;
-    timeSec_=j;
-    timeText_->setCaption(StringConverter::toString(timeMin_) + ":" + StringConverter::toString(timeSec_));
-  }
-
-  void HUD::setTargetWindowName(std::string i){
-    targetWindowName_=i;
-    targetWindowNameText_->setCaption( targetWindowName_ );
-  }
-
-  void HUD::setTargetWindowStatus(std::string i){
-    targetWindowStatus_=i;
-    targetWindowStatusText_->setCaption( targetWindowStatus_ );
-  }
-
-  void HUD::setTargetWindowDistance(int i){
-    targetWindowDistance_=i;
-    targetWindowDistanceText_->setCaption(StringConverter::toString(targetWindowDistance_) + "km" );
-  }
-
-  void HUD::setTargetWindowHitRating(int i){
-    targetWindowHitRating_=i;
-    targetWindowHitRatingText_->setCaption(StringConverter::toString(targetWindowHitRating_) + "%" );
-  }
-
-  void HUD::setEnergyValue(int i){
-    energyValue_=i;
-    energyLength_->setWidth((int)((float)energyValue_/(float)100*200));
-  }
-
-  void HUD::setShieldLeftTopValue(bool i){
-    shieldLeftTopValue_=i;
-    if (shieldLeftTopValue_) shieldLeftTop_->show();
-    else shieldLeftTop_->hide();
-  }
-
-  void HUD::setShieldRightTopValue(bool i){
-    shieldRightTopValue_=i;
-    if (shieldRightTopValue_) shieldRightTop_->show();
-    else shieldRightTop_->hide();
-  }
-
-  void HUD::setShieldLeftBottomValue(bool i){
-    shieldLeftBottomValue_=i;
-    if (shieldLeftBottomValue_) shieldLeftBottom_->show();
-    else shieldLeftBottom_->hide();
-  }
-
-  void HUD::setShieldRightBottomValue(bool i){
-    shieldRightBottomValue_=i;
-    if (shieldRightBottomValue_) shieldRightBottom_->show();
-    else shieldRightBottom_->hide();
-  }
-
-  void HUD::setRocket1(int i){
-    rocket1_=i;
-    rocketNum1_->setCaption(StringConverter::toString(rocket1_));
-  }
-
-  void HUD::setRocket2(int i){
-    rocket2_=i;
-    rocketNum2_->setCaption(StringConverter::toString(rocket2_));
-  }
-
-  void HUD::setRocket3(int i){
-    rocket3_=i;
-    rocketNum3_->setCaption(StringConverter::toString(rocket3_));
-  }
-
-  void HUD::setRocket4(int i){
-    rocket4_=i;
-    rocketNum4_->setCaption(StringConverter::toString(rocket4_));
-  }
-
-  void HUD::setEnergyDistr(float s, float e, float l){
-    energyDistrShield_=s;
-    energyDistrEngine_=e;
-    energyDistrLaser_=l;
-
-    float energyDistrShieldInv_ = 100 - energyDistrShield_;
-    float energyDistrEngineInv_ = 100 - energyDistrEngine_;
-    float energyDistrLaserInv_ = 100 - energyDistrLaser_;
-
-    float energyDistrT_ = -energyDistrPixelX_/((energyDistrPixelX_-energyDistrPixelX_/2*energyDistrShieldInv_/(energyDistrShieldInv_+energyDistrEngineInv_))*energyDistrLaserInv_*(energyDistrShieldInv_+energyDistrEngineInv_)/energyDistrShieldInv_/(energyDistrLaserInv_+energyDistrEngineInv_)+energyDistrPixelX_/2+energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_));
-    float energyDistrX_ = (-energyDistrPixelX_/2-energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_))*energyDistrT_;
-    float energyDistrY_ = energyDistrPixelY_+energyDistrPixelY_*energyDistrLaserInv_/(energyDistrLaserInv_+energyDistrEngineInv_)*energyDistrT_;
-
-    energyDistrPoint_->setLeft((int)energyDistrX_-3);
-    energyDistrPoint_->setTop((int)energyDistrY_-3);
-
-  }
-
-  void HUD::setPrimar(int i){
-    primarValue_=i;
-    if(i==1){
-      primarChoice_->setLeft(2);
-      primarChoice_->setWidth(48);
-    }
-    if(i==2){
-      primarChoice_->setLeft(51);
-      primarChoice_->setWidth(49);
-    }
-    else{
-      primarChoice_->setLeft(101);
-      primarChoice_->setWidth(48);
-    }
-  }
-
-
-
-  void HUD::init(void)
-  {
-    timeText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text");
-
-    targetWindowNameText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name");
-    targetWindowDistanceText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText");
-    targetWindowStatusText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText");
-    targetWindowHitRatingText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText");
-
-    energyLength_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground");
-
-    shieldLeftTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftTop");
-    shieldRightTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightTop");
-    shieldLeftBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftBottom");
-    shieldRightBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightBottom");
-
-    rocketNum1_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1");
-    rocketNum2_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2");
-    rocketNum3_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3");
-    rocketNum4_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4");
-
-    // FIXME: unused vars!
-    float energyDistrPixelX_ = 100;
-    float energyDistrPixelY_ = 86;
-    energyDistrPoint_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint");
-
-    primarChoice_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/PrimarChoice");
-  }
-
-}
-*/
Index: code/branches/hud2/src/orxonox/hud/HUD.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/HUD.h	(revision 1098)
+++ code/branches/hud2/src/orxonox/hud/HUD.h	(revision 1099)
@@ -38,10 +38,10 @@
 
 #include "core/Tickable.h"
-#include "Bar.h"
+#include "BarOverlayElement.h"
 
 
 namespace orxonox
 {
-  class _OrxonoxExport HUD : Tickable
+  class _OrxonoxExport HUD// : Tickable
   {
   private:
@@ -51,106 +51,11 @@
     ~HUD();
 
-    virtual void tick(float);
+//    virtual void tick(float);
 
-    Bar* energyCounter;
-    Ogre::SceneNode* ogreNode_;
+    SmartBarOverlayElement* energyCounter;
+//    Ogre::SceneNode* ogreNode_;
   };
 }	
 
 
-
-
-
-
-
-
-
 #endif
-
-/*#ifndef _HUD_H__
-#define _HUD_H__
-
-#include <string>
-
-#include <OgrePrerequisites.h>
-
-#include "../OrxonoxPrereqs.h"
-
-
-namespace orxonox
-{
-  class _OrxonoxExport HUD
-  {
-  private:
-    Ogre::OverlayElement* timeText_;
-    Ogre::OverlayElement* targetWindowNameText_;
-    Ogre::OverlayElement* targetWindowStatusText_;
-    Ogre::OverlayElement* targetWindowDistanceText_;
-    Ogre::OverlayElement* targetWindowHitRatingText_;
-    Ogre::OverlayElement* energyLength_;
-    Ogre::OverlayElement* shieldLeftTop_;
-    Ogre::OverlayElement* shieldRightTop_;
-    Ogre::OverlayElement* shieldLeftBottom_;
-    Ogre::OverlayElement* shieldRightBottom_;
-    Ogre::OverlayElement* rocketNum1_;
-    Ogre::OverlayElement* rocketNum2_;
-    Ogre::OverlayElement* rocketNum3_;
-    Ogre::OverlayElement* rocketNum4_;
-    Ogre::OverlayElement* energyDistrPoint_;
-    Ogre::OverlayElement* primarChoice_;
-
-    int timeMin_;
-    int timeSec_;
-
-    std::string targetWindowName_;
-    std::string targetWindowStatus_;
-    int targetWindowDistance_;
-    int targetWindowHitRating_;
-
-    int energyValue_;
-
-    bool shieldLeftTopValue_;
-    bool shieldRightTopValue_;
-    bool shieldLeftBottomValue_;
-    bool shieldRightBottomValue_;
-
-    int rocket1_;
-    int rocket2_;
-    int rocket3_;
-    int rocket4_;
-
-    float energyDistrShield_;
-    float energyDistrEngine_;
-    float energyDistrLaser_;
-
-    float energyDistrPixelX_;
-    float energyDistrPixelY_;
-
-    int primarValue_;
-
-  public:
-    HUD( void );
-    ~HUD( void );
-    void init( void );
-
-    void setTime(int i, int j);
-    void setTargetWindowName(std::string i);
-    void setTargetWindowStatus(std::string i);
-    void setTargetWindowDistance(int i);
-    void setTargetWindowHitRating(int i);
-    void setEnergyValue(int i);
-    void setShieldLeftTopValue(bool i);
-    void setShieldRightTopValue(bool i);
-    void setShieldLeftBottomValue(bool i);
-    void setShieldRightBottomValue(bool i);
-    void setRocket1(int i);
-    void setRocket2(int i);
-    void setRocket3(int i);
-    void setRocket4(int i);
-    void setEnergyDistr(float s, float e, float l);
-    void setPrimar(int i);
-
-  };
-}
-
-#endif /* _HUD_H__ */
Index: code/branches/hud2/src/orxonox/hud/OverlayElementFactories.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/OverlayElementFactories.h	(revision 1099)
+++ code/branches/hud2/src/orxonox/hud/OverlayElementFactories.h	(revision 1099)
@@ -0,0 +1,69 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   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
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
+#ifndef _FACTORIES_H__
+#define _FACTORIES_H__
+
+
+#include <OgreOverlayElement.h>
+#include <OgrePrerequisites.h>
+#include <OgreOverlayElementFactory.h>
+
+#include "BarOverlayElement.h"
+
+
+namespace orxonox{
+
+  class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{
+  public:
+    Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
+      return new BarOverlayElement(instanceName);
+    }
+    const Ogre::String& getTypeName(void) const{
+      static Ogre::String name = "Bar";
+      return name;
+    }
+  };
+
+
+  class _OrxonoxExport SmartBarOverlayElementFactory : public Ogre::OverlayElementFactory{
+    public:
+      Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
+	return new SmartBarOverlayElement(instanceName);
+      }
+      const Ogre::String& getTypeName(void) const{
+	static Ogre::String name = "SmartBar";
+	return name;
+      }
+  };
+
+}
+
+
+
+
+#endif
Index: code/branches/hud2/src/orxonox/hud/Radar.cpp
===================================================================
--- code/branches/hud2/src/orxonox/hud/Radar.cpp	(revision 1098)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
-*   ORXONOX - the hottest 3D action shooter ever to exist
-*
-*
-*   License notice:
-*
-*   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
-*   of the License, or (at your option) any later version.
-*
-*   This program is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with this program; if not, write to the Free Software
-*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*
-*   Author:
-*      Yuning Chai
-*   Co-authors:
-*      ...
-*
-*/
-
-#include <OgreOverlayManager.h>
-#include <OgreOverlayElement.h>
-#include <OgreTextAreaOverlayElement.h>
-#include <OgreStringConverter.h>
-#include <string.h>
-
-#include "Radar.h"
-
-
-namespace orxonox
-{
-  using namespace Ogre;
-
-  RadarObject::RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z){
-    name_ = name;
-    x = x_;
-    y = y_;
-    z = z_;
-  }
-
-  RadarObject::~RadarObject(void){}
-    
-  void RadarObject::reset(Ogre::Real x, Ogre::Real y, Ogre::Real z){
-    x = x_;
-    y = y_;
-    z = z_;
-  }
-
-
-  Radar::Radar(){
-    number = 0;
-    
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
-
-
Index: code/branches/hud2/src/orxonox/hud/Radar.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/Radar.h	(revision 1098)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*
-*   ORXONOX - the hottest 3D action shooter ever to exist
-*
-*
-*   License notice:
-*
-*   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
-*   of the License, or (at your option) any later version.
-*
-*   This program is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with this program; if not, write to the Free Software
-*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*
-*   Author:
-*      Yuning Chai
-*   Co-authors:
-*      ...
-*
-*/
-
-
-#ifndef _RADAR_H__
-#define _RADAR_H__
-
-#include <string.h>
-#include <OgreOverlayElement.h>
-#include <OgreTextAreaOverlayElement.h>
-#include <OgrePrerequisites.h>
-#include "../OrxonoxPrereqs.h"
-
-namespace orxonox
-{
-
-  class _OrxonoxExport RadarObject
-  {
-  private:
-    int name_;
-    Ogre::Real x_;
-    Ogre::Real y_;
-    Ogre::Real z_;
-  public:
-    RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z);
-    ~RadarObject();
-    void reset(Ogre::Real x, Ogre::Real y, Ogre::Real z);
-    inline Ogre::Real getX(){return x_;}
-    inline Ogre::Real getY(){return y_;}
-    inline Ogre::Real getZ(){return z_;}
-    inline int getName(){return name_;}
-  };
-
-
-  class _OrxonoxExport Radar
-  {
-  private:
-    int number;
-
-
-  public:
-    Radar();
-    ~Radar();
-
-
-
-
-
-  };
-}	
-
-#endif
Index: code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc
===================================================================
--- code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc	(revision 1099)
+++ code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc	(revision 1099)
@@ -0,0 +1,77 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   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
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
+#include <OgreOverlayManager.h>
+#include <OgreOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgreStringConverter.h>
+#include <string.h>
+
+#include "Radar.h"
+
+
+namespace orxonox
+{
+  using namespace Ogre;
+
+  RadarObject::RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z){
+    name_ = name;
+    x = x_;
+    y = y_;
+    z = z_;
+  }
+
+  RadarObject::~RadarObject(void){}
+    
+  void RadarObject::reset(Ogre::Real x, Ogre::Real y, Ogre::Real z){
+    x = x_;
+    y = y_;
+    z = z_;
+  }
+
+
+  Radar::Radar(){
+    number = 0;
+    
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+
Index: code/branches/hud2/src/orxonox/hud/RadarOverlayElement.h
===================================================================
--- code/branches/hud2/src/orxonox/hud/RadarOverlayElement.h	(revision 1099)
+++ code/branches/hud2/src/orxonox/hud/RadarOverlayElement.h	(revision 1099)
@@ -0,0 +1,76 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   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
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
+
+#ifndef _RADAR_H__
+#define _RADAR_H__
+
+#include <string.h>
+#include <OgreOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePrerequisites.h>
+#include "../OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+
+  class _OrxonoxExport RadarObject
+  {
+  private:
+    int name_;
+    Ogre::Real x_;
+    Ogre::Real y_;
+    Ogre::Real z_;
+  public:
+    RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z);
+    ~RadarObject();
+    void reset(Ogre::Real x, Ogre::Real y, Ogre::Real z);
+    inline Ogre::Real getX(){return x_;}
+    inline Ogre::Real getY(){return y_;}
+    inline Ogre::Real getZ(){return z_;}
+    inline int getName(){return name_;}
+  };
+
+
+  class _OrxonoxExport Radar
+  {
+  private:
+    int number;
+
+
+  public:
+    Radar();
+    ~Radar();
+
+
+
+
+
+  };
+}	
+
+#endif
