Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10171 for code


Ignore:
Timestamp:
Dec 11, 2014, 1:01:28 PM (10 years ago)
Author:
maxima
Message:

Branch hudHS14 merged with presentation branch

Location:
code/branches/presentationHS14
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS14

  • code/branches/presentationHS14/data/levels/kecks.oxw

    r10170 r10171  
    33 description = "Save your planet."
    44 tags = "Test"
    5  screenshot = "kecks.png"
     5 screenshot = "missionOne.png"
    66 gametype=Mission
    77/>
  • code/branches/presentationHS14/data/overlays/HUDTemplates3.oxo

    r9939 r10171  
    3636     size              = "0.35, 0.0875"
    3737     position          = "0.0 , 0.9 "
    38      pickpoint         = "0, 1"
     38     pickpoint         = "0, 1"       
    3939     bartexture        = "healthbar_bar.png"
    4040     textfont          = "VeraMono"
     
    8282     background        = "Orxonox/HealthBarBackground"
    8383     size              = "0.35, 0.0875"
    84      position          = "1.0 , 0.1 "
     84     position          = "1 ,0.1"
    8585     pickpoint         = "1, 1"
    8686     bartexture        = "healthbar_bar.png"
  • code/branches/presentationHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc

    r9667 r10171  
    3131#include "core/config/ConfigValueIncludes.h"
    3232#include "worldentities/pawns/Pawn.h"
     33#include "graphics/Camera.h"
    3334
    3435namespace orxonox
     
    5758        this->updateTarget();
    5859
     60
     61
     62/*
     63//--------------------------------------------------------------------------
     64        //first try to place a healthbar under the enemy ship
     65        //getting all the parameters (direction, position, angle) to place the health bar on the screen
     66
     67        Camera* camera = this->owner_->getCamera();
     68
     69        //position and orientation relative to the root space
     70        Vector3 cameraPosition = camera->getWorldPosition();
     71        Quaternion cameraOrientation = camera->getWorldOrientation();
     72
     73        Vector3 cameraDirection = camera->FRONT;
     74        Vector3 cameraOrthonormal = camera->UP;
     75
     76        //get target
     77        //if there is one get it's position (relative to the root space(
     78        WorldEntity* target = this->owner_->getTarget();
     79
     80        if(target != NULL){
     81        Vector3 targetPosition = target->getWorldPosition();
     82
     83
     84        //try 1
     85        Vector2 screenCoordinates = get2DViewcoordinates(cameraPosition, cameraOrientation * WorldEntity::FRONT, cameraOrientation * WorldEntity::UP, targetPosition);
     86
     87        orxout() << screenCoordinates.x << endl;
     88
     89        //shift coordinates because the screen has it's root in the upper left corner (0,0) but get2Dviewcoordiantes return values between -0.5 and 0.5
     90        screenCoordinates.x += 0.5;
     91        screenCoordinates.y += 0.5;
     92        orxout() << screenCoordinates.x << endl;
     93
     94        this->setPosition(screenCoordinates);
     95
     96        this->setTextOffset(screenCoordinates);
     97        }
     98        //--------------------------------------------------------------------------
     99*/
     100
     101
     102
    59103        SUPER(HUDEnemyHealthBar, tick, dt);
    60104    }
     
    71115                target = target->getParent();
    72116            pawn = orxonox_cast<Pawn*>(target);
     117
     118
    73119            // Don't show the HealthBar if the pawn is invisible
    74120            if (pawn && !pawn->isVisible())
    75121                pawn = NULL;
    76122        }
     123
    77124        // Set the pawn as owner of the HealthBar
    78125        this->setHealthBarOwner(pawn);
  • code/branches/presentationHS14/src/modules/overlays/hud/HUDHealthBar.cc

    r9667 r10171  
    8383        SUPER(HUDHealthBar, tick, dt);
    8484
     85
     86
     87
     88
    8589        if (this->owner_)
    8690        {
  • code/branches/presentationHS14/src/modules/overlays/hud/HUDNavigation.cc

    r9939 r10171  
    8282        this->setNavMarkerSize(0.03f);
    8383        this->setAimMarkerSize(0.02f);
     84        this->setHealthMarkerSize(0.06f);
     85        this->setHealthLevelMarkerSize(0.06f);
    8486
    8587        this->setDetectionLimit(10000.0f);
     
    116118        XMLPortParam(HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode);
    117119        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlelement, mode);
     120        XMLPortParam(HUDNavigation, "healthMarkerSize", setHealthMarkerSize, getHealthMarkerSize, xmlelement, mode);
     121        XMLPortParam(HUDNavigation, "healthLevelMarkerSize", setHealthLevelMarkerSize, getHealthLevelMarkerSize, xmlelement, mode);
     122
    118123    }
    119124
     
    206211        for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt)
    207212        {
     213
    208214            std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.find(listIt->first);
    209215            closeEnough = listIt->second < this->detectionLimit_;
     
    275281
    276282
     283
     284
    277285                // Transform to screen coordinates
    278286                Vector3 pos = camTransform * it->first->getRVWorldPosition();
     
    298306                    if (!it->second.wasOutOfView_)
    299307                    {
    300                         it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour()));
     308                        it->second.health_->hide();
     309                        it->second.healthLevel_->hide();
     310                        it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour()));
    301311                        it->second.wasOutOfView_ = true;
    302312                        it->second.target_->hide();
     
    357367                    // Object is in view
    358368
    359                     // Change material only if outOfView changed
     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 = 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
     398                        // Change material only if outOfView changed
    360399                    if (it->second.wasOutOfView_)
    361400                    {
     
    364403                        it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y);
    365404                        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.75*this->healthMarkerSize_ * this->getActualSize().y);
    366410                        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.1*discreteHealthScale, 0.75*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.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
     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.1*discreteHealthScale, 0.75*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.1*HealthLevel, 0.25*this->healthLevelMarkerSize_ * this->getActualSize().y);
     453
    368454
    369455                    // Position marker
     
    376462                    it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
    377463
     464
     465
     466
    378467                    // Make sure the overlays are shown
     468                    it->second.health_->show();
     469                    it->second.healthLevel_->show();
    379470                    it->second.panel_->show();
    380471                    it->second.text_->show();
     
    419510
    420511            {
    421                 it->second.panel_->hide();
     512                it->second.health_->hide();
     513                it->second.healthLevel_->hide();
     514                it->second.panel_->hide();
    422515                it->second.text_->hide();
    423516                it->second.target_->hide();
     
    442535        for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
    443536        {
     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);
    444541            if (it->second.panel_ != NULL)
    445542                it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
     
    468565
    469566        // 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
    470581
    471582        // Create arrow/marker
     
    490601        text->setColour(object->getRadarObjectColour());
    491602
     603        health->hide();
     604        healthLevel->hide();
    492605        panel->hide();
    493606        target->hide();
     
    495608
    496609        ObjectInfo tempStruct =
    497         {   panel, target, text, false, false, false};
     610        {   health, healthLevel, panel, target, text, false, false, false};
    498611        this->activeObjectList_[object] = tempStruct;
    499612
     613        this->background_->addChild(health);
     614        this->background_->addChild(healthLevel);
    500615        this->background_->addChild(panel);
    501616        this->background_->addChild(target);
     
    512627        {
    513628            // Detach overlays
     629                this->background_->removeChild(it->second.health_->getName());
     630                this->background_->removeChild(it->second.healthLevel_->getName());
    514631            this->background_->removeChild(it->second.panel_->getName());
    515632            this->background_->removeChild(it->second.target_->getName());
    516633            this->background_->removeChild(it->second.text_->getName());
    517634            // 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_);
    518637            Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_);
    519638            Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.target_);
  • code/branches/presentationHS14/src/modules/overlays/hud/HUDNavigation.h

    r9667 r10171  
    7777            struct ObjectInfo
    7878            {
    79                 Ogre::PanelOverlayElement* panel_;
     79
     80
     81
     82                Ogre::PanelOverlayElement* health_;
     83                Ogre::PanelOverlayElement* healthLevel_;
     84                Ogre::PanelOverlayElement* panel_;
    8085                Ogre::PanelOverlayElement* target_;
    8186                Ogre::TextAreaOverlayElement* text_;
     
    8893
    8994            // XMLPort accessors
     95            inline void setHealthMarkerSize(float size)
     96                        {
     97                            this->healthMarkerSize_ = size;
     98                            this->sizeChanged();
     99                        }
     100            inline float getHealthMarkerSize() const
     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_; }
     110
    90111            inline void setNavMarkerSize(float size)
    91112            {
     
    100121                this->sizeChanged();
    101122            }
     123
    102124            inline float getAimMarkerSize() const
    103125                { return aimMarkerSize_; }
     
    121143            std::list<std::pair<RadarViewable*, unsigned int> > sortedObjectList_;
    122144
     145            float healthMarkerSize_;
     146            float healthLevelMarkerSize_;
    123147            float navMarkerSize_;
    124148            float aimMarkerSize_;
Note: See TracChangeset for help on using the changeset viewer.