Index: code/branches/hud/src/orxonox/GraphicsEngine.h
===================================================================
--- code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1587)
+++ code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1588)
@@ -74,4 +74,6 @@
             float getAverageFPS() const
             { if (renderWindow_) return this->renderWindow_->getAverageFPS(); else return 0.0f; }
+            float getAverageRTR() const { return this->renderTimeRatio_; }
+            void setAverageRTR(float rtr) { this->renderTimeRatio_ = rtr; }
 
             void windowMoved       (Ogre::RenderWindow* rw);
@@ -108,4 +110,5 @@
             int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
             unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+            float               renderTimeRatio_;       //!< Ratio between time required to render a frame and to tick() it
     };
 }
Index: code/branches/hud/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/hud/src/orxonox/Orxonox.cc	(revision 1587)
+++ code/branches/hud/src/orxonox/Orxonox.cc	(revision 1588)
@@ -101,5 +101,5 @@
     // turn on frame smoothing by setting a value different from 0
     frameSmoothingTime_(0.0f),
-    orxonoxHUD_(0),
+    //orxonoxHUD_(0),
     bAbort_(false),
     timefactor_(1.0f),
@@ -116,5 +116,6 @@
   {
     // keep in mind: the order of deletion is very important!
-    this->orxonoxHUD_->destroy();
+    /*if (this->orxonoxHUD_)
+      delete this->orxonoxHUD_;*/
     Loader::close();
     InputManager::destroy();
@@ -332,7 +333,8 @@
 
     // Load the HUD
-    COUT(3) << "Orxonox: Loading HUD..." << std::endl;
-    orxonoxHUD_ = &HUD::getSingleton();
-    orxonoxHUD_->initialise();
+    COUT(3) << "Orxonox: Loading HUD" << std::endl;
+
+    Level* hud = new Level("hud/hud.oxh");
+    Loader::load(hud);
 
     return true;
@@ -437,10 +439,4 @@
 //    clock_t time = 0;
 
-    //Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();
-    //Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport();
-
-    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom");
-    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur");
-
     COUT(3) << "Orxonox: Starting the main loop." << std::endl;
     while (!bAbort_)
@@ -459,5 +455,5 @@
       if (mode_ != DEDICATED && frameTime > 0.4f)
       {
-        HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime);
+        GraphicsEngine::getSingleton().setAverageRTR(renderTime / frameTime);
         frameTime = 0.0f;
         renderTime = 0.0f;
Index: code/branches/hud/src/orxonox/Orxonox.h
===================================================================
--- code/branches/hud/src/orxonox/Orxonox.h	(revision 1587)
+++ code/branches/hud/src/orxonox/Orxonox.h	(revision 1588)
@@ -97,5 +97,5 @@
       // TODO: make this a config-value by creating a config class for orxonox
       float                 frameSmoothingTime_;
-      HUD*                  orxonoxHUD_;
+      //HUD*                  orxonoxHUD_;
       bool                  bAbort_;        //!< aborts the render loop if true
       float                 timefactor_;    //!< A factor to change the gamespeed
Index: code/branches/hud/src/orxonox/hud/BarOverlayElement.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/BarOverlayElement.cc	(revision 1587)
+++ 	(revision )
@@ -1,178 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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:
- *      Felix Schulthess
- *      Fabian 'x3n' Landau
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "BarOverlayElement.h"
-
-#include <OgreOverlayManager.h>
-#include <OgreMaterialManager.h>
-#include <OgreTechnique.h>
-
-#include "GraphicsEngine.h"
-#include "util/Convert.h"
-
-namespace orxonox
-{
-    using namespace Ogre;
-
-    unsigned int BarOverlayElement::materialcount_s = 0;
-
-    BarOverlayElement::BarOverlayElement(const String& name) : PanelOverlayElement(name)
-    {
-        this->textureUnitState_ = 0;
-        this->name_ = name;
-        this->widthratio_ = 100.0f / 800.0f; // calculates the ratio (backgroundwidth - barwidth) / backgroundwidth
-    }
-
-    BarOverlayElement::~BarOverlayElement()
-    {
-        OverlayManager::getSingleton().destroyOverlayElement(this->background_);
-    }
-
-    void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container)
-    {
-        // init some values...
-        this->value_ = -1;
-        this->autoColour_ = true;
-        this->right2Left_ = false; // default is left to right progress
-        this->leftRel_ = leftRel;
-        this->topRel_ = topRel;
-        this->dimRel_ = dimRel;
-
-        // create background...
-        this->background_ = static_cast<OverlayContainer*>(OverlayManager::getSingleton().createOverlayElement("Panel", name_+"container"));
-        this->background_->show();
-        container->addChild(background_);
-        this->background_->setMetricsMode(GMM_PIXELS);
-        this->background_->setMaterialName("Orxonox/BarBackground");
-
-        // calculate absolute coordinates...
-        this->resize();
-        this->show();
-
-        // create new material
-        std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(BarOverlayElement::materialcount_s++);
-        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
-        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
-        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
-        this->textureUnitState_->setTextureName("bar2.tga");
-        // use the default colour
-        this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
-        this->setMaterialName(materialname);
-        this->setMetricsMode(GMM_PIXELS);
-
-        this->background_->addChild(this);
-    }
-
-    void BarOverlayElement::resize()
-    {
-        // calculate new absolute coordinates...
-        this->left_ = (int) (this->leftRel_ * GraphicsEngine::getSingleton().getWindowWidth());
-        this->top_ = (int) (this->topRel_ * GraphicsEngine::getSingleton().getWindowHeight());
-        this->width_ = (int) (this->dimRel_ * GraphicsEngine::getSingleton().getWindowWidth());
-        this->height_ = (int) (0.1 * this->width_);	// the texture has dimensions height:length = 1:10
-        this->offset_ = (int) (this->width_ * this->widthratio_ * 0.5);
-        this->barwidth_ = (int) (this->width_ * (1.0f - this->widthratio_));
-
-        // adapt background
-        this->background_->setPosition(this->left_, this->top_);
-        this->background_->setDimensions(this->width_,this-> height_);
-        // adapt bar
-        this->setValue(this->value_);
-    }
-
-    void BarOverlayElement::setValue(float value)
-    {
-        if (value == this->value_)
-            return;
-
-        this->value_ = clamp<float>(value, 0, 1);
-        if (this->autoColour_ && this->textureUnitState_)
-        {
-            // set colour
-            if (this->colours_.size() > 0)
-            {
-                ColourValue colour1, colour2 = (*this->colours_.rbegin()).second;
-                float value1, value2 = (*this->colours_.rbegin()).first;
-                for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
-                {
-                    colour1 = colour2;
-                    value1 = value2;
-                    colour2 = (*it).second;
-                    value2 = (*it).first;
-
-                    if (value2 < this->value_)
-                        break;
-                }
-
-                if (value2 > this->value_)
-                {
-                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
-                }
-                else if (value1 < this->value_)
-                {
-                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
-                }
-                else
-                {
-                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
-                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
-                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
-                }
-            }
-        }
-
-        // set value
-        if (this->right2Left_)
-        {
-            // backward case
-            this->setPosition(this->offset_ + this->barwidth_ * (1 - this->value_), 0);
-            this->setDimensions(this->barwidth_ * this->value_, this->height_);
-        }
-        else
-        {
-            // default case
-            this->setPosition(this->offset_, 0);
-            this->setDimensions(this->barwidth_ * this->value_, this->height_);
-        }
-        if (this->value_ != 0)
-            this->setTiling(this->value_, 1.0);
-    }
-
-    void BarOverlayElement::addColour(float value, const ColourValue& colour)
-    {
-        value = clamp<float>(value, 0, 1);
-        this->colours_[value] = colour;
-    }
-
-    void BarOverlayElement::clearColours()
-    {
-        this->colours_.clear();
-    }
-}
Index: code/branches/hud/src/orxonox/hud/BarOverlayElement.h
===================================================================
--- code/branches/hud/src/orxonox/hud/BarOverlayElement.h	(revision 1587)
+++ 	(revision )
@@ -1,84 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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:
- *      Felix Schulthess
- *      Fabian 'x3n' Landau
- *
- */
-
-#ifndef _BarOverlayElement_H__
-#define _BarOverlayElement_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <map>
-
-#include <OgrePrerequisites.h>
-#include <OgrePanelOverlayElement.h>
-
-#include "util/Math.h"
-
-namespace orxonox
-{
-  class _OrxonoxExport BarOverlayElement : public Ogre::PanelOverlayElement
-  {
-    public:
-      BarOverlayElement(const Ogre::String& name);
-      virtual ~BarOverlayElement();
-
-      void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
-      void resize();
-      void setValue(float value);
-      void addColour(float value, const ColourValue& colour);
-      void clearColours();
-
-      inline void setRightToLeft(bool r2l)
-        { this->right2Left_ = r2l; }
-      inline bool getRightToLeft() const
-        { return this->right2Left_; }
-      inline float getValue() const
-        { return this->value_; }
-
-    private:
-      static unsigned int materialcount_s;
-      bool right2Left_;
-      bool autoColour_;                   // whether bar changes colour automatically
-      float value_;                       // progress of bar
-      int left_;
-      int top_;
-      int width_;
-      int height_;
-      float widthratio_;
-      int offset_;
-      int barwidth_;
-      Ogre::Real leftRel_;
-      Ogre::Real topRel_;
-      Ogre::Real dimRel_;
-      Ogre::OverlayContainer* background_;
-      Ogre::String name_;
-      Ogre::TextureUnitState* textureUnitState_;
-      std::map<float, ColourValue> colours_;
-    };
-}
-#endif /* _BarOverlayElement_H__ */
Index: code/branches/hud/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUD.cc	(revision 1587)
+++ code/branches/hud/src/orxonox/hud/HUD.cc	(revision 1588)
@@ -32,4 +32,5 @@
 #include <string>
 #include <set>
+#include <assert.h>
 #include <OgreOverlay.h>
 #include <OgreOverlayContainer.h>
@@ -39,8 +40,9 @@
 #include "core/Debug.h"
 #include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
 #include "objects/SpaceShip.h"
 #include "objects/WorldEntity.h"
 #include "GraphicsEngine.h"
-#include "BarOverlayElement.h"
+#include "HUDBar.h"
 #include "RadarObject.h"
 #include "RadarOverlayElement.h"
@@ -49,8 +51,11 @@
 namespace orxonox
 {
+    CreateFactory(HUD);
+
     SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
     SetConsoleCommandShortcut(HUD, releaseNavigationFocus).setAccessLevel(AccessLevel::User);
-    SetConsoleCommandShortcut(HUD, toggleFPS).setAccessLevel(AccessLevel::User);
-    SetConsoleCommandShortcut(HUD, toggleRenderTime).setAccessLevel(AccessLevel::User);
+    SetConsoleCommand(HUD, toggleVisibility, false).setAccessLevel(AccessLevel::User);
+
+    HUD* HUD::instance_s = 0;
 
     using namespace Ogre;
@@ -58,4 +63,11 @@
     HUD::HUD()
     {
+        assert(instance_s == 0);
+        instance_s = this;
+        RegisterObject(HUD);
+
+        // Singleton like in Ogre. Constructor and destructor are public,
+        // but the assert prevents from having multiple instances.
+
         orxonoxHUD_ = 0;
         container_ = 0;
@@ -72,35 +84,47 @@
     HUD::~HUD()
     {
-        this->destroy();
-    }
-
-    void HUD::initialise()
-    {
+        if (this->isInitialized())
+        {
+            if (this->container_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->container_);
+            this->container_ = 0;
+            if (this->fpsText_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->fpsText_);
+            this->fpsText_ = 0;
+            if (this->rTRText_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->rTRText_);
+            this->rTRText_ = 0;
+            if (this->energyBar_)
+                delete this->energyBar_;
+            this->energyBar_ = 0;
+            /*if (this->speedoBar_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->speedoBar_);*/
+            this->speedoBar_ = 0;
+            if (this->radar_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->radar_);
+            this->radar_ = 0;
+            if (this->orxonoxHUD_)
+                Ogre::OverlayManager::getSingleton().destroy(this->orxonoxHUD_);
+            this->orxonoxHUD_ = 0;
+
+            if (this->nav_)
+                delete this->nav_;
+            this->nav_ = 0;
+        }
+
+        instance_s = 0;
+    }
+
+    void HUD::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        BaseObject::XMLPort(xmlElement, mode);
+
         showFPS_ = true;
         showRenderTime_ = true;
 
+        XMLPortObject(HUD, HUDOverlay, "", addHUDElement, getHUDElement, xmlElement, mode, false, true);
+
         // create Factories
-        Ogre::OverlayManager::getSingleton().addOverlayElementFactory(&barOverlayElementFactory_);
         Ogre::OverlayManager::getSingleton().addOverlayElementFactory(&radarOverlayElementFactory_);
-
-        // creating text to display fps
-        fpsText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", "fpsText"));
-        fpsText_->setMetricsMode(Ogre::GMM_PIXELS);
-        fpsText_->setDimensions(0.001, 0.001);
-        fpsText_->setPosition(10, 10);
-        fpsText_->setFontName("Console");
-        fpsText_->setCharHeight(20);
-        fpsText_->setCaption("init");
-        fpsText_->show();
-
-        // creating text to display render time ratio
-        rTRText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", "rTRText"));
-        rTRText_->setMetricsMode(Ogre::GMM_PIXELS);
-        rTRText_->setDimensions(0.001, 0.001);
-        rTRText_->setPosition(10, 30);
-        rTRText_->setFontName("Console");
-        rTRText_->setCharHeight(20);
-        rTRText_->setCaption("init");
-        rTRText_->show();
 
         // set up screen-wide container
@@ -111,30 +135,11 @@
         container_->setHeight(1.0);
         container_->setMetricsMode(Ogre::GMM_RELATIVE);
-        container_->addChild(fpsText_);
-        container_->addChild(rTRText_);
-        container_->show();
 
         orxonoxHUD_ = Ogre::OverlayManager::getSingleton().create("Orxonox/HUD");
         orxonoxHUD_->add2D(container_);
-        orxonoxHUD_->show();
-
-        // create energy bar
-        energyBar_ = static_cast<BarOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Bar", "energyBar"));
-        energyBar_->init(0.01, 0.94, 0.4, container_);
-        energyBar_->setValue(1);
-        energyBar_->show();
-
-        // create speedo bar
-        speedoBar_ = static_cast<BarOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Bar", "speedoBar"));
-        speedoBar_->init(0.01, 0.90, 0.4, container_);
-        speedoBar_->addColour(0.7, ColourValue(0.2, 0.7, 0.2));
-        speedoBar_->addColour(0.4, ColourValue(0.7, 0.5, 0.2));
-        speedoBar_->addColour(0.1, ColourValue(0.7, 0.2, 0.2));
-        speedoBar_->show();
 
         // create radar
         radar_ = static_cast<RadarOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Radar", "radar"));
         radar_->init(0.5, 0.9, 0.2, container_);
-        radar_->show();
 
         // create Navigation
@@ -154,77 +159,40 @@
         object->setPosition(10000.0,16000.0,0.0);
         addRadarObject(object);
-    }
-
-    void HUD::destroy()
-    {
-        if (this->container_)
-          Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->container_);
-        this->container_ = 0;
-        if (this->fpsText_)
-            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->fpsText_);
-        this->fpsText_ = 0;
-        if (this->rTRText_)
-            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->rTRText_);
-        this->rTRText_ = 0;
-        if (this->energyBar_)
-            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->energyBar_);
-        this->energyBar_ = 0;
-        if (this->speedoBar_)
-            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->speedoBar_);
-        this->speedoBar_ = 0;
-        if (this->radar_)
-            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->radar_);
-        this->radar_ = 0;
-        if (this->orxonoxHUD_)
-            Ogre::OverlayManager::getSingleton().destroy(this->orxonoxHUD_);
-        this->orxonoxHUD_ = 0;
-
-        if (this->nav_)
-            delete this->nav_;
-        this->nav_ = 0;
+
+        orxonoxHUD_->show();
+    }
+
+    void HUD::addHUDElement(HUDOverlay* element)
+    {
+        if (hudElements_.find(element->getName()) != hudElements_.end())
+        {
+          COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
+        }
+        else
+          hudElements_[element->getName()] = element;
+    }
+
+    HUDOverlay* HUD::getHUDElement(unsigned int index)
+    {
+        if (index < this->hudElements_.size())
+        {
+          std::map<std::string, HUDOverlay*>::const_iterator it = hudElements_.begin();
+          for (unsigned int i = 0; i != index; ++it, ++i)
+            ;
+          return (*it).second;
+        }
+        else
+            return 0;
     }
 
     void HUD::tick(float dt)
     {
-        if(!SpaceShip::getLocalShip())
-          return;
-
-        float v = SpaceShip::getLocalShip()->getVelocity().length();
-        float vmax = SpaceShip::getLocalShip()->getMaxSpeed();
-        speedoBar_->setValue(v/vmax);
-
         radar_->update();
         nav_->update();
-
-        setFPS();
     }
 
     void HUD::resize()
     {
-        this->speedoBar_->resize();
-        this->energyBar_->resize();
         this->radar_->resize();
-    }
-
-    void HUD::setRenderTimeRatio(float ratio)
-    {
-        if(showRenderTime_){
-            rTRText_->setCaption("Render time ratio: " + Ogre::StringConverter::toString(ratio));
-        }
-        else{
-            rTRText_->setCaption("");
-            return;
-        }
-    }
-
-    void HUD::setFPS(){
-        if(showFPS_){
-            float fps = GraphicsEngine::getSingleton().getAverageFPS();
-            fpsText_->setCaption("FPS: " + Ogre::StringConverter::toString(fps));
-        }
-        else{
-            fpsText_->setCaption("");
-            return;
-        }
     }
 
@@ -257,7 +225,16 @@
     }
 
-    /*static*/ HUD& HUD::getSingleton(){
-        static HUD theInstance;
-        return theInstance;
+    /*static*/ HUD& HUD::getSingleton()
+    {
+        assert(instance_s);
+        return *instance_s;
+    }
+
+    /*static*/ void HUD::toggleVisibility(const std::string& name)
+    {
+        if (HUD::getSingleton().hudElements_.find(name) != HUD::getSingleton().hudElements_.end())
+        {
+            HUD::getSingleton().hudElements_[name]->setVisibility(!HUD::getSingleton().hudElements_[name]->isVisible());
+        }
     }
 
@@ -273,11 +250,3 @@
         HUD::getSingleton().nav_->releaseFocus();
     }
-
-    /*static*/ void HUD::toggleFPS(){
-        HUD::getSingleton().showFPS_ = !HUD::getSingleton().showFPS_;
-    }
-
-    /*static*/ void HUD::toggleRenderTime(){
-        HUD::getSingleton().showRenderTime_ = !HUD::getSingleton().showRenderTime_;
-    }
 }
Index: code/branches/hud/src/orxonox/hud/HUD.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUD.h	(revision 1587)
+++ code/branches/hud/src/orxonox/hud/HUD.h	(revision 1588)
@@ -35,4 +35,5 @@
 #include <OgrePrerequisites.h>
 #include <OgreTextAreaOverlayElement.h>
+#include "core/BaseObject.h"
 #include "objects/Tickable.h"
 #include "util/Math.h"
@@ -41,9 +42,14 @@
 namespace orxonox
 {
-    class _OrxonoxExport HUD : public TickableReal
+    class HUDBar;
+    class HUDOverlay;
+
+    class _OrxonoxExport HUD : public BaseObject, public TickableReal
     {
       public:
-        void initialise();
-        void destroy();
+        HUD();
+        ~HUD();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
 
         virtual void tick(float);
@@ -52,5 +58,4 @@
         void addRadarObject(WorldEntity* object, const ColourValue& colour = ColourValue(0.5, 0.5, 0.5, 1));
         void removeRadarObject(WorldEntity* object);
-        void setRenderTimeRatio(float ratio);
         void setFPS();
 
@@ -63,14 +68,16 @@
         static void cycleNavigationFocus();
         static void releaseNavigationFocus();
-        static void toggleFPS();
-        static void toggleRenderTime();
+        static void toggleVisibility(const std::string& name);
 
       private:
-        HUD();
         HUD(const HUD& instance);
-        ~HUD();
+
+        void addHUDElement(HUDOverlay* element);
+        HUDOverlay* getHUDElement(unsigned int index);
+
+        std::map<std::string, HUDOverlay*> hudElements_;
 
         std::list<RadarObject*> roSet_;
-        BarOverlayElementFactory barOverlayElementFactory_;
+
         RadarOverlayElementFactory radarOverlayElementFactory_;
 
@@ -79,5 +86,5 @@
         Ogre::TextAreaOverlayElement* fpsText_;
         Ogre::TextAreaOverlayElement* rTRText_;
-        BarOverlayElement* energyBar_;
+        HUDBar* energyBar_;
         BarOverlayElement* speedoBar_;
         RadarOverlayElement* radar_;
@@ -86,4 +93,6 @@
         bool showFPS_;
         bool showRenderTime_;
+
+        static HUD* instance_s;
     };
 }
Index: code/branches/hud/src/orxonox/hud/HUDBar.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDBar.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDBar.cc	(revision 1588)
@@ -0,0 +1,176 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDBar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    unsigned int HUDBar::materialcount_s = 0;
+
+    using namespace Ogre;
+
+    HUDBar::HUDBar()
+    {
+        RegisterObject(HUDBar);
+
+        this->bar_ = 0;
+        this->background_ = 0;
+        this->textureUnitState_ = 0;
+
+        barWidth_s = 0.88f;
+        barHeight_s = 0.3f;
+        barOffsetLeft_s = 0.06f;
+        barOffsetTop_s = 0.0f;
+
+        this->value_ = -1;
+        this->autoColour_ = true;
+        this->right2Left_ = false; // default is left to right progress
+    }
+
+    HUDBar::~HUDBar()
+    {
+        if (this->isInitialized())
+        {
+            if (this->bar_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
+        }
+    }
+
+    void HUDBar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        HUDOverlay::XMLPort(xmlElement, mode);
+
+        // create background
+        this->background_ = static_cast<PanelOverlayElement*>(
+                OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));
+        this->background_->setMaterialName("Orxonox/BarBackground");
+        this->background_->setMetricsMode(GMM_RELATIVE);
+        this->background_->setDimensions(1.0f, 0.3f);
+        this->background_->setPosition(0.0f, 0.0f);
+        this->overlay_->add2D(this->background_);
+
+        // create new material
+        std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
+        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
+        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+        this->textureUnitState_->setTextureName("bar2.tga");
+        // use the default colour
+        this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
+
+        // create bar
+        this->bar_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "Bar"));
+        this->bar_->setMaterialName(materialname);
+        this->bar_->setMetricsMode(GMM_RELATIVE);
+        this->background_->addChild(bar_);
+
+        XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode);
+
+        this->addColour(0.7, ColourValue(0.2, 0.7, 0.2));
+        this->addColour(0.4, ColourValue(0.7, 0.5, 0.2));
+        this->addColour(0.1, ColourValue(0.7, 0.2, 0.2));
+    }
+
+    void HUDBar::setValue(float value)
+    {
+        if (value == this->value_)
+            return;
+
+        this->value_ = clamp<float>(value, 0, 1);
+        if (this->autoColour_ && this->textureUnitState_)
+        {
+            // set colour
+            if (this->colours_.size() > 0)
+            {
+                ColourValue colour1, colour2 = (*this->colours_.rbegin()).second;
+                float value1, value2 = (*this->colours_.rbegin()).first;
+                for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
+                {
+                    colour1 = colour2;
+                    value1 = value2;
+                    colour2 = (*it).second;
+                    value2 = (*it).first;
+
+                    if (value2 < this->value_)
+                        break;
+                }
+
+                if (value2 > this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
+                }
+                else if (value1 < this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
+                }
+                else
+                {
+                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
+                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
+                }
+            }
+        }
+
+        // set value
+        if (this->right2Left_)
+        {
+            // backward casew
+            this->bar_->setPosition(barOffsetLeft_s + barWidth_s * (1 - this->value_), barOffsetTop_s);
+            this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
+        }
+        else
+        {
+            // default case
+            this->bar_->setPosition(barOffsetLeft_s, barOffsetTop_s);
+            this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
+        }
+        if (this->value_ != 0)
+            this->bar_->setTiling(this->value_, 1.0);
+    }
+
+    void HUDBar::addColour(float value, const ColourValue& colour)
+    {
+        value = clamp<float>(value, 0, 1);
+        this->colours_[value] = colour;
+    }
+
+    void HUDBar::clearColours()
+    {
+        this->colours_.clear();
+    }
+}
Index: code/branches/hud/src/orxonox/hud/HUDBar.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDBar.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDBar.h	(revision 1588)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDBar_H__
+#define _HUDBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "HUDOverlay.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDBar : public HUDOverlay, public TickableReal
+  {
+    public:
+      HUDBar();
+      virtual ~HUDBar();
+
+      virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      //virtual void tick(float dt) { }
+
+      void setValue(float value);
+      void addColour(float value, const ColourValue& colour);
+      void clearColours();
+
+      inline void setRightToLeft(bool r2l)
+        { this->right2Left_ = r2l; }
+      inline bool getRightToLeft() const
+        { return this->right2Left_; }
+      inline float getValue() const
+        { return this->value_; }
+
+    private:
+      static unsigned int materialcount_s;
+      bool right2Left_;
+      bool autoColour_;                   // whether bar changes colour automatically
+      float value_;                       // progress of bar
+      Ogre::PanelOverlayElement* bar_;
+      Ogre::PanelOverlayElement* background_;
+      Ogre::TextureUnitState* textureUnitState_;
+      std::map<float, ColourValue> colours_;
+
+      float barWidth_s;
+      float barHeight_s;
+      float barOffsetLeft_s;
+      float barOffsetTop_s;
+    };
+}
+#endif /* _HUDBar_H__ */
Index: code/branches/hud/src/orxonox/hud/HUDFPSText.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDFPSText.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDFPSText.cc	(revision 1588)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDFPSText.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDFPSText);
+
+  HUDFPSText::HUDFPSText()
+  {
+    RegisterObject(HUDFPSText);
+  }
+
+  HUDFPSText::~HUDFPSText()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDFPSText::tick(float dt)
+  {
+    float fps = GraphicsEngine::getSingleton().getAverageFPS();
+    this->text_->setCaption(this->getCaption() + convertToString(fps));
+  }
+}
Index: code/branches/hud/src/orxonox/hud/HUDFPSText.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDFPSText.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDFPSText.h	(revision 1588)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDFPSText_H__
+#define _HUDFPSText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDText.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDFPSText : public HUDText
+  {
+  public:
+    HUDFPSText();
+    virtual ~HUDFPSText();
+
+    //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    virtual void tick(float dt);
+
+  private:
+  };
+}
+#endif /* _HUDFPSText_H__ */
Index: code/branches/hud/src/orxonox/hud/HUDOverlay.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDOverlay.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDOverlay.cc	(revision 1588)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDOverlay.h"
+
+#include <OgreOverlayManager.h>
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDOverlay);
+  unsigned int HUDOverlay::hudOverlayCounter_s = 0;
+
+  HUDOverlay::HUDOverlay()
+    : overlay_(0)
+  {
+    RegisterObject(HUDOverlay);
+  }
+
+  void HUDOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+  {
+    BaseObject::XMLPort(xmlElement, mode);
+
+    overlay_ = Ogre::OverlayManager::getSingleton().create("HUDOverlay"
+          + convertToString(hudOverlayCounter_s++) + "_" + this->getName());
+
+    XMLPortParam(HUDOverlay, "scale", setScale, getScale, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "scroll", setScroll, getScroll, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "rotation", setRotation, getRotation, xmlElement, mode);
+
+    this->overlay_->show();
+    if (!this->isVisible())
+        this->overlay_->hide();
+  }
+
+  HUDOverlay::~HUDOverlay()
+  {
+  }
+
+  void HUDOverlay::changedVisibility()
+  {
+      if (this->overlay_)
+      {
+          if (this->isVisible())
+              overlay_->show();
+          else
+              overlay_->hide();
+      }
+  }
+
+}
Index: code/branches/hud/src/orxonox/hud/HUDOverlay.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDOverlay.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDOverlay.h	(revision 1588)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDOverlay_H__
+#define _HUDOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "util/Math.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDOverlay : public BaseObject
+  {
+    public:
+      HUDOverlay();
+      virtual ~HUDOverlay();
+
+      virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      virtual void changedVisibility();
+
+      /** Sets the scrolling factor of this overlay. */
+      void setScroll(Vector2 scroll) { overlay_->setScroll(scroll.x, scroll.y); }
+
+      /** Gets the current scroll value */
+      Vector2 getScroll() const { return Vector2(overlay_->getScrollX(), overlay_->getScrollY()); }
+
+      /** Scrolls the overlay by the offsets provided. */
+      void scroll(Vector2 scroll) { overlay_->scroll(scroll.x, scroll.y); }
+
+      /** Sets the rotation applied to this overlay.*/
+      void setRotation(const Ogre::Radian& angle) { overlay_->setRotate(angle); }
+
+      /** Gets the rotation applied to this overlay, in degrees.*/
+      const Radian& getRotation() const { return overlay_->getRotate(); }
+
+      /** Adds the passed in angle to the rotation applied to this overlay. */
+      void rotate(const Radian& angle) { overlay_->rotate(angle); }
+
+      /** Sets the scaling factor of this overlay. */
+      void setScale(const Vector2& scale) { overlay_->setScale(scale.x, scale.y); }
+
+      /** Gets the current scale value */
+      Vector2 getScale() const { return Vector2(overlay_->getScaleX(), overlay_->getScaleY()); }
+
+      /** Scales the overlay */
+      void scale(Vector2 scale) { overlay_->setScale(overlay_->getScaleX()*scale.x, overlay_->getScaleY()*scale.y); }
+
+    protected:
+      Ogre::Overlay* overlay_;
+
+  private:
+    static unsigned int hudOverlayCounter_s;
+
+  };
+}
+
+#endif /* _HUDOverlay_H__ */
Index: code/branches/hud/src/orxonox/hud/HUDRTRText.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDRTRText.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDRTRText.cc	(revision 1588)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDRTRText.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDRTRText);
+
+  HUDRTRText::HUDRTRText()
+  {
+    RegisterObject(HUDRTRText);
+  }
+
+  HUDRTRText::~HUDRTRText()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDRTRText::tick(float dt)
+  {
+    float rtr = GraphicsEngine::getSingleton().getAverageRTR();
+    this->text_->setCaption(this->getCaption() + convertToString(rtr));
+  }
+}
Index: code/branches/hud/src/orxonox/hud/HUDRTRText.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDRTRText.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDRTRText.h	(revision 1588)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDRTRText_H__
+#define _HUDRTRText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDText.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDRTRText : public HUDText
+  {
+  public:
+    HUDRTRText();
+    virtual ~HUDRTRText();
+
+    //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    virtual void tick(float dt);
+
+  private:
+  };
+}
+#endif /* _HUDRTRText_H__ */
Index: code/branches/hud/src/orxonox/hud/HUDSpeedBar.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDSpeedBar.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDSpeedBar.cc	(revision 1588)
@@ -0,0 +1,62 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDSpeedBar.h"
+#include "objects/SpaceShip.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDSpeedBar);
+
+  using namespace Ogre;
+
+  HUDSpeedBar::HUDSpeedBar()
+  {
+    RegisterObject(HUDSpeedBar);
+
+  }
+
+  HUDSpeedBar::~HUDSpeedBar()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDSpeedBar::tick(float dt)
+  {
+    SpaceShip* ship = SpaceShip::getLocalShip();
+    if (ship)
+    {
+      float v = ship->getVelocity().length();
+      float vmax = ship->getMaxSpeed();
+      this->setValue(v/vmax);
+    }
+  }
+}
Index: code/branches/hud/src/orxonox/hud/HUDSpeedBar.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDSpeedBar.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDSpeedBar.h	(revision 1588)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDSpeedBar_H__
+#define _HUDSpeedBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDBar.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDSpeedBar : public HUDBar
+  {
+    public:
+      HUDSpeedBar();
+      virtual ~HUDSpeedBar();
+
+      //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      virtual void tick(float dt);
+
+    private:
+
+    };
+}
+#endif /* _HUDSpeedBar_H__ */
Index: code/branches/hud/src/orxonox/hud/HUDText.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDText.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDText.cc	(revision 1588)
@@ -0,0 +1,124 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDText.h"
+
+#include <OgreOverlayManager.h>
+
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDText);
+
+  using namespace Ogre;
+
+  HUDText::HUDText()
+    : background_(0)
+    , text_(0)
+  {
+    RegisterObject(HUDText);
+  }
+
+  HUDText::~HUDText()
+  {
+    if (this->isInitialized())
+    {
+      if (this->text_)
+          OverlayManager::getSingleton().destroyOverlayElement(this->text_);
+      if (this->background_)
+          OverlayManager::getSingleton().destroyOverlayElement(this->background_);
+    }
+  }
+
+  void HUDText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+  {
+    HUDOverlay::XMLPort(xmlElement, mode);
+
+    // create background
+    this->background_ = static_cast<PanelOverlayElement*>(
+            OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));
+    this->background_->setMetricsMode(GMM_RELATIVE);
+    this->background_->setDimensions(1.0f, 1.0f);
+    this->background_->setPosition(0.0f, 0.0f);
+
+    this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
+    this->text_->setMetricsMode(Ogre::GMM_RELATIVE);
+    this->text_->setDimensions(1.0f, 1.0f);
+    this->text_->setPosition(0.0f, 0.0f);
+    this->text_->setCharHeight(1.0f);
+
+    this->overlay_->add2D(this->background_);
+    this->background_->addChild(this->text_);
+
+    XMLPortParam(HUDText, "material", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
+    XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode);
+    XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
+
+    this->text_->setCaption(this->caption_);
+  }
+
+  void HUDText::setBackgroundMaterial(const std::string& material)
+  {
+    if (this->background_ && material != "")
+      this->background_->setMaterialName(material);
+  }
+
+  std::string HUDText::getBackgroundMaterial() const
+  {
+    if (this->background_)
+      return this->background_->getMaterialName();
+    else
+      return "";
+  }
+
+  void HUDText::setCaption(const std::string& caption)
+  {
+    this->caption_ = caption;
+  }
+
+  const std::string& HUDText::getCaption() const
+  {
+    return this->caption_;
+  }
+
+  void HUDText::setFont(const std::string& font)
+  {
+    if (this->text_ && font != "")
+      this->text_->setFontName(font);
+  }
+
+  std::string HUDText::getFont() const
+  {
+    if (this->text_)
+      return this->text_->getFontName();
+    else
+      return "";
+  }
+}
Index: code/branches/hud/src/orxonox/hud/HUDText.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUDText.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUDText.h	(revision 1588)
@@ -0,0 +1,67 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDText_H__
+#define _HUDText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "HUDOverlay.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDText : public HUDOverlay, public TickableReal
+  {
+  public:
+    HUDText();
+    virtual ~HUDText();
+
+    virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    virtual void tick(float dt) { }
+
+  protected:
+    void setBackgroundMaterial(const std::string& material);
+    std::string getBackgroundMaterial() const;
+    void setCaption(const std::string& caption);
+    const std::string& getCaption() const;
+    void setFont(const std::string& font);
+    std::string getFont() const;
+
+    Ogre::TextAreaOverlayElement* text_;
+  private:
+    std::string caption_;
+    Ogre::PanelOverlayElement* background_;
+  };
+}
+#endif /* _HUDText_H__ */
Index: code/branches/hud/src/orxonox/hud/OverlayElementFactories.h
===================================================================
--- code/branches/hud/src/orxonox/hud/OverlayElementFactories.h	(revision 1587)
+++ code/branches/hud/src/orxonox/hud/OverlayElementFactories.h	(revision 1588)
@@ -36,20 +36,8 @@
 #include <OgreOverlayElementFactory.h>
 
-#include "BarOverlayElement.h"
 #include "RadarOverlayElement.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 RadarOverlayElementFactory : public Ogre::OverlayElementFactory{
       public:
Index: code/branches/hud/src/orxonox/objects/Ambient.cc
===================================================================
--- code/branches/hud/src/orxonox/objects/Ambient.cc	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/Ambient.cc	(revision 1588)
@@ -73,27 +73,10 @@
       
     }
-    
-    void Ambient::loadParams(TiXmlElement* xmlElem)
+
+    void Ambient::setAmbientLight(const ColourValue& colour)
     {
-    	if (xmlElem->Attribute("colourvalue"))
-    	{
-        SubString colourvalues(xmlElem->Attribute("colourvalue"), ',');
-
-	    	float r, g, b;
-        convertValue<std::string, float>(&r, colourvalues[0]);
-        convertValue<std::string, float>(&g, colourvalues[1]);
-        convertValue<std::string, float>(&b, colourvalues[2]);
-
-	    	this->setAmbientLight(ColourValue(r, g, b));
-
-	    	COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b  << std::endl << std::endl;
-    	}
-   }
-
-   void Ambient::setAmbientLight(const ColourValue& colour)
-   {
-    	GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
+	    GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
       ambientLight_=colour;	
-   }
+    }
 
     /**
Index: code/branches/hud/src/orxonox/objects/Ambient.h
===================================================================
--- code/branches/hud/src/orxonox/objects/Ambient.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/Ambient.h	(revision 1588)
@@ -44,5 +44,4 @@
             virtual ~Ambient();
 
-            void loadParams(TiXmlElement* xmlElem);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setAmbientLight(const ColourValue& colour);
Index: code/branches/hud/src/orxonox/objects/NPC.cc
===================================================================
--- code/branches/hud/src/orxonox/objects/NPC.cc	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/NPC.cc	(revision 1588)
@@ -45,9 +45,4 @@
   NPC::~NPC()
   {
-  }
-
-  void NPC::loadParams(TiXmlElement* xmlElem)
-  {
-    Model::loadParams(xmlElem);
   }
 
Index: code/branches/hud/src/orxonox/objects/NPC.h
===================================================================
--- code/branches/hud/src/orxonox/objects/NPC.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/NPC.h	(revision 1588)
@@ -48,5 +48,4 @@
       NPC();
       virtual ~NPC();
-      virtual void loadParams(TiXmlElement* xmlElem);
       void tick(float dt);
       void update();
Index: code/branches/hud/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/branches/hud/src/orxonox/objects/WorldEntity.cc	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/WorldEntity.cc	(revision 1588)
@@ -95,11 +95,4 @@
     }
 
-    void WorldEntity::loadParams(TiXmlElement* xmlElem)
-    {
-
-        BaseObject::loadParams(xmlElem);
-        create();
-    }
-
 
     void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
Index: code/branches/hud/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/branches/hud/src/orxonox/objects/WorldEntity.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/WorldEntity.h	(revision 1588)
@@ -51,5 +51,4 @@
 
             virtual void tick(float dt);
-            virtual void loadParams(TiXmlElement* xmlElem);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual inline bool create(){ return Synchronisable::create(); }
Index: code/branches/hud/src/orxonox/objects/weapon/AmmunitionDump.h
===================================================================
--- code/branches/hud/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 1588)
@@ -56,6 +56,4 @@
     int getStockSize(const std::string &name);
 
-    virtual void loadParams(TiXmlElement* xmlElem) { BaseObject::loadParams(xmlElem); };
-
 
   protected:
Index: code/branches/hud/src/orxonox/objects/weapon/BaseWeapon.h
===================================================================
--- code/branches/hud/src/orxonox/objects/weapon/BaseWeapon.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/weapon/BaseWeapon.h	(revision 1588)
@@ -72,6 +72,4 @@
     void setAmmoDump(AmmunitionDump*);
 
-    inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); };
-
     virtual void tick(float dt);
 
Index: code/branches/hud/src/orxonox/objects/weapon/Bullet.h
===================================================================
--- code/branches/hud/src/orxonox/objects/weapon/Bullet.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/weapon/Bullet.h	(revision 1588)
@@ -45,6 +45,4 @@
 
     virtual void tick(float dt) { }
-
-    inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); };
  };
 }
Index: code/branches/hud/src/orxonox/objects/weapon/BulletManager.h
===================================================================
--- code/branches/hud/src/orxonox/objects/weapon/BulletManager.h	(revision 1587)
+++ code/branches/hud/src/orxonox/objects/weapon/BulletManager.h	(revision 1588)
@@ -57,6 +57,4 @@
     virtual void tick(float dt);
 
-    inline virtual void loadParams(TiXmlElement* xmlElem) { BaseObject::loadParams(xmlElem); };
-
   protected:
     inline bool create() { return Synchronisable::create(); }
