[Orxonox-commit 5486] r10149 - in code/branches/hudHS14: data/overlays src/modules/overlays/hud

aejonas at orxonox.net aejonas at orxonox.net
Wed Dec 3 16:16:49 CET 2014


Author: aejonas
Date: 2014-12-03 16:16:49 +0100 (Wed, 03 Dec 2014)
New Revision: 10149

Modified:
   code/branches/hudHS14/data/overlays/HUDTemplates3.oxo
   code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc
Log:
the healthbar is now changing its size every thime the spaceship loses one tenth of the initial health

Modified: code/branches/hudHS14/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/hudHS14/data/overlays/HUDTemplates3.oxo	2014-12-03 14:54:27 UTC (rev 10148)
+++ code/branches/hudHS14/data/overlays/HUDTemplates3.oxo	2014-12-03 15:16:49 UTC (rev 10149)
@@ -81,14 +81,14 @@
      name              = "EnemyHealthBar"
      background        = "Orxonox/HealthBarBackground"
      size              = "0.35, 0.0875"
-     position          = "1 ,0"
-     pickpoint         = "0.6, 0.5"
+     position          = "1 ,0.1"
+     pickpoint         = "1, 1"
      bartexture        = "healthbar_bar.png"
      textfont          = "VeraMono"
      textusebarcolour  = true
      textsize          = 0.039
      textoffset        = "0.315, 0.05"
-     textpickpoint     = "2, 1"
+     textpickpoint     = "0, 0"
      textalign         = "right"
      correctaspect     = false
      textcorrectaspect = false

Modified: code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc	2014-12-03 14:54:27 UTC (rev 10148)
+++ code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc	2014-12-03 15:16:49 UTC (rev 10149)
@@ -81,7 +81,7 @@
         this->setTextSize(0.05f);
         this->setNavMarkerSize(0.03f);
         this->setAimMarkerSize(0.02f);
-        this->setHealthMarkerSize(0.08f);
+        this->setHealthMarkerSize(0.06f);
 
         this->setDetectionLimit(10000.0f);
         this->currentMunitionSpeed_ = 2500.0f;
@@ -366,9 +366,18 @@
 
 
 
+                	//calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
 
+                    Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
+                    float health = pawnPtr->getHealth();
+                    float initHealth = pawnPtr->getMaxHealth();
+                    float relativHealthScale = health/initHealth;
 
+                    //values from 0 to 10
+                    int discreteHealthScale = 10*relativHealthScale;
 
+
+
                 	// Change material only if outOfView changed
                     if (it->second.wasOutOfView_)
                     {
@@ -378,28 +387,33 @@
                         it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
 
                         //
-                        it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2.png", it->first->getRadarObjectColour()));
-                        it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , this->healthMarkerSize_ * this->getActualSize().y);
+                        //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour()));
+                        it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+                        it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75*this->healthMarkerSize_ * this->getActualSize().y);
                         it->second.wasOutOfView_ = false;
+
+                        if(1<=discreteHealthScale){
+                        	it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
+                        	it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1*discreteHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
+                        }
                     }
 
 
-                    //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
 
-                    Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
-                    float health = pawnPtr->getHealth();
-                    float initHealth = pawnPtr->getMaxHealth();
-                    float relativHealthScale = health/initHealth;
-
-
                     // Position and Dimensions (amount) health
                     it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
                     it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
-                    it->second.health_->setTop((-pos.y + 1.025f - it->second.panel_->getHeight()) * 0.5f);
-                    it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, this->healthMarkerSize_ * this->getActualSize().y);
-                    orxout() << relativHealthScale << endl;
+                    it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f);
+                   // it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
 
 
+                    if(1<=discreteHealthScale){
+                    it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
+                    it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1*discreteHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y);
+                    }
+
+
+
                     // Position marker
                     it->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
                     it->second.panel_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
@@ -506,11 +520,12 @@
         float yScale = this->getActualSize().y;
 
         // Create everything needed to display the object on the radar and add it to the map
+
         // Create health
                 Ogre::PanelOverlayElement* health = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton()
                         .createOverlayElement("Panel", "HUDNavigation_healthMarker_" + getUniqueNumberString()));
                 //panel->setMaterialName("Orxonox/NavTDC");
-                health->setMaterialName(TextureGenerator::getMaterialName("bar2.png", object->getRadarObjectColour()));
+                health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour()));
                 health->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
                 //panel->setColour(object->getRadarObjectColour());
 




More information about the Orxonox-commit mailing list