Index: code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc	(revision 1342)
@@ -42,5 +42,5 @@
     BarOverlayElement::~BarOverlayElement(){}
 
-    void BarOverlayElement::init(Real leftRel, Real topRel, Real widthRel, Real heightRel, Ogre::OverlayContainer* container){
+    void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
         // init some values...
         container_ = container;
@@ -49,20 +49,9 @@
         color_ = 2;
         autoColor_ = true;
-        left2Right = false; // default: right to left progress
-
-        // get window data...
-        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
-        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        left2Right = false; 	// default is right to left progress
         leftRel_ = leftRel;
         topRel_ = topRel;
-        widthRel_ = widthRel;
-        heightRel_ = heightRel;
-
-        // cálculate absolute coordinates...
-        left_ = leftRel_ * windowW_;
-        top_ = topRel_ * windowH_;
-        width_ = widthRel_ * windowW_;
-        height_ = heightRel_ * windowH_;
-
+        dimRel_ = dimRel;
+        
         // create background...
         background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container"));
@@ -72,9 +61,11 @@
         background_->setMaterialName("Orxonox/BarBackground");
 
+        // calculate absolute coordinates...
+        resize();
+
         show();
-        background_->addChild(this);
         setMetricsMode(Ogre::GMM_PIXELS);
         setMaterialName("Orxonox/Green");
-        resize();
+        background_->addChild(this);
     }
 
@@ -82,9 +73,9 @@
         windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
         windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
-        // cálculate new absolute coordinates...
-        left_ = leftRel_ * windowW_;
-        top_ = topRel_ * windowH_;
-        width_ = widthRel_ * windowW_;
-        height_ = heightRel_ * windowH_;
+        // calculate new absolute coordinates...
+        left_ = (int) (leftRel_ * windowW_);
+        top_ = (int) (topRel_ * windowH_);
+        width_ = (int) (dimRel_ * windowW_);
+        height_ = (int) (0.1*width_);	// the texture has dimensions height:length = 1:10
         // adapt background
         background_->setPosition(left_, top_);
Index: code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc~
===================================================================
--- code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc~	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc~	(revision 1342)
@@ -22,5 +22,5 @@
 *      Yuning Chai
 *   Co-authors:
-*      ...
+*      Felix Schulthess
 *
 */
@@ -29,6 +29,5 @@
 #include <OgreOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
-
-
+#include "GraphicsEngine.h"
 #include "BarOverlayElement.h"
 
@@ -37,93 +36,93 @@
   using namespace Ogre;
 
-
-    BarOverlayElement::BarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){}
+    BarOverlayElement::BarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){
+        name_ = name;
+    }
 
     BarOverlayElement::~BarOverlayElement(){}
 
-    void BarOverlayElement::initialise(){
-	PanelOverlayElement::initialise();
-/*	setDimensions(100,100);
-	setPosition(10,10);
-	setMaterialName("Orxonox/Green");
-	setMetricsMode(Ogre::GMM_PIXELS);
-*/  }
+    void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
+        // init some values...
+        container_ = container;
+        om = &Ogre::OverlayManager::getSingleton();
+        value_ = 0;
+        color_ = 2;
+        autoColor_ = true;
+        left2Right = false; 	// default is right to left progress
+        leftRel_ = leftRel;
+        topRel_ = topRel;
+        dimRel_ = dimRel;
+        
+        // create background...
+        background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container"));
+        background_->show();
+        container_->addChild(background_);
+        background_->setMetricsMode(Ogre::GMM_PIXELS);
+        background_->setMaterialName("Orxonox/BarBackground");
 
+        // calculate absolute coordinates...
+        resize();
 
-    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);
+        show();
+        setMetricsMode(Ogre::GMM_PIXELS);
+        setMaterialName("Orxonox/Green");
+        background_->addChild(this);
     }
 
-
-   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");
-      }
+    void BarOverlayElement::resize(){
+        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        // calculate new absolute coordinates...
+        left_ = (int) (leftRel_ * windowW_);
+        top_ = (int) (topRel_ * windowH_);
+        width_ = (int) (dimRel_ * windowW_);
+        height_ = (int) (0.1*width_);	// the texture has dimensions height:length = 1:10
+        // adapt background
+        background_->setPosition(left_, top_);
+        background_->setDimensions(width_, height_);
+        // adapt bar
+        setValue(value_);
     }
 
-
-    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 BarOverlayElement::setValue(float value){
+        value_ = value;
+        // set color, if nescessary
+        if(autoColor_){
+            if (value_>0.5) {setColor(BarOverlayElement::GREEN);}
+            else if (value_>0.25) {setColor(BarOverlayElement::YELLOW);}
+            else setColor(BarOverlayElement::RED);
+        }
+        // set value
+        if(left2Right){ // backward case
+            setPosition(0+width_-width_*value_, 0);
+            setDimensions(width_*value_,height_);
+        }else{          // default case
+            setPosition(0, 0);
+            setDimensions(width_*value_,height_);
+        }
+        if(value_ != 0) setTiling(value_, 1.0);
     }
 
-
-    void SmartBarOverlayElement::reset(int percentage){
-      if (percentage>50) {setColour(BarOverlayElement::GREEN);}
-      else if (percentage>25) {setColour(BarOverlayElement::YELLOW);}
-      else setColour(BarOverlayElement::RED);
-      OverlayElementBar::reset(percentage);
+    void BarOverlayElement::setColor(int color){
+        color_ = color;
+        switch(color){
+        case 0:
+            setMaterialName("Orxonox/Red");
+            break;
+        case 1:
+            setMaterialName("Orxonox/Yellow");
+            break;
+        case 2:
+            setMaterialName("Orxonox/Green");
+        }
     }
 
+    float BarOverlayElement::getValue(){
+        return(value_);
+    }
+
+    int BarOverlayElement::getBarColor(){
+        return(color_);
+    }
 }
 
Index: code/branches/hud3/src/orxonox/hud/BarOverlayElement.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/BarOverlayElement.h	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/BarOverlayElement.h	(revision 1342)
@@ -54,6 +54,5 @@
         Ogre::Real leftRel_;
         Ogre::Real topRel_;
-        Ogre::Real widthRel_;
-        Ogre::Real heightRel_;
+        Ogre::Real dimRel_;
         Ogre::OverlayManager* om;           // our overlay manager
         Ogre::OverlayContainer* container_; // our parent container to attach to
@@ -69,5 +68,5 @@
         BarOverlayElement(const Ogre::String& name);
         virtual ~BarOverlayElement();
-        void init(Real leftRel, Real topRel, Real widthRel, Real heightRel, Ogre::OverlayContainer* container);
+        void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
         void resize();
         void setValue(float value);
Index: code/branches/hud3/src/orxonox/hud/BarOverlayElement.h~
===================================================================
--- code/branches/hud3/src/orxonox/hud/BarOverlayElement.h~	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/BarOverlayElement.h~	(revision 1342)
@@ -22,5 +22,5 @@
 *      Yuning Chai
 *   Co-authors:
-*      ...
+*      Felix Schulthess
 *
 */
@@ -43,54 +43,38 @@
   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:
+        bool autoColor_;                    // whether bar changes color automatically
+        float value_;                       // progress of bar
+        int color_;
+        int left_;
+        int top_;
+        int width_;
+        int height_;
+        int windowW_, windowH_;
+        Ogre::Real leftRel_;
+        Ogre::Real topRel_;
+        Ogre::Real widthRel_;
+        Ogre::Real heightRel_;
+        Ogre::OverlayManager* om;           // our overlay manager
+        Ogre::OverlayContainer* container_; // our parent container to attach to
+        Ogre::OverlayContainer* background_;
+        Ogre::String name_;
 
     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);
-      
-  };
+        bool left2Right;
+        static const int RED = 0;           // predefined colors
+        static const int YELLOW = 1;
+        static const int GREEN = 2;
+
+        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 setColor(int color);
+        float getValue();
+        int getBarColor();
+    };
 }
-
 #endif
 
Index: code/branches/hud3/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1342)
@@ -75,7 +75,7 @@
         container->setHeight(1.0);
         container->setMetricsMode(Ogre::GMM_RELATIVE);
-        energyBar->init(0.01, 0.94, 0.4, 0.04, container);
+        energyBar->init(0.01, 0.94, 0.4, container);
         energyBar->setValue(1);
-        speedoBar->init(0.01, 0.90, 0.4, 0.04, container);
+        speedoBar->init(0.01, 0.90, 0.4, container);
         radar->init(0.5, 0.9, 0.2, container);
         radar->addObject(Vector3(1500.0, 0.0, 0.0));
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1342)
@@ -81,7 +81,7 @@
         windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
         windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
-        dim_ = dimRel_*windowH_;
-        left_ = leftRel_*windowW_-dim_/2;
-        top_ = topRel_*windowH_-dim_/2;
+        dim_ = (int) (dimRel_*windowH_);
+        left_ = (int) (leftRel_*windowW_-dim_/2);
+        top_ = (int) (topRel_*windowH_-dim_/2);
         setPosition(left_, top_);
         setDimensions(dim_,dim_);
@@ -151,7 +151,7 @@
 	}
 
-	//// RadarObject ////
+//////// RadarObject ////////
 
-	int RadarObject::count = 0;
+	int RadarObject::count = 0;		// initialize static variable
 
 	RadarObject::RadarObject(Ogre::OverlayContainer* container){
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~	(revision 1341)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~	(revision 1342)
@@ -54,10 +54,14 @@
 
     void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
-		om = &Ogre::OverlayManager::getSingleton();        
+        // some initial data
+		om = &Ogre::OverlayManager::getSingleton();
         dimRel_ = dimRel;
         leftRel_ = leftRel;
         topRel_ = topRel;
         container_ = container;
+        firstRadarObject_ = NULL;
+        lastRadarObject_ = NULL;
 
+        // these have to fit the data in the level
         shipPos_ = Vector3(0.0, 0.0, 0.0);
         initialDir_ = Vector3(1.0, 0.0, 0.0);
@@ -69,5 +73,5 @@
         setMaterialName("Orxonox/Radar");
         resize();
-        
+
         container_->addChild(this);
     }
@@ -77,7 +81,7 @@
         windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
         windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
-        dim_ = dimRel_*windowH_;
-        left_ = leftRel_*windowW_-dim_/2;
-        top_ = topRel_*windowH_-dim_/2;
+        dim_ = (int) (dimRel_*windowH_);
+        left_ = (int) (leftRel_*windowW_-dim_/2);
+        top_ = (int) (topRel_*windowH_-dim_/2);
         setPosition(left_, top_);
         setDimensions(dim_,dim_);
@@ -89,36 +93,66 @@
 		currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
 
-		if(tomato_ == NULL) return;		
-		
-		tomato_->radius_ = acos((currentDir_.dotProduct(tomato_->pos_ - shipPos_))/
-			((tomato_->pos_ - shipPos_).length()*currentDir_.length()));
-        tomato_->phi_ = acos((currentOrth_.dotProduct(tomato_->pos_ - shipPos_))/
-        	((tomato_->pos_ - shipPos_).length()*currentOrth_.length()));
-        if((currentDir_.crossProduct(currentOrth_)).dotProduct(tomato_->pos_ - shipPos_) > 0) 
-        	tomato_->right_ = true;
-        else tomato_->right_=false;
+        RadarObject* ro = firstRadarObject_;
+        // iterate through all RadarObjects
+		while(ro != NULL){
+            ro->radius_ = calcRadius(ro);
+            ro->phi_ = calcPhi(ro);
+            ro->right_ = calcRight(ro);
+            if (ro->right_){
+                ro->panel_->setPosition(sin(ro->phi_)*ro->radius_/
+                    3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2);
+            }
+            else {
+                ro->panel_->setPosition(-sin(ro->phi_)*ro->radius_/
+                    3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2);
+            }
+            ro = ro->next;
+		}
+    }
 
-        if (tomato_->right_){
-            tomato_->panel_->setPosition(sin(tomato_->phi_)*tomato_->radius_/
-            	3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2);
+    void RadarOverlayElement::addObject(Vector3 pos){
+        if(firstRadarObject_ == NULL){
+            firstRadarObject_ = new RadarObject(container_);
+            firstRadarObject_->pos_ = pos;
+            lastRadarObject_ = firstRadarObject_;
         }
-        else {
-            tomato_->panel_->setPosition(-sin(tomato_->phi_)*tomato_->radius_/
-            	3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2);
+        else{
+            lastRadarObject_->next = new RadarObject(container_);
+            lastRadarObject_->next->pos_ = pos;
+            lastRadarObject_ = lastRadarObject_->next;
         }
-        COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
-        COUT(3) << tomato_->radius_ << "  " << tomato_->phi_ << std::endl;
-        COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
-    }
-    
-    void RadarOverlayElement::addObject(Vector3 pos){
-		tomato_ = new RadarObject(container_);
-		tomato_->pos_ = pos;
 	}
-	
-	//// RadarObject ////
-	
-	int RadarObject::count = 0;
-	
+
+	void RadarOverlayElement::listObjects(){
+	    int i = 0;
+	    RadarObject* ro = firstRadarObject_;
+	    COUT(3) << "List of RadarObjects:\n";
+	    // iterate through all Radar Objects
+	    while(ro != NULL) {
+	        COUT(3) << i++ << ": " << ro->pos_ << std::endl;
+	        ro = ro->next;
+	    }
+	}
+
+	float RadarOverlayElement::calcRadius(RadarObject* obj){
+	    return(acos((currentDir_.dotProduct(obj->pos_ - shipPos_))/
+			((obj->pos_ - shipPos_).length()*currentDir_.length())));
+	}
+
+	float RadarOverlayElement::calcPhi(RadarObject* obj){
+	    return(acos((currentOrth_.dotProduct(firstRadarObject_->pos_ - shipPos_))/
+        	((firstRadarObject_->pos_ - shipPos_).length()*currentOrth_.length())));
+	}
+
+	bool RadarOverlayElement::calcRight(RadarObject* obj){
+	    if((currentDir_.crossProduct(currentOrth_)).dotProduct(obj->pos_ - shipPos_) > 0)
+        	return true;
+        else return false;
+	}
+
+//////// RadarObject ////////
+
+	int RadarObject::count = 0;		// initialize static variable
+
 	RadarObject::RadarObject(Ogre::OverlayContainer* container){
 		container_ = container;
@@ -126,5 +160,5 @@
 		init();
 	}
-	
+
 	RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){
 		container_ = container;
@@ -132,8 +166,9 @@
 		init();
 	}
-	
+
 	RadarObject::~RadarObject(){}
-	
+
 	void RadarObject::init(){
+	    next = NULL;
 		om = &Ogre::OverlayManager::getSingleton();
 		panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel",
@@ -147,4 +182,7 @@
 }
 
-
-
+/* my local clipboard...
+COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
+COUT(3) << firstRadarObject_->radius_ << "  " << firstRadarObject_->phi_ << std::endl;
+COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
+*/
