/// <summary> /// Initializes a new instance of Turbulence. /// </summary> public Turbulence() : base(1) { _xDistort = new Perlin(); _yDistort = new Perlin(); _zDistort = new Perlin(); }
void Update() { if (noise == null) noise = new Perlin(); float timex = Time.time * speed * 0.1365143f; float timey = Time.time * speed * 1.21688f; float timez = Time.time * speed * 2.5564f; for (int i=0; i < particles.Length; i++) { Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i); Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z), noise.Noise(timey + position.x, timey + position.y, timey + position.z), noise.Noise(timez + position.x, timez + position.y, timez + position.z)); position += (offset * scale * ((float)i * oneOverZigs)); particles[i].position = position; particles[i].color = Color.blue; particles[i].energy = 1f; } particleEmitter.particles = particles; if (particleEmitter.particleCount >= 2) { if (startLight) startLight.transform.position = particles[0].position; if (endLight) endLight.transform.position = particles[particles.Length - 1].position; } }
public Vector3[] CreateTerrain(float seaLevel) { noise = new Perlin(); Mesh mesh = transform.GetComponent<MeshFilter>().mesh; if (baseVertices == null) // not sure about the scope of this if. potentional bug { baseVertices = mesh.vertices; } Vector3[] vertices = new Vector3[baseVertices.Length]; for (var i=0;i<vertices.Length;i++) { Vector3 vertex = baseVertices[i]; vertex.x += noise.Noise(vertex.x, vertex.y, vertex.z) * scale; vertex.y += noise.Noise(vertex.x, vertex.y, vertex.z) * scale; vertex.z += noise.Noise(vertex.x, vertex.y, vertex.z) * scale; // flatten out sea if (vertex.magnitude < seaLevel) { vertex = seaLevel * vertex.normalized; } vertices[i] = vertex; } return vertices; }
void RandomizeParticlePositions(int startIndex, bool isOffset) { if (noise == null) noise = new Perlin(); float timex = Time.time * speed * 0.1365143f; float timey = Time.time * speed * 1.21688f; float timez = Time.time * speed * 2.5564f; for (int i = startIndex; i < particles.Length; i++) { Vector3 position = isOffset ? particles[i].position : Vector3.Lerp(transform.position, target.Vehicle.Position, oneOverZigs * (float)i); Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z), noise.Noise(timey + position.x, timey + position.y, timey + position.z), noise.Noise(timez + position.x, timez + position.y, timez + position.z)); Vector3 displacement = isOffset ? offset * scale : (offset * scale * ((float)i * oneOverZigs)); position += displacement; particles[i].position = position; particles[i].color = Color.white; particles[i].energy = 1f; // Debug.Log("new pos for "+i+" "+position); } }
public static Texture GeneratePlanetTexture(Vector2u texSize) { var imgSize = texSize; perlin = new Perlin(random.Next(2, 3), 0.2, NoiseQuality.Best, 4, 0.7, random.Next(0, 1024)); ridgedMulti = new RidgedMulti(random.NextDouble() * 2, 0.3, 2, NoiseQuality.Best, random.Next(0, 1024)); voronoi = new Voronoi(0.1, random.NextDouble() * 2, true, random.Next(0, 1024)); selectModule = new Select(1.0, 1.0, 0.0); selectModule.SetSourceModule(0, perlin); selectModule.SetSourceModule(1, ridgedMulti); selectModule.SetSourceModule(2, voronoi); heightMapBuilder = new PlanarNoiseMapBuilder(imgSize.X, imgSize.Y, 0, selectModule, 1, 5, 1, 5, true); heightMap = heightMapBuilder.Build(); var texColors = new GradientColour(); texColors.AddGradientPoint(-1, GenerateProceduralColor()); texColors.AddGradientPoint(-0.2 + random.NextDouble() * 0.4, GenerateProceduralColor()); texColors.AddGradientPoint(1, GenerateProceduralColor()); var renderer = new ImageBuilder(heightMap, texColors); var renderedImg = renderer.Render(); var img = new Bitmap(renderedImg); var sfmlImg = new SFML.Graphics.Image(imgSize.X, imgSize.Y); for (uint x = 0; x < imgSize.X; x++) { for (uint y = 0; y < imgSize.Y; y++) { var col = img.GetPixel((int)x, (int)y); sfmlImg.SetPixel(x, y, new Color(col.R, col.G, col.B, col.A)); } } var returnTex = new Texture(sfmlImg); return returnTex; }
/// <summary> /// Initializes a new instance of Turbulence. /// </summary> public Turbulence() : base(1) { this.m_xDistort = new Perlin(); this.m_yDistort = new Perlin(); this.m_zDistort = new Perlin(); }
void Calculate() { if (perlin == null) { perlin = new Perlin(); } fractal = new FractalNoise(h, lacunarity, octaves, perlin); for (int y = 0;y<height;y++) { for (int x = 0;x<width;x++) { if (gray) { float val = fractal.HybridMultifractal(x*scale + Time.time, y * scale + Time.time, offset); texture.SetPixel(x, y, new Color(val, val, val, val)); } else { offsetPos = Time.time; float valuex = fractal.HybridMultifractal((float)(x*scale + offsetPos * 0.6), (float)(y*scale + offsetPos * 0.6), (float)offset); float valuey = fractal.HybridMultifractal((float)(x*scale + 161.7 + offsetPos * 0.2), (float)(y*scale + 161.7 + offsetPos * 0.3), (float)offset); float valuez = fractal.HybridMultifractal((float)(x*scale + 591.1 + offsetPos), (float)(y*scale + 591.1 + offsetPos * 0.1), (float)offset); texture.SetPixel(x, y, new Color (valuex, valuey, valuez, 1)); } } } texture.Apply(); }
void Start() { // STEP 1 // Gradient is set directly on the object var mountainTerrain = new RidgedMultifractal(); RenderAndSetImage(mountainTerrain); // Stop rendering if we're only getting as far as this tutorial // step. It saves me from doing multiple files. if (_tutorialStep <= 1) return; // STEP 2 var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; RenderAndSetImage(baseFlatTerrain); if (_tutorialStep <= 2) return; // STEP 3 var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); RenderAndSetImage(flatTerrain); if (_tutorialStep <= 3) return; // STEP 4 var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); finalTerrain.SetBounds(0, 1000); finalTerrain.FallOff = 0.125; RenderAndSetImage(finalTerrain); }
private Texture2D texture; // texture created for testing #endregion Fields #region Methods void Generate(bool addToSeed) { Perlin mySphere = new Perlin(); mySphere.Seed = seedToModify; mySphere.OctaveCount = octaves; // modify the frequency mySphere.Frequency = frequency; // modify the persistence mySphere.Persistence = persistence; ModuleBase myModule; myModule = mySphere; mySphere.Lacunarity = 2.5; // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a sphere to the generated texture Noise2D heightMap; heightMap = new Noise2D( mapSizeX, mapSizeY, myModule ); heightMap.GenerateSpherical( south, north, west, east ); texture = heightMap.GetTexture(GradientPresets.Grayscale); sphereRenderer.material.mainTexture = texture; texture = heightMap.GetTexture(GradientPresets.planetColors); sphereRenderer.material.SetTexture("_Normals",heightMap.GetNormalMap(3)); texture = heightMap.GetTexture(GradientPresets.planetLightColors); sphereRenderer.material.SetTexture("_Lights",texture); }
public override bool OnLifetime(MBParticle PT) { MBLineEmitter emtype=PT.Parent.EmitterType as MBLineEmitter; if (emtype) { emtype.EvenlySpread = true; emtype.SetDistribution(PT.Parent.ParticleCount - 1, emtype.DistributeOverTotal); if (mPerlin == null) mPerlin = new Perlin(); float timex = PT.ParticleSystem.GlobalTime * Speed * 0.1365143f; float timey = PT.ParticleSystem.GlobalTime * Speed * 1.21688f; float timez = PT.ParticleSystem.GlobalTime * Speed * 2.5564f; float step = (1.0f / (float)Mathf.Max(1, PT.Parent.ParticleCount - 1)); // As we set absolute position here, we need to transform the particles from emitter space into particlesystem space PT.Position = ParticleSystem.Transform.InverseTransformPoint(emtype.Transform.TransformPoint(emtype.GetDistributionPoint(mPtIdx, emtype.DistributeOverTotal))); Vector3 offset = new Vector3(mPerlin.Noise(timex + PT.Position.x, timex + PT.Position.y, timex + PT.Position.z), mPerlin.Noise(timey + PT.Position.x, timey + PT.Position.y, timey + PT.Position.z), mPerlin.Noise(timez + PT.Position.x, timez + PT.Position.y, timez + PT.Position.z)); PT.Position += (offset * Amplitude * (float)mPtIdx * step); if (++mPtIdx >= PT.Parent.ParticleCount) mPtIdx = 0; } return true; }
protected virtual void perlinStart() { _mesh = this.GetComponent<MeshFilter>().mesh; _originalVerts = _mesh.vertices; _verts = new Vector3[_originalVerts.Length]; noise = new Perlin(); }
private Texture2D texture; // texture created for testing #endregion Fields #region Methods // Other Functions // ---------------------------------------------------------------------------- void Generate(bool addToSeed) { Perlin mySphere = new Perlin(); mySphere.Seed = seedToModify; mySphere.OctaveCount = octaves; // modify the frequency mySphere.Frequency = frequency; // modify the persistence mySphere.Persistence = persistence; // ------------------------------------------------------------------------------------------ // - Compiled Terrain - // Debug.LogError ("Not fetching seed data for planets!"); ModuleBase myModule; myModule = mySphere; // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a sphere to the generated texture Noise2D heightMap; heightMap = new Noise2D( mapSizeX, mapSizeY, myModule ); heightMap.GenerateSpherical( south, north, west, east ); texture = heightMap.GetTexture(GradientPresets.Grayscale); sphereRenderer.material.mainTexture = texture; //Debug.LogWarning("Removed Generate Planet Clouds to save on load times for now till I optimize it and make it run better."); }
// Use this for initialization void Start() { IModule mountainTerrain = new RidgedMulti(); IModule baseFlatTerrain = new Billow(); ((Billow)baseFlatTerrain).Frequency = 2.0; IModule flatTerrain = new ScaleBias(baseFlatTerrain, 0.125, -0.75); IModule terrainType = new Perlin(); ((Perlin)terrainType).Frequency = 0.5; ((Perlin)terrainType).Persistence = 0.25; IModule terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType); ((Select)terrainSelector).SetBounds(0.0, 1000.0); ((Select)terrainSelector).SetEdgeFallOff(0.125); IModule finalTerrain = new Turbulence(terrainSelector); ((Turbulence)finalTerrain).Frequency = 4.0; ((Turbulence)finalTerrain).Power = 0.125; NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(finalTerrain); RendererImage render = new RendererImage(); render.SourceNoiseMap = heightMapBuilder.Map; render.ClearGradient (); render.AddGradientPoint(-1.0000, new Color32(32, 160, 0, 255)); render.AddGradientPoint(-0.2500, new Color32(224, 224, 0, 255)); render.AddGradientPoint(0.2500, new Color32(128, 128, 128, 255)); render.AddGradientPoint(1.0000, new Color32(255, 255, 255, 255)); render.IsLightEnabled = true; render.LightContrast = 3.0; render.LightBrightness = 2.0; render.Render(); tex = render.GetTexture(); }
void Update() { int length = particle_system.GetParticles(particles); if (noise == null) noise = new Perlin(); float timex = Time.time * speed * 0.1365143f; float timey = Time.time * speed * 1.21688f; float timez = Time.time * speed * 2.5564f; for (int i=0; i < length; i++) { Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i); Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z), noise.Noise(timey + position.x, timey + position.y, timey + position.z), noise.Noise(timez + position.x, timez + position.y, timez + position.z)); position += (offset * scale * ((float)i * oneOverZigs)); particles[i].position = position; // particles[i].color = Color.white; // particles[i].energy = 1f; } particle_system.SetParticles(particles, length); }
void Update() { if (m_Noise == null) m_Noise = new Perlin(); float timex = Time.time * m_Speed * 0.1365143f; float timey = Time.time * m_Speed * 1.21688f; float timez = Time.time * m_Speed * 2.5564f; for (int i=0; i < m_Particles.Length; i++) { Vector3 position = Vector3.Lerp(transform.position, m_Target.position, m_OneOverZigs * (float)i); Vector3 offset = new Vector3(m_Noise.Noise(timex + position.x, timex + position.y, timex + position.z), m_Noise.Noise(timey + position.x, timey + position.y, timey + position.z), m_Noise.Noise(timez + position.x, timez + position.y, timez + position.z)); position += (offset * m_Scale * ((float)i * m_OneOverZigs)); m_Particles[i].position = position; m_Particles[i].color = Color.white; m_Particles[i].energy = 1f; } particleEmitter.particles = m_Particles; if (particleEmitter.particleCount >= 30) { if (m_StartLight) m_StartLight.transform.position = m_Particles[0].position; if (m_EndLight) m_EndLight.transform.position = m_Particles[m_Particles.Length - 29].position; } }
public void Generate() { // Create the module network ModuleBase moduleBase; switch(noise) { case NoiseType.Billow: moduleBase = new Billow(); break; case NoiseType.RiggedMultifractal: moduleBase = new RiggedMultifractal(); break; case NoiseType.Voronoi: moduleBase = new Voronoi(); break; case NoiseType.Mix: Perlin perlin = new Perlin(); RiggedMultifractal rigged = new RiggedMultifractal(); moduleBase = new Add(perlin, rigged); break; default: moduleBase = new Perlin(); break; } // Initialize the noise map this.m_noiseMap = new Noise2D(resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar( offset + -1 * 1/zoom, offset + offset + 1 * 1/zoom, offset + -1 * 1/zoom, offset + 1 * 1/zoom); Debug.Log (moduleBase.GetValue (0, 0, UnityEngine.Random.value)); // Generate the textures this.m_textures[0] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); this.m_textures[0].Apply(); this.m_textures[1] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Terrain); this.m_textures[1].Apply(); this.m_textures[2] = this.m_noiseMap.GetNormalMap(3.0f); this.m_textures[2].Apply(); //display on plane GetComponent<Renderer>().material.mainTexture = m_textures[0]; //write images to disk File.WriteAllBytes(Application.dataPath + "/../Gray.png", m_textures[0].EncodeToPNG() ); File.WriteAllBytes(Application.dataPath + "/../Terrain.png", m_textures[1].EncodeToPNG() ); File.WriteAllBytes(Application.dataPath + "/../Normal.png", m_textures[2].EncodeToPNG() ); Debug.Log("Wrote Textures out to "+Application.dataPath + "/../"); }
/// <summary> /// Initializes a new instance of Turbulence. /// </summary> /// <param name="input">The input module.</param> public Turbulence(ModuleBase input) : base(1) { _xDistort = new Perlin(); _yDistort = new Perlin(); _zDistort = new Perlin(); Modules[0] = input; }
// Use this for initialization void Start () { Debug.Log("Tutorial conversion for http://libnoise.sourceforge.net/tutorials/tutorial2.html"); var perlin = new Perlin(); Debug.Log(string.Format("First value: {0}", perlin.GetValue(_firstValue))); Debug.Log(string.Format("First value, displaced: {0}", perlin.GetValue(_firstValue + _displacement))); Debug.Log(string.Format("Second value: {0}", perlin.GetValue(_secondValue))); }
private Texture2D texture; // texture created for testing #endregion Fields #region Methods public void Generate() { Perlin mySphere = new Perlin(); mySphere.Seed = seedHandler.currentSeed; seedModifier = Random.Range(0,2048); mySphere.Seed = mySphere.Seed + seedModifier + specialSeedModifier; // modify the seed with the variable declared in the editor (default 0, or no change) mySphere.OctaveCount = octaves; // modify the frequency mySphere.Frequency = frequency; // modify the persistence mySphere.Persistence = persistence; // ------------------------------------------------------------------------------------------ // - Compiled Terrain - Debug.LogError ("Not fetching seed data for planets!"); ModuleBase myModule; myModule = mySphere; // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a sphere to the generated texture Noise2D heightMap; heightMap = new Noise2D( mapSizeX, mapSizeY, myModule ); heightMap.GeneratePlanar( sampleOffsetX, sampleOffsetX + sampleSizeX, sampleOffsetY, sampleOffsetY + sampleSizeY ); heightMap.GenerateSpherical( south, north, west, east ); potentialRandomGradiants = Random.Range (0,3); if(potentialRandomGradiants == 0){ texture = heightMap.GetTexture(GradientPresets.nebulaColorsD); } else if(potentialRandomGradiants == 1){ texture = heightMap.GetTexture(GradientPresets.nebulaColorsD); } else if(potentialRandomGradiants == 2){ texture = heightMap.GetTexture(GradientPresets.nebulaColorsD); } else { texture = heightMap.GetTexture(GradientPresets.nebulaColorsD); } //nebulaColorsB, C, A, D sphereRenderer.material.mainTexture = texture; }
void Start() { if (perlin == null) { perlin = new Perlin(); } particles = new ParticleSystem.Particle[pCount]; particleSystem.Emit(pCount); StartCoroutine(waitForParticles()); }
/// <summary> /// Initializes a new instance of Turbulence. /// </summary> /// <param name="x">The perlin noise to apply on the x-axis.</param> /// <param name="y">The perlin noise to apply on the y-axis.</param> /// <param name="z">The perlin noise to apply on the z-axis.</param> /// <param name="power">The power of the turbulence.</param> /// <param name="input">The input module.</param> public Turbulence(Perlin x, Perlin y, Perlin z, double power, ModuleBase input) : base(1) { this.m_xDistort = x; this.m_yDistort = y; this.m_zDistort = z; this.m_modules[0] = input; this.Power = power; }
/// <summary> /// Initializes a new instance of Turbulence. /// </summary> /// <param name="x">The perlin noise to apply on the x-axis.</param> /// <param name="y">The perlin noise to apply on the y-axis.</param> /// <param name="z">The perlin noise to apply on the z-axis.</param> /// <param name="power">The power of the turbulence.</param> /// <param name="input">The input module.</param> public Turbulence(Perlin x, Perlin y, Perlin z, double power, ModuleBase input) : base(1) { _xDistort = x; _yDistort = y; _zDistort = z; Modules[0] = input; Power = power; }
void Start() { noise = new Perlin(); oneOverZigs = 1f / (float)zigs; particleEmitter.emit = false; particleEmitter.Emit(zigs); particles = particleEmitter.particles; }
public Turbulence(double power, double frequency, int roughness, int seed) { zDistortModule = new Perlin(); yDistortModule = new Perlin(); xDistortModule = new Perlin(); Power = power; Seed = seed; Frequency = frequency; Roughness = roughness; }
public Noise(float s, float p, float o, Calculate c, Generator g) { scale = s; power = p; offset = o; calc = c; if (g == Generator.Vonoroi) vonoroi = Generators.Vonoroi(0.1, offset); else if (g == Generator.Perlin) perlin = Generators.Perlin(0.1, offset); else if (g == Generator.Billow) billow = Generators.Billow(0.1, offset); generator = g; }
public Turbulence() { zDistortModule = new Perlin(); yDistortModule = new Perlin(); xDistortModule = new Perlin(); Power = DefaultTurbulencePower; Seed = DefaultTurbulenceSeed; Frequency = DefaultTurbulenceFrequency; Roughness = DefaultTurbulenceRoughness; }
protected override ModuleBase CreateAndReadyModule() { Perlin perlin = new Perlin(); perlin.Quality = quality; perlin.Seed = seed; perlin.Frequency = frequency; perlin.OctaveCount = octaves; perlin.Lacunarity = lacunarity; perlin.Persistence = persistance; return perlin; }
public Turbulence(IModule mod0) { Module0 = mod0; XDistortModule = new Perlin(); YDistortModule = new Perlin(); ZDistortModule = new Perlin(); Frequency = 1.0; Power = 1.0; Roughness = 3; Seed = 0; }
void Awake() { noise = new Perlin(); oneOverZigs = 1f / (float) zigs; particleEmitter.emit = false; particleEmitter.maxEmission = zigs; particleEmitter.Emit(zigs); particles = particleEmitter.particles; _myParticleRenderer = GetComponent < ParticleRenderer > (); }
void Start() { var perlin = new Perlin(); var heightMapBuilder = new Noise2D(512, 256, perlin); heightMapBuilder.GenerateSpherical(_north, _south, _west, _east); var image = heightMapBuilder.GetTexture(_gradient); renderer.material.mainTexture = image; }
void Awake() { perlin = new Perlin(); seed = 100f * Random.value; }
void Start() { listener = Camera.main.GetComponent <AudioListener>(); noise = new Perlin(); }
private void SetupRainfallNoise() { float freqMultiplier = WorldGenStep_Terrain.FreqMultiplier; ModuleBase moduleBase = new Perlin((double)(0.015f * freqMultiplier), 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); moduleBase = new ScaleBias(0.5, 0.5, moduleBase); NoiseDebugUI.StorePlanetNoise(moduleBase, "basePerlin"); ModuleBase moduleBase2 = new AbsLatitudeCurve(new SimpleCurve { { 0f, 1.12f, true }, { 25f, 0.94f, true }, { 45f, 0.7f, true }, { 70f, 0.3f, true }, { 80f, 0.05f, true }, { 90f, 0.05f, true } }, 100f); NoiseDebugUI.StorePlanetNoise(moduleBase2, "latCurve"); this.noiseRainfall = new Multiply(moduleBase, moduleBase2); float num = 0.000222222225f; float num2 = -500f * num; ModuleBase moduleBase3 = new ScaleBias((double)num, (double)num2, this.noiseElevation); moduleBase3 = new ScaleBias(-1.0, 1.0, moduleBase3); moduleBase3 = new Clamp(0.0, 1.0, moduleBase3); NoiseDebugUI.StorePlanetNoise(moduleBase3, "elevationRainfallEffect"); this.noiseRainfall = new Multiply(this.noiseRainfall, moduleBase3); Func <double, double> processor = delegate(double val) { if (val < 0.0) { val = 0.0; } if (val < 0.12) { val = (val + 0.12) / 2.0; if (val < 0.03) { val = (val + 0.03) / 2.0; } } return(val); }; this.noiseRainfall = new Arbitrary(this.noiseRainfall, processor); this.noiseRainfall = new Power(this.noiseRainfall, new Const(1.5)); this.noiseRainfall = new Clamp(0.0, 999.0, this.noiseRainfall); NoiseDebugUI.StorePlanetNoise(this.noiseRainfall, "noiseRainfall before mm"); this.noiseRainfall = new ScaleBias(4000.0, 0.0, this.noiseRainfall); SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve(); if (rainfallCurve != null) { this.noiseRainfall = new CurveSimple(this.noiseRainfall, rainfallCurve); } }
public float Value(int seed2) { var i1 = _hash1.Range(-100.0f, 100.0f, seed2); return(Perlin.Fbm(_time + i1, _fractal) * _fbmNorm); }
float GetNoise(Vector3 p) { return(Perlin.Noise(p * _frequency)); }
public void Generate () { // Create the module network ModuleBase moduleBase; switch (noise) { case NoiseType.Billow: moduleBase = new Billow (); break; case NoiseType.RidgedMultifractal: moduleBase = new RidgedMultifractal (); break; case NoiseType.Voronoi: // moduleBase = new Voronoi(); seed = UnityEngine.Random.Range (0, 100); moduleBase = new Voronoi (frequency, displacement, seed, false); break; case NoiseType.Mix: Perlin perlin = new Perlin (); var rigged = new RidgedMultifractal (); moduleBase = new Add (perlin, rigged); break; case NoiseType.Practice: var bill = new Billow (); bill.Frequency = frequency; moduleBase = new Turbulence (turbulence / 10, bill); break; default: var defPerlin = new Perlin (); defPerlin.OctaveCount = perlinOctaves; moduleBase = defPerlin; break; } // Initialize the noise map this.m_noiseMap = new Noise2D (resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar ( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom, true); // Generate the textures this.m_textures [0] = this.m_noiseMap.GetTexture (GradientPresets.Grayscale); this.m_textures [0].Apply (); this.m_textures [1] = this.m_noiseMap.GetTexture (GradientPresets.Terrain); this.m_textures [1].Apply (); this.m_textures [2] = this.m_noiseMap.GetNormalMap (3.0f); this.m_textures [2].Apply (); //display on plane renderer.material.mainTexture = this.m_textures [0]; //write images to disk File.WriteAllBytes (Application.dataPath + "/../Gray.png", m_textures [0].EncodeToPNG ()); File.WriteAllBytes (Application.dataPath + "/../Terrain.png", m_textures [1].EncodeToPNG ()); File.WriteAllBytes (Application.dataPath + "/../Normal.png", m_textures [2].EncodeToPNG ()); Debug.Log ("Wrote Textures out to " + Application.dataPath + "/../"); }
public void Populate(byte[] seed) { Object[] airBiome = Resources.LoadAll("Air/"); Object[] earthBiome = Resources.LoadAll("Earth/"); Object[] waterBiome = Resources.LoadAll("Water/"); Object[] fireBiome = Resources.LoadAll("Fire/"); Object[] darkBiome = Resources.LoadAll("Dark/"); Object[] lightBiome = Resources.LoadAll("Light/"); Object[] misc = Resources.LoadAll("Misc/"); Perlin perlin = new Perlin(); double f = 0; double p = 0; double l = 0; int o = 0; //int pSeed = 0; float sc = 0; //99.0f float amplitude = 42; //42 //int h = 0; //int iterations = 0; runes = new List <Rune>(); //set generation to 3, the 0 state for life casting foreach (HexTile ht in tiles) { ht.generation = zeroState; } sc = 99; //Random.Range(99f,111f); f = 0.0000024; //(double)Random.Range(.0000014618f,.000001918f); //(double)Random.Range(0.000000618f,0.000000918f);//.01618;// * Random.Range(0.5f,1.5f);// * i; //.0000024 l = 2.4; //(double)Random.Range(2.24f,4.42f);// * Random.Range(0.5f,1.5f);//2.4; p = .2; //(double)Random.Range(.16f,.191f);// * Random.Range(0.5f,1.5f); //.24 o = 6; //Random.Range(3,7);// + i; amplitude = 42; //Random.Range(24,42); glyphProb /= 64; for (int i = 0; i < seed.Length; i++) { UnityEngine.Random.InitState(seed[i]); perlin.Seed = seed[i]; float stepHeight = Random.Range(0.1f, 0.5f); PerlinPopulate(perlin, f, l, p, o, amplitude, sc, stepHeight); } //Heightmap perlin seed //UnityEngine.Random.InitState(randseed); //perlin.Seed = perlinseed; //pSeed += seed[i]; //iterations = 32;//Random.Range(2,7); //Populate with params found in seed //Normalize perlin values //pSeed /= seed.Length; //sc /= seed.Length; //f /= seed.Length; //l /= seed.Length; //p /= seed.Length; //iterations = (iterations % 12) + 1; //seed.Length; //o = (o % 32) + 3; //glyphProb /= iterations; //populationProb /= iterations; //Debug.Log("octave: " + o + " sc: " + sc + " freq: " + f + " lac: " + l + " pers: " + p + " iterations: " + iterations); //PerlinPopulate(perlin,pSeed,f*6,l,p,o,amplitude,sc); //PerlinPopulate(perlin,pSeed,f,l,p,o,amplitude*10,sc); //biomes and ocean int water = 0; int fire = 0; int vapor = 0; int crystal = 0; seaLevel = AverageTileHeight() - 1;// + 0.1f; Debug.Log("sea level: " + seaLevel); //water world foreach (HexTile ht in tiles) { if (ht.type == TileType.Water) { water++; } if (ht.type == TileType.Fire) { fire++; } if (ht.type == TileType.Vapor) { vapor++; } if (ht.type == TileType.Crystal) { crystal++; } } if (water >= fire && water >= vapor && water >= crystal) { element = TileType.Water; foreach (HexTile ht in tiles) { if ((ht.type == TileType.Water))//&& ht.hexagon.scale < seaLevel) { if (ht.hexagon.scale > seaLevel) { ht.type = TileType.Earth; } } } LightToDark(); } //fire world if (fire > water && fire > vapor && fire > crystal) { element = TileType.Fire; foreach (HexTile ht in tiles) { if ((ht.type == TileType.Water || ht.type == TileType.Fire))// && ht.hexagon.scale < seaLevel) { //ht.hexagon.scale = seaLevel; } } DarkToLight(); } //vapor if (vapor >= water && vapor >= fire && vapor >= crystal) { element = TileType.Vapor; //foreach(HexTile ht in tiles) //{ /* * if(ht.type == TileType.Vapor || ht.type == TileType.Crystal) * { * ht.hexagon.scale = seaLevel; * } */ //} //DarkToLight(); } //crystal if (crystal > fire && crystal > vapor && crystal > water) { element = TileType.Crystal; //foreach(HexTile ht in tiles) //{ /* * if(ht.type == TileType.Vapor || ht.type == TileType.Crystal) * { * ht.hexagon.scale = seaLevel; * } */ //} //LightToDark(); } foreach (HexTile ht in tiles) { if (element == TileType.Water || element == TileType.Fire) { if (ht.hexagon.scale <= seaLevel) { ht.type = element; ht.oceanTile = true; //ht.passable = false; ht.hexagon.scale = seaLevel; } } } int numObjects = 0; //biome objects foreach (HexTile ht in tiles) { //if surrounded by ocean tiles, become oceantile int x = 0; foreach (int n in ht.neighbors) { if (tiles[n].oceanTile) { x++; } } if (x == ht.neighbors.Count) { ht.generation = zeroState; ht.hexagon.scale = seaLevel; } //choose which object to place if (ht.placeObject && numObjects <= maxObjects && !ht.oceanTile) { ht.passable = false; numObjects++; switch (ht.type) { case TileType.Gray: ht.objectToPlace = Random.Range(0, misc.Length); break; case TileType.Water: ht.objectToPlace = Random.Range(0, waterBiome.Length); break; case TileType.Fire: ht.objectToPlace = Random.Range(0, fireBiome.Length); break; case TileType.Earth: ht.objectToPlace = Random.Range(0, earthBiome.Length); break; case TileType.Air: ht.objectToPlace = Random.Range(0, airBiome.Length); break; case TileType.Dark: ht.objectToPlace = Random.Range(0, darkBiome.Length); break; case TileType.Light: ht.objectToPlace = Random.Range(0, lightBiome.Length); break; case TileType.Ice: ht.objectToPlace = Random.Range(0, waterBiome.Length); break; case TileType.Metal: ht.objectToPlace = Random.Range(0, fireBiome.Length); break; case TileType.Arbor: ht.objectToPlace = Random.Range(0, earthBiome.Length); break; case TileType.Vapor: ht.objectToPlace = Random.Range(0, airBiome.Length); break; case TileType.Astral: ht.objectToPlace = Random.Range(0, darkBiome.Length); break; case TileType.Crystal: ht.objectToPlace = Random.Range(0, lightBiome.Length); break; default: break; } } } //random generation foreach (HexTile ht in tiles) { if (ht.generation == zeroState) { ht.generation = Random.Range(zeroState, oneState + 1); } } }
void GenerateObject() { body = Instantiate(terrain); if (body) { this.name = "Terrain"; body.transform.parent = transform; body.name = "body"; body.transform.localPosition = new Vector3(-250.0f, 0.0f, -250.0f); } else { Debug.LogError("Failed to created body on " + this.name + " object."); return; } if (generateWater) { sea = Instantiate(water); if (sea) { sea.transform.parent = transform; sea.name = "water"; waterHeight = Random.Range(seaLevel.x, seaLevel.y); sea.transform.localPosition = new Vector3(0.0f, waterHeight, 0.0f); } else { Debug.LogError("Failed to created water on " + this.name + " object."); return; } } //Get the terrain data of the currently active terrain var terrainData = Terrain.activeTerrain.terrainData; #region One Generator ////Create a new ridged multifractal generator with the settings, and a random seed //var generator = new RidgedMultifractal(frequency, lacu, octaves, Random.Range(0, 0xffffff), QualityMode.High); ////Create a 2D noise generator for the terrain heightmap, using the generator we just created //var noise = new Noise2D(terrainData.heightmapResolution, generator); #endregion #region Scaling ////Create a new perlin noise generator with the given settings. //var perlinGenerator = new Perlin(frequency, lacu, persist, octaves, Random.Range(0, 0xffffff), QualityMode.High); ////Create a constant value generator - every sampled point will be 0.8. //var constGenerator = new Const(0.8f); ////Combine the perlin noise generator and the const generator through multiplication -(perlin[x, y] * 0.8) for all x, y //var mixedGenerator = new Multiply(perlinGenerator, constGenerator); ////Create a new noise map //var noise = new Noise2D(terrainData.heightmapWidth, terrainData.heightmapHeight, mixedGenerator); #endregion #region Adding Two Functions //To scale each point by half var constGenerator = new Const(0.3f); //Create a new perlin noise generator with the given settings. var perlinGenerator = new Perlin(frequency, lacu, persist, octaves, Random.Range(0, 0xffffff), QualityMode.High); //Create a second perlin noise generator with some different settings. var perlinGenerator2 = new Perlin(frequency * 2, lacu, persist, octaves, Random.Range(0, 0xffffff) + 1, QualityMode.High); //Add together both generators scaled by 0.5f (so they add up to 1) var finalGenerator = new Add(new Multiply(perlinGenerator, constGenerator), new Multiply(perlinGenerator2, constGenerator)); var constGenerator2 = new Const(0.8f); var finalGenerator2 = new Multiply(constGenerator2, finalGenerator); //Create a new noise map var noise = new Noise2D(terrainData.heightmapWidth, terrainData.heightmapHeight, finalGenerator2); #endregion //Generate a plane from [0, 1] on x, [0, 1] on y noise.GeneratePlanar(0, 1, 0, 1); //Get the data in an array so we can use it to set the heights var data = noise.GetData(true, 0, 0, true); //.. and actually set the heights terrainData.SetHeights(0, 0, data); }
public void Generate() { // Create the module network ModuleBase moduleBase; switch (noise) { case NoiseType.Billow: moduleBase = new Billow(); break; case NoiseType.RiggedMultifractal: moduleBase = new RiggedMultifractal(); break; case NoiseType.Voronoi: moduleBase = new Voronoi(); break; case NoiseType.Mix: Perlin perlin = new Perlin(); RiggedMultifractal rigged = new RiggedMultifractal(); moduleBase = new Add(perlin, rigged); break; default: moduleBase = new Perlin(); break; } // Initialize the noise map this.m_noiseMap = new Noise2D(resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom); Debug.Log(moduleBase.GetValue(0, 0, UnityEngine.Random.value)); // Generate the textures this.m_textures[0] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); this.m_textures[0].Apply(); this.m_textures[1] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Terrain); this.m_textures[1].Apply(); this.m_textures[2] = this.m_noiseMap.GetNormalMap(3.0f); this.m_textures[2].Apply(); //display on plane GetComponent <Renderer>().material.mainTexture = m_textures[0]; //write images to disk File.WriteAllBytes(Application.dataPath + "/../Gray.png", m_textures[0].EncodeToPNG()); File.WriteAllBytes(Application.dataPath + "/../Terrain.png", m_textures[1].EncodeToPNG()); File.WriteAllBytes(Application.dataPath + "/../Normal.png", m_textures[2].EncodeToPNG()); Debug.Log("Wrote Textures out to " + Application.dataPath + "/../"); }
/// <summary> /// Uses layers Perlin noise to generate the density value at a specific point. /// </summary> /// <param name="point"> /// point.x, point.y, point.z represent the position of the point in multiples of <c>chunkSize</c>. /// point.w represents the y value of the point in global coordinates.</param> /// <returns></returns> public static Vector2 GenerateValueAtPoint(Vector4 point) { // TODO Explain this code float localScaler = 0.75f * Preferences.terrainScaler + 2f * Preferences.terrainScaler * Perlin.Fbm(point.x, Preferences.seed * 1.25f, point.z, 1); point.x /= localScaler; point.y /= localScaler; point.z /= localScaler; float baseNoise = 1; float heightMap = GetHeightAtPoint(new Vector2(point.x, point.z)); baseNoise *= 1 - Mathf.Clamp01(point.w - heightMap); baseNoise *= 1 - point.w / Preferences.maxTerrainHeight; baseNoise = Mathf.Clamp01(baseNoise); float overHang = Perlin.Fbm(point.x * 4f, point.y * 4f, point.z * 4f, 1); float caveBiomeMap = Mathf.Abs(1 - Mathf.PerlinNoise(point.x, point.z)); float caveToSurfaceFalloff = Mathf.Pow(Mathf.Clamp(heightMap * 1.5f - (point.w - heightMap * 0.5f), 0, heightMap) / heightMap, 2); float final = Mathf.Lerp(baseNoise, overHang, caveBiomeMap * caveToSurfaceFalloff); return(new Vector2((1 - Mathf.Clamp01(final)) * 2 - 1f, 0)); }
public static bool Prefix(Map map) { //if (!DefsUtil.Enable) // return true; //if (!DefsUtil.EnableMountainSettings) // return true; if (Settings.detectedImpassableMaps && map.TileInfo.hilliness == Hilliness.Impassable) { return(true); } NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z); ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); input = new ScaleBias(0.5, 0.5, input); NoiseDebugUI.StoreNoiseRender(input, "elev base"); float num = 1f; switch (map.TileInfo.hilliness) { case Hilliness.Flat: num = MapGenTuning.ElevationFactorFlat; break; case Hilliness.SmallHills: num = MapGenTuning.ElevationFactorSmallHills; break; case Hilliness.LargeHills: num = MapGenTuning.ElevationFactorLargeHills; break; case Hilliness.Mountainous: num = MapGenTuning.ElevationFactorMountains; break; case Hilliness.Impassable: num = MapGenTuning.ElevationFactorImpassableMountains; break; } input = new Multiply(input, new Const(num + MapSettings.Mountain.GetMultiplier())); NoiseDebugUI.StoreNoiseRender(input, "elev world-factored"); if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable) { ModuleBase input2 = new DistFromAxis((float)map.Size.x * 0.42f); input2 = new Clamp(0.0, 1.0, input2); input2 = new Invert(input2); input2 = new ScaleBias(1.0, 1.0, input2); Rot4 random; do { random = Rot4.Random; }while (random == Find.World.CoastDirectionAt(map.Tile)); if (random == Rot4.North) { input2 = new Rotate(0.0, 90.0, 0.0, input2); input2 = new Translate(0.0, 0.0, -map.Size.z, input2); } else if (random == Rot4.East) { input2 = new Translate(-map.Size.x, 0.0, 0.0, input2); } else if (random == Rot4.South) { input2 = new Rotate(0.0, 90.0, 0.0, input2); } else { _ = random == Rot4.West; } NoiseDebugUI.StoreNoiseRender(input2, "mountain"); input = new Add(input, input2); NoiseDebugUI.StoreNoiseRender(input, "elev + mountain"); } float b = (map.TileInfo.WaterCovered ? 0f : float.MaxValue); MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 allCell in map.AllCells) { elevation[allCell] = Mathf.Min(input.GetValue(allCell), b); } ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); input3 = new ScaleBias(0.5, 0.5, input3); NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base"); MapGenFloatGrid fertility = MapGenerator.Fertility; foreach (IntVec3 allCell2 in map.AllCells) { fertility[allCell2] = input3.GetValue(allCell2); } return(false); }
ModuleBase GetModule(NoiseType type) { ModuleBase Generator; switch (type) { case NoiseType.Perlin: Generator = new Perlin( 1d, 2d, .5d, 6, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.Billow: Generator = new Billow( 1d, 2d, .5d, 6, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.RiggedMultifractal: Generator = new RidgedMultifractal( 1d, 2d, 6, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.Voronoi: Generator = new Voronoi( 1d, 0, Random.Range(0, int.MaxValue), true); break; default: Generator = new Perlin( 1d, 2d, .5d, 6, Random.Range(0, int.MaxValue), QualityMode.Low); break; } return(Generator); }
void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { scale += 4; Debug.Log("Scale: " + scale); } if (Input.GetKeyDown(KeyCode.DownArrow)) { scale -= 4; Debug.Log("Scale: " + scale); } mc.cleanUp(); timer += Time.deltaTime / 2; if (timer > 255) { timer = 0; } MeshFilter meshFilter = this.GetComponent <MeshFilter>(); MeshCollider meshCollider = this.GetComponent <MeshCollider>(); // one submesh for each face Vector3 cubeSize = size * 0.5f; // top of the cube // t0 is top left point float perlinX1 = (transform.position.x + cubeSize.x) / scale; float perlinX2 = (transform.position.x - cubeSize.x) / scale; float perlinY1 = (transform.position.z - cubeSize.z) / scale; float perlinY2 = (transform.position.z + cubeSize.z) / scale; //Calculate each top vertex height individually float height1 = Perlin.Noise(perlinX1, perlinY1, timer) * 1.2f + 0.9f; float height2 = Perlin.Noise(perlinX2, perlinY1, timer) * 1.2f + 0.9f; float height3 = Perlin.Noise(perlinX2, perlinY2, timer) * 1.2f + 0.9f; float height4 = Perlin.Noise(perlinX1, perlinY2, timer) * 1.2f + 0.9f; Vector3 position = GetComponentInChildren <ParticleSystem>().GetComponentInParent <Transform>().position; GetComponentInChildren <ParticleSystem>().GetComponentInParent <Transform>().position = new Vector3(position.x, ((height1 + height2 + height3 + height4) / 4f), position.z); if ((((height1 + height2 + height3 + height4) / 4f) > 1.2f) && !GetComponentInChildren <ParticleSystem>().isPlaying) { GetComponentInChildren <ParticleSystem>().Play(); } Vector3 t0 = new Vector3(cubeSize.x, height1, -cubeSize.z); Vector3 t1 = new Vector3(-cubeSize.x, height2, -cubeSize.z); Vector3 t2 = new Vector3(-cubeSize.x, height3, cubeSize.z); Vector3 t3 = new Vector3(cubeSize.x, height4, cubeSize.z); // bottom of the cube Vector3 b0 = new Vector3(cubeSize.x, -cubeSize.y, -cubeSize.z); Vector3 b1 = new Vector3(-cubeSize.x, -cubeSize.y, -cubeSize.z); Vector3 b2 = new Vector3(-cubeSize.x, -cubeSize.y, cubeSize.z); Vector3 b3 = new Vector3(cubeSize.x, -cubeSize.y, cubeSize.z); // Top square mc.BuildTriangle(t0, t1, t2); mc.BuildTriangle(t0, t2, t3); // Bottom square mc.BuildTriangle(b2, b1, b0); mc.BuildTriangle(b3, b2, b0); // Back square mc.BuildTriangle(b0, t1, t0); mc.BuildTriangle(b0, b1, t1); mc.BuildTriangle(b1, t2, t1); mc.BuildTriangle(b1, b2, t2); mc.BuildTriangle(b2, t3, t2); mc.BuildTriangle(b2, b3, t3); mc.BuildTriangle(b3, t0, t3); mc.BuildTriangle(b3, b0, t0); meshFilter.mesh.Clear(); Destroy(oldMesh); oldMesh = mc.CreateMesh(); meshCollider.sharedMesh = oldMesh; meshFilter.mesh = oldMesh; }
private float GetSdf(Vector3 pos) { var n = Perlin.Fbm(pos * scale, octaves) - offset; return(n); }
public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes) { //Test Seed: 291887241 var perlin = new Perlin(); perlin.Lacunarity = 1; perlin.Amplitude = 7; perlin.Frequency = 0.015; perlin.Seed = world.Seed; var chanceNoise = new ClampNoise(perlin); var noise = new ScaledNoise(perlin); var random = new Random(world.Seed); var lowWeightOffset = new int[2] { 2, 3 }; var highWeightOffset = new int[2] { 2, 2 }; foreach (var data in Ores) { var midpoint = (data.MaxY + data.MinY) / 2; var weightOffsets = (data.MaxY > 30) ? highWeightOffset : lowWeightOffset; const int weightPasses = 4; for (int i = 0; i < data.Veins; i++) { double weight = 0; for (int j = 0; j < weightPasses; j++) { weight += random.NextDouble(); } weight /= data.Rarity; weight = weightOffsets[0] - Math.Abs(weight - weightOffsets[1]); double x = random.Next(0, Chunk.Width); double z = random.Next(0, Chunk.Depth); double y = weight * midpoint; double randomOffsetX = (float)random.NextDouble() - 1; double randomOffsetY = (float)random.NextDouble() - 1; double randomOffsetZ = (float)random.NextDouble() - 1; int abundance = random.Next(0, data.Abundance); for (int k = 0; k < abundance; k++) { x += randomOffsetX; y += randomOffsetY; z += randomOffsetZ; if (x >= 0 && z >= 0 && y >= data.MinY && x < Chunk.Width && y < data.MaxY && z < Chunk.Depth) { var biome = biomes.GetBiome(chunk.Biomes[(int)(x * Chunk.Width + z)]); if (biome.Ores.Contains(data.Type) && chunk.GetBlockID(new Coordinates3D((int)x, (int)y, (int)z)).Equals(StoneBlock.BlockID)) { chunk.SetBlockID(new Coordinates3D((int)x, (int)y, (int)z), data.ID); } } var blockX = MathHelper.ChunkToBlockX((int)(x), chunk.Coordinates.X); var blockZ = MathHelper.ChunkToBlockZ((int)(z), chunk.Coordinates.Z); double offsetX = 0; double offsetY = 0; double offsetZ = 0; int offset = random.Next(0, 3); double offset2 = random.NextDouble(); if (offset.Equals(0) && offset2 < 0.4) { offsetX += 1; } else if (offset.Equals(1) && offset2 >= 0.4 && offset2 < 0.65) { offsetY += 1; } else { offsetZ += 1; } var newX = (int)(x + offsetX); var newY = (int)(y + offsetY); var newZ = (int)(z + offsetZ); if (newX >= 0 && newZ >= 0 && newY >= data.MinY && newX < Chunk.Width && newY < data.MaxY && newZ < Chunk.Depth) { IBiomeProvider Biome = biomes.GetBiome(chunk.Biomes[newX * Chunk.Width + newZ]); var coordinates = new Coordinates3D((int)newX, (int)newY, (int)newZ); if (Biome.Ores.Contains(data.Type) && chunk.GetBlockID(coordinates).Equals(StoneBlock.BlockID)) { chunk.SetBlockID(coordinates, data.ID); } } } } } }