locked
What is D3D11 analogue to ID3DX10Mesh::Intersect

    Question

  • To implement object picking functionality in my app, I was looking for a function in DirectX11 SDK that is analogue to ID3DX10Mesh::Intersect but failed to find one. Could someone help? Thanks.
    Monday, November 11, 2013 4:15 PM

Answers

  • All the intersect method did in D3DX10 was:

    - Perform a ray-hit test against the bounding box of the mesh. If it missed, no hits. If it hit, further processing.

    - Allocate an array of Booleans with the same number of entries as the maximum vertex index in the mesh.

    - Generates a plane containing the test ray, and store if the vertex was 'in front' or 'behind' that test plane.

    - For each triangle in the mesh, first check to see if all vertices in the triangle are on the same 'side' of the test plane by looking in that array. If they are, skip testing that triangle because it can't hit the ray.

    - Compute triangle hit test. All hits are stored in an array in sorted order.

    All the tests in this algorithm can be performed with DirectXMath functions.

    D3DX kept all the IB/VB data as both STAGING buffers and DEFAULT buffers so it could lock them for this test. This is not particularly memory efficient, as only the position information needs to be kept for the collision testing, and in many cases a simplified mesh can be used instead of the rendering mesh to speed up collision.

    Tuesday, November 12, 2013 6:26 AM

All replies

  • D3DX10Mesh::Intersect performed a number of collision functions. It used a ray-bounding-box to check for an overall hit, and then did a face-by-face ray-triangle hit test.

    You can accomplish these tests using DirectXMath's BoundingBox and TriangleTests.

    See also Living without D3DX


    Monday, November 11, 2013 7:49 PM
  • D3DX10Mesh::Intersect performed a number of collision functions. It used a ray-bounding-box to check for an overall hit, and then did a face-by-face ray-triangle hit test.

    You can accomplish these tests using DirectXMath's BoundingBox and TriangleTests.

    See also Living without D3DX


    Thank you for your help, Chuck.

    I've read the documents for these functions and found they all lack an important feature of ID3DX10Mesh::Intersect, that is, return the information all the hits in the form of an array of D3DX10_INTERSECT_INFO objects. Maybe DirectXMath already has this feature but I failed to find one.


    • Edited by Leonard Tuesday, November 12, 2013 12:19 AM
    Tuesday, November 12, 2013 12:18 AM
  • All the intersect method did in D3DX10 was:

    - Perform a ray-hit test against the bounding box of the mesh. If it missed, no hits. If it hit, further processing.

    - Allocate an array of Booleans with the same number of entries as the maximum vertex index in the mesh.

    - Generates a plane containing the test ray, and store if the vertex was 'in front' or 'behind' that test plane.

    - For each triangle in the mesh, first check to see if all vertices in the triangle are on the same 'side' of the test plane by looking in that array. If they are, skip testing that triangle because it can't hit the ray.

    - Compute triangle hit test. All hits are stored in an array in sorted order.

    All the tests in this algorithm can be performed with DirectXMath functions.

    D3DX kept all the IB/VB data as both STAGING buffers and DEFAULT buffers so it could lock them for this test. This is not particularly memory efficient, as only the position information needs to be kept for the collision testing, and in many cases a simplified mesh can be used instead of the rendering mesh to speed up collision.

    Tuesday, November 12, 2013 6:26 AM
  • Hi, There's new function in DirectXMath.

    Intersects(...)

    Hope this helps.

    • Proposed as answer by halcyons Wednesday, November 13, 2013 6:10 AM
    Wednesday, November 13, 2013 6:10 AM
  • Hi,

    I have been able to replicate this functionality with an algorithm found online. However, after storing all hits in the array, I can't seem to get the plane that is occluding (the front-most plane) the others. I have tried getting the distance between the ray position and the planes using another algorithm found online, but it doesn't seem to work. I would really appreciate pointers as I have been on this for quite some time now.

    Tuesday, June 3, 2014 9:53 PM