Jump to content

  • Log In with Google      Sign In   
  • Create Account


Getting Intersected Face Vertices from D3DXInterect


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 January 2013 - 05:34 AM

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().



Sponsor:

#2 Tispe   Members   -  Reputation: 978

Like
0Likes
Like

Posted 08 January 2013 - 06:04 AM

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, 08 January 2013 - 06:05 AM.


#3 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 January 2013 - 06:30 AM

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.



#4 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 January 2013 - 07:11 AM

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.



#5 Tispe   Members   -  Reputation: 978

Like
0Likes
Like

Posted 08 January 2013 - 07:57 AM

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.



#6 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 January 2013 - 08:19 AM

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) ?



#7 hossainiir   Members   -  Reputation: 962

Like
0Likes
Like

Posted 08 January 2013 - 10:10 AM

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.

خلیج تا ابد فارس

Persian Gulf





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS