• Advertisement
Sign in to follow this  

Getting Intersected Face Vertices from D3DXInterect

This topic is 1839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get the intersected face vertices and not sure if I should use D3DXInterect() or D3DXIntersectTri().

 

If I have to use D3DXIntersectTri(), I don't know how I should pass LPD3DXMESH like I do in D3DXInterect().

Share this post


Link to post
Share on other sites
Advertisement

With D3DXIntersectTri() you pass in a face(3 vertices) so you already know what the intersected face is.

 

Unless you want to call this function for every face on the mesh you probably want to stick with D3DXInterect() and read the DWORD *pFaceIndex, parameter.

Edited by Tispe

Share this post


Link to post
Share on other sites

I'm not sure how should I use D3DXIntersectTri()

 

I tried:

 

D3DXIntersectTri(&v1, &v2, &v3, &rayOrigin, &rayDirection, NULL, NULL, NULL);

But it doesn't work.

 

Basically, I am trying to get the intersected face vertices to create bullet holes.

Share this post


Link to post
Share on other sites

I found out that I should be doing something like this:

 

 

D3DXVECTOR3 *vertices;
mesh->LockVertexBuffer(D3DLOCK_READONLY, (void **)&vertices);
for(int j = 0; j < mesh->GetNumFaces(); j++)
{
    p1 = vertices[j];
    p2 = vertices[j+1];
    p3 = vertices[j+2];
    if (D3DXIntersectTri(&p1, &p2, &p3, &rayOrigin, &rayDirection, NULL, NULL, NULL))
    {
        // p1, p2, p3 are the intersected face vertices
    }
}

Let me know if this is correct.

Share this post


Link to post
Share on other sites

Seems right, but you want to read the UV values to know where on the texture you want to place the holes, if that is the method you use.

 

 

This function returns the resulting point by using the following equation: V1 + U(V2 - V1) + V(V3 - V1).

 

The function is not advanced it just figures out if a ray intersect with the triangle with a few equations and returns the result.

Share this post


Link to post
Share on other sites

To place the bullet hole, I think I need:

- The intersection point

- The intersected face (v1, v2 and v3)

 

How I will use the equation V1 + U(V2 - V1) + V(V3 - V1) ?

Share this post


Link to post
Share on other sites
hi, see the Pick sample in DirectX SDK ,in this sample if you select a face, the app will draw this face which means the app will find the intersected face vertices and draw them in another Draw call. i had same problem with directx 11 ,this sample help me a lot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement