Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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/src/libraries/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.