Changeset 10163 for code/branches/hudHS14
- Timestamp:
- Dec 10, 2014, 3:10:55 PM (10 years ago)
- Location:
- code/branches/hudHS14/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc
r10149 r10163 83 83 this->setAimMarkerSize(0.02f); 84 84 this->setHealthMarkerSize(0.06f); 85 this->setHealthLevelMarkerSize(0.06f); 85 86 86 87 this->setDetectionLimit(10000.0f); … … 118 119 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlelement, mode); 119 120 XMLPortParam(HUDNavigation, "healthMarkerSize", setHealthMarkerSize, getHealthMarkerSize, xmlelement, mode); 121 XMLPortParam(HUDNavigation, "healthLevelMarkerSize", setHealthLevelMarkerSize, getHealthLevelMarkerSize, xmlelement, mode); 120 122 121 123 } … … 305 307 { 306 308 it->second.health_->hide(); 309 it->second.healthLevel_->hide(); 307 310 it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour())); 308 311 it->second.wasOutOfView_ = true; … … 367 370 368 371 369 //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health) 370 372 //calculate the health of the actual selected radarViewable (relativHealthScale: while (0) is no health left, (1) is the initial health) 371 373 Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity()); 372 374 float health = pawnPtr->getHealth(); … … 374 376 float relativHealthScale = health/initHealth; 375 377 376 // values from 0 to 10378 //integer values from 0 to 10 (0 is no health and 10 is full health) 377 379 int discreteHealthScale = 10*relativHealthScale; 380 381 //calculate the HealthLevel (= OponentLevel or Strength) there are 5 Levels 382 //Level 1, Level 2,... , Level 5 383 int HealthLevel = 1; 384 385 if(initHealth < 200) 386 HealthLevel = 1; 387 if(200 <= initHealth && initHealth < 500) 388 HealthLevel = 2; 389 if(500 <= initHealth && initHealth < 1000) 390 HealthLevel = 3; 391 if(1000 <= initHealth && initHealth < 2500) 392 HealthLevel = 4; 393 if(2500 <= initHealth) 394 HealthLevel = 5; 378 395 379 396 … … 387 404 it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y); 388 405 389 // 406 390 407 //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour())); 391 408 it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour())); … … 393 410 it->second.wasOutOfView_ = false; 394 411 412 // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the 413 // spaceship is still intact there should be at least one part of the bar left. 395 414 if(1<=discreteHealthScale){ 396 415 it->second.health_->setTiling((float)discreteHealthScale , 1 ,0); 397 416 it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1*discreteHealthScale, 0.75*this->healthMarkerSize_ * this->getActualSize().y); 398 417 } 399 } 400 401 402 403 // Position and Dimensions (amount) health 418 419 420 421 //healthLevel 422 it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour())); 423 it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x , 0.75*this->healthLevelMarkerSize_ * this->getActualSize().y); 424 it->second.wasOutOfView_ = false; 425 it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0); 426 it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1*HealthLevel, 0.25*this->healthLevelMarkerSize_ * this->getActualSize().y); 427 } 428 429 430 431 // sets Position and Dimensions (amount) health 404 432 it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f); 405 433 it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f); 406 434 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 435 436 437 // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the 438 // spaceship is still intact there should be at least one part of the bar left. 410 439 if(1<=discreteHealthScale){ 411 440 it->second.health_->setTiling((float)discreteHealthScale , 1 ,0); … … 413 442 } 414 443 444 445 //sets Position and Dimensions (level) of healthLevel 446 it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour())); 447 it->second.healthLevel_->setUV(0.0f, 0.0f, 1.0f, 1.0f); 448 it->second.healthLevel_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f); 449 it->second.healthLevel_->setTop((-pos.y + 1.125f - it->second.panel_->getHeight()) * 0.5f); 450 451 it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0); 452 it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1*HealthLevel, 0.25*this->healthLevelMarkerSize_ * this->getActualSize().y); 415 453 416 454 … … 424 462 it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f); 425 463 464 465 466 426 467 // Make sure the overlays are shown 427 428 468 it->second.health_->show(); 469 it->second.healthLevel_->show(); 429 470 it->second.panel_->show(); 430 471 it->second.text_->show(); … … 470 511 { 471 512 it->second.health_->hide(); 472 it->second.panel_->hide(); 513 it->second.healthLevel_->hide(); 514 it->second.panel_->hide(); 473 515 it->second.text_->hide(); 474 516 it->second.target_->hide(); … … 495 537 if (it->second.health_ != NULL) 496 538 it->second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale); 539 if (it->second.healthLevel_ != NULL) 540 it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale); 497 541 if (it->second.panel_ != NULL) 498 542 it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale); … … 523 567 524 568 // Create health 525 Ogre::PanelOverlayElement* health = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton() 526 .createOverlayElement("Panel", "HUDNavigation_healthMarker_" + getUniqueNumberString())); 527 //panel->setMaterialName("Orxonox/NavTDC"); 528 health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour())); 529 health->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale); 530 //panel->setColour(object->getRadarObjectColour()); 569 Ogre::PanelOverlayElement* health = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDNavigation_healthMarker_" + getUniqueNumberString())); 570 //panel->setMaterialName("Orxonox/NavTDC"); 571 health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour())); 572 health->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale); 573 //panel->setColour(object->getRadarObjectColour()); 574 575 // Create healthLevel 576 Ogre::PanelOverlayElement* healthLevel = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDNavigation_healthLevelMarker_" + getUniqueNumberString())); 577 //panel->setMaterialName("Orxonox/NavTDC"); 578 health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour())); 579 health->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale); 531 580 532 581 … … 553 602 554 603 health->hide(); 604 healthLevel->hide(); 555 605 panel->hide(); 556 606 target->hide(); … … 558 608 559 609 ObjectInfo tempStruct = 560 { health, panel, target, text, false, false, false};610 { health, healthLevel, panel, target, text, false, false, false}; 561 611 this->activeObjectList_[object] = tempStruct; 562 612 563 613 this->background_->addChild(health); 614 this->background_->addChild(healthLevel); 564 615 this->background_->addChild(panel); 565 616 this->background_->addChild(target); … … 577 628 // Detach overlays 578 629 this->background_->removeChild(it->second.health_->getName()); 630 this->background_->removeChild(it->second.healthLevel_->getName()); 579 631 this->background_->removeChild(it->second.panel_->getName()); 580 632 this->background_->removeChild(it->second.target_->getName()); … … 582 634 // Properly destroy the overlay elements (do not use delete!) 583 635 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.health_); 636 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.healthLevel_); 584 637 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_); 585 638 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.target_); -
code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.h
r10122 r10163 78 78 { 79 79 80 //manipulation bzw versuch !!! health additional 80 81 81 82 Ogre::PanelOverlayElement* health_; 83 Ogre::PanelOverlayElement* healthLevel_; 82 84 Ogre::PanelOverlayElement* panel_; 83 85 Ogre::PanelOverlayElement* target_; … … 98 100 inline float getHealthMarkerSize() const 99 101 { return healthMarkerSize_; } 102 103 inline void setHealthLevelMarkerSize(float size) 104 { 105 this->healthLevelMarkerSize_ = size; 106 this->sizeChanged(); 107 } 108 inline float getHealthLevelMarkerSize() const 109 { return healthLevelMarkerSize_; } 100 110 101 111 inline void setNavMarkerSize(float size) … … 134 144 135 145 float healthMarkerSize_; 146 float healthLevelMarkerSize_; 136 147 float navMarkerSize_; 137 148 float aimMarkerSize_;
Note: See TracChangeset
for help on using the changeset viewer.