Unity 5: automatically detect a list of triangles for grid vertices

Is there a way or algorithm to automatically determine how the vertex list should be related?

For example, let's say I have this (in 2D for simplicity):

     *(0,0)     *(2,0)

*(-1,-1)   *(1,-1)

So, I add vertices in the order of (-1, -1), (0,0), (1, -1), (2,0) and then in the list of triangles I add indices 0,1,2 and 2,1 , 3, and this should generate a grid with two triangles.

However, as the number of vertices increases, the process of defining triangles becomes more tedious, unless, of course, I add vertices to the sorted order so that I can keep track of which triangle I am and just add an offset every time (which I don’t want do).

Where am I going with this, this (again in 2D for simplicity): I want to define an array, let's say:

[0, 0, 1, 0, 1, 0]

[0, 0, 0, 0, 0, 0]

[0, 1, 0, 1, 0, 0]

xy, - (1) (0). , [0,0] x = 0, y = 0 (), [2,1] () x = 1, y = 2. , .

? .

EDIT: , script, 2D.

+4
2

, . , Marching Cubes, , (EDIT: GPU).

0

, .

.

, "" .

, , , .

Unity3D : O

(1) tis "gotchya" Unity

http://answers.unity3d.com/answers/417487/view.html

, .

(2) .

(3) ... http://answers.unity3d.com/answers/352167/view.html

(4) . http://answers.unity3d.com/answers/267076/view.html


. , . , Unity , . ( , , , , .)

+2

Source: https://habr.com/ru/post/1628731/


All Articles