DXSceneGet |
public Ray GetRayFromNearPlane( int x, int y, bool adjustForDpiScale = true, bool adjustForSupersamplingFactor = true )
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.