how to transform a point from space to the screen?
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!
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.
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 :(
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 :(
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement