Esempio n. 1
0
    void TriangulateCornerTerraces(Vector3 bottomVertex, Cell bottomCell, Vector3 leftVertex, Cell leftCell,
                                   Vector3 rightVertex, Cell rightCell)
    {
        //Bottom triangle
        var intermediateLeftVertex  = Metrics.TerraceLerp(bottomVertex, leftVertex, 1);
        var intermediateRightVertex = Metrics.TerraceLerp(bottomVertex, rightVertex, 1);
        var intermediateLeftColor   = Metrics.TerraceLerp(bottomCell.Color, leftCell.Color, 1);
        var intermediateRightColor  = Metrics.TerraceLerp(bottomCell.Color, rightCell.Color, 1);

        terrain.AddTriangle(bottomVertex, intermediateLeftVertex, intermediateRightVertex);
        terrain.AddTriangleColor(bottomCell.Color, intermediateLeftColor, intermediateRightColor);

        //Intermediate
        for (var i = 2; i < Metrics.SlopeSteps; i++)
        {
            var startLeftVertex  = intermediateLeftVertex;
            var startRightVertex = intermediateRightVertex;
            var startLeftColor   = intermediateLeftColor;
            var startRightColor  = intermediateRightColor;
            intermediateLeftVertex  = Metrics.TerraceLerp(bottomVertex, leftVertex, i);
            intermediateRightVertex = Metrics.TerraceLerp(bottomVertex, rightVertex, i);
            intermediateLeftColor   = Metrics.TerraceLerp(bottomCell.Color, leftCell.Color, i);
            intermediateRightColor  = Metrics.TerraceLerp(bottomCell.Color, rightCell.Color, i);

            terrain.AddQuad(startLeftVertex, startRightVertex, intermediateLeftVertex, intermediateRightVertex);
            terrain.AddQuadColor(startLeftColor, startRightColor, intermediateLeftColor, intermediateRightColor);
        }

        //Top Quad
        terrain.AddQuad(intermediateLeftVertex, intermediateRightVertex, leftVertex, rightVertex);
        terrain.AddQuadColor(intermediateLeftColor, intermediateRightColor, leftCell.Color, rightCell.Color);
    }