how to transform a point from space to the screen?

Started by
4 comments, last by m_iSnow 17 years, 4 months ago
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!
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.
Vector3.Project(...)

:)
ooop~

i'll have a try

thanks!

^_^
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 :(
the coordinates should be in the range -1 to +1 or 0 to +1 and easy to transformed into pixel coordinates....

This topic is closed to new replies.

Advertisement