Advertisement

World coordinates to screen coordinates

Started by October 27, 2020 08:25 PM
12 comments, last by taby 4 years, 3 months ago

Yes, let me show you a mock-up. If the piece lies off-screen, there is an arrow indicating its location. The arrows in the toolbar rotate the playing field (and all the game pieces, etc). Thank you so much for your help!

P.S.

    if (v.z != 0)
    {
        v.x /= v.z;
        v.y /= v.z;
        v.z /= v.z;
    }
Advertisement

Never did such HUD, but i think this would work:

If point is behind front clip plane, project it to it (in world space).
Clamp the resulting screenspace position inside the visible screen rectangle.

The hack that I use relies on a stationary camera. The geometry to draw is rotated instead.

const vertex_3 camera_pos(0, 0, -1); // Camera position.
const vertex_3 look_at_pos(0, 0, 0); // Look at position.

Thanks again for your help, you guys!

This topic is closed to new replies.

Advertisement