Click or drag to resize
Ab4d.SharpEngine logo

SceneViewGetClosestHitObject(Ray, HitTestOptions) Method

GetClosestHitObject method executes a hit testing by using the specified Ray on the SceneNodes that are shown by this SceneView and returns a RayHitTestResult object with the closest triangle hit. When no triangle is hit, null is returned.

Namespace: Ab4d.SharpEngine
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 3.0.9208+3b2441d6a11f923f2600f40f4296bdc3d8b46035
Syntax
C#
public RayHitTestResult? GetClosestHitObject(
	Ray ray,
	HitTestOptions? customHitTestOptions = null
)

Parameters

ray  Ray
Ray object that defines the ray that is used for hit testing
customHitTestOptions  HitTestOptions  (Optional)
Optional HitTestOptions that will be used for this hit test. When null (by default), then DefaultHitTestOptions from Scene will be used.

Return Value

RayHitTestResult
RayHitTestResult with the closest hit object or null if no object was hit
Remarks

GetClosestHitObject method executes a hit testing on the SceneNodes that are shown by this SceneView and returns a RayHitTestResult object with the closest triangle hit. When no triangle is hit, null is returned.

This method takes a Ray as a parameter. The ray can be created by the GetRayFromCamera(Single, Single, Boolean) or GetRayFromNearPlane(Single, Single, Boolean) methods. You can also use the GetClosestHitObject(Single, Single, Boolean, HitTestOptions) method that takes mouse coordinates instead of a Ray.

To control advanced hit-testing options set the customHitTestOptions parameter (HitTestOptions) or change the Scene.DefaultHitTestOptions that is used when customHitTestOptions parameter is not set (null by default).

To get all hit results (ant not just the closest hit), use the GetAllHitObjects(Single, Single, Boolean, HitTestOptions) or GetAllHitObjects(Ray, HitTestOptions) methods.

See Also