?/TD>
Microsoft DirectX 9.0

D3DXIntersectSubset Function


Intersects the specified ray with the given mesh subset. This provides similar functionality to D3DXIntersect.

Syntax

HRESULT D3DXIntersectSubset(      

    LPD3DXBASEMESH pMesh,     DWORD AttribId,     const D3DXVECTOR3 *pRayPos,     const D3DXVECTOR3 *pRayDir,     BOOL *pHit,     DWORD *pFaceIndex,     FLOAT *pU,     FLOAT *pV,     FLOAT *pDist,     LPD3DXBUFFER *ppAllHits,     DWORD *pCountOfHits );

Parameters

pMesh
[in] Pointer to an ID3DXBaseMesh interface, representing the mesh to be tested. The mesh must be attribute sorted.
AttribId
[in] Attribute identifier of the subset to intersect with.
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, U.
pV
[out] Pointer to a barycentric hit coordinate, V.
pDist
[out] Pointer to a ray intersection parameter distance.
ppAllHits
[out] Array of D3DXINTERSECTINFO structures, representing all hits, not just closest hits.
pCountOfHits
[out] Number of elements in the array returned from ppAllHits.

Return Value

If the function succeeds, the return value is D3D_OK.

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

E_OUTOFMEMORYMicrosoft?Direct3D?could not allocate sufficient memory to complete the call.


Remarks

The D3DXIntersectSubset function provides a way to understand points in and around a triangle, independent of where the triangle is actually located. This function returns the resulting point by using the following equation: V1 + U(V2-V1) + V(V3-V1).

Any point in the plane V1V2V3 can be represented by the barycentric coordinate (U,V). The parameter U controls how much V2 gets weighted into the result and the parameter V controls how much V3 gets weighted into the result. Lastly, 1-U-V controls how much V1 gets weighted into the result.

Barycentric coordinates are a form of general coordinates. In this context, using barycentric coordinates represents a change in coordinate systems. What holds true for Cartesian coordinates holds true for barycentric coordinates.

Function Information

Headerd3dx9mesh.h
Import libraryd3dx9.lib
Minimum operating systems Windows 98


© 2002 Microsoft Corporation. All rights reserved.