Beispiel #1
0
    protected override void DoFracture()
    {
        var mainQuad = new D2D_Quad();

        mainQuad.BL = new D2D_Point(0, 0);
        mainQuad.BR = new D2D_Point(width - 1, 0);
        mainQuad.TL = new D2D_Point(0, height - 1);
        mainQuad.TR = new D2D_Point(width - 1, height - 1);

        quads.Clear();
        quads.Add(mainQuad);

        for (var i = 0; i < Count; i++)
        {
            SplitLargest();
        }

        for (var i = 0; i < quads.Count; i++)
        {
            var quad  = quads[i];
            var group = D2D_SplitBuilder.CreateGroup();

            group.AddTriangle(quad.BL, quad.BR, quad.TL);
            group.AddTriangle(quad.TR, quad.TL, quad.BR);
        }
    }
Beispiel #2
0
    public void UpdateSplit()
    {
        if (destructible == null)
        {
            destructible = GetComponent <D2D_Destructible>();
        }

        BeginSplitting();
        {
            // Find which pixels are solid
            for (var y = 0; y < height; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    cells.Add(alphaTex.GetPixel(x, y).a >= Threshold);
                }
            }

            // Go through all pixels
            for (var i = 0; i < total; i++)
            {
                // First pixel of unclaimed island?
                if (cells[i] == true)
                {
                    splitGroup = D2D_SplitBuilder.CreateGroup();

                    BeginFloodFill(i, i % width, i / width);
                }
            }
        }
        EndSplitting();
    }