Adding vertices to procedural mesh generator

Hello everyone.

This is going to be a little rough, so stay with me

Here is what I have currently working:

I have a mesh (generated with script) that is built like this:

``````1------2
|   /  |
| /    |
0------3
``````

Iâ€™ve added 4 gameobjects around the mesh like this:

(light green are vertices, blue are gameobjects)

When I drag a gameobject, Iâ€™m rebuilding the mesh to fit the new locations of the gameobjects.

This way, Iâ€™m getting a stretched out mesh.

#######################################################

The problem is, I donâ€™t want the mesh to be stretched.

I want to add more vertices when I drag the gameobjects around.

Something like this:

(light green are vertices, drak green are double vertices, blue are gameobjects, orange is the dragged gameobject)

So the mesh should be built like this:

``````1-----2/5-----6
|   /  |   /  |
|  /   |  /   |
0-----3/4-----7
``````

Imagine Iâ€™m dragging another gameobject:

(light green are vertices, drak green are double vertices, blue are gameobjects, orange is the dragged gameobject)

So now the mesh should be built like this:

`````` 9------10/13-------14
|    /   |     /   |
|   /    |    /    |
1/8----2/5/11/12----6/15
|   /    |     /   |
|  /     |   /     |
0-------3/4--------7
``````

So here is where Iâ€™m struggling.

I have no clue how to go about managing the vertices (and triangles and uvs).

Any ideas, leads, scripts will be appreciated.

Thanks a lot!

If i got you right you want something like this

I didnâ€™t use gameobjects as handles but dragging areas around the plane. You can even grab a corner (outside of the plane) to drag two directions at once.

Keep in mind that Unity has a vertex limit of 65000 which equals roundabout 127 x 127 tiles.

The scene has only two gameobjects. One with the camera (and a modified MouseOrbit script) and one with this script.

Simply google â€śprocedural mesh generation unityâ€ť. There are plenty of tutorials. You simply need to create array of vertices and indices and assign them to your mesh.