Jump to content
  • Advertisement
Sign in to follow this  
monk3y_furr

Obtaining mesh.x coordinates with C++

This topic is 4856 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
Advertisement
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 );
for(...)
{
polygon.point1 = pVertices[pIndices[i*3]].p;
polygon.point2 = pVertices[pIndices[i*3+1]].p;
polygon.point3 = pVertices[pIndices[i*3+2]].p;
}
pVB->Unlock();
pIB->Unlock();


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