Index: code/branches/hud/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/hud/src/orxonox/CMakeLists.txt	(revision 1588)
+++ code/branches/hud/src/orxonox/CMakeLists.txt	(revision 1590)
@@ -18,4 +18,5 @@
   tools/ParticleInterface.cc
   tools/Timer.cc
+  tools/WindowEventListener.cc
 
   objects/Ambient.cc
Index: code/branches/hud/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/branches/hud/src/orxonox/GraphicsEngine.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/GraphicsEngine.cc	(revision 1590)
@@ -50,5 +50,4 @@
 #include "core/CommandExecutor.h"
 #include "core/ConsoleCommand.h"
-#include "core/input/InputManager.h"
 
 #include "console/InGameConsole.h"
@@ -56,7 +55,9 @@
 #include "tools/ParticleInterface.h"
 #include "Settings.h"
-
-
-namespace orxonox {
+#include "tools/WindowEventListener.h"
+
+
+namespace orxonox
+{
   /**
     @brief Returns the singleton instance and creates it the first time.
@@ -435,10 +436,11 @@
 
   /**
-  * Window has resized.
+  * Window has moved.
   * @param rw The render window it occured in
   */
   void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
   {
-    // note: this doesn't change the window extents
+    for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+      it->windowMoved();
   }
 
@@ -451,28 +453,25 @@
   void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
   {
-    // change the mouse clipping size for absolute mouse movements
-    int w = rw->getWidth();
-    int h = rw->getHeight();
-    InputManager::setWindowExtents(w, h);
-    InGameConsole::getInstance().resize();
-    HUD::getSingleton().resize();
-  }
-
-  /**
-  * Window has resized.
+    for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+      it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+  }
+
+  /**
+  * Window has changed Focus.
   * @param rw The render window it occured in
   */
   void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
   {
-    // note: this doesn't change the window extents
-  }
-
-  /**
-  * Window has resized.
+    for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+      it->windowFocusChanged();
+  }
+
+  /**
+  * Window was closed.
   * @param rw The render window it occured in
   */
   void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
   {
-    // using CommandExecutor in order to avoid depending on Orxonox class.
+    // using CommandExecutor in order to avoid depending on Orxonox.h.
     CommandExecutor::execute("exit", false);
   }
Index: code/branches/hud/src/orxonox/GraphicsEngine.h
===================================================================
--- code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1588)
+++ code/branches/hud/src/orxonox/GraphicsEngine.h	(revision 1590)
@@ -47,6 +47,6 @@
 
 
-namespace orxonox {
-
+namespace orxonox
+{
     /**
     @brief Graphics engine manager class
Index: code/branches/hud/src/orxonox/console/InGameConsole.cc
===================================================================
--- code/branches/hud/src/orxonox/console/InGameConsole.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/console/InGameConsole.cc	(revision 1590)
@@ -170,5 +170,5 @@
         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
 
-        this->resize();
+        this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
 
         // move overlay "above" the top edge of the screen
@@ -370,8 +370,8 @@
         @brief Resizes the console elements. Call if window size changes.
     */
-    void InGameConsole::resize()
-    {
-        this->windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
-        this->windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+    void InGameConsole::windowResized(int newWidth, int newHeight)
+    {
+        this->windowW_ = newWidth;
+        this->windowH_ = newHeight;
         this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
         this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
@@ -468,5 +468,5 @@
             Shell::getInstance().registerListener(this);
 
-            this->resize();
+            this->windowResized(this->windowW_, this->windowH_);
             this->linesChanged();
             this->cursorChanged();
Index: code/branches/hud/src/orxonox/console/InGameConsole.h
===================================================================
--- code/branches/hud/src/orxonox/console/InGameConsole.h	(revision 1588)
+++ code/branches/hud/src/orxonox/console/InGameConsole.h	(revision 1590)
@@ -38,9 +38,10 @@
 #include "core/Shell.h"
 #include "objects/Tickable.h"
+#include "tools/WindowEventListener.h"
 
 
 namespace orxonox
 {
-    class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener
+    class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener
     {
         public: // functions
@@ -50,5 +51,4 @@
 
             void tick(float dt);
-            void resize();
 
             static InGameConsole& getInstance();
@@ -76,4 +76,6 @@
             void setCursorPosition(unsigned int pos);
             void print(const std::string& text, int index, bool alwaysShift = false);
+
+            void windowResized(int newWidth, int newHeight);
 
             static Ogre::UTFString convert2UTF(std::string s);
Index: code/branches/hud/src/orxonox/hud/HUD.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/HUD.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUD.cc	(revision 1590)
@@ -107,8 +107,4 @@
                 Ogre::OverlayManager::getSingleton().destroy(this->orxonoxHUD_);
             this->orxonoxHUD_ = 0;
-
-            if (this->nav_)
-                delete this->nav_;
-            this->nav_ = 0;
         }
 
@@ -143,7 +139,4 @@
         radar_->init(0.5, 0.9, 0.2, container_);
 
-        // create Navigation
-        nav_ = new Navigation(container_);
-
         WorldEntity* object;
         object = new WorldEntity();
@@ -189,8 +182,7 @@
     {
         radar_->update();
-        nav_->update();
-    }
-
-    void HUD::resize()
+    }
+
+    void HUD::windowResized(int newWidth, int newHeight)
     {
         this->radar_->resize();
@@ -215,6 +207,6 @@
             if ((*it)->getObject() == object)
             {
-                if (this->nav_ && this->nav_->getFocus() == (*it))
-                    this->nav_->releaseFocus();
+                /*if (this->nav_ && this->nav_->getFocus() == (*it))
+                    this->nav_->releaseFocus();*/
 
                 delete (*it);
@@ -243,10 +235,15 @@
     }
 
-    /*static*/ void HUD::cycleNavigationFocus(){
-        HUD::getSingleton().nav_->cycleFocus();
+    /*static*/ void HUD::cycleNavigationFocus()
+    {
+        if (HUD::getSingleton().hudElements_.find("Navigation") != HUD::getSingleton().hudElements_.end())
+        {
+            Navigation* navi = dynamic_cast<Navigation*>(HUD::getSingleton().hudElements_["Navigation"]);
+            navi->cycleFocus();
+        }
     }
 
     /*static*/ void HUD::releaseNavigationFocus(){
-        HUD::getSingleton().nav_->releaseFocus();
+        //HUD::getSingleton().nav_->releaseFocus();
     }
 }
Index: code/branches/hud/src/orxonox/hud/HUD.h
===================================================================
--- code/branches/hud/src/orxonox/hud/HUD.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/HUD.h	(revision 1590)
@@ -39,4 +39,5 @@
 #include "util/Math.h"
 #include "OverlayElementFactories.h"
+#include "tools/WindowEventListener.h"
 
 namespace orxonox
@@ -45,5 +46,5 @@
     class HUDOverlay;
 
-    class _OrxonoxExport HUD : public BaseObject, public TickableReal
+    class _OrxonoxExport HUD : public BaseObject, public TickableReal, public WindowEventListener
     {
       public:
@@ -76,4 +77,6 @@
         HUDOverlay* getHUDElement(unsigned int index);
 
+        void windowResized(int newWidth, int newHeight);
+
         std::map<std::string, HUDOverlay*> hudElements_;
 
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 1590)
@@ -75,33 +75,39 @@
         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_);
+        if (mode == XMLPort::LoadObject)
+        {
+            // 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 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_);
+            // 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));
+        if (mode == XMLPort::LoadObject)
+        {
+            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));
+        }
     }
 
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 1590)
@@ -42,5 +42,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDBar : public HUDOverlay, public TickableReal
+  class _OrxonoxExport HUDBar : public HUDOverlay
   {
     public:
@@ -49,6 +49,4 @@
 
       virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-
-      //virtual void tick(float dt) { }
 
       void setValue(float value);
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 1590)
@@ -36,5 +36,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDFPSText : public HUDText
+  class _OrxonoxExport HUDFPSText : public HUDText, public Tickable
   {
   public:
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 1590)
@@ -33,8 +33,8 @@
 #include "util/Convert.h"
 #include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
 
 namespace orxonox
 {
-  CreateFactory(HUDOverlay);
   unsigned int HUDOverlay::hudOverlayCounter_s = 0;
 
@@ -49,6 +49,13 @@
     BaseObject::XMLPort(xmlElement, mode);
 
-    overlay_ = Ogre::OverlayManager::getSingleton().create("HUDOverlay"
-          + convertToString(hudOverlayCounter_s++) + "_" + this->getName());
+    if (mode == XMLPort::LoadObject)
+    {
+      overlay_ = Ogre::OverlayManager::getSingleton().create("HUDOverlay"
+            + convertToString(hudOverlayCounter_s++) + "_" + this->getName());
+
+      this->windowWidth_ = GraphicsEngine::getSingleton().getWindowWidth();
+      this->windowHeight_ = GraphicsEngine::getSingleton().getWindowHeight();
+      this->windowAspectRatio_ = windowWidth_/(float)windowHeight_;
+    }
 
     XMLPortParam(HUDOverlay, "scale", setScale, getScale, xmlElement, mode);
@@ -56,7 +63,10 @@
     XMLPortParam(HUDOverlay, "rotation", setRotation, getRotation, xmlElement, mode);
 
-    this->overlay_->show();
-    if (!this->isVisible())
-        this->overlay_->hide();
+    if (mode == XMLPort::LoadObject)
+    {
+      this->overlay_->show();
+      if (!this->isVisible())
+          this->overlay_->hide();
+    }
   }
 
@@ -76,3 +86,10 @@
   }
 
+  void HUDOverlay::windowResized(int newWidth, int newHeight)
+  {
+    this->windowWidth_ = newWidth;
+    this->windowHeight_ = newHeight;
+    this->windowAspectRatio_ = windowWidth_/(float)windowHeight_;
+  }
+
 }
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 1590)
@@ -33,4 +33,5 @@
 
 #include <OgrePrerequisites.h>
+#include "tools/WindowEventListener.h"
 #include "util/Math.h"
 #include "core/BaseObject.h"
@@ -38,5 +39,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDOverlay : public BaseObject
+  class _OrxonoxExport HUDOverlay : public BaseObject, public WindowEventListener
   {
     public:
@@ -76,8 +77,13 @@
 
     protected:
+      virtual void windowResized(int newWidth, int newHeight);
+
       Ogre::Overlay* overlay_;
+      float windowAspectRatio_;
+      int windowWidth_;
+      int windowHeight_;
 
-  private:
-    static unsigned int hudOverlayCounter_s;
+    private:
+      static unsigned int hudOverlayCounter_s;
 
   };
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 1590)
@@ -36,5 +36,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDRTRText : public HUDText
+  class _OrxonoxExport HUDRTRText : public HUDText, public Tickable
   {
   public:
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 1590)
@@ -36,5 +36,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDSpeedBar : public HUDBar
+  class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable
   {
     public:
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 1590)
@@ -62,19 +62,22 @@
     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);
+    if (mode == XMLPort::LoadObject)
+    {
+      // 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->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
+      this->text_->setMetricsMode(Ogre::GMM_RELATIVE);
+      this->text_->setPosition(0.0f, 0.0f);
+      this->text_->setCharHeight(1.0f);
+      this->text_->setFontName("Monofur");
 
-    this->overlay_->add2D(this->background_);
-    this->background_->addChild(this->text_);
+      this->overlay_->add2D(this->background_);
+      this->background_->addChild(this->text_);
+    }
 
     XMLPortParam(HUDText, "material", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
@@ -82,5 +85,8 @@
     XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
 
-    this->text_->setCaption(this->caption_);
+    if (mode == XMLPort::LoadObject)
+    {
+      this->text_->setCaption(this->caption_);
+    }
   }
 
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 1590)
@@ -41,5 +41,5 @@
 namespace orxonox
 {
-  class _OrxonoxExport HUDText : public HUDOverlay, public TickableReal
+  class _OrxonoxExport HUDText : public HUDOverlay
   {
   public:
@@ -48,6 +48,4 @@
 
     virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-
-    virtual void tick(float dt) { }
 
   protected:
Index: code/branches/hud/src/orxonox/hud/Navigation.cc
===================================================================
--- code/branches/hud/src/orxonox/hud/Navigation.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/Navigation.cc	(revision 1590)
@@ -23,5 +23,5 @@
  *      Felix Schulthess
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -33,63 +33,151 @@
 #include <OgreStringConverter.h>
 
-#include "GraphicsEngine.h"
+//#include "GraphicsEngine.h"
 // TODO: remove the SpaceShip and CameraHandler dependencies
 #include "objects/SpaceShip.h"
 #include "objects/Projectile.h"
 #include "objects/CameraHandler.h"
+#include "HUD.h"
 #include "RadarObject.h"
 #include "RadarOverlayElement.h"
-#include "HUD.h"
 #include "core/Debug.h"
-#include "util/Math.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
 {
+    CreateFactory(Navigation);
+
     using namespace Ogre;
 
-    Navigation::Navigation(OverlayContainer* container)
-    {
-        container_ = container;
-        focus_ = NULL;
-        init();
+    Navigation::Navigation()
+      : container_(0)
+      , navMarker_(0)
+      , aimMarker_(0)
+      , focus_(0)
+    {
+        RegisterObject(Navigation);
     }
 
     Navigation::~Navigation()
     {
-        OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
-        OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
-        OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
-    }
-
-    void Navigation::init()
-    {
-        // create nav text
-        navText_ = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("TextArea", "navText"));
-        navText_->show();
-        navText_->setMetricsMode(Ogre::GMM_PIXELS);
-        navText_->setDimensions(0.001, 0.001);
-        navText_->setPosition(0.02, 0.02);
-        navText_->setFontName("Console");
-        navText_->setCharHeight(20);
-        navText_->setCaption("");
-        navText_->hide();
-        container_->addChild(navText_);
-
-
-        // create nav marker ...
-        navMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", "NavMarker"));
-        aimMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", "aimMarker"));
-        navMarker_->setMetricsMode(GMM_PIXELS);
-        aimMarker_->setMetricsMode(GMM_PIXELS);
-        navMarker_->hide();
-        aimMarker_->hide();
-        aimMarker_->setMaterialName("Orxonox/NavCrosshair");
-        aimMarker_->setDimensions(20, 20);
-        aimMarker_->setUV(0.0, 0.0, 1.0, 1.0);
-        container_->addChild(navMarker_);
-        container_->addChild(aimMarker_);
-    }
-
-    void Navigation::update()
+        if (this->isInitialized())
+        {
+            if (this->container_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->container_);
+            if (this->navMarker_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
+            if (this->navText_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
+            if (this->aimMarker_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+        }
+    }
+
+    void Navigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        HUDOverlay::XMLPort(xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // create container
+            this->container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer"));
+            this->container_->setMetricsMode(Ogre::GMM_RELATIVE);
+            this->container_->setLeft(0.0);
+            this->container_->setTop(0.0);
+            this->container_->setWidth(1.0);
+            this->container_->setHeight(1.0);
+
+            // create nav text
+            this->navText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_navText"));
+            this->navText_->setMetricsMode(Ogre::GMM_RELATIVE);
+            this->navText_->setPosition(0.0f, 0.0f);
+            this->navText_->setCharHeight(0.05f);
+            this->navText_->setFontName("Monofur");
+
+            // create nav marker
+            navMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navMarker"));
+            navMarker_->setMetricsMode(GMM_RELATIVE);
+            navMarker_->setDimensions(0.05f, 0.05f);
+            navMarker_->setMaterialName("Orxonox/NavArrows");
+            this->wasOutOfView_ = true; // just a to ensure the material is changed right the first time..
+
+            // create aim marker
+            aimMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_aimMarker"));
+            aimMarker_->setMetricsMode(GMM_RELATIVE);
+            aimMarker_->setDimensions(0.05f, 0.05f);
+            aimMarker_->setMaterialName("Orxonox/NavCrosshair");
+            
+            container_->addChild(navMarker_);
+            container_->addChild(aimMarker_);
+            container_->addChild(navText_);
+            container_->show();
+
+            this->overlay_->add2D(container_);
+            this->overlay_->hide();
+        }
+
+        XMLPortParam(Navigation, "font", setFont, getFont, xmlElement, mode);
+        XMLPortParam(Navigation, "textsize", setTextSize, getTextSize, xmlElement, mode);
+        XMLPortParam(Navigation, "navmarkersize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
+        XMLPortParam(Navigation, "aimmarkersize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
+    }
+
+    void Navigation::setNavMarkerSize(Vector2 size)
+    {
+        if (this->navMarker_ && size.squaredLength() >= 0.0f)
+            this->navMarker_->setDimensions(size.x, size.y);
+    }
+
+    Vector2 Navigation::getNavMarkerSize() const
+    {
+        if (this->navMarker_)
+            return Vector2(navMarker_->getWidth(), navMarker_->getHeight());
+        else
+            return Vector2::ZERO;
+    }
+
+    void Navigation::setAimMarkerSize(Vector2 size)
+    {
+        if (this->aimMarker_ && size.squaredLength() >= 0.0f)
+            this->aimMarker_->setDimensions(size.x, size.y);
+    }
+
+    Vector2 Navigation::getAimMarkerSize() const
+    {
+        if (this->aimMarker_)
+            return Vector2(aimMarker_->getWidth(), aimMarker_->getHeight());
+        else
+            return Vector2::ZERO;
+    }
+
+    void Navigation::setFont(const std::string& font)
+    {
+        if (this->navText_ && font != "")
+            this->navText_->setFontName(font);
+    }
+
+    std::string Navigation::getFont() const
+    {
+        if (this->navText_)
+            return this->navText_->getFontName();
+        else
+            return "";
+    }
+
+    void Navigation::setTextSize(float size)
+    {
+        if (this->navText_ && size >= 0.0f)
+            this->navText_->setCharHeight(size);
+    }
+
+    float Navigation::getTextSize() const
+    {
+        if (this->navText_)
+            return this->navText_->getCharHeight();
+        else
+            return 0.0f;
+    }
+
+    void Navigation::tick(float dt)
     {
         if (!focus_)
@@ -101,129 +189,79 @@
     void Navigation::updateMarker()
     {
-        int windowW = GraphicsEngine::getSingleton().getWindowWidth();
-        int windowH = GraphicsEngine::getSingleton().getWindowHeight();
-
         // set text
-        int dist = (int) getDist2Focus()/100;
-        navText_->setCaption(Ogre::StringConverter::toString(dist));
+        int dist = (int) getDist2Focus()/100.0f;
+        navText_->setCaption(convertToString(dist));
+        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
 
         Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
+        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
         // transform to screen coordinates
-        Vector3 pos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * focus_->getPosition();
-        Vector3 aimpos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), Projectile::getSpeed(), focus_->getPosition(), focus_->getOrientedVelocity());
-
-        float xPosRel = 0.5*pos.x+0.5;
-        float yPosRel = 1-(0.5*pos.y+0.5);
-        float xAimPosRel = 0.5*aimpos.x+0.5;
-        float yAimPosRel = 1-(0.5*aimpos.y+0.5);
-        int xPos = (int) (xPosRel*windowW);
-        int yPos = (int) (yPosRel*windowH);
-        int xAimPos = (int) (xAimPosRel*windowW);
-        int yAimPos = (int) (yAimPosRel*windowH);
-        int xFromCenter = xPos-windowW/2;
-        int yFromCenter = yPos-windowH/2;
-
-        // is object in view?
-        Vector3 navCamPos = SpaceShip::getLocalShip()->getPosition();
-        Vector3 currentDir = SpaceShip::getLocalShip()->getDir();
-        Vector3 currentOrth = SpaceShip::getLocalShip()->getOrth();
-        float radius = getAngle(navCamPos, currentDir, focus_->getPosition());
-        bool isRight = (currentDir.crossProduct(currentOrth)).dotProduct(focus_->getPosition() - navCamPos)>0;
-        bool isAbove = currentOrth.dotProduct(focus_->getPosition() - navCamPos)>0;
-        bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1);
-
-        // if object is behind us, it is out of view anyway:
-        if (!outOfView && radius > Ogre::Math::PI / 2)
+        Vector3 pos = transformationMatrix * focus_->getPosition();
+
+        bool outOfView;
+        if (pos.z > 1.0)
+        {
+            // z > 1.0 means that the object is behind the camera
             outOfView = true;
+            // we have to switch all coordinates (if you don't know why,
+            // try linear algebra lectures, because I can't explain..)
+            pos.x = -pos.x;
+            pos.y = -pos.y;
+            pos.z = -pos.z;
+        }
+        else
+            outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
 
         if (outOfView)
         {
             // object is not in view
-            navMarker_->setMaterialName("Orxonox/NavArrows");
-            navMarker_->setDimensions(16,16);
             aimMarker_->hide();
-            float phiUpperCorner = atan((float)(windowW)/(float)(windowH));
-            // from the angle we find out on which edge to draw the marker
-            // and which of the four arrows to take
-            float phiNav = atan((float) xFromCenter / (float) yFromCenter);
-
-            if (isAbove && isRight)
-            {
-                // top right quadrant
-                if (-phiNav < phiUpperCorner)
-                {
-                    //COUT(3) << "arrow up\n";
-                    navMarker_->setPosition(-tan(phiNav)*windowH/2+windowW/2, 0);
+
+            if (!wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavArrows");
+                wasOutOfView_ = true;
+            }
+
+            if (pos.x < pos.y)
+            {
+                if (pos.y > -pos.x)
+                {
+                    // up
+                    float position = pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 0.0);
                     navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
-                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
+                    navText_->setLeft((position - textLength) * 0.5);
                     navText_->setTop(navMarker_->getHeight());
                 }
                 else
                 {
-                    //COUT(3) << "arrow right\n";
-                    navMarker_->setPosition(windowW-16, tan((3.14-2*phiNav)/2)*windowW/2+windowH/2);
+                    // left
+                    float position = pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(0.0, (position - navMarker_->getWidth()) * 0.5);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth() + 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+            else
+            {
+                if (pos.y < -pos.x)
+                {
+                    // down
+                    float position = -pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 1.0 - navMarker_->getHeight());
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(1.0 - navMarker_->getHeight() - navText_->getCharHeight());
+                }
+                else
+                {
+                    // right
+                    float position = -pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(1.0 - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5);
                     navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
-                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
-                }
-            }
-            if (!isAbove && isRight)
-            {
-                // bottom right quadrant
-                if (phiNav < phiUpperCorner)
-                {
-                    //COUT(3) << "arrow down\n";
-                    navMarker_->setPosition(tan(phiNav)*windowH/2+windowW/2, windowH-16);
-                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
-                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
-                }
-                else
-                {
-                    //COUT(3) << "arrow right\n";
-                    navMarker_->setPosition(windowW-16, tan((3.14-2*phiNav)/2)*windowW/2+windowH/2);
-                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
-                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
-                }
-            }
-            if (isAbove && !isRight)
-            {
-                // top left quadrant
-                if (phiNav<phiUpperCorner)
-                {
-                    //COUT(3) << "arrow up\n";
-                    navMarker_->setPosition(-tan(phiNav)*windowH/2+windowW/2, 0);
-                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
-                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getHeight());
-                }
-                else
-                {
-                    //COUT(3) << "arrow left\n";
-                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW/2+windowH/2);
-                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
-                    navText_->setLeft(navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
-                }
-            }
-            if (!isAbove && !isRight)
-            {
-                // bottom left quadrant
-                if (phiNav>-phiUpperCorner)
-                {
-                    //COUT(3) << "arrow down\n";
-                    navMarker_->setPosition(tan(phiNav)*windowH/2+windowW/2, windowH-16);
-                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
-                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
-                }
-                else
-                {
-                    //COUT(3) << "arrow left\n";
-                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW/2+windowH/2);
-                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
-                    navText_->setLeft(navMarker_->getWidth());
-                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
+                    navText_->setLeft(1.0 - navMarker_->getWidth() - textLength - 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
                 }
             }
@@ -232,13 +270,25 @@
         {
             // object is in view
-            navMarker_->setMaterialName("Orxonox/NavTDC");
-            navMarker_->setDimensions(35, 35);
+
+            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
+                    Projectile::getSpeed(), focus_->getPosition(), focus_->getOrientedVelocity());
+
+            if (wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavTDC");
+                wasOutOfView_ = false;
+            }
+
+            // object is in view
             navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
-            navMarker_->setPosition(xPos-navMarker_->getWidth()/2, yPos-navMarker_->getHeight()/2);
+            navMarker_->setLeft((pos.x + 1.0 - navMarker_->getWidth()) * 0.5);
+            navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5);
 
             aimMarker_->show();
-            aimMarker_->setPosition(xAimPos-aimMarker_->getWidth()/2, yAimPos-aimMarker_->getHeight()/2);
-
-            navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2);
+            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
+            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
+
+            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
+            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
         }
     }
@@ -293,13 +343,10 @@
         if (focus_)
         {
-            navMarker_->show();
-            navText_->show();
+            overlay_->show();
             focus_->setColour(ColourValue::White);
         }
         else
         {
-            navMarker_->hide();
-            aimMarker_->hide();
-            navText_->hide();
+            overlay_->hide();
         }
     }
@@ -318,3 +365,12 @@
             return 0;
     }
+
+    void Navigation::windowResized(int newWidth, int newHeight)
+    {
+        HUDOverlay::windowResized(newWidth, newHeight);
+
+        //if (this->navMarker_)
+        //    navMarker_->setDimensions(0.05, 0.05);
+
+    }
 }
Index: code/branches/hud/src/orxonox/hud/Navigation.h
===================================================================
--- code/branches/hud/src/orxonox/hud/Navigation.h	(revision 1588)
+++ code/branches/hud/src/orxonox/hud/Navigation.h	(revision 1590)
@@ -23,5 +23,5 @@
  *      Felix Schulthess
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -35,14 +35,19 @@
 #include <OgreTextAreaOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
+#include "HUDOverlay.h"
+#include "util/Math.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Navigation
+    class _OrxonoxExport Navigation : public HUDOverlay, public Tickable
     {
       public:
-        Navigation(Ogre::OverlayContainer* container);
-        ~Navigation();
+        Navigation();
+        virtual ~Navigation();
 
-        void update();
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        virtual void tick(float dt);
+
         void cycleFocus();
         float getDist2Focus() const;
@@ -52,4 +57,7 @@
         void releaseFocus();
 
+    protected:
+      virtual void windowResized(int newWidth, int newHeight);
+
       private:
         void init();
@@ -57,5 +65,14 @@
         void updateFocus();
 
-        Ogre::OverlayContainer* container_;
+        void setNavMarkerSize(Vector2 size);
+        Vector2 getNavMarkerSize() const;
+        void setAimMarkerSize(Vector2 size);
+        Vector2 getAimMarkerSize() const;
+        void setTextSize(float size);
+        float getTextSize() const;
+        void setFont(const std::string& font);
+        std::string getFont() const;
+
+        Ogre::OverlayContainer* container_;         //!< Container that holds the navigation elements
         Ogre::PanelOverlayElement* navMarker_;      // the panel used to show the arrow
         Ogre::PanelOverlayElement* aimMarker_;
@@ -63,4 +80,5 @@
         std::list<RadarObject*>::iterator it_;
         RadarObject* focus_;                        // next pointer of linked list
+        bool wasOutOfView_;
   };
 }
Index: code/branches/hud/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/hud/src/orxonox/objects/SpaceShip.cc	(revision 1588)
+++ code/branches/hud/src/orxonox/objects/SpaceShip.cc	(revision 1590)
@@ -369,7 +369,7 @@
 
     std::string SpaceShip::whereAmI() {
-	return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
-	+ "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
-	+ "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
+  return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
+  + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
+  + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
     }
 
@@ -380,5 +380,5 @@
 
         currentDir_ = getOrientation()*initialDir_;
-		currentOrth_ = getOrientation()*initialOrth_;
+    currentOrth_ = getOrientation()*initialOrth_;
 
         if (this->cam_)
Index: code/branches/hud/src/orxonox/tools/WindowEventListener.cc
===================================================================
--- code/branches/hud/src/orxonox/tools/WindowEventListener.cc	(revision 1590)
+++ code/branches/hud/src/orxonox/tools/WindowEventListener.cc	(revision 1590)
@@ -0,0 +1,41 @@
+/*
+ *   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 "WindowEventListener.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor for the WindowEventListener.
+    */
+    WindowEventListener::WindowEventListener()
+    {
+        RegisterObject(WindowEventListener);
+    }
+}
Index: code/branches/hud/src/orxonox/tools/WindowEventListener.h
===================================================================
--- code/branches/hud/src/orxonox/tools/WindowEventListener.h	(revision 1590)
+++ code/branches/hud/src/orxonox/tools/WindowEventListener.h	(revision 1590)
@@ -0,0 +1,58 @@
+/*
+ *   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 _WindowEventListener_H__
+#define _WindowEventListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+
+namespace orxonox
+{
+    /**
+        @brief Interface for receiving window events.
+    */
+    class _OrxonoxExport WindowEventListener : virtual public OrxonoxClass
+    {
+    public:
+        WindowEventListener();
+        virtual ~WindowEventListener() { }
+
+		    /** Window has moved position */
+		    virtual void windowMoved() { }
+
+		    /** Window has resized */
+		    virtual void windowResized(int newWidth, int newHeight) { }
+
+		    /** Window has lost/gained focus */
+		    virtual void windowFocusChanged() { }
+    };
+}
+
+#endif /* _WindowEventListener_H__ */
