Jump to content
  • Advertisement
Sign in to follow this  
m_iSnow

how to transform a point from space to the screen?

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

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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!