Click or drag to resize
AB4D logo

SimpleMeshTHitTest Method

HitTest method test the triangles defined in this mesh for hitting with the specified ray. When getOnlyNextHitTest is false, then the closest hit result is returned, else the next hit result is returned. When no hit is found, null is returned.

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 7.0.8865.1045
Syntax
C#
public DXRayHitTestResult HitTest(
	ref Ray localRay,
	DXHitTestContext hitTestContext,
	int startTriangleIndex,
	bool getOnlyNextHitTest,
	bool throwExceptionWhenUnsupported = false
)

Parameters

localRay  Ray
SharpDX.Ray in local SceneNode coordinate system
hitTestContext  DXHitTestContext
DXHitTestContext
startTriangleIndex  Int32
triangle index where to start looking for hit. Note that this is not an index in the triangle indices array (index buffer) but triangle index - index in triangle indices array is get by multiplying this value by 3.
getOnlyNextHitTest  Boolean
When getOnlyNextHitTest is false, then the closest hit result is returned, else the next hit result is returned.
throwExceptionWhenUnsupported  Boolean  (Optional)
when true an exception is thrown in case an unsupported vertex buffer type is used (supported types: PositionNormalTexture, PositionNormal, PositionTexture, Vector3). Default value is false.

Return Value

DXRayHitTestResult
DXRayHitTestResult when hit is found or null when no hit is found
Remarks

HitTest method test the triangles defined in this mesh for hitting with the specified ray. When getOnlyNextHitTest is false, then the closest hit result is returned, else the next hit result is returned. When no hit is found, null is returned.

SimpleMesh can be created with any type of vertex buffer. The HitTest method support only vertex buffer arrays with the following types:
PositionNormalTexture
PositionNormal
PositionTexture
Vector3

In case of those type this method will call the appropriate method in the HitTester class.

Other types will always return null or throw a NotSupportedException when throwExceptionWhenUnsupported parameter is true (false by default).

See Also