ID3DXPRTEngine::ClosestRayIntersects

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.

BOOL ClosestRayIntersects(
  CONST D3DXVECTOR3 * pRayPos,
  CONST D3DXVECTOR3 * pRayDir,
  DWORD * pFaceIndex,
  FLOAT * pU,
  FLOAT * pV,
  FLOAT * pDist
);

Parameters

pRayPos
[in] Pointer to a D3DXVECTOR3 structure, specifying the point where the ray begins.
pRayDir
[in] Pointer to a D3DXVECTOR3 structure, specifying the normalized direction of the ray.
pFaceIndex
[in] 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] Pointer to a barycentric hit coordinate, U, for vertex 0 of the triangle.
pV
[out] Pointer to a barycentric hit coordinate, V, for vertex 1 of the triangle.
pDist
[out] Pointer to the distance of the intersection point along the ray.

Return Values

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

Header: Declared in D3dx9mesh.h.

See Also

ID3DXPRTEngine::ShadowRayIntersects, ID3DXPRTEngine::SetMinMaxIntersection