public IGameObject Generate() { for (var i = 0; i < GenStep; i++) { var x1 = _rand.Next() % MapSize; var y1 = _rand.Next() % MapSize; var x2 = x1 + Density / 4 + _rand.Next() % Density; var y2 = y1 + Density / 4 + _rand.Next() % Density; if (y2 > MapSize) { y2 = MapSize; } if (x2 > MapSize) { x2 = MapSize; } for (int i2 = x1; i2 < x2; i2++) { for (int j2 = y1; j2 < y2; j2++) { _heightMap[i2][j2] = (ZScale / GenStep + _rand.Next() % Height) / Smoothness; } } } //_heightMap = Utils.ShiftTerrain(_heightMap); HeightMapGenerator.Generate(_graphicDevice, _heightMap, "Rectangle"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, _heightMap, MapSize)); }
public IGameObject Generate() { var arr = GenerateVertices(MapSize); arr = Utils.ShiftTerrain(arr); HeightMapGenerator.Generate(_graphicDevice, arr, "Hill algorithm"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, MapSize)); }
public IGameObject Generate() { var arr = Generate(GridSize, Seed); arr = PostModifications.NormalizeAndFlatten(arr, GridSize, Flattening, Height); arr = Utils.ShiftTerrain(arr); HeightMapGenerator.Generate(_graphicDevice, arr, "Simplex Noise"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, GridSize)); }
public IGameObject Generate() { if (Parameters.ContainsKey("MapSize")) { MapSize = (int)Parameters["MapSize"]; } var arr = GenerateVertices(MapSize); arr = Utils.ShiftTerrain(arr); HeightMapGenerator.Generate(_graphicDevice, arr, "Random"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, MapSize)); }
public IGameObject Generate() { var arr = Utils.GetEmptyArray(Size, Size, 0); for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { arr[i][j] = GetCellular(i, j); } } arr = PostModifications.Normalize(arr, Size, Height); HeightMapGenerator.Generate(_graphicDevice, arr, "Voronoi (" + noiseType.ToString() + ")"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, Size)); }
public IGameObject Generate() { var arr = Utils.GetEmptyArray(2, 2, -1); for (var i = 0; i < arr.Length; i++) { for (var j = 0; j < arr.Length; j++) { arr[i][j] = GetRandom(); } } for (int i = 1; i < Iterations; i++) { var Divided = DivideToSquares(arr); var squaredArray = new List <float[][]>(); for (int j = 0; j < Divided.Count; j++) { var div = Square(Divided.ElementAt(j)); squaredArray.Add(div); } var middedArray = new List <float[][]>(); for (int j = 0; j < squaredArray.Count; j++) { var mid = Mid(squaredArray.ElementAt(j)); middedArray.Add(mid); } var diamondedArray = new List <float[][]>(); for (int j = 0; j < middedArray.Count; j++) { var diamond = Diamond(middedArray.ElementAt(j)); diamondedArray.Add(diamond); } arr = ConnectArrays(diamondedArray); Displacement /= 2; } arr = PostModifications.Normalize(arr, arr.Length, Height); arr = Utils.ShiftTerrain(arr); HeightMapGenerator.Generate(_graphicDevice, arr, "Diamond Square"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, arr.Length)); }
public IGameObject Generate() { var arr = Utils.GetEmptyArray(MapSize, MapSize, 10); for (int j = 0; j < Walkers; j++) { int PointX = rand.Next(0, MapSize); int PointY = rand.Next(0, MapSize); int Steps = rand.Next(MinSteps, MaxSteps); for (int i = 0; i < Steps; i++) { Walk(arr, ref PointX, ref PointY); } } arr = PostModifications.Smooth(arr, 1); arr = Utils.ShiftTerrain(arr); HeightMapGenerator.Generate(_graphicDevice, arr, "Drunkard walk"); return(new PrimitiveBase(_graphicDevice, _graphicDeviceManeger, arr, MapSize)); }