I’m creating a 2D grid of points like such:
[
[0, 0, 0], [1, 0, 0], [2, 0, 0], // bottom row
[0, 1, 0], [1, 1, 0], [2, 1, 0] // top row
]
Ignoring syntax, consider it as a 3 x 2 grid space on which I’m trying to create a Mesh grid that is made of a series of triangles, like such:
This is a much bigger grid obviously, but the points creating this triangle are found within the above array example: t = [[0, 0, 0], [0, 1, 0], [1, 0, 0]]
Question
My question is how Unity’s Mesh object interprets a list of vertices as triangles. After reading the documentation, I’ve gathered that Mesh.vertices
is an array of Vector3's
and Mesh.triangles
is a list of indexes into the Mesh.vertices
array.
Mesh.vertices = [ [0, 0, 0], [1, 0, 0], [2, 0, 0] , [0, 1, 0], [1, 1, 0], [2, 1, 0] ]
Mesh.triangles = [0, 3, 1]
So does Unity’s Mesh object interpret triangles simply by taking every group of three, starting with the beginning? So mesh.triangles[0], mesh.triangles[1], mesh.triangles[2] is always the first triangle and so on, so forth such that mesh.triangles[x+0], mesh.triangles[x+1, mesh.triangles[x+2] is always the xth triangle?
I don’t know how else it would be, it’s just been hard to wrap my head around it.