コード例 #1
0
ファイル: HexWater.cs プロジェクト: GodSeven7/MapEditor
    void TriangulateEdgeTerracesTriangle(Vector3 beginLeft, Color beginLeftColor, HexCell leftCell, Vector3 beginRight, Color beginRightColor, HexCell rightCell, Vector3 end, Color endColor, HexCell endCell)
    {
        Vector3 lastLeft       = beginLeft;
        Vector3 lastRight      = beginRight;
        Color   lastLeftColor  = beginLeftColor;
        Color   lastRightColor = beginRightColor;

        for (int i = 1; i <= HexCellConf.terraceSteps; i++)
        {
            Vector3 v3 = HexCellConf.TerraceLerp(beginLeft, end, i, HexCellConf.terracesPerSlope);
            Vector3 v4 = HexCellConf.TerraceLerp(beginRight, end, i, HexCellConf.terracesPerSlope);
            Color   c2 = HexCellConf.TerraceLerpColor(beginLeftColor, endColor, i, HexCellConf.terracesPerSlope);
            Color   c3 = HexCellConf.TerraceLerpColor(beginRightColor, endColor, i, HexCellConf.terracesPerSlope);
            if (i == HexCellConf.terraceSteps)
            {
                AddTriangle(lastLeft, lastRight, end);
                AddTriangleColor(lastLeftColor, lastRightColor, endColor);
            }
            else
            {
                AddQuad(lastRight, lastLeft, v4, v3);
                AddQuadColor(lastRightColor, lastLeftColor, c3, c2);
            }

            lastLeft       = v3;
            lastRight      = v4;
            lastLeftColor  = c2;
            lastRightColor = c3;
        }
    }
コード例 #2
0
ファイル: HexWater.cs プロジェクト: GodSeven7/MapEditor
    void TriangulateEdgeTerracesQuat(Vector3 beginLeft, Vector3 beginRight, Color beginColor, Vector3 endLeft, Vector3 endRight, Color endColor)
    {
        Vector3 lastLeft  = beginLeft;
        Vector3 lastRight = beginRight;
        Color   lastColor = beginColor;

        for (int i = 1; i <= HexCellConf.terraceSteps; i++)
        {
            Vector3 v3 = HexCellConf.TerraceLerp(beginLeft, endLeft, i, HexCellConf.terracesPerSlope);
            Vector3 v4 = HexCellConf.TerraceLerp(beginRight, endRight, i, HexCellConf.terracesPerSlope);
            Color   c2 = HexCellConf.TerraceLerpColor(beginColor, endColor, i, HexCellConf.terracesPerSlope);

            AddQuad(lastLeft, lastRight, v3, v4);
            AddQuadColor(lastColor, c2);

            lastLeft  = v3;
            lastRight = v4;
            lastColor = c2;
        }
    }
コード例 #3
0
ファイル: HexWater.cs プロジェクト: GodSeven7/MapEditor
    void TriangulateCornerTerracesCliff(Vector3 first, Color firstColor, HexCell firstCell, Vector3 second, Color secondColor, HexCell secondCell, Vector3 third, Color thirdColor, HexCell thirdCell)
    {
        int second_first = Mathf.Abs(secondCell.Elevation - firstCell.Elevation);
        int third_first  = Mathf.Abs(thirdCell.Elevation - firstCell.Elevation);

        if (firstCell.Elevation != secondCell.Elevation && secondCell.Elevation != thirdCell.Elevation && thirdCell.Elevation != firstCell.Elevation)
        {
            if (HexCellConf.GetEdgeType(firstCell.Elevation, secondCell.Elevation) == HexEdgeType.Slope || HexCellConf.GetEdgeType(firstCell.Elevation, thirdCell.Elevation) == HexEdgeType.Slope)
            {
                if (second_first > third_first)
                {
                    float   b             = (1f - 1f / second_first);
                    Vector3 boundary      = Vector3.Lerp(first, second, b);
                    Color   boundaryColor = Color.Lerp(firstColor, secondColor, b);

                    Vector3 lastPos   = first;
                    Color   lastColor = firstColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(first, third, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(firstColor, thirdColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(lastPos, boundary, v3);
                        AddTriangleColor(lastColor, boundaryColor, c3);

                        lastPos   = v3;
                        lastColor = c3;
                    }

                    lastPos   = third;
                    lastColor = thirdColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(third, second, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(thirdColor, secondColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(boundary, v3, lastPos);
                        AddTriangleColor(boundaryColor, c3, lastColor);

                        lastPos   = v3;
                        lastColor = c3;
                    }
                }
                else
                {
                    float   b             = (1f - 1f / third_first);
                    Vector3 boundary      = Vector3.Lerp(first, third, b);
                    Color   boundaryColor = Color.Lerp(firstColor, thirdColor, b);

                    Vector3 lastPos   = first;
                    Color   lastColor = firstColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(first, second, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(firstColor, secondColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(boundary, lastPos, v3);
                        AddTriangleColor(boundaryColor, lastColor, c3);

                        lastPos   = v3;
                        lastColor = c3;
                    }

                    lastPos   = second;
                    lastColor = secondColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(second, third, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(secondColor, thirdColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(boundary, lastPos, v3);
                        AddTriangleColor(boundaryColor, lastColor, c3);

                        lastPos   = v3;
                        lastColor = c3;
                    }
                }
            }
            else
            {
                if (second_first > third_first)
                {
                    float   b             = (1f - 1f / second_first);
                    Vector3 boundary      = Vector3.Lerp(first, second, b);
                    Color   boundaryColor = Color.Lerp(firstColor, secondColor, b);

                    AddTriangle(first, boundary, third);
                    AddTriangleColor(firstColor, boundaryColor, thirdColor);

                    Vector3 lastPos   = third;
                    Color   lastColor = thirdColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(third, second, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(thirdColor, secondColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(boundary, v3, lastPos);
                        AddTriangleColor(boundaryColor, c3, lastColor);

                        lastPos   = v3;
                        lastColor = c3;
                    }
                }
                else
                {
                    float   b             = (1f - 1f / third_first);
                    Vector3 boundary      = Vector3.Lerp(first, third, b);
                    Color   boundaryColor = Color.Lerp(firstColor, thirdColor, b);

                    AddTriangle(first, second, boundary);
                    AddTriangleColor(firstColor, secondColor, boundaryColor);

                    Vector3 lastPos   = second;
                    Color   lastColor = secondColor;
                    for (int i = 1; i <= HexCellConf.terraceSteps; i++)
                    {
                        Vector3 v3 = HexCellConf.TerraceLerp(second, third, i, HexCellConf.terracesPerSlope);
                        Color   c3 = HexCellConf.TerraceLerpColor(secondColor, thirdColor, i, HexCellConf.terracesPerSlope);

                        AddTriangle(boundary, lastPos, v3);
                        AddTriangleColor(boundaryColor, lastColor, c3);

                        lastPos   = v3;
                        lastColor = c3;
                    }
                }
            }
        }
        else
        {
            if ((secondCell.Elevation > thirdCell.Elevation && secondCell.Elevation > firstCell.Elevation) || (secondCell.Elevation < thirdCell.Elevation && secondCell.Elevation < firstCell.Elevation))
            {
                TriangulateEdgeTerracesTriangle(third, thirdColor, thirdCell, first, firstColor, firstCell, second, secondColor, secondCell);
            }
            else if ((thirdCell.Elevation > secondCell.Elevation && thirdCell.Elevation > firstCell.Elevation) || (thirdCell.Elevation < secondCell.Elevation && thirdCell.Elevation < firstCell.Elevation))
            {
                TriangulateEdgeTerracesTriangle(first, firstColor, firstCell, second, secondColor, secondCell, third, thirdColor, thirdCell);
            }
            else
            {
                TriangulateEdgeTerracesTriangle(second, secondColor, secondCell, third, thirdColor, thirdCell, first, firstColor, firstCell);
            }
        }
    }