Microsoft DirectX 8.0 (C++)

D3DXIntersect

Determines if a ray intersects with a mesh.

HRESULT D3DXIntersect(
  LPD3DXBASEMESH pMesh,
  CONST D3DXVECTOR3* pRayPos,
  CONST D3DXVECTOR3* pRayDir,
  BOOL* pHit,
  DWORD* pFaceIndex,
  FLOAT* pU,
  FLOAT* pV,
  FLOAT* pDist
);

Parameters

pMesh
[in] Pointer to an ID3DXBaseMesh interface, representing the mesh to be tested.
pRayPos
[in] Pointer to a D3DXVECTOR3 structure, specifying the origin coordinate of the ray.
pRayDir
[in] Pointer to a D3DXVECTOR3 structure, specifying the direction of the ray.
pHit
[out] Pointer to a BOOL. If the ray intersects a triangular face on the mesh, this value will be set to TRUE. Otherwise, this value is set to FALSE.
pFaceIndex
[out] Pointer to an index value of the face closest to the ray origin, if pHit is TRUE.
pU
[out] Pointer to a Barycentric hit coordinate.
pV
[out] Pointer to a Barycentric hit coordinate.
pDist
[out] Pointer to a ray intersection parameter distance.

Return Values

If the function succeeds, the return value is D3D_OK.

If the function fails, the return value can be E_OUTOFMEMORY.

Requirements

  Header: Declared in D3dx8mesh.h.
  Import Library: Use D3dx8.lib.