Jump to content
  • Advertisement
Sign in to follow this  
xissburg

Getting the vertices properties

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

Is there a way for me to get the vertices properties of a D3DXMESH? I would like to get the vertices positions mainly. I think use the ID3DXBuffer->GetBufferPointer() is the way but I don't know how to do it...heh Thanks

Share this post


Link to post
Share on other sites
Advertisement
1) Clone the mesh with only a position format you want. This step is optional though if you want to parse through the vertex buffer and only extract the position data ignoring the other data(I recommend this).

firstMesh->CloneFVF( options, D3DFVF_XYZ, pDevice, &pNewMesh );

2) Lock the vertex buffer to get access to the data. If you only want to read from the vertex buffer use the flag D3DLOCK_READONLY as this will give you a good speed-up.

void* pData = 0;

pNewMesh->LockVertexBuffer( flags, &pData );

3) Get the position data from the void* array.

Share this post


Link to post
Share on other sites
ph33r's solution is by far the simplest way of extracting the position data - it's perfectly good for a load-time/occasional operation, but you wouldn't want to do all that cloning/locking on a per-frame basis...

As a general aside though, you can use the ID3DXMesh::GetFVF() value to determine what vertex format is being used. Doing some simple binary arithmetic (e.g. if((FVF & D3DFVF_XYZ) == D3DFVF_XYZ)) will tell you what fields exist.

hth
Jack

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!