# Extracting vertex position from a mesh.

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

## Recommended Posts

Hi everyone! I want to use D3DXVec3BaryCentric function to find out the exact location where a triangle from a mesh is being intersected. I have the barycentric values from D3DXIntersect function but I dont understand very well how do you find out the vertex position in a mesh. I know you must retrieve that postion from your active mesh (LPD3DXMESH), but I cant find any detailed explanation on how to do this. I have used already both MSDN and google. Can someone give a brief explanation or point a place where I can find some information on this isssue. Thanks for any input! [Edited by - Dan Caranfil on October 10, 2005 7:14:24 AM]

##### Share on other sites
Have a look at the picking sample distributed with the DX SDK. It does exactly that.

Illco

##### Share on other sites

Quote:
 Original post by IllcoHave a look at the picking sample distributed with the DX SDK. It does exactly that.

I can`t find the picking sample. I have DX 9 SDK (June update). Do I have to download another version to get that sample?

[Edited by - Dan Caranfil on October 11, 2005 3:42:44 PM]

##### Share on other sites
Hmm. I used to have the SDK until the 2003 Summer Update. I thought they would not exclude existing samples. If I could I'd send it to you but currently I have nothing installed because of computer overhaul. Perhaps someone else?

Here is a DX book which discusses it. The samples can be downloaded. I don't know about the book or the samples at all, it just might be in there.

Illco

##### Share on other sites
Thank you for that link. I will take a look at that page.

##### Share on other sites
The pick example was dropped quite a while back. Although I have heard enough people talking about it such that it may well make a reappearance at some point in the future...

Till then, you need to identify which triangle you've intersected. Once you've worked that out, you need to identify the three indicies corresponding to that triangle. Once you've got those indicies, look up the corresponding vertex positions. Use your barycentric coordinates to find your precise point of intersection. Easy [lol]

From the documentation, the key is the pFaceIndex value you can retrieve from a successful intersection.

Use ID3DXMesh::LockIndexBuffer() to gain access to that information, the 3 indicies should be at pFaceIndex * 3 + 0, +1 and +2.

Then use the ID3DXMesh::LockVertexBuffer() and look up the values extracted in the previous step (simple array lookup should be okay).

You can finally use D3DXVec3BaryCentric() to feed in the 3 coordinates (that you got from the VBuffer) and the two barycentric coordinates you originally had from D3DXMeshIntersect().

hth
Jack

##### Share on other sites
Quote:
 From the documentation, the key is the pFaceIndex value you can retrieve from a successful intersection.Use ID3DXMesh::LockIndexBuffer() to gain access to that information, the 3 indicies should be at pFaceIndex * 3 + 0, +1 and +2.Then use the ID3DXMesh::LockVertexBuffer() and look up the values extracted in the previous step (simple array lookup should be okay).

That's enough to put me on the right track. Thanks!

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 13
• 13
• 14
• 68
• 15
• ### Forum Statistics

• Total Topics
632137
• Total Posts
3004314

×