1

I want to create a procedural mesh like you can see in the following picture:

enter image description here

Unfortunately I have no idea how to do that. Can anyone of you help me out? I think I know how to create the mesh of the tube, but I do not know how to create those circles.

CoderOfTheForce
  • 359
  • 7
  • 22

1 Answers1

1

The following is a rough overview of how to edit the vertices of a mesh, but for more details this link might help you.

List<Vector3> vertices = new List<Vector3>();
List<int> triangles = new List<int>();
GenerateMesh(vertices, triangles);
Mesh mesh = gameObject.GetComponent<MeshFilter>().mesh;
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();

In terms of actually generating your mesh, I would suggest generating N points in a circle on a plane, this is your start point. Then repeatedly move the plane forward slightly, rotate it, and generate more points. Each time connect the points to the previous set of points generated to make your triangles.

Benjamin James Drury
  • 2,353
  • 1
  • 14
  • 27