Sign in to follow this  
ahmedhussain85

Vetices from Mesh in DirectX

Recommended Posts

Hello, I have learnt through tutorials how to make meshes from vertices. But now I wana know how to get vertices and the position of vertices from a mesh. The mesh is created by loading a DirectX file. It is a 3D model. Thank you, Best Wishes, Ahmed H.

Share this post


Link to post
Share on other sites
You get the structure of the vertex data using mesh->GetFVF or mesh->GetDeclaration. Those calls will tell how the vertex structure is arranged and the offset in bytes to each element of the vertex.

You can then use mesh->LockVertexBuffer to get a pointer to the vertices.

Given the vertex buffer pointer, say BYTE *vb:

for(WORD v=0; v < numVertices; v++)
{
D3DXVECTOR3 pos = *((D3DXVECTOR3*)(vb + v*numBytesPerVertex + offset_to_what_you_want));
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this