Example #1
0
        void GenerateMesh(Mesh meshToFill, bool sharpEdges = true)
        {
            using (LFContext.Active = new Context()) {
                float  innerRadius = 0.6f + (Mathf.Sin(Time.time) * 0.05f);
                LFTree cylinder    = LFMath.Cylinder(innerRadius, 2f, Vector3.back);
                LFTree toRender    = LFMath.Difference(
                    LFMath.Sphere(1f),
                    cylinder,
                    LFMath.ReflectXZ(cylinder),
                    LFMath.ReflectYZ(cylinder));

                toRender.RenderMesh(meshToFill, new Bounds(Vector3.zero, Vector3.one * 3.1f), resolution, 20f);

                if (sharpEdges)
                {
                    meshToFill.RecalculateNormals(25f);
                }
            }
        }
Example #2
0
 LFTree evaluateNonary(LibFive_Operation op)
 {
     if (op == LibFive_Operation.Circle)
     {
         return(LFMath.Circle(0.5f));
     }
     else if (op == LibFive_Operation.Sphere)
     {
         return(LFMath.Sphere(0.5f));
     }
     else if (op == LibFive_Operation.Box)
     {
         return(LFMath.Box(-Vector3.one * 0.5f, Vector3.one * 0.5f));
     }
     else if (op == LibFive_Operation.Cylinder)
     {
         return(LFMath.Cylinder(0.5f, 1f, Vector3.back * 0.5f));
     }
     return(tree);
 }