LPD3DXMESH tempMesh;
m_pMesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM, D3DFVF_XYZ, RendererMgr::GetInstance().GetDevice(), &tempMesh);
DWORD fvf = tempMesh->GetFVF();
// get the vertices
D3DXVECTOR3 *vertices;
tempMesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID *)&vertices);
Getting vertices out of x file
Hi,
I am trying to get the vertex information out of a X file using DirectX. This is the code I have currently :-
But this seems to give me wrong results. Could someone please tell me what I am doing wrong here.
Thanks
Why do you think you're getting the wrong results?
Not knowing what you're comparing the vertices to, you might try locking the index buffer and accessing the vertices as indexed.
Not knowing what you're comparing the vertices to, you might try locking the index buffer and accessing the vertices as indexed.
Here is a snippet, that you can extract all vertices.
Hope it helps. :)
//Get the number of vertices in the meshint numVertices = mesh->GetNumVertices();//The size of the FVFDWORD stride = D3DXGetFVFVertexSize(mesh->GetFVF());//Pointer to the current position in the mesh vertex bufferBYTE *ptr = NULL;//Lock the vertex buffermesh->LockVertexBuffer(0, (void**)&ptr);//vector to hold the positions of the vertices in the meshstd::vector<D3DXVECTOR3>positions;//For all of the vertices put them in the vectorfor(int i = 0; i < numVertices; i ++){ //pos = the position of a vertex D3DXVECTOR3 *pos = (D3DXVECTOR3*)ptr; //put it in the vector positions.push_back(D3DXVECTOR3(pos->x, pos->y, pos->z)); //Increase the pointer in the vertex buffer by the size of the FVF ptr += stride;}
Hope it helps. :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement