Index: code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.cc	(revision 6923)
+++ code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.cc	(revision 6924)
@@ -28,11 +28,11 @@
 
 #include "HUDNavigation.h"
-#include <utility>
-
-#include <string>
+
 #include <OgreCamera.h>
+#include <OgreFontManager.h>
 #include <OgreOverlayManager.h>
 #include <OgreTextAreaOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
+
 #include "util/Math.h"
 #include "util/Convert.h"
@@ -50,155 +50,100 @@
 namespace orxonox
 {
-CreateFactory(HUDNavigation);
-
-HUDNavigation::HUDNavigation(BaseObject* creator)
+    CreateFactory(HUDNavigation);
+
+    HUDNavigation::HUDNavigation(BaseObject* creator)
         : OrxonoxOverlay(creator)
-{
-    RegisterObject(HUDNavigation);
-
-    setFont("Monofur");
-    setTextSize(0.05f);
-    setNavMarkerSize(0.05f);
-
-
-    
-//         // create nav text
-//         navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
-//             .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
-//
-//         // create nav marker
-//         navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
-//             .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
-//         navMarker_->setMaterialName("Orxonox/NavArrows");
-
-        /*
-                // create aim marker
-                aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
-                    .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
-                aimMarker_->setMaterialName("Orxonox/NavCrosshair");
-                this->wasOutOfView_ = true; // Ensure the material is changed right the first time..
-
-
-        */
-        /*
-                background_->addChild(navMarker_);*/
-//        background_->addChild(aimMarker_);
-//         background_->addChild(navText_);
-
-        // hide at first
-//         this->setVisible(false);
-
-
-
-//         setAimMarkerSize(0.04f);
-    
-}
-
-HUDNavigation::~HUDNavigation()
-{
-    if (this->isInitialized())
-    {
-        for (activeObjectListType::iterator it = activeObjectList_.begin(); it != activeObjectList_.end();)
-            removeObject((it++)->first);
-    }
-}
-
-void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
-{
-    SUPER(HUDNavigation, XMLPort, xmlElement, mode);
-
-    XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode);
-    XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
-    XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
-//        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
-}
-
-void HUDNavigation::setFont(const std::string& font)
-{
-    fontName_ = font;
-    if (!activeObjectList_.empty())
-    {
-        for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable)
-        {
-            if (tempRadarViewable->second.text_ && !fontName_.empty())
-                tempRadarViewable->second.text_->setFontName(fontName_);
-        }
-    }
-}
-
-const std::string& HUDNavigation::getFont() const
-{
-    return fontName_;
-}
-
-void HUDNavigation::setTextSize(float size)
-{
-    textSize_ = size;
-    if (!activeObjectList_.empty())
-    {
-        for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable)
-        {
-            if (tempRadarViewable->second.text_ && size >= 0.0f)
-                tempRadarViewable->second.text_->setCharHeight(size);
-        }
-    }
-}
-
-float HUDNavigation::getTextSize() const
-{
-    return textSize_;
-}
-
-void HUDNavigation::tick(float dt)
-{
-    SUPER(HUDNavigation, tick, dt);
-
-// 	updateActiveObjectList(activeObjectList_);
-
-    // Get radar
-//         Radar* radar = this->getOwner()->getScene()->getRadar();
-//
-//         if (!radar->getFocus())
-//         {
-//             this->overlay_->hide();
-//             return;
-//         }
-//         else
-//         {
-//             this->overlay_->show();
-//         }
-
-    // set text
-//         int dist = static_cast<int>(getDist2Focus());
-//         navText_->setCaption(multi_cast<std::string>(dist));
-//         float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3f;
-
-    if (!activeObjectList_.empty())
-    {
-        for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable)
-        {
-
-
-            //get Distance to HumanController and save it in the TextAreaOverlayElement.
-            int dist = (int)(tempRadarViewable->first->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
-            tempRadarViewable->second.text_->setCaption(multi_cast<std::string>(dist));
-            float textLength = multi_cast<std::string>(dist).size() * tempRadarViewable->second.text_->getCharHeight() * 0.3f;
-
-
-
-            orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera();
-            if (!cam)
-                return;
-            const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
-            // transform to screen coordinates
-            Vector3 pos = transform * tempRadarViewable->first->getRVWorldPosition();
-
-
-
-
+    {
+        RegisterObject(HUDNavigation);
+
+        // Set default values
+        setFont("Monofur");
+        setTextSize(0.05f);
+        setNavMarkerSize(0.05f);
+    }
+
+    HUDNavigation::~HUDNavigation()
+    {
+        if (this->isInitialized())
+        {
+            for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end();)
+                removeObject((it++)->first);
+        }
+    }
+
+    void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
+
+        XMLPortParam(HUDNavigation, "font",          setFont,          getFont,          xmlElement, mode);
+        XMLPortParam(HUDNavigation, "textSize",      setTextSize,      getTextSize,      xmlElement, mode);
+        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
+    }
+
+    void HUDNavigation::setFont(const std::string& font)
+    {
+        const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName(font);
+        if (fontPtr.isNull())
+        {
+            COUT(2) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl;
+            return;
+        }
+        fontName_ = font;
+        for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
+        {
+            if (it->second.text_ != NULL)
+                it->second.text_->setFontName(fontName_);
+        }
+    }
+
+    const std::string& HUDNavigation::getFont() const
+    {
+        return fontName_;
+    }
+
+    void HUDNavigation::setTextSize(float size)
+    {
+        if (size <= 0.0f)
+        {
+            COUT(2) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl;
+            return;
+        }
+        textSize_ = size;
+        for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it)
+        {
+            if (it->second.text_)
+                it->second.text_->setCharHeight(size);
+        }
+    }
+
+    float HUDNavigation::getTextSize() const
+    {
+        return textSize_;
+    }
+
+    void HUDNavigation::tick(float dt)
+    {
+        SUPER(HUDNavigation, tick, dt);
+
+        Camera* cam = CameraManager::getInstance().getActiveCamera();
+        if (cam == NULL)
+            return;
+        const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
+
+        for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
+        {
+            // Get Distance to HumanController and save it in the TextAreaOverlayElement.
+            int dist = (int)((it->first->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length() + 0.5f);
+            it->second.text_->setCaption(multi_cast<std::string>(dist));
+            float textLength = multi_cast<std::string>(dist).size() * it->second.text_->getCharHeight() * 0.3f;
+
+            // Transform to screen coordinates
+            Vector3 pos = camTransform * it->first->getRVWorldPosition();
+
+            bool outOfView = true;
             if (pos.z > 1.0)
             {
                 // z > 1.0 means that the object is behind the camera
-                tempRadarViewable->second.outOfView_ = true;
+                outOfView = true;
                 // we have to switch all coordinates (if you don't know why,
                 // try linear algebra lectures, because I can't explain..)
@@ -207,38 +152,37 @@
             }
             else
-                tempRadarViewable->second.outOfView_ = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
-
-            if (tempRadarViewable->second.outOfView_)
+                outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+
+            if (outOfView)
             {
-                // object is not in view
-//            aimMarker_->hide();
-
-                if (!tempRadarViewable->second.wasOutOfView_)
+                // Object is not in view
+
+                // Change material only if outOfView changed
+                if (!it->second.wasOutOfView_)
                 {
-                    tempRadarViewable->second.panel_->setMaterialName("Orxonox/NavArrows");
-                    tempRadarViewable->second.wasOutOfView_ = true;
+                    it->second.panel_->setMaterialName("Orxonox/NavArrows");
+                    it->second.wasOutOfView_ = true;
                 }
 
-
-
+                // Switch between top, bottom, left and right position of the arrow at the screen border
                 if (pos.x < pos.y)
                 {
                     if (pos.y > -pos.x)
                     {
-                        // up
+                        // Top
                         float position = pos.x / pos.y + 1.0f;
-                        tempRadarViewable->second.panel_->setPosition((position - tempRadarViewable->second.panel_->getWidth()) * 0.5f, 0.0f);
-                        tempRadarViewable->second.panel_->setUV(0.5f, 0.0f, 1.0f, 0.5f);
-                        tempRadarViewable->second.text_->setLeft((position - textLength) * 0.5f);
-                        tempRadarViewable->second.text_->setTop(tempRadarViewable->second.panel_->getHeight());
+                        it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 0.0f);
+                        it->second.panel_->setUV(0.5f, 0.0f, 1.0f, 0.5f);
+                        it->second.text_->setLeft((position - textLength) * 0.5f);
+                        it->second.text_->setTop(it->second.panel_->getHeight());
                     }
                     else
                     {
-                        // left
+                        // Left
                         float position = pos.y / pos.x + 1.0f;
-                        tempRadarViewable->second.panel_->setPosition(0.0f, (position - tempRadarViewable->second.panel_->getWidth()) * 0.5f);
-                        tempRadarViewable->second.panel_->setUV(0.0f, 0.0f, 0.5f, 0.5f);
-                        tempRadarViewable->second.text_->setLeft(tempRadarViewable->second.panel_->getWidth() + 0.01f);
-                        tempRadarViewable->second.text_->setTop((position - tempRadarViewable->second.text_->getCharHeight()) * 0.5f);
+                        it->second.panel_->setPosition(0.0f, (position - it->second.panel_->getWidth()) * 0.5f);
+                        it->second.panel_->setUV(0.0f, 0.0f, 0.5f, 0.5f);
+                        it->second.text_->setLeft(it->second.panel_->getWidth() + 0.01f);
+                        it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
                     }
                 }
@@ -248,19 +192,19 @@
                     if (pos.y < -pos.x)
                     {
-                        // down
+                        // Bottom
                         float position = -pos.x / pos.y + 1.0f;
-                        tempRadarViewable->second.panel_->setPosition((position - tempRadarViewable->second.panel_->getWidth()) * 0.5f, 1.0f - tempRadarViewable->second.panel_->getHeight());
-                        tempRadarViewable->second.panel_->setUV(0.0f, 0.5f, 0.5f, 1.0f);
-                        tempRadarViewable->second.text_->setLeft((position - textLength) * 0.5f);
-                        tempRadarViewable->second.text_->setTop(1.0f - tempRadarViewable->second.panel_->getHeight() - tempRadarViewable->second.text_->getCharHeight());
+                        it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 1.0f - it->second.panel_->getHeight());
+                        it->second.panel_->setUV(0.0f, 0.5f, 0.5f, 1.0f);
+                        it->second.text_->setLeft((position - textLength) * 0.5f);
+                        it->second.text_->setTop(1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight());
                     }
                     else
                     {
-                        // right
+                        // Right
                         float position = -pos.y / pos.x + 1.0f;
-                        tempRadarViewable->second.panel_->setPosition(1.0f - tempRadarViewable->second.panel_->getWidth(), (position - tempRadarViewable->second.panel_->getHeight()) * 0.5f);
-                        tempRadarViewable->second.panel_->setUV(0.5f, 0.5f, 1.0f, 1.0f);
-                        tempRadarViewable->second.text_->setLeft(1.0f - tempRadarViewable->second.panel_->getWidth() - textLength - 0.01f);
-                        tempRadarViewable->second.text_->setTop((position - tempRadarViewable->second.text_->getCharHeight()) * 0.5f);
+                        it->second.panel_->setPosition(1.0f - it->second.panel_->getWidth(), (position - it->second.panel_->getHeight()) * 0.5f);
+                        it->second.panel_->setUV(0.5f, 0.5f, 1.0f, 1.0f);
+                        it->second.text_->setLeft(1.0f - it->second.panel_->getWidth() - textLength - 0.01f);
+                        it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
                     }
                 }
@@ -268,158 +212,114 @@
             else
             {
-
-
-                // object is in view
-                /*
-                            Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
-                                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
-                */
-                if (tempRadarViewable->second.wasOutOfView_)
+                // Object is in view
+
+                // Change material only if outOfView changed
+                if (it->second.wasOutOfView_)
                 {
-                    tempRadarViewable->second.panel_->setMaterialName("Orxonox/NavTDC");
-                    tempRadarViewable->second.wasOutOfView_ = false;
+                    it->second.panel_->setMaterialName("Orxonox/NavTDC");
+                    it->second.wasOutOfView_ = false;
                 }
 
-                // object is in view
-                tempRadarViewable->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
-                tempRadarViewable->second.panel_->setLeft((pos.x + 1.0f - tempRadarViewable->second.panel_->getWidth()) * 0.5f);
-                tempRadarViewable->second.panel_->setTop((-pos.y + 1.0f - tempRadarViewable->second.panel_->getHeight()) * 0.5f);
-
-
-//                 aimMarker_->show();
-//                 aimMarker_->setLeft((aimpos.x + 1.0f - aimMarker_->getWidth()) * 0.5f);
-//                 aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f);
-//
-                tempRadarViewable->second.text_->setLeft((pos.x + 1.0f + tempRadarViewable->second.panel_->getWidth()) * 0.5f);
-                tempRadarViewable->second.text_->setTop((-pos.y + 1.0f + tempRadarViewable->second.panel_->getHeight()) * 0.5f);
+                // Position marker
+                it->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+                it->second.panel_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
+                it->second.panel_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
+
+                // Position text
+                it->second.text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);
+                it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
             }
 
-            tempRadarViewable->second.panel_->show();
-            tempRadarViewable->second.text_->show();
-//             tempRadarViewable->second.text_->hide();
-        }
-
-    }
-
+            // Make sure the overlays are shown
+            it->second.panel_->show();
+            it->second.text_->show();
+        }
+    }
+
+
+    /** Overridden method of OrxonoxOverlay.
+    @details
+        Usually the entire overlay scales with scale().
+        Here we obviously have to adjust this.
+    */
+    void HUDNavigation::sizeChanged()
+    {
+        // Use size to compensate for aspect ratio if enabled.
+        float xScale = this->getActualSize().x;
+        float yScale = this->getActualSize().y;
+
+        for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it)
+        {
+            if (it->second.panel_ != NULL)
+                it->second.panel_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+            if (it->second.text_ != NULL)
+                it->second.text_->setCharHeight(it->second.text_->getCharHeight() * yScale);
+        }
+    }
+
+    void HUDNavigation::addObject(RadarViewable* object)
+    {
+        if (object == NULL)
+            return;
+
+        // Don't display our own ship
+        if (object == dynamic_cast<RadarViewable*>(this->getOwner()))
+            return;
+
+        // Object hasn't been added yet (we know that)
+        assert(this->activeObjectList_.find(object) == this->activeObjectList_.end());
+
+        // Scales used for dimensions and text size
+        float xScale = this->getActualSize().x;
+        float yScale = this->getActualSize().y;
+
+        // Create everything needed to display the object on the radar and add it to the map
+
+        // Create arrow/marker
+        Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
+        panel->setMaterialName("Orxonox/NavArrows");
+        panel->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+
+        Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
+        text->setFontName(this->fontName_);
+        text->setCharHeight(text->getCharHeight() * yScale);
+
+        ObjectInfo tempStruct = {panel, text, true};
+        activeObjectList_[object] = tempStruct;
+
+        this->background_->addChild(panel);
+        this->background_->addChild(text);
+    }
+
+    void HUDNavigation::removeObject(RadarViewable* viewable)
+    {
+        ObjectMap::iterator it = activeObjectList_.find(viewable);
+
+        if (activeObjectList_.find(viewable) != activeObjectList_.end())
+        {
+            // Detach overlays
+            this->background_->removeChild(it->second.panel_->getName());
+            this->background_->removeChild(it->second.text_->getName());
+            // Properly destroy the overlay elements (do not use delete!)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_);
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);
+            // Remove from the list
+            activeObjectList_.erase(viewable);
+        }
+        else
+            COUT(2) << "Warning, HUDNavigation: Attempting to remove non-existent object" << std::endl;
+    }
+
+    void HUDNavigation::changedOwner()
+    {
+        // TODO: Delete old objects?
+        const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
+        for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it)
+        {
+            if (!(*it)->isHumanShip_)
+                this->addObject(*it);
+        }
+    }
 }
-
-
-// float HUDNavigation::getDist2Focus() const {
-// 
-//     Radar* radar = this->getOwner()->getScene()->getRadar();
-//     if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn())
-//         return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
-//     else
-//         return 0;
-// }
-
-/**
-@brief Overridden method of OrxonoxOverlay. Usually the entire overlay
-       scales with scale(). Here we obviously have to adjust this.
-*/
-void HUDNavigation::sizeChanged()
-{
-    // use size to compensate for aspect ratio if enabled.
-    float xScale = this->getActualSize().x;
-    float yScale = this->getActualSize().y;
-
-    if (!activeObjectList_.empty())
-    {
-        for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable)
-        {
-
-            if (tempRadarViewable->second.panel_)
-                tempRadarViewable->second.panel_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
-//            if (this->aimMarker_)
-//            aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
-            if (tempRadarViewable->second.text_)
-                tempRadarViewable->second.text_->setCharHeight(tempRadarViewable->second.text_->getCharHeight() * yScale);
-        }
-    }
-}
-
-
-void HUDNavigation::addObject(RadarViewable* object)
-{
-    if (object == dynamic_cast<RadarViewable*>(this->getOwner()))
-        return;
-
-    assert(object);
-
-    // Make sure the object hasn't been added yet
-    assert( this->activeObjectList_.find(object) == this->activeObjectList_.end() );
-
-    // Create everything needed to display the object on the radar and add it to the map
-
-    // create nav marker
-    Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
-                                       .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
-
-    panel->setMaterialName("Orxonox/NavArrows");
-
-    Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
-                                         .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
-		
-   
-    float xScale = this->getActualSize().x;
-    float yScale = this->getActualSize().y;
-
-    panel->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
-    text->setFontName(this->fontName_);
-    text->setCharHeight(text->getCharHeight() * yScale);
-
-    objectStruct tempStruct = {panel, text, true};
-    activeObjectList_[object] = tempStruct;
-
-    this->background_->addChild(panel);
-    this->background_->addChild(text);
-
-// 	background_->addChild(activeObjectList_[object].first);
-// 	background_->addChild(activeObjectList_[object].second);
-
-}
-
-void HUDNavigation::removeObject(RadarViewable* viewable)
-{
-    activeObjectListType::iterator it = activeObjectList_.find(viewable);
-
-    if (activeObjectList_.find(viewable) != activeObjectList_.end())
-    {
-        // Remove overlays from Ogre
-        this->background_->removeChild(it->second.panel_->getName());
-        this->background_->removeChild(it->second.text_->getName());
-        // correctly destroy the overlay elements
-        Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_);
-        Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);
-
-        activeObjectList_.erase(viewable);
-    }
-   
-}
-
-void HUDNavigation::changedOwner()
-{
-    respawnObjectSetType respawnObjectSet = this->getOwner()->getScene()->getRadar()->getRadarObjects();
-    respawnObjectSetType::iterator respawnObjectSetIt_;
-    for (respawnObjectSetIt_ = respawnObjectSet.begin(); respawnObjectSetIt_ != respawnObjectSet.end(); ++respawnObjectSetIt_)
-    {
-        if (!(*respawnObjectSetIt_)->isHumanShip_)
-            this->addObject(*respawnObjectSetIt_);
-    }
-
-}
-
-
-
-// 	void updateActiveObjectList(map activeObjectList_){}
-//
-// 	void HUDNavigation::objectChanged(RadarViewable* viewable){}
-//
-//
-//         float HUDNavigation::getRadarSensitivity(){}
-//         void HUDNavigation::radarTick(float dt){}
-
-
-}
-
-
Index: code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h	(revision 6923)
+++ code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h	(revision 6924)
@@ -30,106 +30,66 @@
 #define _HUDNavigation_H__
 
-#include <utility>
+#include "overlays/OverlaysPrereqs.h"
+
 #include <map>
-#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/RadarViewable.h"
+#include <string>
 
-#include "interfaces/RadarListener.h"
 #include "util/OgreForwardRefs.h"
 #include "tools/interfaces/Tickable.h"
+#include "interfaces/RadarListener.h"
 #include "overlays/OrxonoxOverlay.h"
-
-#include <vector>
 
 namespace orxonox
 {
-class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener
-{
-public:
-    HUDNavigation(BaseObject* creator);
-    virtual ~HUDNavigation();
+    class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener
+    {
+    public:
+        HUDNavigation(BaseObject* creator);
+        virtual ~HUDNavigation();
 
-    virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-    virtual void tick(float dt);
-    virtual void addObject(RadarViewable* object);
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+        virtual void tick(float dt);
 
-    virtual void removeObject(RadarViewable* viewable);
-    virtual void objectChanged(RadarViewable* viewable) {}
-    inline float getRadarSensitivity() const {return 1.0f;}
-    inline void radarTick(float dt) {}
-    virtual void changedOwner();
+        virtual void addObject(RadarViewable* object);
+        virtual void removeObject(RadarViewable* viewable);
+        virtual void objectChanged(RadarViewable* viewable) {}
 
+        virtual void changedOwner();
+        virtual void sizeChanged();
+        virtual void angleChanged() { }
+        virtual void positionChanged() { }
+        virtual void radarTick(float dt) {}
 
-private:
+        inline float getRadarSensitivity() const
+            { return 1.0f; }
 
+    private:
+        struct ObjectInfo
+        {
+            Ogre::PanelOverlayElement* panel_;
+            Ogre::TextAreaOverlayElement* text_;
+            bool outOfView_;
+            bool wasOutOfView_;
+        };
 
+        // XMLPort accessors
+        void setNavMarkerSize(float size)
+            { navMarkerSize_ = size; this->sizeChanged(); }
+        float getNavMarkerSize() const
+            { return navMarkerSize_; }
 
-    void sizeChanged();
-    void angleChanged() { }
-    void positionChanged() { }
+        void setTextSize(float size);
+        float getTextSize() const;
 
-// 	void updateActiveObjectList(map activeObjectList_);
+        void setFont(const std::string& font);
+        const std::string& getFont() const;
 
+        typedef std::map<RadarViewable*, ObjectInfo > ObjectMap;
+        ObjectMap activeObjectList_;
 
-
-    // XMLPort accessors
-    void setNavMarkerSize(float size) {
-        navMarkerSize_ = size;
-        this->sizeChanged();
-    }
-    float getNavMarkerSize() const    {
-        return navMarkerSize_;
-    }
-
-    /*
-            void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }
-            float getAimMarkerSize() const    { return this->aimMarkerSize_; }
-    */
-
-    void setTextSize(float size);
-    float getTextSize() const;
-
-    void setFont(const std::string& font);
-    const std::string& getFont() const;
-
-    void updateMarker();
-    void updateFocus();
-//     float getDist2Focus() const;
-    void getSingleton();
-
-
-    void updateActiveObjectMap();
-
-    Ogre::PanelOverlayElement* navMarker_;      //!< the panel used to show the arrow and the target marker
-    float navMarkerSize_;                       //!< One paramter size of the navigation marker
-    /*
-            Ogre::PanelOverlayElement* aimMarker_;      //!< Panel used to show the aim Marker
-            float aimMarkerSize_;                       //!< One paramter size of the aim marker
-    */
-    Ogre::TextAreaOverlayElement* navText_;     //!< Text overlay to display the target distance
-    
-
-    struct objectStruct{
-      
-      Ogre::PanelOverlayElement* panel_;
-      Ogre::TextAreaOverlayElement* text_;
-      bool outOfView_;
-      bool wasOutOfView_;
-    
+        float navMarkerSize_;
+        std::string fontName_;
+        float textSize_;
     };
-    
-    typedef std::map<RadarViewable*, objectStruct > activeObjectListType;
-    activeObjectListType activeObjectList_;
-    activeObjectListType::iterator tempRadarViewable;
-        
-    typedef std::set<RadarViewable*> respawnObjectSetType;
-    
-
-
-    std::string fontName_;
-    float textSize_;
-
-};
-
 }
 
