Beispiel #1
0
    /// <summary>
    /// Generates a new InstanceShape value based off the BaseShape.
    /// </summary>
    /// <param name="render">
    /// If true, this instance shape will immediately be rendered to "RenderedShape".
    /// </param>
    /// <param name="renderInto">
    /// If "render" is true, this is the texture that will be rendered into.
    /// Pass null to render into "RenderedShape".
    /// </param>
    public void GenerateInstanceBlotch(bool render = true, RenderTexture renderInto = null)
    {
        Update();

        UnityEngine.Assertions.Assert.IsNotNull(BaseShape, "Didn't generate a base shape first!");

        //Make a copy of the base shape.
        var points = new PolyShape.Point[BaseShape.NPoints];

        for (int i = 0; i < points.Length; ++i)
        {
            points[i] = new PolyShape.Point(BaseShape.GetPoint(i), baseShape.GetVariance(i));
        }
        InstanceShape = new PolyShape(points);

        Subdivide(InstanceShape,
                  InitialBlotchIterations,
                  InitialBlotchIterations + ExtraBlotchIterations - 1);

        if (render)
        {
            Render(InstanceShape, renderInto == null ? RenderedShape : renderInto);
        }
    }