Пример #1
0
        public static GameObject[] SliceInstantiate(this GameObject obj, Plane pl, TextureRegion cuttingRegion, Material crossSectionMaterial = null)
        {
            SlicedHull slice = Slicer.Slice(obj, pl, cuttingRegion, crossSectionMaterial);

            if (slice == null)
            {
                return(null);
            }

            GameObject upperHull = slice.CreateUpperHull(obj, crossSectionMaterial);
            GameObject lowerHull = slice.CreateLowerHull(obj, crossSectionMaterial);

            if (upperHull != null && lowerHull != null)
            {
                return(new GameObject[] { upperHull, lowerHull });
            }

            // otherwise return only the upper hull
            if (upperHull != null)
            {
                return(new GameObject[] { upperHull });
            }

            // otherwise return only the lower hull
            if (lowerHull != null)
            {
                return(new GameObject[] { lowerHull });
            }

            // nothing to return, so return nothing!
            return(null);
        }
Пример #2
0
 public static SlicedHull Slice(this GameObject obj, Plane pl, TextureRegion textureRegion, Material crossSectionMaterial = null)
 {
     return(Slicer.Slice(obj, pl, textureRegion, crossSectionMaterial));
 }