Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2013, 4:01:10 PM (11 years ago)
Author:
wroennin
Message:

HUDRadar: Added various XML ports, added changing between different BackgroundMaterials; MiscConfigMenu.lua: added point to change between 3D/2D; HUDTemplates3: updated parameters for new ports

Location:
code/branches/radarDreiD/src/modules/overlays/hud
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/radarDreiD/src/modules/overlays/hud/HUDNavigation.cc

    r9667 r9818  
    7474        OrxonoxOverlay(context)
    7575    {
    76         RegisterObject(HUDNavigation)
    77 ;        this->setConfigValues();
     76        RegisterObject(HUDNavigation);
     77        this->setConfigValues();
    7878
    7979        // Set default values
  • code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc

    r9796 r9818  
    4242#include "Scene.h"
    4343#include "Radar.h"
     44#include "core/config/ConfigValueIncludes.h"
    4445
    4546namespace orxonox
     
    5152    {
    5253        RegisterObject(HUDRadar);
     54        this->setConfigValues();
    5355
    5456        this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     
    6163        this->setHalfDotSizeDistance(3000.0f);
    6264        this->setMaximumDotSize(0.1f);
     65        this->setMaximumDotSize3D(0.07f);
    6366
    6467        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.png";
     
    8285    }
    8386
     87
     88
     89    void HUDRadar::setConfigValues()
     90       {
     91           SetConfigValue(RadarMode_, true);
     92       }
     93
    8494    void HUDRadar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    8595    {
     
    8999        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);
    90100        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlelement, mode);
     101        XMLPortParam(HUDRadar, "maximumDotSize3D", setMaximumDotSize3D, getMaximumDotSize3D, xmlelement, mode);
     102        XMLPortParam(HUDRadar, "Material2D", set2DMaterial, get2DMaterial, xmlelement, mode);
     103        XMLPortParam(HUDRadar, "Material3D", set3DMaterial, get3DMaterial, xmlelement, mode);
    91104    }
    92105
     
    153166        // update the distances for all objects
    154167        std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it;
     168
     169
     170        if(RadarMode_)
     171        {
     172                this->setBackgroundMaterial(material3D_);
     173
     174
     175
     176        }
     177        else
     178                this->setBackgroundMaterial(material2D_);
     179
     180
     181
    155182        for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it )
    156183        {
     
    166193            float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
    167194            // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
    168             float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
    169 
    170 
     195
     196            float size;
     197            if(RadarMode_)
     198                size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
     199            else
     200                size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
    171201            it->second->setDimensions(size, size);
    172202
    173203            // calc position on radar...
    174             //Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
    175             Vector2 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_);
    176 
    177             // set zOrder on screen
    178             bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011);
    179 
    180             if(overXZPlain == false && (it->second->getZOrder() >  100 * this->overlay_->getZOrder())) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay
    181                 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1);
    182             if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder()))
    183                 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1);
    184 
    185 
     204            Vector2 coord;
     205            if(RadarMode_)
     206            {
     207                coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_);
     208
     209                // set zOrder on screen
     210                bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011);
     211
     212                if(overXZPlain == false && (it->second->getZOrder() >  100 * this->overlay_->getZOrder())) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay
     213                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1);
     214                if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder()))
     215                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1);
     216            }
     217            else
     218                coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
    186219
    187220            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
  • code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.h

    r9667 r9818  
    3535#include <map>
    3636#include <vector>
     37#include <string>
    3738
    3839#include "util/OgreForwardRefs.h"
     
    5152        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5253        virtual void changedOwner();
     54        void setConfigValues();
    5355
    5456    private:
     
    6466        float getMaximumDotSize() const { return this->maximumDotSize_; }
    6567        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
     68
     69        float getMaximumDotSize3D() const { return this->maximumDotSize3D_; }
     70        void setMaximumDotSize3D(float size) { this->maximumDotSize3D_ = size;}
     71
     72        std::string get2DMaterial() const {return this->material2D_; }
     73        void set2DMaterial(std::string material2D) { this->material2D_ = material2D; }
     74
     75        std::string get3DMaterial() const {return this->material3D_; }
     76        void set3DMaterial(std::string material3D) { this->material3D_ = material3D; }
    6677
    6778        float getRadarSensitivity() const { return this->sensitivity_; }
     
    8596        Ogre::PanelOverlayElement* marker_;
    8697
     98        bool RadarMode_; // Determines, if Radar runs in 3D or 2D Mode
     99
    87100        float halfDotSizeDistance_;
    88101        float maximumDotSize_;
     102        float maximumDotSize3D_;
     103
     104        std::string material2D_;
     105        std::string material3D_;
    89106
    90107        float sensitivity_;
Note: See TracChangeset for help on using the changeset viewer.