Click or drag to resize
AB4D logo

DXSceneGetRayFromNearPlane Method

Returns SharpDX.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 DXScene object).

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 7.1.9105.2048 (1.0.0.0)
Syntax
C#
public Ray GetRayFromNearPlane(
	int x,
	int y,
	bool adjustForDpiScale = true,
	bool adjustForSupersamplingFactor = true
)

Parameters

x  Int32
x position in the viewport of this DXScene
y  Int32
y position in the viewport of this DXScene
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 DXViewportView object. When x any y are from the DXScene.Width and DXScene.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 DXViewportView object. When x any y are from the DXScene.Width and DXScene.Height, then this parameter needs to be false.

Return Value

Ray
SharpDX.Ray in world coordinates that is defined from x and y screen positions (the ray stars at camera's near plane)
Remarks

Returns SharpDX.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 DXScene object).

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 DXViewportView object. When x any y are from the DXScene.Width and DXScene.Height, then this parameter needs to be false. For example: when DpiScale is 1.5 (144 DPI) and the width of the DXViewportView is 1000, then the DXScene.Width is 1500. To correctly use the x from DXViewportView on the DXScene, 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(Int32, Int32, 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(Int32, Int32, 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