Tagged: 3D Toggle Comment Threads | Keyboard Shortcuts

  • frankiezafe 14:47 on 2018-04-05 Permalink | Reply
    Tags: 3D, , , , ,   

    Hey! The first polymorph production is available on itch.io!

    The page of the game.

  • frankiezafe 21:11 on 2016-09-17 Permalink | Reply
    Tags: 3D, , , , trigonometry   

    Trigonometry hell.

    Finishing the day with cool code running:

    • World coordinates to camera coordinates, especially usefull for sound sources. Indeed, top, right and front depends on the relative position of the source in the camera space, not the global one.
    • Transformation of the sticks direction into world coordinates relative to camera, once again. This time, calculation is based on the lookat location, keeping the system centered on the screen.

    Second point was trickier but solved first… Finding the position of an object in the camera space is basically a conversion of reference: center of the world is not (0,0,0) anymore, but camera world location + up is not (0,1,0) anymore, but camera orientation.

    A bit of code, it can help to understand the trick:

    // creation of the camera matrix, not sure it’s possible to retrieve it easier…
    Matrix4 cam_mat = Matrix4( cam->getDerivedOrientation() );
    cam_mat.setTrans( cam->getDerivedPosition() );
    // inversion of the cam matrix
    Matrix4 cam_mat_inverse = cam_mat.inverse();
    // for a given vector expressed in global
    Vector3 v( 10, 5, -45 );
    // construction of a matrix representing this translation
    Matrix4 m = Matrix4::IDENTITY;
    m.setTrans( rel );
    // MAGIC! > conversion to camera space
    m = cam_mat_inverse * m * cam_mat;
    // and, finally, getting back the coordinates in camera space
    v = relm.getTrans();


Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc