Jump to content
  • Advertisement
Sign in to follow this  

Retrieve vertex data from a mesh

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

I'm having trouble figuring out exactly how to manipulate vertex data from a mesh. I have the ID3DXMesh* loaded in aomesh->mesh. I have the following code written.
// calc stride of vertex
int numBytePerVertex = aomesh->mesh->GetNumBytesPerVertex();

// get vertex buffer description
IDirect3DVertexBuffer9* p_vb;

// lock vertex buffer
BYTE* v = 0;
aomesh->mesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&v);

// code to retrieve position and normal data not yet written

// unlock vertex buffer

Is this the proper way to get the stride of each vertex? Once you have a FVF description, stored in desc.FVF, how do you tell the byte offset from the beginning of the vertex data where a particular data is, such as position, normal, or color data?

Share this post

Link to post
Share on other sites
That is pretty much the only way of generalising the process. If you know that the incoming format is you can optimize accordingly - You might want to look into using ID3DXMesh::CloneMesh() to help out.

I would recommend using the vertex declaration rather than FVF's; given that FVF's are a subset of declarations you shouldn't have any problems (however, some vertex formats cannot be represented by FVF's). The various fields in D3DVERTEXELEMENT9 will reveal the appropriate offsets/lengths etc...


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!