Example #1
0
    // Ball vs Slice Collision
    public void BallToSlicerCollision()
    {
        if (Math2D.Circle.IntersectLine(Slicer2DController.Get().linearControllerObject.GetPair(0), new Vector2D(transform.position), radius))
        {
            ThinSlicerParticles.Create();

            // Remove Current Slicing Process
            Slicer2DController.Get().complexControllerObject.pointsList[0].Clear();
        }
    }
Example #2
0
    static public void Create()
    {
        if (Slicer2DController.Get().linearControllerObject.startedSlice == false)
        {
            return;
        }

        List <Vector2D> points = Slicer2DLinearControllerObject.GetLinearVertices(Slicer2DController.Get().linearControllerObject.GetPair(0), Slicer2DController.Get().linearControllerObject.minVertexDistance);

        if (points.Count < 3)
        {
            return;
        }

        Max2DParticles.CreateSliceParticles(points);

        float   size = 0.5f;
        Vector2 f    = points.First().ToVector2();

        f.x -= size / 2;
        f.y -= size / 2;

        List <Vector2D> list = new List <Vector2D>();

        list.Add(new Vector2D(f.x, f.y));
        list.Add(new Vector2D(f.x + size, f.y));
        list.Add(new Vector2D(f.x + size, f.y + size));
        list.Add(new Vector2D(f.x, f.y + size));
        list.Add(new Vector2D(f.x, f.y));

        Max2DParticles.CreateSliceParticles(list).stripped = false;

        f    = points.Last().ToVector2();
        f.x -= size / 2;
        f.y -= size / 2;

        list = new List <Vector2D>();
        list.Add(new Vector2D(f.x, f.y));
        list.Add(new Vector2D(f.x + size, f.y));
        list.Add(new Vector2D(f.x + size, f.y + size));
        list.Add(new Vector2D(f.x, f.y + size));
        list.Add(new Vector2D(f.x, f.y));

        Max2DParticles.CreateSliceParticles(list).stripped = false;
    }
Example #3
0
    // Triggered Before Every Slice
    // Should we perform slice? Is it succesful according our rules?
    bool OnSlice(Slice2D sliceResult)
    {
        Polygon2D CutObject = ThinSliceHelper.GetSmallestPolygon(sliceResult);

        // Forbidden double slices // Shouldn't be possible with linear slicer
        if (sliceResult.GetPolygons().Count > 2)
        {
            return(false);
        }

        // Add Particles if slice is succesful
        if (CutObject == null)
        {
            ThinSlicerParticles.Create();
            Slicer2DController.Get().complexControllerObject.pointsList[0].Clear();
            return(false);
        }

        return(true);
    }
 void Start()
 {
     dropdown   = GetComponent <Dropdown>();
     controller = Slicer2DController.Get();
 }