Example #1
0
    } = 0;                                  //tamamlanan basamak sayısı

    //Editör debugging için
    public void OnDrawGizmos()
    {
        EzySlice.Plane cuttingPlane = new EzySlice.Plane();

        cuttingPlane.Compute(knifeBlade.transform);
        cuttingPlane.OnDebugDraw();
    }
Example #2
0
        public static SlicedHull Slice(this GameObject obj, Vector3 position, Vector3 direction, TextureRegion textureRegion, Material crossSectionMaterial = null)
        {
            Plane cuttingPlane = new Plane();

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

            cuttingPlane.Compute(refPt, refUp);

            return(Slice(obj, cuttingPlane, textureRegion, crossSectionMaterial));
        }
    public void SliceWithPoints(Vector3 p1, Vector3 p2)
    {
        var dir1 = p1 - camera.position;
        var dir2 = p2 - camera.position;

        var normal = Vector3.Cross(dir1, dir2); //calculate normal of triangle formed by user-points and camera-position

        planeAssist.up = normal.normalized;     //planeassist is used by easy-slice to orient plane along object. plane makes cut in sphere

        plane = new Plane();
        plane.Compute(planeAssist);//plane is self is oriented along xz-axis, y-axis is normal
        SliceGameObject(gameObject, plane);
    }
    /**
     * This is for Visual debugging purposes in the editor
     */
    public void OnDrawGizmos()
    {
        EzySlice.Plane cuttingPlane = new EzySlice.Plane();

        // the plane will be set to the same coordinates as the object that this
        // script is attached to
        // NOTE -> Debug Gizmo drawing only works if we pass the transform
        cuttingPlane.Compute(transform);

        // draw gizmos for the plane
        // NOTE -> Debug Gizmo drawing is ONLY available in editor mode. Do NOT try
        // to run this in the final build or you'll get crashes (most likey)
        cuttingPlane.OnDebugDraw();
    }
        public static SlicedHull Slice(this GameObject obj, Vector3 position, Vector3 direction, TextureRegion textureRegion, Material crossSectionMaterial = null)
        {
            Plane cuttingPlane = new 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(Slice(obj, cuttingPlane, textureRegion, crossSectionMaterial));
        }
    /**
     * Computes a Plane in regards to the reference frame of the provided GameObject
     * which can be used to cut the provided Object
     */
    public EzySlice.Plane ComputePlaneAgainst(GameObject obj)
    {
        // ensure to generate an EzySlice version of the Plane instead of the
        // default Unity.
        EzySlice.Plane cuttingPlane = new EzySlice.Plane();

        // since this GameObject represents our Plane's coordinates, we first need
        // to bring the Plane into the coordinate frame of the object we want to slice
        // this is because the Mesh data is always in local coordinates
        // we need the position of the plane and direction
        Vector3 refUp = obj.transform.InverseTransformDirection(transform.up);
        Vector3 refPt = obj.transform.InverseTransformPoint(transform.position);

        // once we have the coordinates we need, we can initialize our plane with the new
        // coordinates (now in obj's coordinate frame) and safely perform the slice
        // operation
        cuttingPlane.Compute(refPt, refUp);

        return(cuttingPlane);
    }
Example #7
0
    /**
     * This function will slice the provided object by the plane defined in this
     * GameObject. We use the GameObject this script is attached to define the position
     * and direction of our cutting Plane. Results are then returned to the user.
     */
    public SlicedHull SliceObject(GameObject obj)
    {
        // ensure to generate an EzySlice version of the Plane instead of the
        // default Unity.
        EzySlice.Plane cuttingPlane = new EzySlice.Plane();

        // since this GameObject represents our Plane's coordinates, we first need
        // to bring the Plane into the coordinate frame of the object we want to slice
        // this is because the Mesh data is always in local coordinates
        // we need the position of the plane and direction
        Vector3 refUp = obj.transform.InverseTransformDirection(transform.up);
        Vector3 refPt = obj.transform.InverseTransformPoint(transform.position);

        // once we have the coordinates we need, we can initialize our plane with the new
        // coordinates (now in obj's coordinate frame) and safely perform the slice
        // operation
        cuttingPlane.Compute(refPt, refUp);

        // finally, slice the object and return the results. SlicedHull will have all the mesh
        // details which the application can use to do whatever it wants to do
        return(Slicer.Slice(obj, cuttingPlane));
    }
Example #8
0
    void OnDrawGizmos()
    {
        if (triPisitionA == null || triPositionB == null || triPositionC == null || plane == null)
        {
            return;
        }

        Triangle newTri = new Triangle(triPisitionA.transform.position, triPositionB.transform.position, triPositionC.transform.position);

        EzySlice.Plane newPlane = new EzySlice.Plane();
        newPlane.Compute(plane);

        newTri.OnDebugDraw(Color.yellow);
        newPlane.OnDebugDraw(Color.yellow);

        IntersectionResult newResult = new IntersectionResult();

        bool result = newTri.Split(newPlane, newResult);

        if (result)
        {
            newResult.OnDebugDraw(Color.green);
        }
    }
Example #9
0
 public void OnDrawGizmos()
 {
     EzySlice.Plane cuttingPlane = new EzySlice.Plane(transform.position, transform.up);
     cuttingPlane.Compute(transform);
     cuttingPlane.OnDebugDraw();
 }