protected TerrainTriangulationData GetConnectionEdgeVertices( Hex source, Hex neighbor, HexDirections direction, TerrainTriangulationData data, float hexOuterRadius ) { Vector3 bridge = HexagonPoint.GetBridge( direction, hexOuterRadius ); bridge.y = neighbor.Position.y - source.Position.y; data.connectionEdgeVertices = new EdgeVertices( data.centerEdgeVertices.vertex1 + bridge, data.centerEdgeVertices.vertex5 + bridge ); return(data); }
private TerrainTriangulationData TriangulateNeighborTerrainCorner( Hex source, Hex neighbor, Hex nextNeighbor, HexDirections direction, TerrainTriangulationData data, float hexOuterRadius, int wrapSize, MapMeshChunkLayer terrain, FeatureContainer features ) { // Create a 5th vertex and assign it with the elevation of the neighbor // under consideration. This will be used as the final vertex in the // triangle which fills the gap between bridges. Vector3 vertex5 = data.centerEdgeVertices.vertex5 + HexagonPoint.GetBridge( direction.NextClockwise(), hexOuterRadius ); vertex5.y = nextNeighbor.Position.y; if (source.elevation <= neighbor.elevation) { if (source.elevation <= nextNeighbor.elevation) { // This hex has lowest elevation, no rotation. TriangulateTerrainCorner( data.centerEdgeVertices.vertex5, source, data.connectionEdgeVertices.vertex5, neighbor, vertex5, nextNeighbor, hexOuterRadius, wrapSize, terrain, features ); } else { // Next neighbor has lowest elevation, rotate counter-clockwise. TriangulateTerrainCorner( vertex5, nextNeighbor, data.centerEdgeVertices.vertex5, source, data.connectionEdgeVertices.vertex5, neighbor, hexOuterRadius, wrapSize, terrain, features ); } } else if (neighbor.elevation <= nextNeighbor.elevation) { // Neighbor is lowest hex, rotate triangle clockwise. TriangulateTerrainCorner( data.connectionEdgeVertices.vertex5, neighbor, vertex5, nextNeighbor, data.centerEdgeVertices.vertex5, source, hexOuterRadius, wrapSize, terrain, features ); } else { // Next neighbor has lowest elevation, rotate counter-clockwise. TriangulateTerrainCorner( vertex5, nextNeighbor, data.centerEdgeVertices.vertex5, source, data.connectionEdgeVertices.vertex5, neighbor, hexOuterRadius, wrapSize, terrain, features ); } return(data); }