Archived

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

peter86

How do I get the coordinates of an object?

Recommended Posts

After useing ID3DXBaseMesh::GetIndexBuffer and ID3DXBaseMesh::GetVertexBuffer, then how do i get the coordinates of the object (x, y, z, tu, tv).

Share this post


Link to post
Share on other sites
To start, you need an appropriate VERTEX structure for the FVF format of your mesh. Then you can, for example, do:

struct VERTEX
{
float x, y, z;
float tu, tv;
// Possibly other stuff -- see GetFVF on BaseMesh, I think
};

VERTEX *pv = (VERTEX *) LockMeshVertexBuffer(...);
WORD *pi = (WORD *) LockMeshIndexBuffer(...);

// First point on the object
float x = pv[pi[0]].x;
// And so on

I believe objects are stored as triangle lists.

Share this post


Link to post
Share on other sites