Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2011, 4:11:58 PM (13 years ago)
Author:
mspaling
Message:

Arrow in HUD now changes its size according to distance

Location:
code/branches/hud/src/modules/overlays/hud
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud/src/modules/overlays/hud/HUDNavigation.cc

    r8906 r8920  
    2525 *      Reto Grieder
    2626 *      Oliver Scheuss
     27 *      Matthias Spalinger
    2728 *
    2829 */
     
    7778    setTextSize ( 0.05f );
    7879    setNavMarkerSize ( 0.05f );
     80    this->showDistance = false;
    7981}
    8082
     
    141143}
    142144
    143 
     145float HUDNavigation::getArrowSizeX(int dist)
     146{   
     147    if (dist < 600)
     148        dist = 600;
     149    return this->getActualSize().x * 900 * navMarkerSize_ / dist;
     150}
     151
     152float HUDNavigation::getArrowSizeY(int dist)
     153{   
     154    if (dist < 600)
     155        dist = 600;   
     156    return this->getActualSize().y * 900 * navMarkerSize_ / dist;
     157}
    144158
    145159void HUDNavigation::tick ( float dt )
     
    173187            // Get Distance to HumanController and save it in the TextAreaOverlayElement.
    174188            int dist = listIt->second;
    175 
    176             //it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); //display distance next to cursor
    177             //float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
    178            
    179             it->second.text_->setCaption(it->first->getRVName()); //display name next to cursor
    180             float textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f;
     189            float textLength = 0.0f;
     190
     191            //display distance next to cursor
     192            if (showDistance){
     193            it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
     194            textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
     195            }
     196
     197            //display name next to cursor
     198            else{
     199            it->second.text_->setCaption(it->first->getRVName());
     200            textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f;
     201            }
    181202
    182203            // Transform to screen coordinates
     
    206227                    it->second.wasOutOfView_ = true;
    207228                }
     229
     230                //float xDistScale = this->getActualSize().x * 1000.0f * navMarkerSize_ / dist;
     231                //float yDistScale = this->getActualSize().y * 1000.0f * navMarkerSize_ / dist;
     232
     233                // Adjust Arrowsize according to distance
     234                it->second.panel_->setDimensions(getArrowSizeX(dist),getArrowSizeY(dist));
    208235
    209236                // Switch between top, bottom, left and right position of the arrow at the screen border
     
    262289                  //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
    263290                    it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) );
     291                    it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y );
    264292                    it->second.wasOutOfView_ = false;
    265293                }
  • code/branches/hud/src/modules/overlays/hud/HUDNavigation.h

    r7401 r8920  
    2424 *   Co-authors:
    2525 *      Reto Grieder
     26 *      Matthias Spalinger
    2627 *
    2728 */
     
    9798    sortedList sortedObjectList_;
    9899
     100    float getArrowSizeX(int dist);   
     101    float getArrowSizeY(int dist);
    99102
    100103    float navMarkerSize_;
    101104    std::string fontName_;
    102105    float textSize_;
     106    bool showDistance;
    103107
    104108    unsigned int markerLimit_;; //TODO: is it possible to set this over the console and/or the IG-Setting
Note: See TracChangeset for help on using the changeset viewer.