Vetices from Mesh in DirectX

Started by
0 comments, last by Buckeye 14 years, 1 month ago
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.
Advertisement
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));}

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement