示例#1
0
 LFTree evaluateNnary(LibFive_Operation op, params LFTree[] trees)
 {
     if (trees.Length > 0 && trees[0] != null)
     {
         if (trees.Length == 1)
         {
             return(trees[0]);
         }
         if (op == LibFive_Operation.Union)
         {
             return(LFMath.Union(trees));
         }
         else if (op == LibFive_Operation.Intersection)
         {
             return(LFMath.Intersection(trees));
         }
         else if (op == LibFive_Operation.Difference)
         {
             return(LFMath.Difference(trees));
         }
         else if (op == LibFive_Operation.Blend)
         {
             return(LFMath.Blend(0.1f, trees));
         }
     }
     return(tree);
 }
示例#2
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);
                }
            }
        }