public static Mesh CreateCylinder(Cylinder.CylinderPrimitive cylinderToMeasure) { Mesh cylinder = new Mesh(); List<Vertex> bottomVerts = new List<Vertex>(); List<Vertex> topVerts = new List<Vertex>(); int count = 20; for (int i = 0; i < count; i++) { Vector2 bottomRadialPos = Vector2.Rotate(new Vector2(cylinderToMeasure.Radius1, 0), MathHelper.Tau*i/20); Vertex bottomVertex = cylinder.CreateVertex(new Vector3(bottomRadialPos.x, bottomRadialPos.y, - cylinderToMeasure.Height / 2)); bottomVerts.Add(bottomVertex); Vector2 topRadialPos = Vector2.Rotate(new Vector2(cylinderToMeasure.Radius1, 0), MathHelper.Tau * i / 20); Vertex topVertex = cylinder.CreateVertex(new Vector3(topRadialPos.x, topRadialPos.y, cylinderToMeasure.Height / 2)); topVerts.Add(topVertex); } cylinder.ReverseFaceEdges(cylinder.CreateFace(bottomVerts.ToArray())); cylinder.CreateFace(topVerts.ToArray()); for (int i = 0; i < count - 1; i++) { cylinder.CreateFace(new Vertex[] { topVerts[i], bottomVerts[i], bottomVerts[i + 1], topVerts[i + 1] }); } cylinder.CreateFace(new Vertex[] { topVerts[count - 1], bottomVerts[count - 1], bottomVerts[0], topVerts[0] }); return cylinder; }