예제 #1
0
    private void TriangulateTerrainCorner(
        Vector3 begin,
        Hex beginHex,
        Vector3 left,
        Hex leftHex,
        Vector3 right,
        Hex rightHex,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        ElevationEdgeTypes leftEdgeType  = beginHex.GetEdgeType(leftHex);
        ElevationEdgeTypes rightEdgeType = beginHex.GetEdgeType(rightHex);

        if (leftEdgeType == ElevationEdgeTypes.Slope)
        {
            if (rightEdgeType == ElevationEdgeTypes.Slope)
            {
// Corner is also a terrace. Slope-Slope-Flat.
                TriangulateCornerTerraces(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }

// If the right edge is flat, must terrace from left instead of bottom.
// Slope-Flat-Slope
            else if (rightEdgeType == ElevationEdgeTypes.Flat)
            {
                TriangulateCornerTerraces(
                    left,
                    leftHex,
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
            else
            {
/* At least one edge is a cliff. Slope-Cliff-Slope or Slope-Cliff-Cliff. Standard case
 * because slope on left and flat on right.
 */
                TriangulateCornerTerracesCliff(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }
        else if (rightEdgeType == ElevationEdgeTypes.Slope)
        {
            if (leftEdgeType == ElevationEdgeTypes.Flat)
            {
/* If the right edge is a slope, and the left edge is flat, must terrace from right instead
 * of bottom. Flat-Slope-Slope.
 */
                TriangulateCornerTerraces(
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
            else
            {
/* At least one edge is a cliff. Slope-Cliff-Slope or Slope-Cliff-Cliff. Mirror case because
 * slope on right and flat on left.
 */
                TriangulateCornerCliffTerraces(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }

/* Neither the left or right hex edge type is a slope. If the right hex type of the left hex
 * is a slope, then terraces must be calculated for a corner between two cliff edges.
 * Cliff-Cliff-Slope Right, or Cliff-Cliff-Slope Left.
 */
        else if (leftHex.GetEdgeType(rightHex) == ElevationEdgeTypes.Slope)
        {
// If Cliff-Cliff-Slope-Left
            if (leftHex.elevation < rightHex.elevation)
            {
                TriangulateCornerCliffTerraces(
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }

// If Cliff-Cliff-Slope-Right
            else
            {
                TriangulateCornerTerracesCliff(
                    left,
                    leftHex,
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }

// Else all edges are cliffs. Simply draw a triangle.
        else
        {
            terrain.AddTrianglePerturbed(
                begin,
                left,
                right,
                hexOuterRadius,
                wrapSize
                );

            Vector3 indices;
            indices.x = beginHex.Index;
            indices.y = leftHex.Index;
            indices.z = rightHex.Index;

            terrain.AddTriangleHexData(
                indices,
                _weights1,
                _weights2,
                _weights3
                );
        }

        features.AddWall(
            begin,
            beginHex,
            left,
            leftHex,
            right,
            rightHex,
            hexOuterRadius,
            wrapSize
            );
    }
예제 #2
0
    private TerrainTriangulationData TriangulateTerrainConnection(
        Hex source,
        Hex neighbor,
        TerrainTriangulationData data,
        HexDirections direction,
        HexRiverData riverData,
        Dictionary <HexDirections, bool> roadEdges,
        Dictionary <HexDirections, ElevationEdgeTypes> elevationEdgeTypes,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        if (riverData.HasRiverInDirection(direction))
        {
            data.connectionEdgeVertices.vertex3.y = neighbor.StreamBedY;
        }

        bool hasRoad = roadEdges[direction];

        if (
//            hex.GetEdgeType(direction) == ElevationEdgeTypes.Slope
            elevationEdgeTypes[direction] == ElevationEdgeTypes.Slope
            )
        {
            TriangulateEdgeTerracesTerrain(
                data.centerEdgeVertices,
                source,
                data.connectionEdgeVertices,
                neighbor,
                hexOuterRadius,
                wrapSize,
                terrain
                );
        }
        else
        {
            TriangulateEdgeStripTerrain(
                data.centerEdgeVertices,
                _weights1,
                source.Index,
                data.connectionEdgeVertices,
                _weights2,
                neighbor.Index,
                hexOuterRadius,
                wrapSize,
                terrain
                );
        }

        features.AddWall(
            data.centerEdgeVertices,
            source,
            data.connectionEdgeVertices,
            neighbor,
            riverData.HasRiverInDirection(direction),
            hasRoad,
            hexOuterRadius,
            wrapSize
            );

        return(data);
    }