Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 18, 2013, 1:54:40 PM (11 years ago)
Author:
wroennin
Message:

Math.cc: fixed Transformation; HUDRadar.cc: added transparence setting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/radarDreiD/src/libraries/util/Math.cc

    r9779 r9787  
    213213        //                                                      y_axsis:        myorthonormal   (points up)
    214214        //                                                      z_axsis:        myside                  (points right)
    215         orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal);
    216         orxout() << "mydirection " << mydirection << endl;
    217         orxout() << "mydirection.lenght " << mydirection.length() << endl;
    218         orxout() << "myorthonormal " << myorthonormal << endl;
    219         orxout() << "myorthonormal.lenght " << myorthonormal.length() << endl;
    220         orxout() << "myside " << myside << endl;
    221         orxout() << "myside.lenght " << myside.length() << endl;
    222 
    223         distance = 5 * distance / detectionlimit; // shrink vector on map
     215
     216        orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector from Ship to object
     217
     218        distance = 4*distance / detectionlimit; // shrink vector on map
     219        if(distance.length() > 1.0f) // if object would wander outside of the map
     220                {
     221                distance = distance / distance.length();
     222                        }
     223
    224224
    225225        // inverse of the transform matrix
     
    245245
    246246        // coordinate transformation
    247         distance.x = xinvtransform.x * distance.x + yinvtransform.x * distance.y + zinvtransform.x * distance.z;
    248         distance.y = xinvtransform.y * distance.x + yinvtransform.y * distance.y + zinvtransform.y * distance.z;
    249         distance.z = xinvtransform.z * distance.x + yinvtransform.z * distance.y + zinvtransform.z * distance.z;
    250 
    251         // cap vector for map
     247        orxonox::Vector3 distanceShip;
     248        distanceShip.x = xinvtransform.x * distance.x + yinvtransform.x * distance.y + zinvtransform.x * distance.z;
     249        distanceShip.y = xinvtransform.y * distance.x + yinvtransform.y * distance.y + zinvtransform.y * distance.z;
     250        distanceShip.z = xinvtransform.z * distance.x + yinvtransform.z * distance.y + zinvtransform.z * distance.z;
     251
     252        // cap vector for map if its to long
    252253        //distance.x = clamp<float>(distance.x, -detectionlimit/5, detectionlimit/5);
    253254        //distance.y = clamp<float>(distance.y, -detectionlimit/5, detectionlimit/5);
     
    257258
    258259        // project vector for the rotated 3DMap on screen
    259         float xcoordinate = distance.z;
    260         float ycoordinate = distance.y;
    261 
    262         //float xcoordinate = distance.z; // z; cause z direction is to the side
    263         //float ycoordinate = distance.x*sin(mapangle)+distance.y*cos(mapangle);// -; cause on screen y coordinate points down
     260        //float xcoordinate = distance.z;
     261        //float ycoordinate = distance.y;
     262
     263        float xcoordinate = distanceShip.z; // z; cause z direction is to the side
     264        float ycoordinate = distanceShip.x*sin(mapangle)+distanceShip.y*cos(mapangle);// -; cause on screen y coordinate points down
    264265        return orxonox::Vector2(xcoordinate , ycoordinate);
    265266    }
Note: See TracChangeset for help on using the changeset viewer.