Jump to content
  • Advertisement

Archived

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

Pulling vertices from a mesh

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

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!