## Recommended Posts

Hi everyone. I am trying to read data back from my mesh's. I can retrieve the index information and vertex information into variables by using mesh->LockVertexBuffer() and mesh->LockIndexBuffer(), but the problem is in how to read this. At the moment I am saving the index data as a WORD array and the Vertex data as a DWORD array. I've also tried FLOAT for the vertex. Those were the two that seemed might be indicated by examining the .x files. My problem is that the values that I print to the screen do not seem to match those in the file. It is possible this may be a problem with how I am printing to screen though, rather than the data itself. So my question is two-fold: 1) What format do these two values need to be saved as, and 2) How do I convert it to a string so that I can output it correctly to the screen? Thanks everyone for the help. I can post code if that will help. PS. I'm using C/C++

##### Share on other sites
Indices are usually WORDs, but they can also be DWORDs, it depends if it's 16bit (WORD) indices, or 32bit (DWORD).
You can see if your ID3DXMesh uses 32 bit indices like this:
bool bUses32bitIndices = mesh->GetOptions() & D3DXMESH_32BIT;

Now the vertices use different structs that matches it's FVF.
To get the FVF that your mesh uses, you'd call mesh->GetFVF().

If you don't know the original FVF, you can call mesh->CloneMeshFVF() to create a mesh with the desired FVF.

here's an example:
DWORD newFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE;D3DXMESH *pNewMesh;DWORD meshOptions = mesh->GetOptions();hr = mesh->CloneMeshFVF( meshOptions, newFVF, d3dDevice, &pNewMesh );... // handle errorsmesh->Release();mesh = pNewMesh;struct myVertices{   D3DXVECTOR3 position;   D3DXVECTOR3 normal;   D3DCOLOR color;};myVertices* pVerticesData;mesh->LockVertexBuffer( D3DLOCK_READONLY, &pVerticesData );... // handle errors;... // access your vertex data with pVerticesData[vertexIndex].xxxxmesh->UnlockVertexBuffer();

Thanks a lot!

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627681
• Total Posts
2978611

• 13
• 12
• 10
• 12
• 22