[Orxonox-commit 2255] r6971 - code/branches/presentation3/src/modules/overlays/hud

sfluecki at orxonox.net sfluecki at orxonox.net
Thu May 27 15:58:24 CEST 2010


Author: sfluecki
Date: 2010-05-27 15:58:24 +0200 (Thu, 27 May 2010)
New Revision: 6971

Modified:
   code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
   code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
Log:
Final changes in HUDNavigation. marker are now working and are limitable by setting markerLimit in HUDNavigation.h -mission accomplished-

Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc	2010-05-27 13:41:20 UTC (rev 6970)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc	2010-05-27 13:58:24 UTC (rev 6971)
@@ -46,102 +46,130 @@
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/WorldEntity.h"
 #include "interfaces/RadarViewable.h"
+// #include <boost/bind/bind_template.hpp>
 
+
 namespace orxonox
 {
-    CreateFactory(HUDNavigation);
+bool compareDistance ( std::pair<RadarViewable*, unsigned int > a, std::pair<RadarViewable*, unsigned int > b )
+{
+    return a.second<b.second;
 
-    HUDNavigation::HUDNavigation(BaseObject* creator)
-        : OrxonoxOverlay(creator)
-    {
-        RegisterObject(HUDNavigation);
+}
+CreateFactory ( HUDNavigation );
 
-        // Set default values
-        setFont("Monofur");
-        setTextSize(0.05f);
-        setNavMarkerSize(0.05f);
-    }
+HUDNavigation::HUDNavigation ( BaseObject* creator )
+        : OrxonoxOverlay ( creator )
+{
+    RegisterObject ( HUDNavigation );
 
-    HUDNavigation::~HUDNavigation()
-    {
-        if (this->isInitialized())
-        {
-            for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end();)
-                removeObject((it++)->first);
-        }
-    }
+    // Set default values
+    setFont ( "Monofur" );
+    setTextSize ( 0.05f );
+    setNavMarkerSize ( 0.05f );
+}
 
-    void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+HUDNavigation::~HUDNavigation()
+{
+    if ( this->isInitialized() )
     {
-        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
+        for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); )
+            removeObject ( ( it++ )->first );
 
-        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)
+    sortedObjectList_.clear();
+}
+
+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() )
     {
-        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_);
-        }
+        COUT ( 2 ) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl;
+        return;
     }
-
-    const std::string& HUDNavigation::getFont() const
+    fontName_ = font;
+    for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it )
     {
-        return fontName_;
+        if ( it->second.text_ != NULL )
+            it->second.text_->setFontName ( fontName_ );
     }
+}
 
-    void HUDNavigation::setTextSize(float size)
+const std::string& HUDNavigation::getFont() const
+{
+    return fontName_;
+}
+
+void HUDNavigation::setTextSize ( float size )
+{
+    if ( size <= 0.0f )
     {
-        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);
-        }
+        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
+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();
+
+
+    //TODO: sort list 'sortedObjectList_' according to distance.$
+    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt )
     {
-        return textSize_;
+        listIt->second = ( int ) ( ( listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition() ).length() + 0.5f );
     }
 
-    void HUDNavigation::tick(float dt)
+    sortedObjectList_.sort ( compareDistance );
+
+    unsigned int markerCount_ = 0;
+
+//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
+    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
     {
-        SUPER(HUDNavigation, tick, dt);
+        ObjectMap::iterator it = activeObjectList_.find ( listIt->first );
 
-        Camera* cam = CameraManager::getInstance().getActiveCamera();
-        if (cam == NULL)
-            return;
-        const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
+        if ( markerCount_ < markerLimit_ )
+        {
 
-        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::getLocalControllerSingleton()->getControllableEntity()->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;
+            int dist = listIt->second;
+            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)
+            if ( pos.z > 1.0 )
             {
                 // z > 1.0 means that the object is behind the camera
                 outOfView = true;
@@ -152,60 +180,63 @@
             }
             else
                 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+            // Get Distance to HumanController and save it in the TextAreaOverlayElement.
+            it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
 
-            if (outOfView)
+            if ( outOfView )
             {
                 // Object is not in view
 
                 // Change material only if outOfView changed
-                if (!it->second.wasOutOfView_)
+                if ( !it->second.wasOutOfView_ )
                 {
-                    it->second.panel_->setMaterialName("Orxonox/NavArrows");
+                    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.x < pos.y )
                 {
-                    if (pos.y > -pos.x)
+                    if ( pos.y > -pos.x )
                     {
                         // Top
                         float position = pos.x / pos.y + 1.0f;
-                        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());
+                        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
                         float position = pos.y / pos.x + 1.0f;
-                        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);
+                        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 );
                     }
                 }
+
                 else
                 {
 
-                    if (pos.y < -pos.x)
+                    if ( pos.y < -pos.x )
                     {
                         // Bottom
                         float position = -pos.x / pos.y + 1.0f;
-                        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());
+                        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
                         float position = -pos.y / pos.x + 1.0f;
-                        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);
+                        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 );
                     }
                 }
             }
@@ -214,112 +245,144 @@
                 // Object is in view
 
                 // Change material only if outOfView changed
-                if (it->second.wasOutOfView_)
+                if ( it->second.wasOutOfView_ )
                 {
-                    it->second.panel_->setMaterialName("Orxonox/NavTDC");
+                    it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
                     it->second.wasOutOfView_ = false;
                 }
 
                 // 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);
+                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);
+                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 );
             }
 
             // Make sure the overlays are shown
             it->second.panel_->show();
             it->second.text_->show();
         }
+        else
+        {
+            it->second.panel_->hide();
+            it->second.text_->hide();
+        }
+
     }
+}
 
 
-    /** Overridden method of OrxonoxOverlay.
-    @details
-        Usually the entire overlay scales with scale().
-        Here we obviously have to adjust this.
-    */
-    void HUDNavigation::sizeChanged()
+/** Overridden method of OrxonoxOverlay.
+ at 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 )
     {
-        // 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);
-        }
+        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;
+void HUDNavigation::addObject ( RadarViewable* object )
+{
 
-        // Don't display our own ship
-        if (object == dynamic_cast<RadarViewable*>(this->getOwner()))
+    if ( activeObjectList_.size() >= markerLimit_ )
+        if ( object == NULL )
             return;
 
-        // Object hasn't been added yet (we know that)
-        assert(this->activeObjectList_.find(object) == this->activeObjectList_.end());
+    // Don't display our own ship
+    if ( object == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
+        return;
 
-        // Scales used for dimensions and text size
-        float xScale = this->getActualSize().x;
-        float yScale = this->getActualSize().y;
+    // Object hasn't been added yet (we know that)
+    assert ( this->activeObjectList_.find ( object ) == this->activeObjectList_.end() );
 
-        // Create everything needed to display the object on the radar and add it to the map
+    // Scales used for dimensions and text size
+    float xScale = this->getActualSize().x;
+    float yScale = this->getActualSize().y;
 
-        // Create arrow/marker
-        Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
-            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
-        panel->setMaterialName("Orxonox/NavTDC");
-        panel->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+    // Create everything needed to display the object on the radar and add it to the map
 
-        Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
-            .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
-        text->setFontName(this->fontName_);
-        text->setCharHeight(text->getCharHeight() * yScale);
+    // Create arrow/marker
+    Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*> ( Ogre::OverlayManager::getSingleton()
+                                       .createOverlayElement ( "Panel", "HUDNavigation_navMarker_" + getUniqueNumberString() ) );
+    panel->setMaterialName ( "Orxonox/NavTDC" );
+    panel->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale );
 
-        ObjectInfo tempStruct = {panel, text, false};
-        activeObjectList_[object] = tempStruct;
+    Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*> ( Ogre::OverlayManager::getSingleton()
+                                         .createOverlayElement ( "TextArea", "HUDNavigation_navText_" + getUniqueNumberString() ) );
+    text->setFontName ( this->fontName_ );
+    text->setCharHeight ( text->getCharHeight() * yScale );
 
-        this->background_->addChild(panel);
-        this->background_->addChild(text);
-    }
+    panel->hide();
+    text->hide();
 
-    void HUDNavigation::removeObject(RadarViewable* viewable)
+    ObjectInfo tempStruct = {panel, text, false};
+    activeObjectList_[object] = tempStruct;
+
+    this->background_->addChild ( panel );
+    this->background_->addChild ( text );
+
+    sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) );
+
+    //TODO: hide elements
+}
+
+void HUDNavigation::removeObject ( RadarViewable* viewable )
+{
+
+    ObjectMap::iterator it = activeObjectList_.find ( viewable );
+
+    if ( activeObjectList_.find ( viewable ) != activeObjectList_.end() )
     {
-        ObjectMap::iterator it = activeObjectList_.find(viewable);
+        // 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 );
 
-        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()
+
+    else
+        COUT ( 2 ) << "Warning, HUDNavigation: Attempting to remove non-existent object" << std::endl;
+
+    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt )
     {
-        // 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 ( (listIt->first) == viewable )
         {
-            if (!(*it)->isHumanShip_)
-                this->addObject(*it);
+            sortedObjectList_.erase ( listIt );
+            break;
         }
+
     }
+
 }
+
+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 );
+    }
+}
+}

Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h	2010-05-27 13:41:20 UTC (rev 6970)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h	2010-05-27 13:58:24 UTC (rev 6971)
@@ -34,6 +34,7 @@
 #include <map>
 #include <string>
 
+
 #include "util/OgreForwardRefs.h"
 #include "tools/interfaces/Tickable.h"
 #include "interfaces/RadarListener.h"
@@ -41,56 +42,65 @@
 
 namespace orxonox
 {
-    class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener
+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 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 ) {}
+
+    inline float getRadarSensitivity() const
+    { return 1.0f; }
+
+private:
+    struct ObjectInfo
     {
-    public:
-        HUDNavigation(BaseObject* creator);
-        virtual ~HUDNavigation();
+        Ogre::PanelOverlayElement* panel_;
+        Ogre::TextAreaOverlayElement* text_;
+        bool outOfView_;
+        bool wasOutOfView_;
 
-        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-        virtual void tick(float dt);
+    };
 
-        virtual void addObject(RadarViewable* object);
-        virtual void removeObject(RadarViewable* viewable);
-        virtual void objectChanged(RadarViewable* viewable) {}
+    // XMLPort accessors
+    void setNavMarkerSize ( float size )
+    { navMarkerSize_ = size; this->sizeChanged(); }
+    float getNavMarkerSize() const
+    { return navMarkerSize_; }
 
-        virtual void changedOwner();
-        virtual void sizeChanged();
-        virtual void angleChanged() { }
-        virtual void positionChanged() { }
-        virtual void radarTick(float dt) {}
+    void setTextSize ( float size );
+    float getTextSize() const;
 
-        inline float getRadarSensitivity() const
-            { return 1.0f; }
+    void setFont ( const std::string& font );
+    const std::string& getFont() const;
 
-    private:
-        struct ObjectInfo
-        {
-            Ogre::PanelOverlayElement* panel_;
-            Ogre::TextAreaOverlayElement* text_;
-            bool outOfView_;
-            bool wasOutOfView_;
-        };
+    typedef std::map<RadarViewable*, ObjectInfo > ObjectMap;
+    ObjectMap activeObjectList_;
 
-        // XMLPort accessors
-        void setNavMarkerSize(float size)
-            { navMarkerSize_ = size; this->sizeChanged(); }
-        float getNavMarkerSize() const
-            { return navMarkerSize_; }
+    typedef std::list < std::pair<RadarViewable*, unsigned int > > sortedList;
+    sortedList sortedObjectList_;
 
-        void setTextSize(float size);
-        float getTextSize() const;
 
-        void setFont(const std::string& font);
-        const std::string& getFont() const;
+    float navMarkerSize_;
+    std::string fontName_;
+    float textSize_;
 
-        typedef std::map<RadarViewable*, ObjectInfo > ObjectMap;
-        ObjectMap activeObjectList_;
+    static const unsigned int markerLimit_ = 5; //TODO: is it possible to set this over the console and/or the IG-Setting
 
-        float navMarkerSize_;
-        std::string fontName_;
-        float textSize_;
-    };
+
+};
 }
 
 #endif /* _HUDNavigation_H__ */




More information about the Orxonox-commit mailing list