So to generate all of the vertices and triangles for this mesh, begin with an empty vertex array and an empty triangle array.
forr = 0 to n − 1 forc = 0 to n − 1
Add a new vertex $[x, y, z]$ at row r column c. forr = 0 to n − 2 forc = 0 to n − 2
Add a new triangle $[i_0, i_1, i_2]$ at row r column c.
Add a new triangle $[i_2, i_1, i_3]$ at row r column c.