Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Finding Mesh Faces

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

Given the number of face of a mesh (LPD3DXMESH) is there any way to generate the three vertices of that triangle? There probably is some way with the adjacency buffer, but I can''t seem to find it. Any help would be appreciated. Thanks.

Share this post

Link to post
Share on other sites
You can use the index buffer of the ID3DXMesh interface to find all the vertices of a particular face (triangle). The index buffer is stored as a triangle list.

Here''s some code to show you how to do it:

const D3DXVECTOR3 &v0 = pVertices[pIndices[faceNum*3]].position;
const D3DXVECTOR3 &v1 = pVertices[pIndices[faceNum*3 + 1]].position;
const D3DXVECTOR3 &v2 = pVertices[pIndices[faceNum*3 + 2]].position;

This assumes that "pVertices" is a pointer to your vertex type. To get a pointer to the vertices of your mesh, you need to call ID3DXMesh::LockVertexBuffer(), preferably using the D3DLOCK_READONLY flag so that it goes a little faster. "pIndices" is a pointer to your index buffer. You get this by calling ID3DXMesh::LockIndexBuffer.

Hope this helps,

Share this post

Link to post
Share on other sites

  • 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!