Advertisement Jump to content
Sign in to follow this  

Obtaining mesh.x coordinates with C++

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

Hi, im fairly new to programming and even direct x in general. I have built a simple 3D racing game before and came up with a collision detection method. However this method was quite poor. Surely there is a way to extract the coordinates of a mesh.x file in direct x into an array or something. These coordinates could then be used to create a much better collision detection system. Any help would be great!

Share this post

Link to post
Share on other sites
I belive you could grab them by iterating through the index buffer and vertex buffer of the mesh and storing them in some sort of triangle(polygon) object, incorporated with a linked list or array. You can get the index and vertex buffers of the mesh the following way.

The code isn't full code but it gives you the idea.

g_pMesh->GetVertexBuffer( &pVB );
g_pMesh->GetIndexBuffer( &pIB );

pVB->Lock( 0, 0, (void**)&pVertices, 0 );
pIB->Lock( 0,0, (void**)&pIndices, 0 );
polygon.point1 = pVertices[pIndices[i*3]].p;
polygon.point2 = pVertices[pIndices[i*3+1]].p;
polygon.point3 = pVertices[pIndices[i*3+2]].p;

I hope that helps. [grin]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!