Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10149


Ignore:
Timestamp:
Dec 3, 2014, 4:16:49 PM (9 years ago)
Author:
aejonas
Message:

the healthbar is now changing its size every thime the spaceship loses one tenth of the initial health

Location:
code/branches/hudHS14
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hudHS14/data/overlays/HUDTemplates3.oxo

    r10110 r10149  
    8282     background        = "Orxonox/HealthBarBackground"
    8383     size              = "0.35, 0.0875"
    84      position          = "1 ,0"
    85      pickpoint         = "0.6, 0.5"
     84     position          = "1 ,0.1"
     85     pickpoint         = "1, 1"
    8686     bartexture        = "healthbar_bar.png"
    8787     textfont          = "VeraMono"
     
    8989     textsize          = 0.039
    9090     textoffset        = "0.315, 0.05"
    91      textpickpoint     = "2, 1"
     91     textpickpoint     = "0, 0"
    9292     textalign         = "right"
    9393     correctaspect     = false
  • code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc

    r10143 r10149  
    8282        this->setNavMarkerSize(0.03f);
    8383        this->setAimMarkerSize(0.02f);
    84         this->setHealthMarkerSize(0.08f);
     84        this->setHealthMarkerSize(0.06f);
    8585
    8686        this->setDetectionLimit(10000.0f);
     
    367367
    368368
     369                        //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
     370
     371                    Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
     372                    float health = pawnPtr->getHealth();
     373                    float initHealth = pawnPtr->getMaxHealth();
     374                    float relativHealthScale = health/initHealth;
     375
     376                    //values from 0 to 10
     377                    int discreteHealthScale = 10*relativHealthScale;
    369378
    370379
     
    379388
    380389                        //
    381                         it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2.png", it->first->getRadarObjectColour()));
    382                         it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , this->healthMarkerSize_ * this->getActualSize().y);
     390                        //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour()));
     391                        it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
     392                        it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75*this->healthMarkerSize_ * this->getActualSize().y);
    383393                        it->second.wasOutOfView_ = false;
    384                     }
    385 
    386 
    387                     //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
    388 
    389                     Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
    390                     float health = pawnPtr->getHealth();
    391                     float initHealth = pawnPtr->getMaxHealth();
    392                     float relativHealthScale = health/initHealth;
     394
     395                        if(1<=discreteHealthScale){
     396                                it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
     397                                it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1*discreteHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
     398                        }
     399                    }
     400
    393401
    394402
     
    396404                    it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
    397405                    it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
    398                     it->second.health_->setTop((-pos.y + 1.025f - it->second.panel_->getHeight()) * 0.5f);
    399                     it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, this->healthMarkerSize_ * this->getActualSize().y);
    400                     orxout() << relativHealthScale << endl;
     406                    it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f);
     407                   // it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
     408
     409
     410                    if(1<=discreteHealthScale){
     411                    it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
     412                    it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1*discreteHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
     413                    }
     414
    401415
    402416
     
    507521
    508522        // Create everything needed to display the object on the radar and add it to the map
     523
    509524        // Create health
    510525                Ogre::PanelOverlayElement* health = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton()
    511526                        .createOverlayElement("Panel", "HUDNavigation_healthMarker_" + getUniqueNumberString()));
    512527                //panel->setMaterialName("Orxonox/NavTDC");
    513                 health->setMaterialName(TextureGenerator::getMaterialName("bar2.png", object->getRadarObjectColour()));
     528                health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour()));
    514529                health->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
    515530                //panel->setColour(object->getRadarObjectColour());
Note: See TracChangeset for help on using the changeset viewer.