Index: code/branches/hud3/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1335)
@@ -34,5 +34,5 @@
 #include <OgreEntity.h>
 #include "core/Debug.h"
-
+#include "objects/SpaceShip.h"
 #include "HUD.h"
 #include "BarOverlayElement.h"
@@ -46,25 +46,26 @@
     HUD::HUD(int zoom){
         om = &Ogre::OverlayManager::getSingleton();
-
+		
+		// create Factories
         BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
         om->addOverlayElementFactory(barOverlayElementFactory);
-
         RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
         om->addOverlayElementFactory(radarOverlayElementFactory);
 
         orxonoxHUD = om->create("Orxonox/HUD");
-
         container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container"));
-
-        energyCounter = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyCounter"));
-        energyCounter->show();
-
-        speedo = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "speedo"));
-        speedo->show();
-
+        // create energy bar    
+        energyBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyBar"));
+        energyBar->show();
+        // create speedo bar
+        speedoBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "speedoBar"));
+        speedoBar->show();
+        // create radar
         radar = static_cast<RadarOverlayElement*>(om->createOverlayElement("Radar", "radar"));
         radar->show();
 
+		// set up screen-wide container
         container->show();
+        
         orxonoxHUD->add2D(container);
         orxonoxHUD->show();
@@ -74,21 +75,19 @@
         container->setHeight(1.0);
         container->setMetricsMode(Ogre::GMM_RELATIVE);
-
-        energyCounter->init(0.01, 0.95, 0.4, 0.04, container);
-        energyCounter->setValue(1);
-
-        speedo->init(0.01, 0.90, 0.4, 0.04, container);
-
+        energyBar->init(0.01, 0.94, 0.4, 0.04, container);
+        energyBar->setValue(1);
+        speedoBar->init(0.01, 0.90, 0.4, 0.04, container);
         radar->init(0.5, 0.9, 0.2, container);
+        radar->addObject(Vector3(1337.0, 0.0, 0.0));
     }
 
     void HUD::tick(float dt)
     {
-        energyCounter->resize();
+        energyBar->resize();
 
         float v = SpaceShip::instance_s->getVelocity().length();
         float vmax = SpaceShip::instance_s->getMaxSpeed();
-        speedo->setValue(v/vmax);
-        speedo->resize();
+        speedoBar->setValue(v/vmax);
+        speedoBar->resize();
 
         radar->resize();
Index: code/branches/hud3/src/orxonox/hud/HUD.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1335)
@@ -32,9 +32,7 @@
 #include <string.h>
 #include <OgreOverlayElement.h>
-#include <OgreTextAreaOverlayElement.h>
 #include <OgrePrerequisites.h>
 
 #include "OrxonoxPrereqs.h"
-#include "objects/SpaceShip.h"
 #include "core/Tickable.h"
 #include "BarOverlayElement.h"
@@ -50,6 +48,6 @@
             Ogre::Overlay* orxonoxHUD;
             Ogre::OverlayContainer* container;
-            BarOverlayElement* energyCounter;
-            BarOverlayElement* speedo;
+            BarOverlayElement* energyBar;
+            BarOverlayElement* speedoBar;
             RadarOverlayElement* radar;
 
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1335)
@@ -53,10 +53,6 @@
     }
 
-    void RadarOverlayElement::initialise(){
-        PanelOverlayElement::initialise();
-    }
-
     void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
-        count_ = 0;
+		om = &Ogre::OverlayManager::getSingleton();        
         dimRel_ = dimRel;
         leftRel_ = leftRel;
@@ -65,5 +61,4 @@
 
         shipPos_ = Vector3(0.0, 0.0, 0.0);
-        targetPos_ = Vector3(1337.0, 0.0, 0.0);
         initialDir_ = Vector3(1.0, 0.0, 0.0);
         currentDir_ = initialDir_;
@@ -74,14 +69,6 @@
         setMaterialName("Orxonox/Radar");
         resize();
-
-        om = &Ogre::OverlayManager::getSingleton();
-        point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point"));
-        point->show();
-        container->addChild(this);
-        container->addChild(point);
-        point->setMaterialName("Orxonox/RedDot");
-        point->setDimensions(5,5);
-        point->setMetricsMode(Ogre::GMM_PIXELS);
-
+        
+        container_->addChild(this);
     }
 
@@ -102,19 +89,62 @@
 		currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
 
-		radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
-        phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
-        if((currentDir_.crossProduct(currentOrth_)).dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
-        else right_=false;
+		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;
 
-        if (right_){
-            point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
+        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);
         }
         else {
-            point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
+            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){
+		tomato_ = new RadarObject(container_);
+		tomato_->pos_ = pos;
+	}
+	
+	//// RadarObject ////
+	
+	int RadarObject::count = 0;
+	
+	RadarObject::RadarObject(Ogre::OverlayContainer* container){
+		container_ = container;
+		pos_ = Vector3(0.0, 0.0, 0.0);
+		init();
+	}
+	
+	RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){
+		container_ = container;
+		pos_ = pos;
+		init();
+	}
+	
+	RadarObject::~RadarObject(){}
+	
+	void RadarObject::init(){
+		om = &Ogre::OverlayManager::getSingleton();
+		panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel",
+			"Object"+Ogre::StringConverter::toString(count++)));
+		panel_->setMaterialName("Orxonox/RedDot");
+		panel_->setDimensions(5,5);
+        panel_->setMetricsMode(Ogre::GMM_PIXELS);
+        panel_->show();
+        container_->addChild(panel_);
+	}
 }
 
-
-
+/* my local clipboard...
+COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
+COUT(3) << tomato_->radius_ << "  " << tomato_->phi_ << std::endl;
+COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
+*/
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~	(revision 1335)
@@ -41,4 +41,5 @@
 #include <OgreStringConverter.h>
 #include "RadarOverlayElement.h"
+#include "GraphicsEngine.h"
 
 namespace orxonox
@@ -52,71 +53,96 @@
     }
 
-    void RadarOverlayElement::initialise(){
-        PanelOverlayElement::initialise();
-    }
-
-    void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
-        dim_ = dim;
-        left_ = left;
-        top_ = top;
-        count_ = 100;
+    void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
+		om = &Ogre::OverlayManager::getSingleton();        
+        dimRel_ = dimRel;
+        leftRel_ = leftRel;
+        topRel_ = topRel;
         container_ = container;
 
         shipPos_ = Vector3(0.0, 0.0, 0.0);
-        targetPos_ = Vector3(42.0, 0.0, 0.0);
         initialDir_ = Vector3(1.0, 0.0, 0.0);
         currentDir_ = initialDir_;
         initialOrth_ = Vector3(0.0, 0.0, 1.0);
         currentOrth_ = initialOrth_;
-     
+
         setMetricsMode(Ogre::GMM_PIXELS);
-        setPosition(left,top);
-        setDimensions(dim_,dim_);
         setMaterialName("Orxonox/Radar");
-
-        om = &Ogre::OverlayManager::getSingleton();
-        point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point"));
-        point->show();
-        container->addChild(point);
-        point->setMaterialName("Orxonox/RedPoint");
-        point->setDimensions(5,5);
-        point->setMetricsMode(Ogre::GMM_PIXELS);
-
+        resize();
+        
+        container_->addChild(this);
     }
 
-//    void RadarOverlayElement::setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ){
-//        dirX_=dirX;
-//        dirY_=dirY;
-//        dirZ_=dirZ;
-//        ortX_=ortX;
-//        ortY_=ortY;
-//        ortZ_=ortZ;
-//    }
+    void RadarOverlayElement::resize() {
+        // if window is resized, we must adapt these...
+        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        dim_ = dimRel_*windowH_;
+        left_ = leftRel_*windowW_-dim_/2;
+        top_ = topRel_*windowH_-dim_/2;
+        setPosition(left_, top_);
+        setDimensions(dim_,dim_);
+    }
 
     void RadarOverlayElement::update() {
-    	if(count_++ >= 100) {		// for testing purposes
-			count_ = 0;
-			COUT(3) << "pos:  " << shipPos_ << std::endl;
-			COUT(3) << "dir:  " << currentDir_ << std::endl;
-			COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl;     	
-    	}
         shipPos_ = SpaceShip::instance_s->getPosition();
         currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; 		// according to beni....
 		currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
+
+		if(tomato_ == NULL) return;		
 		
-		radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
-        phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
-        vec_ = currentDir_.crossProduct(currentOrth_);
-        if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
-        else right_=false;
-        
-        if (right_){
-            point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);         
+		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;
+
+        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);
         }
         else {
-            point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
+            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);
         }
+        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;
+	
+	RadarObject::RadarObject(Ogre::OverlayContainer* container){
+		container_ = container;
+		pos_ = Vector3(0.0, 0.0, 0.0);
+		init();
+	}
+	
+	RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){
+		container_ = container;
+		pos_ = pos;
+		init();
+	}
+	
+	RadarObject::~RadarObject(){}
+	
+	void RadarObject::init(){
+		om = &Ogre::OverlayManager::getSingleton();
+		panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel",
+			"Object"+Ogre::StringConverter::toString(count++)));
+		panel_->setMaterialName("Orxonox/RedDot");
+		panel_->setDimensions(5,5);
+        panel_->setMetricsMode(Ogre::GMM_PIXELS);
+        panel_->show();
+        container_->addChild(panel_);
+	}
 }
 
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h	(revision 1335)
@@ -41,36 +41,49 @@
 namespace orxonox
 {
+    class _OrxonoxExport RadarObject
+    {
+    	private:
+    		Ogre::OverlayManager* om;				// our one and only overlay manager
+    		void init();
+    		
+    	public:
+    		RadarObject(Ogre::OverlayContainer* container);
+    		RadarObject(Ogre::OverlayContainer* container, Vector3 pos);
+    		~RadarObject();
+    		
+    		Vector3 pos_;							// position in space
+			Ogre::Real radius_, phi_;				// position on radar
+			bool right_;
+			Ogre::OverlayContainer* container_;
+			Ogre::PanelOverlayElement* panel_;		// the panel used to show the dot
+			
+    		static int count;
+	};
+
     class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement
     {
         private:
-            Ogre::PanelOverlayElement* point;
+            Ogre::OverlayManager* om;               // our one and only overlay manager
             Ogre::OverlayContainer* container_;
-            Ogre::OverlayManager* om;               // pointer to the one and only overlay manager
             Vector3 initialDir_;	                // direction of nose
-            Vector3 currentDir_;
+            Vector3 currentDir_;					
             Vector3 initialOrth_;                   // direction of normal
             Vector3 currentOrth_;
-            Vector3 targetPos_;                     // position of target
             Vector3 shipPos_;                       // position of ship
-
-            Ogre::Real radius_;                     // radius on the radar
-            Ogre::Real phi_;                        // angle on the radar
-            bool right_;                            // checks whether the object is on the right side (since cos is not bijective)
+            
+			RadarObject* tomato_;            
+            
             Ogre::Real leftRel_, topRel_, dimRel_;  // relative position/dimension
             int left_, top_, dim_;                  // absolute position/dimension
-            int windowW_, windowH_;                   // absolute window dimensions
-            int count_;
+            int windowW_, windowH_;             	// absolute window dimensions
 
         public:
             RadarOverlayElement(const Ogre::String& name);
-            virtual ~RadarOverlayElement();
-            virtual void initialise();
+            ~RadarOverlayElement();
+            void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
+			void resize();            
             void update();
-            void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
-            void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ);
-            int newShip(int X, int Y, int Z);
-            void resize();
-            void resetShip(int shipID, int Y, int Z);
-    };
+            void addObject(Vector3 pos);
+	};
 }
 
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h~
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h~	(revision 1334)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h~	(revision 1335)
@@ -32,45 +32,58 @@
 #include <OgreOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
-#include <math.h>
 #include <util/Math.h>
 #include <string.h>
-#include <Tickable.h>
+#include "core/Tickable.h"
 #include <OgrePrerequisites.h>
+#include "objects/SpaceShip.h"
 #include "../OrxonoxPrereqs.h"
 
 namespace orxonox
 {
+    class _OrxonoxExport RadarObject
+    {
+    	private:
+    		Ogre::OverlayManager* om;				// our one and only overlay manager
+    		
+    	public:
+    		RadarObject(Ogre::OverlayContainer* container);
+    		RadarObject(Ogre::OverlayContainer* container, Vector3 pos);
+    		~RadarObject();
+    		
+    		Vector3 pos_;							// position in space
+			Ogre::Real radius_, phi_;				// position on radar
+			bool right_;
+			Ogre::OverlayContainer* container_;
+			Ogre::PanelOverlayElement* panel_;		// the panel used to show the dot
+			
+    		static int count;
+	};
 
-  class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement, public Tickable
-  {
-  private:
-    
-    PanelOverlayElement* point[100];
-    
-    Vector3 initialDir;		//initial direction
-    int dirX_, dirY_, dirZ_;    //flying direction
-    int ortX_, ortY_, ortZ_;    //orthogonal direction
-    int dX_, dY_, dZ_;          //distance between main ship and the object
-    int vecX_, vecY_, vecZ_;    //vector product dir X ort
-    double alpha_;              //defines the radius in the radar
-    double beta_;               //defines the angle in the radar
-    bool right_;                //checks whether the object is on the right side (since cos is not bijective)
-    
-//    static int ID = 0;
+    class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement
+    {
+        private:
+            Ogre::OverlayManager* om;               // our one and only overlay manager
+            Ogre::OverlayContainer* container_;
+            Vector3 initialDir_;	                // direction of nose
+            Vector3 currentDir_;					
+            Vector3 initialOrth_;                   // direction of normal
+            Vector3 currentOrth_;
+            Vector3 shipPos_;                       // position of ship
+            
+			RadarObject* tomato_;            
+            
+            Ogre::Real leftRel_, topRel_, dimRel_;  // relative position/dimension
+            int left_, top_, dim_;                  // absolute position/dimension
+            int windowW_, windowH_;             	// absolute window dimensions
 
-  public:
-    
-    RadarOverlayElement(const Ogre::String& name);
-    virtual ~RadarOverlayElement();
-    virtual void initialise();
-
-    void initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container);
-    void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ);
-    void tick(float dt); 
-    int newShip(int X, int Y, int Z);
-    
-    void resetShip(int shipID, int Y, int Z);
-  };
-}	
+        public:
+            RadarOverlayElement(const Ogre::String& name);
+            ~RadarOverlayElement();
+            void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
+			void resize();            
+            void update();
+            void addObject(Vector3 pos);
+	};
+}
 
 #endif
