Exemplo n.º 1
0
    /*!
     * Add a reflection line with the specified Rotation on the specified face.
     *
     * \param cubemap The Cubemap to add to.
     * \param rotation Rotation of the reflection line
     * \param faces The Cubemap faces to add the line to.
     */

    public static void addReflectionlineToCubemap(Cubemap cubemap, float rotation, int lineWidth, params CubemapFace[] faces)
    {
        UnityDebug.assert(cubemap.width == cubemap.height, "Cubemap is not square!");

        foreach (CubemapFace face in faces)
        {
            var colors = cubemap.GetPixels(face);

            int middle = (cubemap.width / 2) - 1;

            var center = new int[] { middle, middle };

            var origStart = new int[] { middle, 0 };
            var newStart  = rotatePointAroundPoint2D(origStart, center, rotation);

            var origEnd = new int[] { middle, cubemap.height - 2 };
            var newEnd  = rotatePointAroundPoint2D(origEnd, center, rotation);

            LineDrawer.plotThickLineAA(newStart[0], newStart[1], newEnd[0], newEnd[1], lineWidth, delegate(int x, int y, float i) {
                colors[y * cubemap.width + (cubemap.width - 1 - x)] = new Color(i, i, i);
            });

            cubemap.SetPixels(colors, face);
        }

        if (faces.Length > 0)
        {
            cubemap.Apply();
        }
    }