Jump to content
  • Advertisement
Sign in to follow this  
sipickles

HUD coords

This topic is 4666 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

Hello, I'm ready to start implementing my HeadsUpDisplay in my game. Say for instance, I wanted to print the name of the selected object above its mesh. I have done the raytracing, and know which object is selected. I knwo its going to involve a similar process, maybe in reverse. I need to translate the vector position into screen coord ( also I suppose, it would be worth checking if its visible before doing too much! ). So how would I go about that? Thanks Simon

Share this post


Link to post
Share on other sites
Advertisement
Depending on how you're doing your picking, it may be more or less the reverse, as you suggest. OpenGL has gluProject(), and I believe DirectX has something similar - perhaps you could use one of these functions to get the screen coordinates corresponding with the model.

Share this post


Link to post
Share on other sites
Have some psuedo code:

viewspaceposition=VecSub(object.position,cam.position)
screendist=VecDot(viewspaceposition,cam.viewmatrix.z)
screenspaceposition=VecMultiply(viewspaceposition,1.0/screendist)
screenX=VecDot(screenspaceposition,cam.viewmatrix.x)
screenY=VecDot(screenspaceposition,cam.viewmatrix.y)


It is assumed that you have already written equivalent Vector functions.
also assumes that the camera viewmatrix x,y, and z axis are normalized


That *should* work, unless I have forgotten to compensate for some kind of screen aspect ratio stuff, but thats just divisions at most, so if there's an issue you can figure it out...

[Edited by - haphazardlynamed on January 11, 2006 3:52:20 PM]

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!