Ejemplo n.º 1
0
        public static GameObject[] SliceInstantiate(this GameObject obj, Vector3 position, Vector3 direction, TextureRegion cuttingRegion, Material crossSectionMaterial = null)
        {
            EzySlice.Plane cuttingPlane = new EzySlice.Plane();

            Vector3 refUp = obj.transform.InverseTransformDirection(direction);
            Vector3 refPt = obj.transform.InverseTransformPoint(position);

            cuttingPlane.Compute(refPt, refUp);

            return(SliceInstantiate(obj, cuttingPlane, cuttingRegion, crossSectionMaterial));
        }
Ejemplo n.º 2
0
        public static GameObject[] SliceInstantiate(this GameObject obj, Vector3 position, Vector3 direction, TextureRegion cuttingRegion, Material crossSectionMaterial = null)
        {
            EzySlice.Plane cuttingPlane = new EzySlice.Plane();

            Matrix4x4 mat       = obj.transform.worldToLocalMatrix;
            Matrix4x4 transpose = mat.transpose;
            Matrix4x4 inv       = transpose.inverse;

            Vector3 refUp = inv.MultiplyVector(direction).normalized;
            Vector3 refPt = obj.transform.InverseTransformPoint(position);

            cuttingPlane.Compute(refPt, refUp);

            return(SliceInstantiate(obj, cuttingPlane, cuttingRegion, crossSectionMaterial));
        }