Index: code/branches/hud3/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1301)
+++ code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1302)
@@ -30,5 +30,5 @@
 #include <OgreOverlay.h>
 #include <OgreOverlayContainer.h>
-#include <OgreOverlayManager.h>ma
+#include <OgreOverlayManager.h>
 #include <OgreSceneNode.h>
 #include <OgreEntity.h>
@@ -50,28 +50,28 @@
 
     Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
-    
+
     BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
     overlayManager.addOverlayElementFactory(barOverlayElementFactory);
-    
+
     SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory();
     overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory);
-    
+
     RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
     overlayManager.addOverlayElementFactory(radarOverlayElementFactory);
-    
-    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 
+
+    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
 
     Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
-    
+
     energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter"));
     energyCounter->show();
-    
-    
+
+
     radar = static_cast<RadarOverlayElement*>(overlayManager.createOverlayElement("Radar", "radar"));
     radar->show();
 
-    
+
 /*    TextAreaOverlayElement* test = static_cast<TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "test"));
-    
+
     int dirX, dirY, dirZ;      //flying direction
     int ortX, ortY, ortZ;      //orthogonal direction
@@ -81,17 +81,17 @@
     double beta;               //defines the angle in the radar
     bool right;                //checks whether the object is on the right side (since cos is not bijective)
-    
+
     dirX = 1;
     dirY = 0;
     dirZ = 0;
-    
+
     ortX = 0;
     ortY = 0;
     ortZ = 1;
-    
+
     dX = -2;
     dY = 2;
     dZ = 0;
-    
+
     alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))));
     beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))));
@@ -99,30 +99,30 @@
     vecY = dirZ*ortX - dirX*ortZ;
     vecZ = dirX*ortY - dirY*ortX;
-    
+
     if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;}
     else right=false;
-    
+
     test->setCaption("hell");
     test->setPosition(10,10);
     test->setDimensions(20,20);
     test->show();
-    test->setMetricsMode(Ogre::GMM_PIXELS);	
+    test->setMetricsMode(Ogre::GMM_PIXELS);
     energyCounterPanel->addChild(test);
-    
+
     COUT(0)<<alpha<<" "<<beta<<" "<<right<<std::endl;
 */
-    
+
     energyCounterPanel->addChild(energyCounter);
     energyCounterPanel->addChild(radar);
     energyCounterPanel->show();
-    
+
     orxonoxOverlay->add2D(energyCounterPanel);
     orxonoxOverlay->show();
 
-    
-    
+
+
     // important: don't use SceneManager to create the node! but register the creator scene manager.
 /*    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
-    
+
     ogreNode_->setPosition(80,-60,-200);
     ogreNode_->setScale(0.4,0.4,0.4);
@@ -132,5 +132,5 @@
 //    orxonoxOverlay->add3D(ogreNode_);
 */
-   
+
     energyCounterPanel->setLeft(-50);
     energyCounterPanel->setTop(10);
@@ -138,27 +138,26 @@
     energyCounterPanel->setHeight(20);
     energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER);
-    energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);	
-        
+    energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);
+
     energyCounter->initSmartBarOverlayElement(-100,0,200,20,BarOverlayElement::LEFT);
     energyCounter->reset(80);
-    
+
     radar->initRadarOverlayElement(10,10,200,energyCounterPanel);
 
-    
+
   }
 
-/*  void HUD::tick(float dt)
+  void HUD::tick(float dt)
   {
-    if (this->ogreNode_)
+      radar->update();
+    /*if (this->ogreNode_)
     {
       this->ogreNode_->roll(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
-      this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL); 
+      this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
       this->ogreNode_->pitch(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
-    }
+    }*/
   }
-*/
+
   HUD::~HUD(void){}
-
-
 
 }
Index: code/branches/hud3/src/orxonox/hud/HUD.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1301)
+++ code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1302)
@@ -44,5 +44,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUD// : Tickable
+  class _OrxonoxExport HUD : Tickable
   {
   private:
@@ -52,12 +52,11 @@
     ~HUD();
 
-//    virtual void tick(float);
+    virtual void tick(float);
 
     SmartBarOverlayElement* energyCounter;
-    
+
     RadarOverlayElement* radar;
-//    Ogre::SceneNode* ogreNode_;
   };
-}	
+}
 
 #endif
Index: code/branches/hud3/src/orxonox/hud/OverlayElementFactories.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/OverlayElementFactories.h	(revision 1301)
+++ code/branches/hud3/src/orxonox/hud/OverlayElementFactories.h	(revision 1302)
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1301)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc	(revision 1302)
@@ -26,5 +26,5 @@
 */
 
-/*	local coordinate system of space ship:
+/*	local coordinate system of space ship at the beginning:
 
 			y
@@ -33,5 +33,5 @@
 			| /
 			|/
-	       x +------O
+   x +------O
 */
 
@@ -42,80 +42,80 @@
 #include "RadarOverlayElement.h"
 
-
 namespace orxonox
 {
-  using namespace Ogre;
+    using namespace Ogre;
 
-  RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){
-    initialDir = Vector3(0.0, 0.0, 1.0);
-  }
+    RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){
+    }
 
-  RadarOverlayElement::~RadarOverlayElement(){}
+    RadarOverlayElement::~RadarOverlayElement(){
+    }
 
-  void RadarOverlayElement::initialise(){
-    PanelOverlayElement::initialise();
-  }
-  
-  void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
+    void RadarOverlayElement::initialise(){
+        PanelOverlayElement::initialise();
+    }
 
-    dirX_ = 0;	// direction of travel
-    dirY_ = 0;
-    dirZ_ = 1;
-    
-    ortX_ = 0;	// normal of ship
-    ortY_ = 1;
-    ortZ_ = 0;
-    
-    dX_ = 37;
-    dY_ = 0;
-    dZ_ = 0;
-    
-    alpha_ = acos((dirX_*dX_+dirY_*dY_+dirZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(dirX_,2)+pow(dirY_,2)+pow(dirZ_,2))));
-    beta_ = acos((ortX_*dX_+ortY_*dY_+ortZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(ortX_,2)+pow(ortY_,2)+pow(ortZ_,2))));
-    vecX_ = dirY_*ortZ_ - dirZ_*ortY_;
-    vecY_ = dirZ_*ortX_ - dirX_*ortZ_;
-    vecZ_ = dirX_*ortY_ - dirY_*ortX_;
-    
-    if((vecX_*dX_+vecY_*dY_+vecZ_*dZ_)>0){right_=true;}
-    else right_=false;
-    
-    setMetricsMode(Ogre::GMM_PIXELS);
-    setPosition(left,top);
-    setDimensions(dim,dim);
-    setMaterialName("Orxonox/Radar");
-    
-    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
+    void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
+        dim_ = dim;
+        left_ = left;
+        top_ = top;
+        count_ = 0;
+        container_ = container;
 
-    PanelOverlayElement* point = static_cast<PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "point"));
-    point->show();
-    
-    container->addChild(point);
-    
-    if (right_){
-      point->setPosition(sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
-      point->setMaterialName("Orxonox/RedPoint");
-      point->setDimensions(5,5);
-      point->setMetricsMode(Ogre::GMM_PIXELS);
+        shipPos_ = Vector3(0.0, 0.0, 0.0);
+        targetPos_ = Vector3(42.0, 42.0, 0.0);
+        initialDir_ = Vector3(0.0, 0.0, 1.0);
+        currentDir_ = initialDir_;
+        initialOrth_ = Vector3(0.0, 1.0, 0.0);
+        currentOrth_ = initialOrth_;
+
+        alpha_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
+        beta_ = 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;
+
+        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);
+
+        if (right_){
+            point->setPosition(sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
+            point->setMaterialName("Orxonox/RedPoint");
+            point->setDimensions(5,5);
+            point->setMetricsMode(Ogre::GMM_PIXELS);
+        }
+
+        else {
+            point->setPosition(-sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
+            point->setMaterialName("Orxonox/RedPoint");
+            point->setDimensions(5,5);
+            point->setMetricsMode(Ogre::GMM_PIXELS);
+        }
     }
-  
-    else {
-      point->setPosition(-sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
-      point->setMaterialName("Orxonox/RedPoint");
-      point->setDimensions(5,5);
-      point->setMetricsMode(Ogre::GMM_PIXELS);
+
+//    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::update() {
+        shipPos_ = SpaceShip::instance_s->getPosition();
+        currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni....
     }
-  } 
-   
-  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;
-  }
-  
-  
-  
+
 }
 
Index: code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
===================================================================
--- code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h	(revision 1301)
+++ code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h	(revision 1302)
@@ -32,9 +32,9 @@
 #include <OgreOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
-#include <math.h>
 #include <util/Math.h>
 #include <string.h>
 #include "core/Tickable.h"
 #include <OgrePrerequisites.h>
+#include "objects/SpaceShip.h"
 #include "../OrxonoxPrereqs.h"
 
@@ -42,35 +42,38 @@
 {
 
-  class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement, public Tickable
+  class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement
   {
   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;
+
+    Ogre::PanelOverlayElement* point;
+    Ogre::OverlayContainer* container_;
+    Ogre::OverlayManager* om;       //pointer to the one and only overlay manager
+    Vector3 initialDir_;	        //initial direction of ship
+    Vector3 currentDir_;            //current direction of ship
+    Vector3 initialOrth_;
+    Vector3 currentOrth_;
+    Vector3 targetPos_;             //position of target
+    Vector3 shipPos_;               //position of ship
+    Vector3 vec_;                   //vector product dir X ort
+    double alpha_;                  //defines the radius in the radar
+    double beta_;                   //defines the angle in the radar
+    float left_, top_;
+    bool right_;                    //checks whether the object is on the right side (since cos is not bijective)
+    int count_;
+    int dim_;
 
   public:
-    
+
     RadarOverlayElement(const Ogre::String& name);
     virtual ~RadarOverlayElement();
     virtual void initialise();
-
+    void update();
     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);
   };
-}	
+}
 
 #endif
Index: code/branches/hud3/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/branches/hud3/src/orxonox/objects/SpaceShip.h	(revision 1301)
+++ code/branches/hud3/src/orxonox/objects/SpaceShip.h	(revision 1302)
@@ -64,5 +64,5 @@
 
             void getFocus();
-
+	    static SpaceShip* instance_s;
 	    static Vector3 getSPosition();
 	    static Quaternion getSOrientation();
@@ -80,5 +80,4 @@
         private:
             void createCamera();
-            static SpaceShip* instance_s;
 
             Vector3 testvector_;
