public void clearArrayIn2d(float[] array, uint arrayLength, Vector3 position, Vector2 size, ShapeDirection dir, ShapeFront front, ShapeOrientation orientation, bool explode)
 {
     generateArrayIn2d(array, arrayLength, position, size, dir, front, orientation, TransparentColor, explode);
 }
    public void generateArrayIn2d(float[] array, uint arrayLength, Vector3 position, Vector2 size, ShapeDirection dir, ShapeFront front, ShapeOrientation orientation, QuantizedColor color, bool explode)
    {
        int y0   = 0;
        int xMin = 0;

        int y   = 0;
        int x   = 0;
        int idx = 0;

        //plane we're drawing on:
        int pos = 0;

        //how many voxels we need for each value in the array:
        int voxelsPerValue = Mathf.FloorToInt(size.x / arrayLength);

        //if we end up getting 0, then just round up to 1.
        if (voxelsPerValue <= 0)
        {
            voxelsPerValue++;
        }

        float val = 0.0f;

        switch (dir)
        {
        case ShapeDirection.UP:
            y0   = Mathf.FloorToInt(position.x);
            xMin = Mathf.FloorToInt(position.z - size.x / 2);
            pos  = Mathf.FloorToInt(position.y);
            break;

        case ShapeDirection.FRONT:
            y0   = Mathf.FloorToInt(position.y);
            xMin = Mathf.FloorToInt(position.x - size.x / 2);
            pos  = Mathf.FloorToInt(position.z);
            break;

        case ShapeDirection.SIDE:
            y0   = Mathf.FloorToInt(position.y);
            xMin = Mathf.FloorToInt(position.z - size.x / 2);
            pos  = Mathf.FloorToInt(position.x);
            break;

        default:
            break;
        }
        y = y0;
        x = xMin;

        //draw array:
        for (idx = 0; idx < arrayLength; idx++)
        {
            //if we are rendering facing the back or left, we reverse the draw.
            if (front == ShapeFront.DOWN_BACK_OR_LEFT && (dir == ShapeDirection.FRONT || dir == ShapeDirection.SIDE))
            {
                val = array[arrayLength - idx];
            }
            else
            {
                val = array[idx];
            }

            //if we are rendering facing downwards, we just negate the array:
            if (front == ShapeFront.DOWN_BACK_OR_LEFT && dir == ShapeDirection.FRONT)
            {
                y = y0 - Mathf.FloorToInt(val * size.y);
            }
            else
            {
                y = y0 + Mathf.FloorToInt(val * size.y);
            }
            //to do: if voxels per value is more than 1, draw squares rather than single voxels
            //Debug.Log("Drawing value " + val + " at x: " + x + " y: " + y);
            if (orientation == ShapeOrientation.HORIZONTAL)
            {
                switch (dir)
                {
                case ShapeDirection.UP:
                    drawVoxel(y, pos, x, color, explode);
                    break;

                case ShapeDirection.FRONT:
                    drawVoxel(x, y, pos, color, explode);
                    break;

                case ShapeDirection.SIDE:
                    drawVoxel(pos, y, x, color, explode);
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (dir)
                {
                case ShapeDirection.UP:
                    drawVoxel(x, pos, y, color, explode);
                    break;

                case ShapeDirection.FRONT:
                    drawVoxel(y, x, pos, color, explode);
                    break;

                case ShapeDirection.SIDE:
                    drawVoxel(pos, x, y, color, explode);
                    break;

                default:
                    break;
                }
            }
            x += voxelsPerValue;
        }
    }