Jump to content
  • Advertisement

Archived

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

peter86

How do I get the coordinates of an object?

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

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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!