Jump to content
  • Advertisement
Sign in to follow this  
wizardpc

how to find postion of a mesh

This topic is 4699 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
so once i do the transformations your saying i can place my text like this?


font.print("TEST", mesh.getXPos(), mesh.GetYPos() );

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!