private void TriangulateEdgeTerracesRoad(
        EdgeVertices begin,
        Hex beginHex,
        EdgeVertices end,
        Hex endHex,
        bool hasRoad,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer roads
        )
    {
        EdgeVertices edge2   = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        weight2 = HexagonPoint.TerraceLerp(_weights1, _weights2, 1);
        float        index1  = beginHex.Index;
        float        index2  = endHex.Index;

        TriangulateEdgeStripRoads(
            begin,
            _weights1,
            index1,
            edge2,
            weight2,
            index2,
            hexOuterRadius,
            wrapSize,
            roads
            );

        for (int i = 2; i < HexagonPoint.terraceSteps; i++)
        {
            EdgeVertices edge1   = edge2;
            Color        weight1 = weight2;
            edge2   = EdgeVertices.TerraceLerp(begin, end, i);
            weight2 = HexagonPoint.TerraceLerp(_weights1, _weights2, i);

            TriangulateEdgeStripRoads(
                edge1,
                weight1,
                index1,
                edge2,
                weight2,
                index2,
                hexOuterRadius,
                wrapSize,
                roads
                );
        }

        TriangulateEdgeStripRoads(
            edge2,
            weight2,
            index1,
            end,
            _weights2,
            index2,
            hexOuterRadius,
            wrapSize,
            roads
            );
    }
示例#2
0
文件: HexMesh.cs 项目: BUGyyc/HexZoom
    void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell,
                                 EdgeVertices end, HexCell endCell)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);

        //Vector3 v3 = HexMetrics.TerraceLerp(beginLeft, endLeft, 1);
        //Vector3 v4 = HexMetrics.TerraceLerp(BeginRight, endRight, 1);
        Color c2 = HexMetrics.TerraceLerp(beginCell.color, endCell.color, 1);

        TriangulateEdgeStrip(begin, beginCell.color, e2, c2);

        //AddQuad(beginLeft, BeginRight, v3, v4);
        //AddQuadColor(beginCell.color, c2);

        for (int i = 2; i < HexMetrics.terraceSteps; i++)
        {
            //Vector3 v1 = v3;
            //Vector3 v2 = v4;
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            //v3 = HexMetrics.TerraceLerp(beginLeft, endLeft, i);
            //v4 = HexMetrics.TerraceLerp(BeginRight, endRight, i);
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.color, endCell.color, i);

            TriangulateEdgeStrip(e1, c1, e2, c2);

            //AddQuad(v1,v2,v3,v4);
            //AddQuadColor(c1, c2);
        }
        TriangulateEdgeStrip(e2, c2, end, endCell.color);
        //AddQuad(v3, v4, endLeft, endRight);
        //AddQuadColor(c2, endCell.color);
    }
示例#3
0
    void TriangulateEdgeTerraces(
        EdgeVertices begin, HexCell beginCell,
        EdgeVertices end, HexCell endCell,
        bool hasRoad = false
        )
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        w2 = HexMetrics.TerraceLerp(weights1, weights2, 1);

        float i1 = beginCell.Index;
        float i2 = endCell.Index;

        TriangulateEdgeStrip(begin, weights1, i1, e2, w2, i2, hasRoad);

        for (int i = 2; i <= HexMetrics.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        w1 = w2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            w2 = HexMetrics.TerraceLerp(weights1, weights2, i);
            TriangulateEdgeStrip(e1, w1, i1, e2, w2, i2, hasRoad);
        }

        TriangulateEdgeStrip(e2, w2, i1, end, weights2, i2, hasRoad);
    }
示例#4
0
    public override void Triangulate(HexMesh mesh)
    {
        EdgeVertices e1 = this.edge1;
        Color        c1 = this.color1;

        for (int step = 1; step < HexMetrics.terraceSteps + 1; ++step)
        {
            EdgeVertices e2 = EdgeVertices.TerraceLerp(this.edge1, this.edge2, step);
            Color        c2 = HexMetrics.ColorLerp(this.color1, this.color2, step);
            HexEdge.TriangulateQuad(mesh, e1, e2, c1, c2);

            c1 = c2;
            e1 = e2;
        }
    }
示例#5
0
    void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell, EdgeVertices end, HexCell endCell)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2);

        for (int i = 2; i < HexMetrics.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2);
        }
        TriangulateEdgeStrip(e2, c2, end, endCell.Color);
    }
示例#6
0
    private void TriangulateEdgeTerraces(EdgeVertices begin, HexObject beginCell, EdgeVertices end, HexObject endCell, bool hasRoad)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2, hasRoad);

        for (int i = 2; i < HexMetrics.Instance.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2, hasRoad);
        }

        TriangulateEdgeStrip(e2, c2, end, endCell.Color, hasRoad);
    }
示例#7
0
    void TriangulateTerraces(EdgeVertices beginEdges, Cell beginCell, EdgeVertices endEdges, Cell endCell, bool hasRoad)
    {
        //First Quad
        var intermediateEdges = EdgeVertices.TerraceLerp(beginEdges, endEdges, 1);
        var intermediateColor = Metrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(beginEdges, intermediateEdges, beginCell.Color, intermediateColor, hasRoad);

        for (var i = 2; i < Metrics.SlopeSteps; i++)
        {
            var startEdges = intermediateEdges;
            var startColor = intermediateColor;
            intermediateEdges = EdgeVertices.TerraceLerp(beginEdges, endEdges, i);
            intermediateColor = Metrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(startEdges, intermediateEdges, startColor, intermediateColor, hasRoad);
        }

        TriangulateEdgeStrip(intermediateEdges, endEdges, intermediateColor, endCell.Color, hasRoad);
    }
示例#8
0
        //三角化桥面阶梯
        void TriangulateEdgeTerraces(EdgeVertices begin, EdgeVertices end, Color beginColor, Color endColor, ref DynamicBuffer <ColorBuffer> colorBuffer, ref DynamicBuffer <VertexBuffer> vertexBuffer)
        {
            EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
            /////////////(First Step)/////////////////
            Color bridgeColor = HexMetrics.TerraceLerp(beginColor, endColor, 1);

            TriangulateEdgeStrip(begin, beginColor, e2, bridgeColor, ref colorBuffer, ref vertexBuffer);
            ///////////////////(Middle Steps)///////////////////
            for (int i = 2; i < HexMetrics.terraceSteps; i++)
            {
                EdgeVertices e1 = e2;
                Color        c1 = bridgeColor;
                e2          = EdgeVertices.TerraceLerp(begin, end, i);
                bridgeColor = HexMetrics.TerraceLerp(beginColor, endColor, i);
                TriangulateEdgeStrip(e1, c1, e2, bridgeColor, ref colorBuffer, ref vertexBuffer);
            }
            ///////////////(Last Step)///////////////////
            TriangulateEdgeStrip(e2, bridgeColor, end, endColor, ref colorBuffer, ref vertexBuffer);
        }
示例#9
0
    void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell, EdgeVertices end, HexCell endCell, bool hasRoad)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = HexMetrics.TerraceLerp(color1, color2, 1);
        float        t1 = beginCell.TerrainTypeIndex;
        float        t2 = endCell.TerrainTypeIndex;

        TriangulateEdgeStrip(begin, color1, t1, e2, c2, t2, hasRoad);

        for (int i = 2; i < HexMetrics.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(color1, color2, i);
            TriangulateEdgeStrip(e1, c1, t1, e2, c2, t2, hasRoad);
        }

        TriangulateEdgeStrip(e2, c2, t1, end, color2, t2, hasRoad);
    }
示例#10
0
    private void TriangulateEdgeTerraces(
        EdgeVertices begin, VoronoiCell beginCell,
        EdgeVertices end, VoronoiCell endCell, bool hasRoad)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2, hasRoad);

        for (int i = 2; i < VoronoiMetrics.TerraceSteps; ++i)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2, hasRoad);
        }

        TriangulateEdgeStrip(e2, c2, end, endCell.Color, hasRoad);
    }
示例#11
0
    public void TriangulateEdgeTerraces(EdgeVertices beginEdges, HexCell beginCell, EdgeVertices endEdges, HexCell endCell, bool hasRoad)
    {
        EdgeVertices e2     = EdgeVertices.TerraceLerp(beginEdges, endEdges, 1);
        Color        w2     = HexMetrics.TerraceLerp(Weights1, Weights2, 1);
        float        index1 = beginCell.CellIndex;
        float        index2 = endCell.CellIndex;

        TriangulateEdgeStrip(beginEdges, Weights1, index1, e2, w2, index2, hasRoad);

        for (int i = 2; i < HexMetrics.TerraceSteps; ++i)
        {
            EdgeVertices e1 = e2;
            Color        w1 = w2;

            e2 = EdgeVertices.TerraceLerp(beginEdges, endEdges, i);
            w2 = HexMetrics.TerraceLerp(Weights1, Weights2, i);
            TriangulateEdgeStrip(e1, w1, index1, e2, w2, index2, hasRoad);
        }

        TriangulateEdgeStrip(e2, w2, index1, endEdges, Weights2, index2, hasRoad);
    }
示例#12
0
    //绘制阶梯
    void TriangulateEdgeTerraces(
        EdgeVertices begin, HexCell beginCell,
        EdgeVertices end, HexCell endCell
        )
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = HexMetrics.instance.TerraceLerp(beginCell.color, endCell.color, 1);

        TriangulateEdgeStrip(begin, beginCell.color, (float)beginCell.TerrainTypeIndex, e2, c2, (float)endCell.TerrainTypeIndex);

        for (int i = 2; i < HexMetrics.instance.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.instance.TerraceLerp(beginCell.color, endCell.color, i);
            TriangulateEdgeStrip(e1, c1, (float)beginCell.TerrainTypeIndex, e2, c2, (float)endCell.TerrainTypeIndex);
        }

        TriangulateEdgeStrip(e2, c2, (float)beginCell.TerrainTypeIndex, end, endCell.color, (float)endCell.TerrainTypeIndex);
    }
示例#13
0
        public void edgeVerticiesTerraceLerpTest()
        {
            int          step = 1;
            EdgeVertices a    = new EdgeVertices(corner1, corner2);
            EdgeVertices b    = new EdgeVertices(corner1, corner2);

            expected.Add(HexMetrics.TerraceLerp(a.v1, b.v1, step));
            expected.Add(HexMetrics.TerraceLerp(a.v2, b.v2, step));
            expected.Add(HexMetrics.TerraceLerp(a.v3, b.v3, step));
            expected.Add(HexMetrics.TerraceLerp(a.v4, b.v4, step));
            expected.Add(HexMetrics.TerraceLerp(a.v5, b.v5, step));

            EdgeVertices vert = EdgeVertices.TerraceLerp(a, b, step);

            actual.Add(v1);
            actual.Add(v2);
            actual.Add(v3);
            actual.Add(v4);
            actual.Add(v5);

            CollectionAssert.AreEqual(expected, actual);
        }
示例#14
0
    private void TriangulateEdgeTerraces(
        EdgeVertices begin, HexCell beginCell,
        EdgeVertices end, HexCell endCell,
        bool hasRoad
        )
    {
        var e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        var c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2, hasRoad);

        for (var i = 2; i < HexMetrics.TerraceSteps; i++)
        {
            var e1 = e2;
            var c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2, hasRoad);
        }

        TriangulateEdgeStrip(e2, c2, end, endCell.Color, hasRoad);
    }
示例#15
0
    private void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell, EdgeVertices end, HexCell endCell,
                                         bool hasRoad)
    {
        var e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        var w2 = HexMetrics.TerraceLerp(weights1, weights2, 1);
        var i1 = beginCell.Index;
        var i2 = endCell.Index;

        TriangulateEdgeStrip(begin, weights1, i1, e2, w2, i2, hasRoad);

        for (var i = 2; i < HexMetrics.terraceSteps; i++)
        {
            var e1 = e2;
            var c1 = w2;

            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            w2 = HexMetrics.TerraceLerp(weights1, weights2, i);

            TriangulateEdgeStrip(e1, c1, i1, e2, w2, i2, hasRoad);
        }

        TriangulateEdgeStrip(e2, w2, i1, end, weights2, i2, hasRoad);
    }
示例#16
0
    /// <summary>
    /// 构建阶梯状连接区域
    /// 这里不再使用单一的顶点,而是直接使用cell与阶梯区域相连接的边,通过计算得出边上的顶点位置以及每个顶点的颜色
    /// </summary>
    /// <param name="begin">第一个cell与相邻阶梯化区域的边上顶点</param>
    /// <param name="beginCell">第一个cell的实例</param>
    /// <param name="end">第二个cell与相邻阶梯化区域的边上顶点</param>
    /// <param name="endCell">第二个cell的实例</param>
    private void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell, EdgeVertices end, HexCell endCell)
    {
        //通过插值计算出相邻cell边的每个坐标点
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        //通过插值计算出相邻cell边每个坐标点的颜色
        Color c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        //构建阶梯的第一段
        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2);

        //循环生成中间部分
        for (int i = 2; i < HexMetrics.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2);
        }

        //构建阶梯的最后一段
        TriangulateEdgeStrip(e2, c2, end, endCell.Color);
    }
    /// <summary>
    /// Given an origin and a destination cell, and their bridge edges, creates the terrace
    /// geometry for their slopped bridge.
    /// </summary>
    void TriangulateEdgeTerraces(EdgeVertices begin, HexCell beginCell, EdgeVertices end, HexCell endCell, bool hasRoad)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        w2 = HexMetrics.TerraceLerp(weights1, weights2, 1);

        float i1 = beginCell.Index;
        float i2 = endCell.Index;

        // First incline
        TriangulateEdgeStrip(begin, weights1, i1, e2, w2, i2, hasRoad);

        // Create the intermediate steps
        for (int i = 2; i < HexMetrics.TerraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        w1 = w2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            w2 = HexMetrics.TerraceLerp(weights1, weights2, i);
            TriangulateEdgeStrip(e1, w1, i1, e2, w2, i2, hasRoad);
        }

        // Last incline
        TriangulateEdgeStrip(e2, w2, i1, end, weights2, i2, hasRoad);
    }
示例#18
0
    void TriangulateEdgeTerraces(
        EdgeVertices begin, HexCell beginCell,
        EdgeVertices end, HexCell endCell)
    {
        // short slope, steeper than original (first terracing step ! :)
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);

        Color c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2);

        for (int i = 2; i < HexMetrics.terraceSteps; i++)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;

            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = HexMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);

            TriangulateEdgeStrip(e1, c1, e2, c2);
        }

        TriangulateEdgeStrip(e2, c2, end, endCell.Color);
    }