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

This topic is 5020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites

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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013231
×