Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 11, 2013, 4:13:02 PM (11 years ago)
Author:
wroennin
Message:

Math.cc: updated (new comments, transformmatrix changed to adapt to the right axis directions

Location:
code/branches/radarDreiD
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/radarDreiD/data/levels/radar3D_test.oxw

    r9771 r9779  
    1818?>
    1919
    20 <Level>
     20<Level
     21  gametype     = "Mission"
     22>
    2123  <templates>
    2224    <Template link=lodtemplate_default />
     
    3032
    3133    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    32     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
     34    <SpawnPoint team=0 position="-500,0,0" lookat="-500,0,1" spawnclass=SpaceShip pawndesign=spaceshipescort />
    3335   
    3436
    3537
    36         <Pawn team=1 health=30 position="0,0,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "Box 1" >
     38        <Pawn team=0 health=30 position="0,0,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "0,0,0" >
    3739                <attached>
    3840                    <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
     
    4345        </Pawn>
    4446
    45         <Pawn team=1 health=30 position="0,200,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "Box 2" >
     47        <Pawn team=1 health=30 position="0,1000,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "0,1000,0" >
    4648                <attached>
    4749                    <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
     
    5355
    5456
    55         <Pawn team=1 health=30 position="0,0,200" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "Box 3" >
     57        <Pawn team=2 health=30 position="0,0,1000" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "0,0,1000" >
    5658                <attached>
    5759                    <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
     
    6264        </Pawn>
    6365
    64         <Pawn team=1 health=30 position="200,0,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "Box 4" >
     66        <Pawn team=3 health=30 position="1000,0,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box radarname = "1000,0,0" >
    6567                <attached>
    6668                    <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
  • code/branches/radarDreiD/src/libraries/util/Math.cc

    r9770 r9779  
    207207    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)
    208208    {
    209         //
     209        // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right
    210210        orxonox::Vector3 distance = otherposition - myposition;
    211211
    212         // new coordinate system base y_coordinate
    213         orxonox::Vector3 myside = -(mydirection.crossProduct(myorthonormal));
     212        // new coordinate system:       x_axsis:        mydirection             (points front)
     213        //                                                      y_axsis:        myorthonormal   (points up)
     214        //                                                      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
    214224
    215225        // inverse of the transform matrix
    216         float determinant = +mydirection.x * (myside.y*myorthonormal.z - myorthonormal.y*myside.z)
    217                                                 -mydirection.y * (myside.x*myorthonormal.z - myside.z*myorthonormal.x)
    218                                                 +mydirection.z * (myside.x*myorthonormal.y - myside.y*myorthonormal.x);
     226        float determinant = +mydirection.x * (myorthonormal.y*myside.z - myside.y*myorthonormal.z)
     227                                                -mydirection.y * (myorthonormal.x*myside.z - myorthonormal.z*myside.x)
     228                                                +mydirection.z * (myorthonormal.x*myside.y - myorthonormal.y*myside.x);
    219229        float invdet = 1/determinant;
    220230
     
    224234        orxonox::Vector3 zinvtransform;
    225235
    226         xinvtransform.x = (myside.y        * myorthonormal.z - myorthonormal.y * myside.z       )*invdet;
    227         xinvtransform.y = (mydirection.z   * myorthonormal.y - mydirection.y   * myorthonormal.z)*invdet;
    228         xinvtransform.z = (mydirection.y   * myside.z        - mydirection.z   * myside.y       )*invdet;
    229         yinvtransform.x = (myside.z        * myorthonormal.x - myside.x        * myorthonormal.z)*invdet;
    230         yinvtransform.y = (mydirection.x   * myorthonormal.z - mydirection.z   * myorthonormal.x)*invdet;
    231         yinvtransform.z = (myside.x        * mydirection.z   - mydirection.x   * myside.z       )*invdet;
    232         zinvtransform.x = (myside.x        * myorthonormal.y - myorthonormal.x * myside.y       )*invdet;
    233         zinvtransform.y = (myorthonormal.x * mydirection.y   - mydirection.x   * myorthonormal.y)*invdet;
    234         zinvtransform.z = (mydirection.x   * myside.y        - myside.x        * mydirection.y  )*invdet;
     236        xinvtransform.x = (myorthonormal.y * myside.z        - myside.y        * myorthonormal.z)*invdet;
     237        xinvtransform.y = (mydirection.z   * myside.y        - mydirection.y   * myside.z       )*invdet;
     238        xinvtransform.z = (mydirection.y   * myorthonormal.z - mydirection.z   * myorthonormal.y)*invdet;
     239        yinvtransform.x = (myorthonormal.z * myside.x        - myorthonormal.x * myside.z       )*invdet;
     240        yinvtransform.y = (mydirection.x   * myside.z        - mydirection.z   * myside.x       )*invdet;
     241        yinvtransform.z = (myorthonormal.x * mydirection.z   - mydirection.x   * myorthonormal.z)*invdet;
     242        zinvtransform.x = (myorthonormal.x * myside.y        - myside.x        * myorthonormal.y)*invdet;
     243        zinvtransform.y = (myside.x        * mydirection.y   - mydirection.x   * myside.y       )*invdet;
     244        zinvtransform.z = (mydirection.x   * myorthonormal.y - myorthonormal.x * mydirection.y  )*invdet;
    235245
    236246        // coordinate transformation
    237         distance.x = (xinvtransform.x + yinvtransform.x + zinvtransform.x) * distance.x;
    238         distance.y = (xinvtransform.y + yinvtransform.y + zinvtransform.y) * distance.y;
    239         distance.z = (xinvtransform.z + yinvtransform.z + zinvtransform.z) * distance.z;
     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;
    240250
    241251        // cap vector for map
     
    244254        //distance.z = clamp<float>(distance.z, -detectionlimit/5, detectionlimit/5);
    245255        //float distancelength = distance.length();
    246         distance = 5 * distance / detectionlimit;
     256
    247257
    248258        // project vector for the rotated 3DMap on screen
    249         float xcoordinate = distance.z; // z; cause z direction is to the side
    250         float ycoordinate = (distance.x*sin(mapangle)+distance.y*cos(mapangle));
     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
    251264        return orxonox::Vector2(xcoordinate , ycoordinate);
    252265    }
  • code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc

    r9742 r9779  
    173173            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
    174174            it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
     175
    175176            if( distance < detectionLimit_ || detectionLimit_ < 0 )
    176177                it->second->show();
Note: See TracChangeset for help on using the changeset viewer.