- Home /
Understanding verts and triangles in Unity
Im trying to create a complex script which will analyse each of the vertex of a mesh and establish the vertices that are linked to that single vertex.
I was wondering if I took say index 5 through to 10 of a vert array, would taking the same 5 to 10 in a triangle array grab the correct triangle allowing me construct a small section of the original mesh?
Or am I completely misunderstanding the way meshes are constructed in unity?
vast discussion of these issues....
http://answers.unity3d.com/questions/193695/in-unity-is-there-a-fast-way-to-find-nearby-triang.html
Answer by DaveA · Oct 02, 2012 at 11:18 PM
This depends on what you mean by 'taking the same'
The triangle array contains indices into the vertex array. You cannot count on low-numbered vertices to be the first indexed by the triangle array. The first triangle in the array may be: [ 501, 1022, 44, ......
So if you want to take part of a mesh, you should look first to the triangle array. If you want a patch of triangles, you'll need to search the triangle array for matching edges (triangles that share two of the same vertices) and make a list of those.
Thank you I was misunderstanding the way meshes are constructed, it makes sence now!