Jump to content
  • Advertisement
Sign in to follow this  
danromeo

How do I find the triangle that any particular point is connected to?

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

Hiya, thanks for reading this. Given a mesh loaded from an x file, how can I find the triangles that any particular vertice is connected to, as well as the other vertices that are connected to that triangle? Confessing my ignorance here: When I look at the .x file, after the vertice info, I see info that looks something like this: 3:20,1,32; 3:5,34,8; etc. This LOOKS like a list of the vertices that make up each triangle, but how do I retrieve this info from the x file in any useful way? Big picture: I'm trying to alter the terrain around any vertices which might collide with any other objects. Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
I'm assuming you're loading your mesh into an ID3DXMesh object.

You can use various D3DX methods to help you out with this problem...

The simplest way would be to acquire the vertex and index buffers for the mesh, and from the vertex buffer know the index, and from the index buffer find all of the triangles that share that vertex.

e.g. if you know your vertex is #1234, then looping through your index buffer with a 3-step any interval that has an index of #1234 is a triangle that is using the vertex you are interested in. For a typical heightmapped terrain engine there should be 6 of them.

A potentially simpler way would be to use ID3DXMesh::GenerateAdjacency( ) and use that to look up exactly which triangles neighbour the triangles around your area of interest.

hth
Jack

Share this post


Link to post
Share on other sites
Thanks for the reply. I guess I don't understand Index Buffers...when I try to acquire the index buffer using much the same method that I acquired the vertex buffer with, the data doesn't seem to be valid. I get a lot of numbers that end in #DEM, or something like that. Any idea what I'm doing wrong? Does a mesh have to be somehow told to use index buffers from the start? Thanks again.

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.

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

Sign me up!