예제 #1
0
    public IEnumerator FilterArch()
    {
        Vector2 minmax = new Vector2(999, -999);

        for (int i = 0; i < triangles.Length; i++)
        {
            if (triangles[i].value < minmax.x)
            {
                minmax.x = triangles[i].value;
            }
            if (triangles[i].value > minmax.y)
            {
                minmax.y = triangles[i].value;
            }
        }
        //All the heights of the triangles will bew stored in this array
        //It will be read to draw the triangles to the screen again
        float[] triangle_values = new float[triangles.Length];
        for (int i = 0; i < triangles.Length; i++)
        {
            triangle_values[i] = Mathf.InverseLerp(minmax.x, minmax.y, triangles[i].value);
        }

        triangle_values = HeightMap.ApplyBubbleFilter(triangle_values, mesh_size);

        //Apply array to the triangles themselves
        for (int i = 0; i < triangles.Length; i++)
        {
            triangles[i].value = triangle_values[i];
        }

        Debug.Log("Applied Arch filter");
        yield break;
    }