public void initializeNoise(String preset, int seed, int noise_resolution, float amplitude, float persistance) { int noisePreset = 3; if (preset.Equals("default")) { noisePreset = 3; } else if (preset.Equals("amplified")) { noisePreset = 1; } else // revert to default { noisePreset = 3; } noise = new FastPerlinNoise(noise_resolution, seed, amplitude, persistance); noise.setNoiseValues(NoiseMap.adjustNoise(noise.getNoiseValues(), noisePreset)); }
public bool regenerateVoronoi(bool drawmesh) { if (GameControl.gameSession == null || (region = GameControl.gameSession.mapGenerator.getRegion()) == null) { //Debug.Log("Cannot regenerate Voronoi for Water - gameSession is not ready."); return(false); } // prepare noise int noise_seed = (useRandomSeed) ? UnityEngine.Random.Range(int.MinValue, int.MaxValue) : this.seed; Noise noise = new FastPerlinNoise(noiseResolution, noise_seed, noiseAmplitude, noisePersistance); noise.setNoiseValues(NoiseMap.adjustNoise(noise.getNoiseValues(), 5)); // get region parameters this.water_elevation = region.getWaterLevelElevation(); this.size = region.getViewableSize(); int halfSize = this.size / 2; // generate random coordinates for polygons generateXY(out this.X, out this.Y); // use voronoi generator voronoi = new Voronoi(minDist); voronoi.generateVoronoi(X, Y, 0, size, 0, size); VoronoiGraph vG = voronoi.getVoronoiGraph(); foreach (GraphEdge gE in vG.edges) { gE.x1 -= halfSize; gE.x2 -= halfSize; gE.y1 -= halfSize; gE.y2 -= halfSize; } if (drawmesh) { Meshes.WaterMesh.InitializeMesh(region, voronoi.getVoronoiGraph(), mesh, noise, maxWaterLevelDisplacement); } return(true); }