Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2011, 4:45:22 PM (14 years ago)
Author:
smerkli
Message:

merged hud branch

Location:
code/branches/presentation2011
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/modules/overlays/hud/HUDNavigation.cc

    r8891 r8988  
    2525 *      Reto Grieder
    2626 *      Oliver Scheuss
     27 *      Matthias Spalinger
    2728 *
    2829 */
     
    6364{
    6465  SetConfigValue(markerLimit_, 3);
    65 
     66  SetConfigValue(showDistance, false);
    6667}
    6768
     
    7879    setTextSize ( 0.05f );
    7980    setNavMarkerSize ( 0.05f );
    80     setDetectionLimit( 10000.0f );
    8181}
    8282
     
    9797    SUPER ( HUDNavigation, XMLPort, xmlelement, mode );
    9898
    99     XMLPortParam ( HUDNavigation, "font",           setFont,           getFont,           xmlelement, mode );
    100     XMLPortParam ( HUDNavigation, "textSize",       setTextSize,       getTextSize,       xmlelement, mode );
    101     XMLPortParam ( HUDNavigation, "navMarkerSize",  setNavMarkerSize,  getNavMarkerSize,  xmlelement, mode );
    102     XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode );
     99    XMLPortParam ( HUDNavigation, "font",          setFont,          getFont,          xmlelement, mode );
     100    XMLPortParam ( HUDNavigation, "textSize",      setTextSize,      getTextSize,      xmlelement, mode );
     101    XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode );
    103102}
    104103
     
    144143}
    145144
    146 
     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}
    147158
    148159void HUDNavigation::tick ( float dt )
     
    164175
    165176    unsigned int markerCount_ = 0;
    166     bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player
     177
    167178//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
    168179    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
    169180    {
    170181        ObjectMap::iterator it = activeObjectList_.find ( listIt->first );
    171         closeEnough_ = listIt->second < detectionLimit_ ;
    172         if ( markerCount_ < markerLimit_ && (closeEnough_ ||  detectionLimit_ < 0) ) // display on HUD if the statement is true
     182
     183        if ( markerCount_ < markerLimit_ )
    173184        {
    174185
     
    176187            // Get Distance to HumanController and save it in the TextAreaOverlayElement.
    177188            int dist = listIt->second;
     189            float textLength = 0.0f;
     190
     191            //display distance next to cursor
     192            if (showDistance){
    178193            it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
    179             float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
     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            }
    180202
    181203            // Transform to screen coordinates
     
    194216            else
    195217                outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
    196             // Get Distance to HumanController and save it in the TextAreaOverlayElement.
    197             it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
    198218
    199219            if ( outOfView )
     
    207227                    it->second.wasOutOfView_ = true;
    208228                }
     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));
    209235
    210236                // Switch between top, bottom, left and right position of the arrow at the screen border
     
    263289                  //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
    264290                    it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) );
     291                    it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y );
    265292                    it->second.wasOutOfView_ = false;
    266293                }
     
    280307            it->second.text_->show();
    281308        }
    282         else // do not display on HUD
     309        else
    283310        {
    284311            it->second.panel_->hide();
     
    312339void HUDNavigation::addObject ( RadarViewable* object )
    313340{
    314     if( showObject(object) == false )
     341    if( showObject(object)==false )
    315342        return;
    316343
     
    399426        return false;
    400427    assert( rv->getWorldEntity() );
    401     if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false )
     428    if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
    402429        return false;
    403430    return true;
Note: See TracChangeset for help on using the changeset viewer.