Open topic with navigation
<window>.worldToScreen
This command will convert a 3d coordinate to a 2d screen coordinate
<window>.worldToScreen( |
|
[x,y,z] |
eye = viz.BOTH_EYE |
mode = viz.WINDOW_NORMALIZED |
) |
|
[x,y,z]
The 3d coordinates to convert to screen coordinates
eye = viz.BOTH_EYE
The eye to perform the operation on. Can be viz.BOTH_EYE, viz.LEFT_EYE, viz.RIGHT_EYE.
mode = viz.WINDOW_NORMALIZED
One of the following modes:
viz.WINDOW_NORMALIZED | The coordinates returned by the function will be in normalized units, [0,1]. |
viz.WINDOW_PIXELS | The coordinates returned by the function will be in pixel units. |
Remarks
Use this command to find out the screen coordinate of a 3D point. This command will return a list of 3 numbers. The first two numbers represent the screen coordinates (0 to 1) in the reference frame of the sub-window. The third number represents the distance of the point from the viewer. If the point is in front of the user the distance will be greater than 0, otherwise the distance will be less than 0.
Return Value
[x,y,distance]
Example
text = viz.addText('Object is here',parent=viz.SCREEN)
x,y,distance = viz.MainWindow.worldToScreen(0,1,4)
#Place the screen text where the 3d coordinate is
text.setPosition([x,y,0])
See also