Page 1 of 1

Get adjacents triangles

Posted: Sun Jul 16, 2006 6:08 pm
by cadue
HI! I get a triangle from a mesh by the collision detection whit a line. Hi want get the vertexes of the adjacent triangle. Is possible?? How??
thanks
8)

Posted: Sun Jul 16, 2006 8:52 pm
by vitek
It would be much more efficient if you were already dealing with the index and vertex buffer, but you aren't.

If you have access to the vertex and index buffer you should be able to figure out which 3 indices refer to the vertices of the triangle. Once you know which indices you're dealing with, search the index buffer again for other faces that share one or more of those indices. Those would be the neighbors.

Posted: Sun Jul 16, 2006 10:19 pm
by hybrid
Yes, but only if all triangles have the same material. Otherwise you have to check all mesh buffers, and maybe also having some floating point inaccuracies to deal with. Maybe try to get the correct triangle dimensions and aim across the triangle borders with the triangle selector or ray casting again.

Posted: Mon Jul 17, 2006 6:04 am
by cadue
thank! I'll follow your advice