Sign in to follow this  
wizardpc

how to find postion of a mesh

Recommended Posts

i have my mesh in 3d, when i render it to the screen lets say i want to put text next to it obviously text is 2d. so is there a way to find the 2d coords of a 3d mesh. using directx and c++

Share this post


Link to post
Share on other sites
By 2D coords you mean 2D screen coords? If that's the case, then it should be fairly simple. Taking the position of the 3D Mesh you can just transform that with your World-View-Projection matrix. Then take the x/y components and remap that to your screen coords.

Keep in mind that the transformed pos will be in the range of -1 to +1 for x, y and z. In other words, if x is -1, it's on the leftmost side of the screen, and if it's +1 it's on the rightmost side of the screen. Same applies to the y.

Share this post


Link to post
Share on other sites
Essentially yes. You'll just have to figure out how to remap the coordinates resulting from the WorldViewProj transformation into screenspace. Lemme know if you have problems =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this