void TriangulateBoundaryTriangle( Vector3 begin, HexCell beginCell, Vector3 left, HexCell leftCell, Vector3 boundary, Color boundaryColor ) { Vector3 v2 = HexData.AddRealismNoiseToBaseMesh(HexData.StepOffset(begin, left, 1)); Color c2 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, 1); terrain.AddTriangleUnperturbed(HexData.AddRealismNoiseToBaseMesh(begin), v2, boundary); terrain.AddTriangleColor(beginCell.Colour, c2, boundaryColor); for (int i = 2; i < HexData.terraceSteps; i++) { Vector3 v1 = v2; Color c1 = c2; v2 = HexData.AddRealismNoiseToBaseMesh(HexData.StepOffset(begin, left, i)); c2 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, i); terrain.AddTriangleUnperturbed(v1, v2, boundary); terrain.AddTriangleColor(c1, c2, boundaryColor); } terrain.AddTriangleUnperturbed(v2, HexData.AddRealismNoiseToBaseMesh(left), boundary); terrain.AddTriangleColor(c2, leftCell.Colour, boundaryColor); }
public void AddTriangle(Vector3 v1, Vector3 v2, Vector3 v3) { int vertexIndex = vertices.Count; vertices.Add(HexData.AddRealismNoiseToBaseMesh(v1)); vertices.Add(HexData.AddRealismNoiseToBaseMesh(v2)); vertices.Add(HexData.AddRealismNoiseToBaseMesh(v3)); triangles.Add(vertexIndex); triangles.Add(vertexIndex + 1); triangles.Add(vertexIndex + 2); }
void TriangulateCornerCliffTerraces( Vector3 begin, HexCell beginCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell ) { float b = 1f / (leftCell.Elevation - beginCell.Elevation); if (b < 0) { b = -b; } Vector3 boundary = Vector3.Lerp( HexData.AddRealismNoiseToBaseMesh(begin), HexData.AddRealismNoiseToBaseMesh(left), b ); Color boundaryColor = Color.Lerp(beginCell.Colour, leftCell.Colour, b); TriangulateBoundaryTriangle( right, rightCell, begin, beginCell, boundary, boundaryColor ); if (leftCell.GetEdgeType(rightCell) == HexEdgeClassification.Slope) { TriangulateBoundaryTriangle( left, leftCell, right, rightCell, boundary, boundaryColor ); } else { terrain.AddTriangleUnperturbed( HexData.AddRealismNoiseToBaseMesh(left), HexData.AddRealismNoiseToBaseMesh(right), boundary ); terrain.AddTriangleColor( leftCell.Colour, rightCell.Colour, boundaryColor ); } }