ID3DXPRTEngine::ClosestRayIntersects method

Uses efficient ray-tracing in precomputed radiance transfer (PRT) simulations to determine whether a ray intersects a mesh. If an intersection is found, the method returns the index of the closest mesh face hit by the ray and the barycentric coordinates of the intersection point.

Syntax

BOOL ClosestRayIntersects(
  [in]  const D3DXVECTOR3 *pRayPos,
  [in]  const D3DXVECTOR3 *pRayDir,
  [in]        DWORD       *pFaceIndex,
  [out]       FLOAT       *pU,
  [out]       FLOAT       *pV,
  [out]       FLOAT       *pDist
);

Parameters

pRayPos [in]

Type: const D3DXVECTOR3*

Pointer to a D3DXVECTOR3 structure, specifying the point where the ray begins.

pRayDir [in]

Type: const D3DXVECTOR3*

Pointer to a D3DXVECTOR3 structure, specifying the normalized direction of the ray.

pFaceIndex [in]

Type: DWORD*

Pointer to the index of the current mesh face that is first hit by the given ray, based upon stacking all blocker mesh faces in front of the current mesh.

pU [out]

Type: FLOAT*

Pointer to a barycentric hit coordinate, U, for vertex 0 of the triangle.

pV [out]

Type: FLOAT*

Pointer to a barycentric hit coordinate, V, for vertex 1 of the triangle.

pDist [out]

Type: FLOAT*

Pointer to the distance of the intersection point along the ray.

Return value

Type: BOOL

Returns TRUE if the ray intersects the current mesh; otherwise, returns FALSE.

Remarks

Use ID3DXPRTEngine::SetMinMaxIntersection to set minimum and maximum distances of intersection with the ray.

The barycentric coordinate of the third vertex (vertex 2) of the triangle is 1 - ( U + V ).

This method executes slower than ID3DXPRTEngine::ShadowRayIntersects. Use ID3DXPRTEngine::ShadowRayIntersects if the location of the intersection point is not needed.

Barycentric coordinates define a point inside a triangle in terms of the triangle's vertices. For a more in-depth description of barycentric coordinates, see Mathworld's Barycentric Coordinates Description.

Requirements

Requirement Value
Header
D3DX9Mesh.h
Library
D3dx9.lib

See also

ID3DXPRTEngine

ID3DXPRTEngine::ShadowRayIntersects

ID3DXPRTEngine::SetMinMaxIntersection