|
SceneViewLine3DTo2D(Vector3, Vector3, Camera, Single, Single) Method |
Converts a 3D line that is defined by startPositionWorld and endPositionWorld to a line on the screen that is defined by startPositionScreen and endPositionScreen.
This method correctly handles the case when the 3D line crosses the camera near plane (goes behind the camera). In this case the line needs to be cropped at the camera's near plane.
Namespace: Ab4d.SharpEngineAssembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax public static (Vector2 startPositionScreen, Vector2 endPositionScreen) Line3DTo2D(
Vector3 startPositionWorld,
Vector3 endPositionWorld,
Camera camera,
float viewWidth,
float viewHeight
)
Parameters
- startPositionWorld Vector3
- start position of the 3D line as Vector3
- endPositionWorld Vector3
- end position of the 3D line as Vector3
- camera Camera
- camera
- viewWidth Single
- width of the view
- viewHeight Single
- height of the view
Return Value
ValueTupleVector2,
Vector2(Vector2 startPositionScreen, Vector2 endPositionScreen) with the line's start and end position on the screen
Remarks
Converts a 3D line that is defined by startPositionWorld and endPositionWorld to a line on the screen that is defined by startPositionScreen and endPositionScreen.
This method correctly handles the case when the 3D line crosses the camera near plane (goes behind the camera). In this case the line needs to be cropped at the camera near plane.
The matrix to convert 3D point to 2D point is calculated from the used Ab4d.Camera. The matrix value is cached and is only recalculated when the camera is changed or when the size of the view is changed.
If the matrix to convert 3D point to 2D point cannot be calculated (for example if the size of this SceneView is not set), the returned points will be Vector2(float.NaN, float.NaN).
See Also