- Timestamp:
- Feb 1, 2015, 8:58:38 PM (10 years ago)
- Location:
- code/branches/presentationHS14merge
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS14merge
- Property svn:mergeinfo changed
/code/branches/hudHS14 (added) merged: 10083,10110,10122,10143,10149,10163,10239-10241
- Property svn:mergeinfo changed
-
code/branches/presentationHS14merge/src/modules/overlays/hud/HUDNavigation.cc
r9939 r10242 82 82 this->setNavMarkerSize(0.03f); 83 83 this->setAimMarkerSize(0.02f); 84 this->setHealthMarkerSize(0.06f); 85 this->setHealthLevelMarkerSize(0.06f); 84 86 85 87 this->setDetectionLimit(10000.0f); … … 116 118 XMLPortParam(HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode); 117 119 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlelement, mode); 120 XMLPortParam(HUDNavigation, "healthMarkerSize", setHealthMarkerSize, getHealthMarkerSize, xmlelement, mode); 121 XMLPortParam(HUDNavigation, "healthLevelMarkerSize", setHealthLevelMarkerSize, getHealthLevelMarkerSize, xmlelement, mode); 122 118 123 } 119 124 … … 206 211 for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt) 207 212 { 213 208 214 std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.find(listIt->first); 209 215 closeEnough = listIt->second < this->detectionLimit_; … … 275 281 276 282 283 284 277 285 // Transform to screen coordinates 278 286 Vector3 pos = camTransform * it->first->getRVWorldPosition(); … … 298 306 if (!it->second.wasOutOfView_) 299 307 { 308 it->second.health_->hide(); 309 it->second.healthLevel_->hide(); 300 310 it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour())); 301 311 it->second.wasOutOfView_ = true; … … 357 367 // Object is in view 358 368 369 370 371 372 //calculate the health of the actual selected radarViewable (relativHealthScale: while (0) is no health left, (1) is the initial health) 373 Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity()); 374 float health = pawnPtr->getHealth(); 375 float initHealth = pawnPtr->getMaxHealth(); 376 float relativHealthScale = health/initHealth; 377 378 //integer values from 0 to 10 (0 is no health and 10 is full health) 379 int discreteHealthScale = (int)(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; 395 396 397 359 398 // Change material only if outOfView changed 360 399 if (it->second.wasOutOfView_) … … 364 403 it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y); 365 404 it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y); 405 406 407 //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour())); 408 it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour())); 409 it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75f*this->healthMarkerSize_ * this->getActualSize().y); 366 410 it->second.wasOutOfView_ = false; 367 } 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. 414 if(1<=discreteHealthScale){ 415 it->second.health_->setTiling((float)discreteHealthScale , 1 ,0); 416 it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y); 417 } 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.75f*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.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y); 427 } 428 429 430 431 // sets Position and Dimensions (amount) health 432 it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f); 433 it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f); 434 it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f); 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. 439 if(1<=discreteHealthScale){ 440 it->second.health_->setTiling((float)discreteHealthScale , 1 ,0); 441 it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y); 442 } 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.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y); 453 368 454 369 455 // Position marker … … 376 462 it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f); 377 463 464 465 466 378 467 // Make sure the overlays are shown 468 it->second.health_->show(); 469 it->second.healthLevel_->show(); 379 470 it->second.panel_->show(); 380 471 it->second.text_->show(); … … 419 510 420 511 { 512 it->second.health_->hide(); 513 it->second.healthLevel_->hide(); 421 514 it->second.panel_->hide(); 422 515 it->second.text_->hide(); … … 442 535 for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it) 443 536 { 537 if (it->second.health_ != NULL) 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); 444 541 if (it->second.panel_ != NULL) 445 542 it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale); … … 468 565 469 566 // Create everything needed to display the object on the radar and add it to the map 567 568 // Create health 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); 580 470 581 471 582 // Create arrow/marker … … 490 601 text->setColour(object->getRadarObjectColour()); 491 602 603 health->hide(); 604 healthLevel->hide(); 492 605 panel->hide(); 493 606 target->hide(); … … 495 608 496 609 ObjectInfo tempStruct = 497 { panel, target, text, false, false, false};610 { health, healthLevel, panel, target, text, false, false, false}; 498 611 this->activeObjectList_[object] = tempStruct; 499 612 613 this->background_->addChild(health); 614 this->background_->addChild(healthLevel); 500 615 this->background_->addChild(panel); 501 616 this->background_->addChild(target); … … 512 627 { 513 628 // Detach overlays 629 this->background_->removeChild(it->second.health_->getName()); 630 this->background_->removeChild(it->second.healthLevel_->getName()); 514 631 this->background_->removeChild(it->second.panel_->getName()); 515 632 this->background_->removeChild(it->second.target_->getName()); 516 633 this->background_->removeChild(it->second.text_->getName()); 517 634 // Properly destroy the overlay elements (do not use delete!) 635 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.health_); 636 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.healthLevel_); 518 637 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_); 519 638 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.target_);
Note: See TracChangeset
for help on using the changeset viewer.