[Orxonox-commit 4249] r8920 - code/branches/hud/src/modules/overlays/hud

mspaling at orxonox.net mspaling at orxonox.net
Wed Nov 2 16:11:58 CET 2011


Author: mspaling
Date: 2011-11-02 16:11:58 +0100 (Wed, 02 Nov 2011)
New Revision: 8920

Modified:
   code/branches/hud/src/modules/overlays/hud/HUDNavigation.cc
   code/branches/hud/src/modules/overlays/hud/HUDNavigation.h
Log:
Arrow in HUD now changes its size according to distance

Modified: code/branches/hud/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/hud/src/modules/overlays/hud/HUDNavigation.cc	2011-11-02 14:43:42 UTC (rev 8919)
+++ code/branches/hud/src/modules/overlays/hud/HUDNavigation.cc	2011-11-02 15:11:58 UTC (rev 8920)
@@ -24,6 +24,7 @@
  *   Co-authors:
  *      Reto Grieder
  *      Oliver Scheuss
+ *      Matthias Spalinger
  *
  */
 
@@ -76,6 +77,7 @@
     setFont ( "Monofur" );
     setTextSize ( 0.05f );
     setNavMarkerSize ( 0.05f );
+    this->showDistance = false;
 }
 
 HUDNavigation::~HUDNavigation()
@@ -140,7 +142,19 @@
     return textSize_;
 }
 
+float HUDNavigation::getArrowSizeX(int dist)
+{    
+    if (dist < 600) 
+        dist = 600;
+    return this->getActualSize().x * 900 * navMarkerSize_ / dist;
+}
 
+float HUDNavigation::getArrowSizeY(int dist)
+{    
+    if (dist < 600)
+        dist = 600;   
+    return this->getActualSize().y * 900 * navMarkerSize_ / dist;
+}
 
 void HUDNavigation::tick ( float dt )
 {
@@ -172,13 +186,20 @@
 
             // Get Distance to HumanController and save it in the TextAreaOverlayElement.
             int dist = listIt->second;
+            float textLength = 0.0f;
 
-            //it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); //display distance next to cursor
-            //float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
-            
-            it->second.text_->setCaption(it->first->getRVName()); //display name next to cursor
-            float textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f;
+            //display distance next to cursor
+            if (showDistance){
+            it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
+            textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
+            }
 
+            //display name next to cursor
+            else{
+            it->second.text_->setCaption(it->first->getRVName()); 
+            textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f;
+            }
+
             // Transform to screen coordinates
             Vector3 pos = camTransform * it->first->getRVWorldPosition();
 
@@ -206,6 +227,12 @@
                     it->second.wasOutOfView_ = true;
                 }
 
+                //float xDistScale = this->getActualSize().x * 1000.0f * navMarkerSize_ / dist;
+                //float yDistScale = this->getActualSize().y * 1000.0f * navMarkerSize_ / dist;
+
+                // Adjust Arrowsize according to distance
+                it->second.panel_->setDimensions(getArrowSizeX(dist),getArrowSizeY(dist));
+
                 // Switch between top, bottom, left and right position of the arrow at the screen border
                 if ( pos.x < pos.y )
                 {
@@ -261,6 +288,7 @@
                 {
                   //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
                     it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) );
+                    it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y );
                     it->second.wasOutOfView_ = false;
                 }
 

Modified: code/branches/hud/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/hud/src/modules/overlays/hud/HUDNavigation.h	2011-11-02 14:43:42 UTC (rev 8919)
+++ code/branches/hud/src/modules/overlays/hud/HUDNavigation.h	2011-11-02 15:11:58 UTC (rev 8920)
@@ -23,6 +23,7 @@
  *      Felix Schulthess
  *   Co-authors:
  *      Reto Grieder
+ *      Matthias Spalinger
  *
  */
 
@@ -96,10 +97,13 @@
     typedef std::list < std::pair<RadarViewable*, unsigned int > > sortedList;
     sortedList sortedObjectList_;
 
+    float getArrowSizeX(int dist);    
+    float getArrowSizeY(int dist);
 
     float navMarkerSize_;
     std::string fontName_;
     float textSize_;
+    bool showDistance;
 
     unsigned int markerLimit_;; //TODO: is it possible to set this over the console and/or the IG-Setting
 




More information about the Orxonox-commit mailing list