public override void Execute(GenerationData data, Random rng, BackgroundWorker worker = null) { int width = data.width; int height = data.height; int x, y; float dX, dY, t, d; float halfHeight = height * 0.5f; NoiseWrapper generator = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.FBM, 9.5f, 0.9f, 8, rng.Next() ); for (int i = 0; i < data.pointData.Length; i++) { x = i % width; y = i / width; dX = x / (float)width; dY = y / (float)height; t = generator.GetValue(dX, dY, 0, true); d = 1 - Math.Abs(y / halfHeight - 1); t = (3 * d + t) / 4.0f; data.pointData[i].temperature = t; } }
public override void Execute(GenerationData data, Random rng, BackgroundWorker worker = null) { int x, y; float dX, dY; float ddX, ddY; float e1, e2, d; float halfHeight = data.height >> 1; NoiseWrapper shapeGenerator1 = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.Billow, 12f, 0.525f, 8, rng.Next() // 22.5f, 0.575f, 8 ); NoiseWrapper shapeGenerator2 = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.FBM, 20.0f, .45f, 8, rng.Next() // 25.0f, 0.4f, 8, ); for (int i = 0; i < data.pointData.Length; i++) { x = i % data.width; y = i / data.width; dX = x / (float)data.width; dY = y / (float)data.height; data.pointData[i].x = x; data.pointData[i].y = y; // Calculate Shape e1 = 1 - Math.Abs(shapeGenerator1.GetValue(dX, dY, 0, true)); e1 *= 0.1f; e1 = (e1 * 2) - 1; ddX = dX + e1; ddY = dY + e1; e1 = shapeGenerator2.GetValue(ddX, ddY, 0, true); d = MathEx.EuclideanDistanceCenter(x, y, data.width, data.height); e2 = e1 + sA - sB * (float)Math.Pow(d, sC); data.pointData[i].land = e2 > oceanThreshold; data.pointData[i].elevation = e2; //Report Progress back to Main thread if (worker != null) { worker.ReportProgress((int)((i / (float)data.pointData.Length) * 100)); } } FillIslands(data); FillLakes(data); }
public void BaseSetUp(LayerConfig config, World world, TerrainGen terrainGen) { this.terrainGen = terrainGen; layerName = config.name; isStructure = LayerConfig.IsStructure(config.structure); this.world = world; index = config.index; noise = new NoiseWrapper(world.name); #if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN) && ENABLE_FASTSIMD noiseSIMD = new NoiseWrapperSIMD(world.name); #endif foreach (var key in config.properties.Keys) { properties.Add(key.ToString(), config.properties[key].ToString()); } SetUp(config); }
public override void Execute(GenerationData data, Random rng, BackgroundWorker worker = null) { int width = data.width; int height = data.height; int x, y; float dX, dY, m; NoiseWrapper generator = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.FBM, 9.5f, 0.9f, 8, rng.Next() ); for (int i = 0; i < data.pointData.Length; i++) { x = i % width; y = i / width; dX = x / (float)width; dY = y / (float)height; m = generator.GetValue(dX, dY, 0, true); data.pointData[i].moisture = m; } }