[Orxonox-commit 2336] r7051 - code/branches/presentation3/src/modules/overlays/hud

scheusso at orxonox.net scheusso at orxonox.net
Mon May 31 15:33:15 CEST 2010


Author: scheusso
Date: 2010-05-31 15:33:14 +0200 (Mon, 31 May 2010)
New Revision: 7051

Modified:
   code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
   code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
Log:
HUDNavigation overlays are coloured now


Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc	2010-05-31 13:17:25 UTC (rev 7050)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc	2010-05-31 13:33:14 UTC (rev 7051)
@@ -46,6 +46,7 @@
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/WorldEntity.h"
 #include "core/ConfigValueIncludes.h"
+#include "tools/TextureGenerator.h"
 // #include <boost/bind/bind_template.hpp>
 
 
@@ -198,7 +199,7 @@
                 // Change material only if outOfView changed
                 if ( !it->second.wasOutOfView_ )
                 {
-                    it->second.panel_->setMaterialName ( "Orxonox/NavArrows" );
+                    it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "arrows.tga", it->first->getRadarObjectColour()) );
                     it->second.wasOutOfView_ = true;
                 }
 
@@ -255,7 +256,8 @@
                 // Change material only if outOfView changed
                 if ( it->second.wasOutOfView_ )
                 {
-                    it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
+                  //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
+                    it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.tga", it->first->getRadarObjectColour()) );
                     it->second.wasOutOfView_ = false;
                 }
 
@@ -305,15 +307,13 @@
 
 void HUDNavigation::addObject ( RadarViewable* object )
 {
+    if( showObject(object)==false )
+        return;
 
     if ( activeObjectList_.size() >= markerLimit_ )
         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() );
 
@@ -326,13 +326,16 @@
     // Create arrow/marker
     Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*> ( Ogre::OverlayManager::getSingleton()
                                        .createOverlayElement ( "Panel", "HUDNavigation_navMarker_" + getUniqueNumberString() ) );
-    panel->setMaterialName ( "Orxonox/NavTDC" );
+//     panel->setMaterialName ( "Orxonox/NavTDC" );
+    panel->setMaterialName( TextureGenerator::getMaterialName( "tdc.tga", object->getRadarObjectColour()) );
     panel->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale );
+//     panel->setColour( object->getRadarObjectColour() );
 
     Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*> ( Ogre::OverlayManager::getSingleton()
                                          .createOverlayElement ( "TextArea", "HUDNavigation_navText_" + getUniqueNumberString() ) );
     text->setFontName ( this->fontName_ );
     text->setCharHeight ( text->getCharHeight() * yScale );
+    text->setColour( object->getRadarObjectColour() );
 
     panel->hide();
     text->hide();
@@ -350,7 +353,7 @@
 
 void HUDNavigation::removeObject ( RadarViewable* viewable )
 {
-    if ( viewable == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
+    if( showObject(viewable)==false )
         return;
 
     ObjectMap::iterator it = activeObjectList_.find ( viewable );
@@ -385,6 +388,24 @@
 
 }
 
+void HUDNavigation::objectChanged(RadarViewable* viewable)
+{
+    // TODO: niceification neccessary ;)
+    removeObject(viewable);
+    addObject(viewable);
+}
+
+
+bool HUDNavigation::showObject(RadarViewable* rv)
+{
+    if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
+        return false;
+    assert( rv->getWorldEntity() );
+    if ( rv->getWorldEntity()->isVisible()==false )
+        return false;
+    return true;
+}
+
 void HUDNavigation::changedOwner()
 {
     

Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h	2010-05-31 13:17:25 UTC (rev 7050)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h	2010-05-31 13:33:14 UTC (rev 7051)
@@ -55,7 +55,7 @@
 
     virtual void addObject ( RadarViewable* object );
     virtual void removeObject ( RadarViewable* viewable );
-    virtual void objectChanged ( RadarViewable* viewable ) {}
+    virtual void objectChanged ( RadarViewable* viewable );
 
     virtual void changedOwner();
     virtual void sizeChanged();
@@ -75,6 +75,8 @@
         bool wasOutOfView_;
 
     };
+    
+    bool showObject( RadarViewable* rv );
 
     // XMLPort accessors
     void setNavMarkerSize ( float size )




More information about the Orxonox-commit mailing list