Sign in to follow this  
m_iSnow

how to transform a point from space to the screen?

Recommended Posts

Hey,all~ there is a point (x, y, z) in the view frustrum space and i want to transform it to the screen space (X, Y) and show a UI Tip on (X, Y) so that when the point(x, y, z) moving in the space and the 2D Tip follow it moving in the screen space. How can i make it ? Thanks!

Share this post


Link to post
Share on other sites
You can map 3D coordinates to 2D by simply multiplying it with the world * view * projection matrix. This will give you (depending on your projection transformation) i.e. coordinates in the range -1 to +1, which can be simply transformed into pixel coordinates.

Share this post


Link to post
Share on other sites
Hey,there~

i tried to transform the point(50, 50, 100) to the screen space....

the ViewMatrix is:
1 0 0 0
0 1 -0.2 0
0 0.2 1 0
0 0 50 1

the ProjMatrix is:
2.78 0 0 0
0 3.71 0 0
0 0 1 1
0 0 -1 0

then i multiply them together:

point(50, 50, 100) * ViewMatrix * ProjMatrix...

the result is a larrrrrge number and my UI Tip is dispear...

i don't know where is it wrong :(

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