|
SceneViewGetRayFromNearPlane(Single, Single, Boolean, Boolean) Method |
Returns a Ray that starts at the camera's near plane and goes into a direction that is calculated from the specified x and y position in screen coordinates.
The ray can be used for hit testing from the mouse position defined by x and y (relative to this SceneView object).
When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Namespace: Ab4d.SharpEngineAssembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax public Ray GetRayFromNearPlane(
float x,
float y,
bool adjustForDpiScale = true,
bool adjustForSupersamplingFactor = true
)
Parameters
- x Single
- x position in this view (for example, a mouse x position)
- y Single
- y position in this view (for example, a mouse y position)
- adjustForDpiScale Boolean (Optional)
- when true (by default) the x and y positions are multiplied by the DpiScaleX and DpiScaleY. This should be used when x and y are get from mouse location on the SharpEngineSceneView object. When x any y are from the SceneView.Width and SceneView.Height, then this parameter needs to be false.
- adjustForSupersamplingFactor Boolean (Optional)
- when true (by default) the x and y positions are multiplied by the SupersamplingFactor. This should be used when x and y are get from mouse location on the SharpEngineSceneView object. When x any y are from the SceneView.Width and SceneView.Height, then this parameter needs to be false.
Return Value
RayRay in world coordinates that is defined from x and y screen positions (the ray stars at camera's near plane). When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Remarks
Returns a Ray that starts at the camera's near plane and goes into a direction that is calculated from the specified x and y position in screen coordinates.
The ray can be used for hit testing from the mouse position defined by x and y (relative to this SceneView object).
When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
When the adjustForDpiScale parameter is set to true (by default), the x and y positions are multiplied by
the DpiScaleX and DpiScaleY.
This should be used when x and y are get from mouse location on the SharpEngineSceneView object.
When x any y are from the SceneView (in pixel and not screen units), then this parameter needs to be false.
For example: when DpiScale is 1.5 (144 DPI) and the width of the SharpEngineSceneView object is 1000, then the SceneView.Width is 1500. To correctly use the x from SharpEngineSceneView on the SceneView, the x value needs to be multiplied by the DpiScale (1.5).
The difference between the ray that is returned from this method and the ray from the GetRayFromCamera(Single, Single, Boolean, Boolean) method is that
the position of the ray from this method is set to a position on the camera's near plane.
The position of the ray from GetRayFromCamera(Single, Single, Boolean, Boolean) method is set to the position of the camera.
Both rays can be get for hit-testing. The difference is only in the distance from the hit origin in the hit test result.
See Also