private static void CreateSolidHex(Vector3 hexPosition, float scale, int x, int z, EmptyGrid map) { Color faceColor = map.values[x, z].cellMapColor; foreach (var direction in SolidPointyHexagonData.PossibleDirections()) { if (map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType == CellType.Empty || map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType == CellType.Floor) { int verticesCount; CreateFace(direction, scale, hexPosition, out verticesCount); ColorizeFace(faceColor, verticesCount); } } }
private static void CreateFace(Direction direction, float scale, Vector3 hexPosition, out int verticesCount) { vertices.AddRange(SolidPointyHexagonData.FaceVertices(direction, scale, hexPosition, out verticesCount)); int triFirstVertCount = vertices.Count - verticesCount; for (int i = 1; i < verticesCount - 1; i++) { triangles.Add(triFirstVertCount); triangles.Add(triFirstVertCount + i); triangles.Add(triFirstVertCount + i + 1); } if (direction == Direction.Down || direction == Direction.Up) { triangles.Add(triFirstVertCount); triangles.Add(vertices.Count - 1); triangles.Add(triFirstVertCount + 1); } }
private static void CreateSolidHex(Vector3 hexPosition, float scale, int x, int z, EmptyGrid map, HeightMap heightMap) { Color faceColor = map.values[x, z].cellMapColor; foreach (var direction in SolidPointyHexagonData.PossibleDirections()) { //CellType neighbourType = map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType; //if (neighbourType == CellType.Empty || neighbourType == CellType.Floor || // (neighbourType == CellType.Wall && heightMap.GetNeighbour(x, z, direction, GridType.PointyHex) < heightMap.values[x, z]) // ) if (map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType == CellType.Empty || map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType == CellType.Floor || ((map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType != CellType.Empty && map.GetNeighbour(x, z, direction, GridType.PointyHex).cellType != CellType.Floor) && heightMap.GetNeighbour(x, z, direction, GridType.PointyHex) < heightMap.values[x, z] - epsilon) ) { int verticesCount; CreateFace(direction, scale, hexPosition, out verticesCount); ColorizeFace(faceColor, verticesCount); } } }