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 ); }
public static EdgeVertices TerraceLerp ( EdgeVertices edgeA, EdgeVertices edgeB, int step ) { EdgeVertices result = new EdgeVertices(); // Note that HexMetrics.TerraceLerp is being called. This method is not recursive. result.vertex1 = HexagonPoint.TerraceLerp(edgeA.vertex1, edgeB.vertex1, step); result.vertex2 = HexagonPoint.TerraceLerp(edgeA.vertex2, edgeB.vertex2, step); result.vertex3 = HexagonPoint.TerraceLerp(edgeA.vertex3, edgeB.vertex3, step); result.vertex4 = HexagonPoint.TerraceLerp(edgeA.vertex4, edgeB.vertex4, step); result.vertex5 = HexagonPoint.TerraceLerp(edgeA.vertex5, edgeB.vertex5, step); return(result); }
protected void TriangulateBoundaryTriangle( Vector3 begin, Color beginWeights, Vector3 left, Color leftWeights, Vector3 boundary, Color boundaryWeights, Vector3 indices, float hexOuterRadius, int wrapSize, MapMeshChunkLayer terrain ) { /* Immediately perturb vertex 2 as an optimization since it is not * being used to derive any other point. */ Vector3 vertex2 = HexagonPoint.Perturb( HexagonPoint.TerraceLerp(begin, left, 1), hexOuterRadius, wrapSize ); Color weight2 = HexagonPoint.TerraceLerp( beginWeights, leftWeights, 1 ); /* Perturb all vertices except the boundary vertex, to avoid moving * the vertex out of alignment with a cliff. vertex2 has already been * perturbed. Handles the Cliff-Slope-Slope and Slope-Cliff-Slope cases * of the Cliff-Slope perturbation problem. */ terrain.AddTriangleUnperturbed( HexagonPoint.Perturb( begin, hexOuterRadius, wrapSize ), vertex2, boundary ); terrain.AddTriangleHexData( indices, beginWeights, weight2, boundaryWeights ); for (int i = 2; i < HexagonPoint.terraceSteps; i++) { /* vertex2 has already been perturbed, need not pertub * vertex1 as it is derived from vertex2. */ Vector3 vertex1 = vertex2; Color weight1 = weight2; vertex2 = HexagonPoint.Perturb( HexagonPoint.TerraceLerp(begin, left, i), hexOuterRadius, wrapSize ); weight2 = HexagonPoint.TerraceLerp( beginWeights, leftWeights, i ); terrain.AddTriangleUnperturbed(vertex1, vertex2, boundary); terrain.AddTriangleHexData( indices, weight1, weight2, boundaryWeights ); } terrain.AddTriangleUnperturbed( vertex2, HexagonPoint.Perturb( left, hexOuterRadius, wrapSize ), boundary ); terrain.AddTriangleHexData(indices, weight2, leftWeights, boundaryWeights); }
private void TriangulateCornerTerraces( Vector3 begin, Hex beginHex, Vector3 left, Hex leftHex, Vector3 right, Hex rightHex, float hexOuterRadius, int wrapSize, MapMeshChunkLayer terrain ) { Vector3 vertex3 = HexagonPoint.TerraceLerp(begin, left, 1); Vector3 vertex4 = HexagonPoint.TerraceLerp(begin, right, 1); Color weight3 = HexagonPoint.TerraceLerp(_weights1, _weights2, 1); Color weight4 = HexagonPoint.TerraceLerp(_weights1, _weights3, 1); Vector3 indices; indices.x = beginHex.Index; indices.y = leftHex.Index; indices.z = rightHex.Index; terrain.AddTrianglePerturbed( begin, vertex3, vertex4, hexOuterRadius, wrapSize ); terrain.AddTriangleHexData( indices, _weights1, weight3, weight4 ); for (int i = 2; i < HexagonPoint.terraceSteps; i++) { Vector3 vertex1 = vertex3; Vector3 vertex2 = vertex4; Color weight1 = weight3; Color weight2 = weight4; vertex3 = HexagonPoint.TerraceLerp(begin, left, i); vertex4 = HexagonPoint.TerraceLerp(begin, right, i); weight3 = HexagonPoint.TerraceLerp(_weights1, _weights2, i); weight4 = HexagonPoint.TerraceLerp(_weights1, _weights3, i); terrain.AddQuadPerturbed( vertex1, vertex2, vertex3, vertex4, hexOuterRadius, wrapSize ); terrain.AddQuadHexData( indices, weight1, weight2, weight3, weight4 ); } terrain.AddQuadPerturbed( vertex3, vertex4, left, right, hexOuterRadius, wrapSize ); terrain.AddQuadHexData( indices, weight3, weight4, _weights2, _weights3 ); }