Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2013, 2:00:00 PM (11 years ago)
Author:
smerkli
Message:

Merged branch radarDreiD into presentationbranch

Location:
code/branches/presentationHS13
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS13

  • code/branches/presentationHS13/src/modules/overlays/hud/HUDNavigation.cc

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

    r9667 r9904  
    2525 *   Co-authors:
    2626 *      Reto Grieder
     27 *      Wolfgang Roenninger
    2728 *
    2829 */
     
    4142#include "Scene.h"
    4243#include "Radar.h"
     44#include "core/config/ConfigValueIncludes.h"
    4345
    4446namespace orxonox
     
    5052    {
    5153        RegisterObject(HUDRadar);
     54        this->setConfigValues();
    5255
    5356        this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     
    6063        this->setHalfDotSizeDistance(3000.0f);
    6164        this->setMaximumDotSize(0.1f);
     65        this->setMaximumDotSize3D(0.07f);
    6266
    6367        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.png";
    6468        this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png";
    6569        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.png";
    66         this->setDetectionLimit( 10000.0f );
    6770        this->owner_ = 0;
     71
     72        this->map3DFront_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     73                .createOverlayElement("Panel", "HUDRadar_mapDreiDFront_" + getUniqueNumberString()));
     74        this->map3DFront_->setMaterialName("Orxonox/Radar3DFront");
     75        this->overlay_->add2D(this->map3DFront_);
     76        this->map3DFront_->hide();
     77
     78        this->map3DBack_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     79                .createOverlayElement("Panel", "HUDRadar_mapDreiDBack_" + getUniqueNumberString()));
     80        this->map3DBack_->setMaterialName("Orxonox/Radar3DBack");
     81        this->overlay_->add2D(this->map3DBack_);
     82        this->map3DBack_->hide();
     83
    6884    }
    6985
     
    7389        {
    7490            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
     91            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DFront_);
     92            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DBack_);
     93
    7594            for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin();
    7695                it != this->radarObjects_.end(); ++it)
     
    8099        }
    81100    }
     101
     102
     103
     104    void HUDRadar::setConfigValues()
     105       {
     106           SetConfigValue(RadarMode_, true);
     107       }
    82108
    83109    void HUDRadar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    88114        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);
    89115        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlelement, mode);
     116        XMLPortParam(HUDRadar, "maximumDotSize3D", setMaximumDotSize3D, getMaximumDotSize3D, xmlelement, mode);
     117        XMLPortParam(HUDRadar, "material2D", set2DMaterial, get2DMaterial, xmlelement, mode);
     118        XMLPortParam(HUDRadar, "material3DMiddle", set3DMaterial, get3DMaterial, xmlelement, mode);
     119        XMLPortParam(HUDRadar, "material3DFront", set3DMaterialFront, get3DMaterialFront, xmlelement, mode);
     120        XMLPortParam(HUDRadar, "material3DBack", set3DMaterialBack, get3DMaterialBack, xmlelement, mode);
     121        XMLPortParam(HUDRadar, "mapAngle3D", setMapAngle, getMapAngle, xmlelement, mode);
     122        XMLPortParam(HUDRadar, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode);
    90123    }
    91124
     
    152185        // update the distances for all objects
    153186        std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it;
     187
     188
     189        if(RadarMode_)
     190        {
     191                this->setBackgroundMaterial(material3D_);
     192                this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 250); // it seems that the ZOrder of overlayelements is 100 times the ZOrder of the overlay
     193                this->map3DBack_->_notifyZOrder(this->overlay_->getZOrder() * 100 - 250); // 250 a little bit buffer so that the two shels are displayed all in the front / in the back
     194                this->map3DFront_->show();
     195                this->map3DBack_->show();
     196        }
     197        else
     198        {
     199                this->setBackgroundMaterial(material2D_);
     200                this->map3DFront_->hide();
     201                this->map3DBack_->hide();
     202        }
     203
    154204        for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it )
    155205        {
     
    165215            float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
    166216            // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
    167             float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
     217
     218            float size;
     219            if(RadarMode_)
     220                size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
     221            else
     222                size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
    168223            it->second->setDimensions(size, size);
    169224
    170225            // calc position on radar...
    171             Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
     226            Vector2 coord;
     227
     228            if(RadarMode_)
     229            {
     230                coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_);
     231
     232                // set zOrder on screen
     233                bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), this->mapAngle_);
     234
     235                int zOrder = determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_);
     236                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
     237                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + zOrder);
     238                if(overXZPlain == true /*&& (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())*/)
     239                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + zOrder);
     240            }
     241            else
     242                coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
     243
    172244            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
    173245            it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
     246
    174247            if( distance < detectionLimit_ || detectionLimit_ < 0 )
    175248                it->second->show();
     
    182255                this->marker_->setDimensions(size * 1.5f, size * 1.5f);
    183256                this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f);
     257                if(RadarMode_)
     258                        this->marker_->_notifyZOrder(it->second->getZOrder() -1);
    184259                this->marker_->show();
    185260            }
  • code/branches/presentationHS13/src/modules/overlays/hud/HUDRadar.h

    r9667 r9904  
    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:
     
    5759        void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; }
    5860
    59         void setDetectionLimit( float limit )
    60         { this->detectionLimit_ = limit; }
    61         float getDetectionLimit() const
    62         { return this->detectionLimit_; }
     61        void setDetectionLimit( float limit ) { this->detectionLimit_ = limit; }
     62        float getDetectionLimit() const { return this->detectionLimit_; }
    6363
    6464        float getMaximumDotSize() const { return this->maximumDotSize_; }
    6565        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
    6666
     67        float getMaximumDotSize3D() const { return this->maximumDotSize3D_; }
     68        void setMaximumDotSize3D(float size) { this->maximumDotSize3D_ = size;}
     69
     70        std::string get2DMaterial() const {return this->material2D_; }
     71        void set2DMaterial(std::string material2D) { this->material2D_ = material2D; }
     72
     73        std::string get3DMaterial() const {return this->material3D_; }
     74        void set3DMaterial(std::string material3D) { this->material3D_ = material3D; }
     75
     76        std::string get3DMaterialFront() const {return this->material3DFront_; }
     77        void set3DMaterialFront(std::string material3DFront) { this->material3DFront_ = material3DFront; }
     78
     79        std::string get3DMaterialBack() const {return this->material3DBack_; }
     80        void set3DMaterialBack(std::string material3DBack) { this->material3DBack_ = material3DBack; }
     81
    6782        float getRadarSensitivity() const { return this->sensitivity_; }
    6883        // used also by RadarListener interface!
    6984        void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; }
     85
     86        // Determines angle between line of sight and x/z-plain on the 3D minimap
     87        float getMapAngle() const { return this->mapAngle_; }
     88        void setMapAngle(float mapAngle) { this->mapAngle_ = mapAngle; }
    7089
    7190        // RadarListener interface
     
    85104        Ogre::PanelOverlayElement* marker_;
    86105
     106        bool RadarMode_; // Determines, if Radar runs in 3D or 2D Mode
     107
    87108        float halfDotSizeDistance_;
    88109        float maximumDotSize_;
     110        float maximumDotSize3D_;
     111        float mapAngle_;
     112
     113        std::string material2D_;                //Material name for 2D map
     114        std::string material3D_;                //Material names For the 3D minimap
     115        std::string material3DFront_;
     116        std::string material3DBack_;
     117
     118        Ogre::PanelOverlayElement* map3DFront_; //Overlayelements for the 3D minimap to be able to draw the points in a semi 3D matter
     119        Ogre::PanelOverlayElement* map3DBack_;
    89120
    90121        float sensitivity_;
Note: See TracChangeset for help on using the changeset viewer.