示例#1
0
        /// <summary>
        /// Handle corner triangle terraces(slope-cliff cases)
        /// </summary>
        /// <param name="begin">begin point of triangle</params>
        /// <param name="beginCell">begin hex cell</param>
        /// <param name="left">left point of triangle</param>
        /// <param name="leftCell">left hex cell</param>
        /// <param name="right">right point of triangle</param>
        /// <param name="rightCell">right hex cell</param>
        private void TriangulateCornerTerracesCliff(Vector3 begin, HexCell beginCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell)
        {
            float b = 1f / (rightCell.Elevation - beginCell.Elevation);

            if (b < 0)
            {
                b = -b;
            }
            Vector3 boundary        = Vector3.Lerp(HexMetrics.Perturb(begin), HexMetrics.Perturb(right), b);
            Color   boundaryWeights = Color.Lerp(weights1, weights3, b);
            Vector3 indices;

            indices.x = beginCell.Index;
            indices.y = leftCell.Index;
            indices.z = rightCell.Index;

            TriangulateBoundaryTriangle(begin, weights1, left, weights2, boundary, boundaryWeights, indices);

            if (leftCell.GetEdgeType(rightCell) == HexEdgeType.Slope)
            {
                TriangulateBoundaryTriangle(left, weights2, right, weights3, boundary, boundaryWeights, indices);
            }
            else
            {
                terrain.AddTriangleUnperturbed(HexMetrics.Perturb(left), HexMetrics.Perturb(right), boundary);
                terrain.AddTriangleCellData(indices, weights2, weights3, boundaryWeights);
            }
        }
示例#2
0
        private void AddWallWedge(Vector3 near, Vector3 far, Vector3 point)
        {
            near  = HexMetrics.Perturb(near);
            far   = HexMetrics.Perturb(far);
            point = HexMetrics.Perturb(point);

            Vector3 center    = HexMetrics.WallLerp(near, far);
            Vector3 thickness = HexMetrics.WallThicknessOffset(near, far);

            Vector3 v1, v2, v3, v4;
            Vector3 pointTop = point;

            point.y = center.y;

            v1   = v3 = center - thickness;
            v2   = v4 = center + thickness;
            v3.y = v4.y = pointTop.y = center.y + HexMetrics.wallHeight;
            walls.AddQuadUnperturbed(v1, point, v3, pointTop);
            walls.AddQuadUnperturbed(point, v2, pointTop, v4);
            walls.AddTriangleUnperturbed(pointTop, v3, v4);
        }