Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9877


Ignore:
Timestamp:
Dec 9, 2013, 2:06:55 PM (11 years ago)
Author:
wroennin
Message:

Math: New function to determine the ZOrder of the radarobjects; HUDTemplates: cleenup

Location:
code/branches/radarDreiD
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo

    r9847 r9877  
    108108    />
    109109
    110 <!--
    111     <HUDRadar
    112      name          = "Radar"
    113      background    = "Orxonox/Radar"
    114      correctaspect = true
    115      size          = "0.17, 0.17"
    116      position      = "1.0, 1.0"
    117      pickpoint     = "1.0, 1.0"
    118      rotation      = 0
    119      sensitivity   = 1.0
    120      halfDotSizeDistance = 3000
    121      maximumDotSize      = 0.1
    122     />
    123     -->
    124    
    125    
    126  
    127     <HUDRadar
     110        <HUDRadar
    128111     name                               = "Radar"
    129112     background                         = "Orxonox/Radar3D"
     
    140123     halfDotSizeDistance        = 3000
    141124     maximumDotSize             = 0.1
    142      maximumDotSize3D           = 0.07
     125     maximumDotSize3D           = 0.06
    143126     mapAngle3D                         = 0.6435011
    144127    />
    145128   
    146 
    147129    <HUDTimer
    148130     name     = "Timer"
  • code/branches/radarDreiD/src/libraries/util/Math.cc

    r9792 r9877  
    208208    {
    209209        // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right
    210         orxonox::Vector3 distance = otherposition - myposition;
     210        orxonox::Vector3 distance = otherposition - myposition; // get vector from Ship to object
    211211
    212212        // new coordinate system:       x_axsis:        mydirection             (points front)
     
    214214        //                                                      z_axsis:        myside                  (points right)
    215215
    216         orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector from Ship to object
     216        orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get 3. base vector
    217217
    218218        distance = 4*distance / detectionlimit; // shrink vector on map
     
    263263        else
    264264                return false;
     265    }
     266
     267    /**
     268                   @brief A value between 0 and 10, in order how other object is in front or in back
     269                   @param myposition My position
     270                   @param mydirection My viewing direction
     271                   @param myorthonormal My orthonormalvector (pointing upwards through my head)
     272                   @param otherposition The position of the other object
     273                   @param detectionlimit The limit in which objects are shown on the map
     274                   @return value between 0 and 100
     275    */
     276    int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit)
     277    {
     278        orxonox::Vector3 distance = otherposition - myposition; // get vector from Ship to object
     279        orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal);      // get vector to the side
     280
     281        distance = 4*distance / detectionlimit; // shrink vector on map
     282        if(distance.length() > 1.0f) // if object would wander outside of the map
     283        {
     284                distance = distance / distance.length();
     285        }
     286
     287        // perform a coordinate transformation to get distance in relation of the position of the ship
     288        orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside);
     289
     290        return (int) 50 - 100*distanceShip.x;
    265291    }
    266292
  • code/branches/radarDreiD/src/libraries/util/Math.h

    r9792 r9877  
    9494    _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit);
    9595    _UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle);
     96    _UtilExport int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit);
    9697    _UtilExport orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside);
    9798    _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
  • code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc

    r9852 r9877  
    193193        {
    194194                this->setBackgroundMaterial(material3D_);
    195                 this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 10);
    196                 this->map3DBack_->_notifyZOrder(this->overlay_->getZOrder() * 100 - 10);
     195                this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 250); // it seems that the ZOrder of overlayelements is 100 times the ZOrder of the overlay
     196                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
    197197                this->map3DFront_->show();
    198198                this->map3DBack_->show();
     
    235235                bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), this->mapAngle_);
    236236
    237                 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
    238                         it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1);
    239                 if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder()))
    240                         it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1);
     237                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
     238                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_));
     239                if(overXZPlain == true /*&& (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())*/)
     240                        it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_));
    241241            }
    242242            else
Note: See TracChangeset for help on using the changeset viewer.