Archived

This topic is now archived and is closed to further replies.

ms291052

Pulling vertices from a mesh

Recommended Posts

To pull vertices from a mesh you simply lock the vertex/index buffers and then you can use D3DXVECTOR3 v0 = pVertices[pIndices[faceNum*3]].position; D3DXVECTOR3 v1 = pVertices[pIndices[faceNum*3 + 1]].position; D3DXVECTOR3 v2 = pVertices[pIndices[faceNum*3 + 2]].position; right? pIndices should be a WORD*, correct, but then if loading from a mesh, what should pVertices be? As of now I have it defined as a MESHVERTEX* where struct MESHVERTEX { D3DXVECTOR3 position; D3DXVECTOR3 normal; float tu, tv; } Is there anything wrong with this? Whenever I run my code I get a System.NullReferenceException pointing to the v0 line, however I have verified that neither pVertices, nor pIndices is NULL. Why is this?

Share this post


Link to post
Share on other sites
I assume that when you say "mesh" you mean an ID3DXMesh (or similar)...

ID3DXBaseMesh::GetDeclaration()
ID3DXBaseMesh::GetFVF()
ID3DXBaseMesh::GetNumBytesPerVertex()

should tell you all you need to know about how big each vertex is and which members it contains.

Share this post


Link to post
Share on other sites
How can I use that information to obtain the vertices? I suppose it''s just a matter of finding the right definition of MESHVERTEX but how can I do that dynamically? Or am I just barking up the wrong tree?

Share this post


Link to post
Share on other sites