Jump to content
  • Advertisement
Sign in to follow this  
Dan Caranfil

Extracting vertex position from a mesh.

This topic is 4782 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

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 don`t 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 can`t 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 this post


Link to post
Share on other sites
Advertisement
Thank you for your input.

Quote:
Original post by Illco
Have 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!