I’ve watched a lot of tutorials about procedural generating of meshes but none of them actually talks about how to correctly assign triangles with real code, not just assigning the array… I think i understeand how it works the manual-way, the clockwise thing and so on… But after creating a simple test mesh i can’t see any pattern in the triangles array.

I made a mesh with a house shape, and the triangles look like this:

```
int[] triangles = { 0,3,2, 0,2,1, 3,4,2 };
```

But i can see no pattern in this.

So the question is: Is there any specific algorythm or are there any tutorials / someone can help? Or do i just have to figure it out?

Hey Wampir888

What kind of pattern are you looking for? When writing procedural mesh generation logic you’re mostly going to be working with triangle strips:

So long as you keep your verts in a good order you can step through the triangles relatively easily. Even at a glance we can see that your triangles will be:

0,1,2

1,3,2

2,3,4

and so on.

I would refer here, you problem is prob. the order you set or normals or you never put the mesh on a GameObject etc…: Creating a plane from a plane equation - Unity Answers & thank @TSLzipper… Also, you can double click the mesh and it will show you num Verts and num Tris… So where they show or now, you can see if those are correct first! GL

I would refer here, you problem is prob. the order you set or normals or you never put the mesh on a GameObject etc…: Creating a plane from a plane equation - Unity Answers & thank @TSLzipper… Also, you can double click the mesh and it will show you num Verts and num Tris… So where they show or now, you can see if those are correct first! GL

Hello. For anyone interested, this is what I do. The figure should be seperated into two shapes, a square and a triangle, otherwise it can still be done.

First you get all the vertices in order, that would be {0, 3, 4, 2, 1}

Then you check groups of 3. so for example, the first three is {0,3,4} so we must “mark” 3 as used. so we have a new group of numbers

{0,4,2,1}

Then again we take 3 {0,4,2} and mark 4 as used.

later you have {0,2,1} thats your last triangle. and you have a valid arrangement.

If you want more info you can ask me I can make a tutorial on my Youtube channel “Creagines”