Sign in to follow this  

HUD coords

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

This topic is 4358 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.

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