public static Geometry Execute(Geometry geometry, float radius, float height, int tesselation = 16) { var processor = new GenCylinder(); processor.Radius = radius; processor.Height = height; processor.Tesselation = tesselation; return(processor.Execute(geometry)); }
void UpdateMesh() { var mr = GetComponent <MeshRenderer>(); if (mr == null) { mr = gameObject.AddComponent <MeshRenderer>(); } var mf = GetComponent <MeshFilter>(); if (mf == null) { mf = gameObject.AddComponent <MeshFilter>(); } var m = mf.sharedMesh; if (m == null) { m = new Mesh(); mf.sharedMesh = m; } if (Mathf.Abs(R1) < RLense) { return; } //generate cylinder var cyl = GenCylinder.Execute(new Geometry(), RLense, Thickness, tessR); var cap1 = GenSphericalCap.Execute(new Geometry(), RLense, R1, tessR, tessC); cap1 = VectorOffset.Execute(cap1, new Vector3(0, Thickness * 0.5f, 0)); var cap2 = GenSphericalCap.Execute(new Geometry(), RLense, R2, tessR, tessC); cap2 = VectorOffset.Execute(cap2, new Vector3(0, -Thickness * 0.5f, 0)); cap2 = FlipFaces.ExecuteStatic(cap2); AttachGeometry.Execute(new Geometry(), new [] { cyl, cap1, cap2 }).StoreToMesh(m); }