public void Button_GenerateHeightmap_CellNoise() { ParseInputFields(); var heightmap = CellNoise.Generate(_cellNoiseSizeX, _cellNoiseSizeY, _cellNoiseCellCount, _cellNoiseFalloff); CreateNewMenuItem(heightmap, "CellNoise_" + ++_cellMapsGenerated); }
public RTGWorld(World world) { this.world = world; this.simplex = new OpenSimplexNoise(world.getSeed()); this.cell = new SimplexCellularNoise(world.getSeed()); this.rand = world.rand; }
public LandscapeGenerator(RTGWorld rtgWorld) { this.rtgWorld = rtgWorld; sampleArraySize = sampleSize * 2 + 5; biomeData = new int[sampleArraySize * sampleArraySize]; this.simplex = rtgWorld.simplex; this.cell = rtgWorld.cell; setWeightings(); }
public float noise(double x, double z, double frequency) { x *= frequency; z *= frequency; int xInt = (x > .0 ? (int)x : (int)x - 1); int zInt = (z > .0 ? (int)z : (int)z - 1); double minDist = 32000000.0; double xCandidate = 0; double zCandidate = 0; for (int zCur = zInt - 2; zCur <= zInt + 2; zCur++) { for (int xCur = xInt - 2; xCur <= xInt + 2; xCur++) { double xPos = xCur + valueNoise2D(xCur, zCur, seed); double zPos = zCur + valueNoise2D(xCur, zCur, seed - 50); double xDist = xPos - x; double zDist = zPos - z; double dist = xDist * xDist + zDist * zDist; if (dist < minDist) { minDist = dist; xCandidate = xPos; zCandidate = zPos; } } } if (useDistance) { double xDist = xCandidate - x; double zDist = zCandidate - z; return((float)getDistance2D(xDist, zDist)); } else { return((float)CellNoise.valueNoise2D( (int)(Math.Round(xCandidate - 0.5)), (int)(Math.Round(zCandidate - 0.5)), seed)); } }
public void Begin() { TexturePack = AssetDatabase.GetAsset <TexturePack>(""); TerrainNoise = new OpenSimplex(Seed.GetSeedNum()); BiomeNoise = new CellNoise(Seed.GetSeedNum()); Randomizer = new Random(Seed.GetSeedNum()); WorldCamera = new Camera(); Skybox = new Skybox(AssetDatabase.GetAsset <Material>("Resources/Materials/World/Sky.mat")); loadingScreenTexture = AssetDatabase.GetAsset <Texture>("Resources/Textures/GUI/img_loading_screen.png"); loadingScreenTextureDickJoke = AssetDatabase.GetAsset <Texture>("Resources/Textures/GUI/img_loading_screen_willy.png"); isDickJoke = Maths.Chance(0.01f); loadingScreenStyle = new GUIStyle() { Normal = new GUIStyleOption() { TextColor = Color4.White }, HorizontalAlignment = HorizontalAlignment.Middle, VerticalAlignment = VerticalAlignment.Middle, FontSize = 48, Font = GUI.LabelStyle.Font }; lightAngle = 5; lightBufferData = new LightingUniformBufferData(); HasFinishedInitialLoading = false; requiredChunksLoadedNum = (worldSize + worldSize + 1) * (worldSize + worldSize + 1); foreach (var entity in loadedEntities) { entity.Begin(); } ThreadStart chunkThreadStart = ChunkThread; chunkThread = new Thread(chunkThreadStart) { Name = "Chunk Generation Thread" }; chunkThread.Start(); }
public BiomeProviderRTG(Texture2D world) : base(world) { //this.rtgWorld = new RTGWorld(world); this.biomesToSpawnIn = new List <Biome>(); this.borderNoise = new float[256]; this.biomePatcher = new RealisticBiomePatcher(); this.riverSeparation /= RTGAPI.config().RIVER_FREQUENCY_MULTIPLIER; this.riverValleyLevel *= RTGAPI.config().riverSizeMultiplier(); this.largeBendSize *= RTGAPI.config().RIVER_BENDINESS_MULTIPLIER; this.smallBendSize *= RTGAPI.config().RIVER_BENDINESS_MULTIPLIER; long seed = this.rtgWorld.world.getSeed(); simplex = new OpenSimplexNoise(seed); cell = new SimplexCellularNoise(seed); //simplexCell = new SimplexCellularNoise(seed); river = new VoronoiCellNoise(seed); testCellBorder(); }
public static float terrainVolcano(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float border, float baseHeight) { float st = 15f - ((cell.noise(x / 500D, y / 500D, 1D) * 42f) + (simplex.noise2(x / 30f, y / 30f) * 2f)); st = st < 0f ? 0f : st; float h = st; h = h < 0f ? 0f : h; h += (h * 0.4f) * ((h * 0.4f) * 2f); if (h > 10f) { float d2 = (h - 10f) / 1.5f > 30f ? 30f : (h - 10f) / 1.5f; h += cell.noise(x / 25D, y / 25D, 1D) * d2; } h += simplex.noise2(x / 18f, y / 18f) * 3; h += simplex.noise2(x / 8f, y / 8f) * 2; return(baseHeight + h * border); }
public static float terrainDunes(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river) { float st = (simplex.noise2(x / 160f, y / 160f) + 0.38f) * (minimumDuneHeight + configRTG.DUNE_HEIGHT); st = st < 0.2f ? 0.2f : st; float h = simplex.noise2(x / 60f, y / 60f) * st * 2f; h = h > 0f ? -h : h; h += st; h *= h / 50f; h += st; if (h < 10f) { float d = (h - 10f) / 2f; d = d > 4f ? 4f : d; h += cell.noise(x / 25D, y / 25D, 1D) * d; h += simplex.noise2(x / 30f, y / 30f) * d; h += simplex.noise2(x / 14f, y / 14f) * d * 0.5f; } return(70f + (h * river)); }
public static float terrainSwampMountain(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river, float width, float heigth, float hMax, float hDivisor, float baseHeight) { float h = simplex.noise2(x / width, y / width) * heigth * river; h *= h / hDivisor; h = h > hMax ? hMax : h; if (h < 14f) { h += simplex.noise2(x / 25f, y / 25f) * (14f - h) * 0.8f; } if (h < 6) { h = 6f - ((6f - h) * 0.07f) + simplex.noise2(x / 20f, y / 20f) + simplex.noise2(x / 5f, y / 5f); } if (h > 10f) { float d = (h - 10f) / 2f > 8f ? 8f : (h - 10f) / 2f; h += simplex.noise2(x / 35f, y / 35f) * d; h += simplex.noise2(x / 60f, y / 60f) * d * 0.5f; if (h > 35f) { float d2 = (h - 35f) / 1.5f > 30f ? 30f : (h - 35f) / 1.5f; h += (float)simplex.octave(4).noise(x / 25D, y / 25D, 1D) * d2; } } if (h > 2f) { float d = (h - 2f) / 2f > 4f ? 4f : (h - 2f) / 2f; h += simplex.noise2(x / 28f, y / 28f) * d; h += simplex.noise2(x / 18f, y / 18f) * (d / 2f); h += simplex.noise2(x / 8f, y / 8f) * (d / 2f); } return(riverized(h + baseHeight, river)); }
public static float terrainMountainRiver(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river, float hPitch, float baseHeight) { float h = simplex.noise2(x / hPitch, y / hPitch) * 135f * river; h *= h / 32f; h = h > 150f ? 150f : h; /*float bn = 0f; * if(h < 1f) * { * bn = 1f - h; * for(int i = 0; i < 3; i++) * { * bn *= bn * 1.25f; * } * bn = bn > 3f ? 3f : bn; * }*/ if (h < 10f) { h += simplex.noise2(x / 14f, y / 14f) * (10f - h) * 0.2f; } if (h > 10f) { float d = (h - 10f) / 2f > 8f ? 8f : (h - 10f) / 2f; h += simplex.noise2(x / 35f, y / 35f) * d; h += simplex.noise2(x / 60f, y / 60f) * d * 0.5f; if (h > 35f) { float d2 = (h - 35f) / 1.5f > 30f ? 30f : (h - 35f) / 1.5f; h += (float)simplex.octave(4).noise(x / 25D, y / 25D, 1D) * d2; } } if (h > 2f) { float d = (h - 2f) / 2f > 4f ? 4f : (h - 2f) / 2f; h += simplex.noise2(x / 28f, y / 28f) * d; h += simplex.noise2(x / 18f, y / 18f) * (d / 2f); h += simplex.noise2(x / 8f, y / 8f) * (d / 2f); } return(riverized(h + baseHeight, river));// - bn; }
public static float terrainMountainSpikes(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river) { float b = (12f + (simplex.noise2(x / 300f, y / 300f) * 6f)); float h = (float)simplex.octave(4).noise(x / 200D, y / 200D, 1D) * b * river; h *= h * 1.5f; h = h > 155f ? 155f : h; if (h > 2f) { float d = (h - 2f) / 2f > 8f ? 8f : (h - 2f) / 2f; h += simplex.noise2(x / 30f, y / 30f) * d; h += simplex.noise2(x / 50f, y / 50f) * d * 0.5f; if (h > 35f) { float d2 = (h - 35f) / 1.5f > 30f ? 30f : (h - 35f) / 1.5f; h += (float)simplex.octave(4).noise(x / 25D, y / 25D, 1D) * d2; } } h += simplex.noise2(x / 18f, y / 18f) * 3; h += simplex.noise2(x / 8f, y / 8f) * 2; return(45f + h + (b * 2)); }
public static float terrainHighland(float x, float y, OpenSimplexNoise simplex, CellNoise cell, float river, float start, float width, float height, float baseAdjust) { float h = simplex.noise2(x / width, y / width) * height * river; //-140 to 140 h = h < start ? start + ((h - start) / 4.5f) : h; if (h < 0f) { h = 0;//0 to 140 } if (h > 0f) { float st = h * 1.5f > 15f ? 15f : h * 1.5f; // 0 to 15 h += (float)simplex.octave(4).noise(x / 70D, y / 70D, 1D) * st; // 0 to 155 h = h * river; } h += blendedHillHeight(simplex.noise2(x / 20f, y / 20f), 0f) * 4f; h += blendedHillHeight(simplex.noise2(x / 12f, y / 12f), 0f) * 2f; h += blendedHillHeight(simplex.noise2(x / 5f, y / 5f), 0f) * 1f; if (h < 0) { h = h / 2f; } if (h < -3) { h = (h + 3f) / 2f - 3f; } return(getTerrainBase(river) + (h + baseAdjust) * river); }
public static float terrainLonelyMountain(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river, float strength, float width, float terrainHeight) { float h = blendedHillHeight(simplex.noise2(x / 20f, y / 20f), 0) * 3; h += blendedHillHeight(simplex.noise2(x / 7f, y / 7f), 0) * 1.3f; float m = simplex.noise2(x / width, y / width) * strength * river; m *= m / 35f; m = m > 70f ? 70f + (m - 70f) / 2.5f : m; float st = m * 0.7f; st = st > 20f ? 20f : st; float c = (float)simplex.octave(4).noise(x / 30f, y / 30f, 1D) * (5f + st); float sm = simplex.noise2(x / 30f, y / 30f) * 8f + simplex.noise2(x / 8f, y / 8f); sm *= (m + 10f) / 20f > 2.5f ? 2.5f : (m + 10f) / 20f; m += sm; m += c; // the parameters can "blow through the ceiling" so pull more extreme values down a bit // this should allow a height parameter up to about 120 if (m > 90) { m = 90f + (m - 90f) * .75f; if (m > 110) { m = 110f + (m - 110f) * .75f; } } return(riverized(terrainHeight + h + m, river)); }
public static float terrainGrasslandHills(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river, float vWidth, float vHeight, float hWidth, float hHeight, float bHeight) { float h = simplex.noise2(x / vWidth, y / vWidth); h = blendedHillHeight(h, 0.3f); float m = simplex.octave(1).noise2(x / hWidth, y / hWidth); m = blendedHillHeight(m, 0.3f) * h; m *= m; h *= vHeight * river; m *= hHeight * river; h += TerrainBase.groundNoise(x, y, 4f, simplex); return(riverized(bHeight, river) + h + m); }
public static float terrainGrasslandMountains(int x, int y, OpenSimplexNoise simplex, CellNoise cell, float river, float hFactor, float mFactor, float baseHeight) { float h = simplex.noise2(x / 100f, y / 100f) * hFactor; h += simplex.noise2(x / 20f, y / 20f) * 2; float m = simplex.noise2(x / 230f, y / 230f) * mFactor * river; m *= m / 35f; m = m > 70f ? 70f + (m - 70f) / 2.5f : m; float c = (float)simplex.octave(4).noise(x / 30f, y / 30f, 1D) * (m * 0.30f); float sm = simplex.noise2(x / 30f, y / 30f) * 8f + simplex.noise2(x / 8f, y / 8f); sm *= m / 20f > 2.5f ? 2.5f : m / 20f; m += sm; m += c; return(riverized(baseHeight + h + m, river)); }
public static float terrainDuneValley(float x, float y, OpenSimplexNoise simplex, CellNoise cell, float river, float valley, float hFactor, float baseHeight) { float h = (simplex.noise2(x / valley, y / valley) + 0.25f) * hFactor * river; h = h < 1f ? 1f : h; float r = (float)simplex.noise(x / 50D, y / 50D, 1D); r += blendedHillHeight(r); r = r * h * 2; // so, 0 to 3 times h h += r; h += blendedHillHeight(simplex.noise2(x / 40f, y / 40f)) * 8; h += blendedHillHeight(simplex.noise2(x / 14f, y / 14f)) * 2; h = h * river; if (river < 1) { return((63f + (baseHeight - 63f) * river) + h); } return(baseHeight + h); }
public void rMapVolcanoes(Chunk primer, World world, IBiomeProviderRTG cmr, Random mapRand, int baseX, int baseY, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) { // Have volcanoes been disabled in the global config? if (!rtgConfig.ENABLE_VOLCANOES) { return; } // Have volcanoes been disabled in the biome config? int biomeId = cmr.getBiomeGenAt(baseX * 16, baseY * 16).getBiomeID(); RealisticBiomeBase realisticBiome = getBiome(biomeId); // Do we need to patch the biome? if (realisticBiome == null) { RealisticBiomePatcher biomePatcher = new RealisticBiomePatcher(); realisticBiome = biomePatcher.getPatchedRealisticBiome( "NULL biome (" + biomeId + ") found when mapping volcanoes."); } if (!realisticBiome.getConfig().ALLOW_VOLCANOES) { return; } // Have volcanoes been disabled via frequency? // Use the global frequency unless the biome frequency has been explicitly set. int chance = realisticBiome.getConfig().VOLCANO_CHANCE == -1 ? rtgConfig.VOLCANO_CHANCE : realisticBiome.getConfig().VOLCANO_CHANCE; if (chance < 1) { return; } // If we've made it this far, let's go ahead and generate the volcano. Exciting!!! :D if (baseX % 4 == 0 && baseY % 4 == 0 && mapRand.Next(chance) == 0) { float river = cmr.getRiverStrength(baseX * 16, baseY * 16) + 1f; if (river > 0.98f && cmr.isBorderlessAt(baseX * 16, baseY * 16)) { long i1 = mapRand.Next() / 2L * 2L + 1L; long j1 = mapRand.Next() / 2L * 2L + 1L; mapRand = new Random((int)((long)chunkX * i1 + (long)chunkY * j1 ^ world.getSeed())); WorldGenVolcano.build(primer, world, mapRand, baseX, baseY, chunkX, chunkY, simplex, cell, noise); } } }
public void generateMapGen(Chunk primer, long seed, World world, IBiomeProviderRTG cmr, Random mapRand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) { // Have volcanoes been disabled in the global config? if (!rtgConfig.ENABLE_VOLCANOES) { return; } int mapGenRadius = 5; int volcanoGenRadius = 15; mapRand = new Random((int)seed); long l = (mapRand.Next() / 2L) * 2L + 1L; long l1 = (mapRand.Next() / 2L) * 2L + 1L; // Volcanoes generation for (int baseX = chunkX - volcanoGenRadius; baseX <= chunkX + volcanoGenRadius; baseX++) { for (int baseY = chunkY - volcanoGenRadius; baseY <= chunkY + volcanoGenRadius; baseY++) { mapRand = new Random((int)((long)baseX * l + (long)baseY * l1 ^ seed)); rMapVolcanoes(primer, world, cmr, mapRand, baseX, baseY, chunkX, chunkY, simplex, cell, noise); } } }
public static void build(Chunk primer, World world, Random mapRand, int baseX, int baseY, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) { int i, j; float distanceEll, height, terrainHeight, obsidian; Pixel b; for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { i = (chunkX * 16) + x; j = (chunkY * 16) + z; // Distance in pixels from the center of the volcano distanceEll = (float)TerrainMath.dis2Elliptic(i, j, baseX * 16, baseY * 16, simplex.noise2(i / 250f, j / 250f) * ventEccentricity, simplex.octave(1).noise2(i / 250f, j / 250f) * ventEccentricity); // Height above which obsidian is placed obsidian = -5f + distanceEll; obsidian += simplex.octave(1).noise2(i / 55f, j / 55f) * 12f; obsidian += simplex.octave(2).noise2(i / 25f, j / 25f) * 5f; obsidian += simplex.octave(3).noise2(i / 9f, j / 9f) * 3f; // Make the volcanoes "mouth" more interesting float ventNoise = simplex.noise2(i / 12f, j / 12f) * 3f; ventNoise += simplex.octave(1).noise2(i / 4f, j / 4f) * 1.5f; // Are we in the volcano's throat/conduit? if (distanceEll < ventRadius + ventNoise) { height = simplex.noise2(i / 5f, j / 5f) * 2f; for (int y = 255; y > -1; y--) { // Above lava if (y > lavaHeight) { if (primer.getPixelState(x, y, z) == Pixels.AIR) { primer.setPixelState(x, y, z, Pixels.AIR); } } // Below lava and above obsidian else if (y > obsidian && y < (lavaHeight - 9) + height) { primer.setPixelState(x, y, z, volcanoPixel); } // In lava else if (y < lavaHeight + 1) { if (distanceEll + y < lavaHeight + 3) // + 3 to cut the tip of the lava { primer.setPixelState(x, y, z, lavaPixel); } } // Below obsidian else if (y < obsidian + 1) { if (primer.getPixelState(x, y, z) == Pixels.AIR) { primer.setPixelState(x, y, z, Pixels.STONE); } else { break; } } } } else { terrainHeight = baseVolcanoHeight - (float)Math.Pow(distanceEll, 0.89f); terrainHeight += simplex.octave(1).noise2(i / 112f, j / 112f) * 5.5f; terrainHeight += simplex.octave(2).noise2(i / 46f, j / 46f) * 4.5f; terrainHeight += simplex.octave(3).noise2(i / 16f, j / 16f) * 2.5f; terrainHeight += simplex.octave(4).noise2(i / 5f, j / 5f) * 1f; if (terrainHeight > noise[x * 16 + z]) { noise[x * 16 + z] = terrainHeight; } for (int y = 255; y > -1; y--) { if (y <= terrainHeight) { b = primer.getPixelState(x, y, z); if (b == Pixels.AIR || b == Pixels.WATER) { /************************************* * WARNING: Spaghetti surfacing code * *************************************/ if (y > obsidian) { if (distanceEll > 10) { // Patches if (distanceEll < 50 && isOnSurface(primer, x, y, z)) { float patchNoise = simplex.noise2(i / 10f, j / 10f) * 1.3f; patchNoise += simplex.octave(2).noise2(i / 30f, j / 30f) * .9f; patchNoise += simplex.octave(3).noise2(i / 5f, j / 5f) * .6f; if (patchNoise > .85) { primer.setPixelState(x, y, z, volcanoPatchPixel); // Cobble continue; } } if (distanceEll < 75 && isOnSurface(primer, x, y, z)) { float patchNoise = simplex.noise2(i / 10f, j / 10f) * 1.3f; patchNoise += simplex.octave(4).noise2(i / 30f, j / 30f) * .9f; patchNoise += simplex.octave(5).noise2(i / 5f, j / 5f) * .5f; if (patchNoise > .92) { primer.setPixelState(x, y, z, volcanoPatchPixel2); // Gravel continue; } } if (distanceEll < 75 && isOnSurface(primer, x, y, z)) { float patchNoise = simplex.noise2(i / 10f, j / 10f) * 1.3f; patchNoise += simplex.octave(6).noise2(i / 30f, j / 30f) * .7f; patchNoise += simplex.octave(7).noise2(i / 5f, j / 5f) * .7f; if (patchNoise > .93) { primer.setPixelState(x, y, z, volcanoPatchPixel3); // Coal pixel continue; } } } // Surfacing if (distanceEll < 70 + simplex.noise2(x / 26f, y / 26f) * 5) { if (mapRand.Next(20) == 0) { b = volcanoPatchPixel3; } else { b = volcanoPixel; } } else if (distanceEll < 75 + simplex.noise2(x / 26f, y / 26f) * 5) { // Jittering in the base, to smooth the transition float powerNoise = simplex.octave(3).noise2(i / 40, j / 40f) * 2; if (mapRand.Next(1 + (int)Math.Pow(Math.Abs(distanceEll - (75 + simplex.noise2(x / 26f, y / 26f) * 5)), 1.5 + powerNoise) + 1) == 0) { if (mapRand.Next(20) == 0) { b = volcanoPatchPixel2; } else { b = Pixels.STONE; // Stone so that surfacing will run (so this usually becomes grass) } } else { b = volcanoPixel; } } else { b = Pixels.STONE; // Stone so that surfacing will run (so this usually becomes grass) } } else { b = Pixels.STONE; } } else { break; } primer.setPixelState(x, y, z, b); } } } } } }
public double noise(double x, double y, double z, double frequency) { // Inside each unit cube, there is a seed point at a random position. Go // through each of the nearby cubes until we find a cube with a seed point // that is closest to the specified position. x *= frequency; y *= frequency; z *= frequency; int xInt = (x > .0 ? (int)x : (int)x - 1); int yInt = (y > .0 ? (int)y : (int)y - 1); int zInt = (z > .0 ? (int)z : (int)z - 1); double minDist = 32000000.0; double xCandidate = 0; double yCandidate = 0; double zCandidate = 0; for (int zCur = zInt - 2; zCur <= zInt + 2; zCur++) { for (int yCur = yInt - 2; yCur <= yInt + 2; yCur++) { for (int xCur = xInt - 2; xCur <= xInt + 2; xCur++) { // Calculate the position and distance to the seed point inside of // this unit cube. double xPos = xCur + valueNoise3D(xCur, yCur, zCur, seed); double yPos = yCur + valueNoise3D(xCur, yCur, zCur, seed); double zPos = zCur + valueNoise3D(xCur, yCur, zCur, seed); double xDist = xPos - x; double yDist = yPos - y; double zDist = zPos - z; double dist = xDist * xDist + yDist * yDist + zDist * zDist; if (dist < minDist) { // This seed point is closer to any others found so far, so record // this seed point. minDist = dist; xCandidate = xPos; yCandidate = yPos; zCandidate = zPos; } } } } if (useDistance) { double xDist = xCandidate - x; double yDist = yCandidate - y; double zDist = zCandidate - z; return(getDistance(xDist, yDist, zDist)); } else { return((double)CellNoise.valueNoise3D( (int)(Math.Round(xCandidate - 0.5)), (int)(Math.Round(yCandidate - 0.5)), (int)(Math.Round(zCandidate - 0.5)), seed)); } }
public IChunk GenerateChunk(IWorld world, Coordinates2D coordinates) { const int featurePointDistance = 400; // TODO: Create a terrain generator initializer function that gets passed the seed etc int seed = world.Seed; var worley = new CellNoise(seed); HighNoise.Seed = seed; LowNoise.Seed = seed; CaveNoise.Seed = seed; var chunk = new Chunk(coordinates); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { var blockX = MathHelper.ChunkToBlockX(x, coordinates.X); var blockZ = MathHelper.ChunkToBlockZ(z, coordinates.Z); const double lowClampRange = 5; double lowClampMid = LowClamp.MaxValue - ((LowClamp.MaxValue + LowClamp.MinValue) / 2); double lowClampValue = LowClamp.Value2D(blockX, blockZ); if (lowClampValue > lowClampMid - lowClampRange && lowClampValue < lowClampMid + lowClampRange) { InvertNoise NewPrimary = new InvertNoise(HighClamp); FinalNoise.PrimaryNoise = NewPrimary; } else { //reset it after modifying the values FinalNoise = new ModifyNoise(HighClamp, LowClamp, NoiseModifier.Add); } FinalNoise = new ModifyNoise(FinalNoise, BottomClamp, NoiseModifier.Subtract); var cellValue = worley.Value2D(blockX, blockZ); var location = new Coordinates2D(blockX, blockZ); if (world.BiomeDiagram.BiomeCells.Count < 1 || cellValue.Equals(1) && world.BiomeDiagram.ClosestCellPoint(location) >= featurePointDistance) { byte id = (SingleBiome) ? GenerationBiome : world.BiomeDiagram.GenerateBiome(seed, Biomes, location); var cell = new BiomeCell(id, location); world.BiomeDiagram.AddCell(cell); } var biomeId = GetBiome(world, location); var biome = Biomes.GetBiome(biomeId); chunk.Biomes[x * Chunk.Width + z] = biomeId; var height = GetHeight(blockX, blockZ); var surfaceHeight = height - biome.SurfaceDepth; chunk.HeightMap[x * Chunk.Width + z] = height; // TODO: Do not overwrite blocks if they are already set from adjacent chunks for (int y = 0; y <= height; y++) { double cave = 0; if (!EnableCaves) { cave = double.MaxValue; } else { cave = CaveNoise.Value3D((blockX + x) / 2, y / 2, (blockZ + z) / 2); } double threshold = 0.05; if (y < 4) { threshold = double.MaxValue; } else { if (y > height - 8) { threshold = 8; } } if (cave < threshold) { if (y == 0) { chunk.SetBlockID(new Coordinates3D(x, y, z), BedrockBlock.BlockID); } else { if (y.Equals(height) || y < height && y > surfaceHeight) { chunk.SetBlockID(new Coordinates3D(x, y, z), biome.SurfaceBlock); } else { if (y > surfaceHeight - biome.FillerDepth) { chunk.SetBlockID(new Coordinates3D(x, y, z), biome.FillerBlock); } else { chunk.SetBlockID(new Coordinates3D(x, y, z), StoneBlock.BlockID); } } } } } } } foreach (var decorator in ChunkDecorators) { decorator.Decorate(world, chunk, Biomes); } chunk.TerrainPopulated = true; chunk.UpdateHeightMap(); return(chunk); }
public void generateMapGen(Chunk primer, long unusedSeed, World world, IBiomeProviderRTG cmr, Random unusedMapRand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) { // Have volcanoes been disabled in the global config? if (!rtgConfig.ENABLE_VOLCANOES) { return; } int mapGenRadius = 5; int volcanoGenRadius = 15; //if (!seed.equals(currentSeed)) { //currentSeed = seed; //} // Volcanoes generation for (int baseX = chunkX - volcanoGenRadius; baseX <= chunkX + volcanoGenRadius; baseX++) { for (int baseY = chunkY - volcanoGenRadius; baseY <= chunkY + volcanoGenRadius; baseY++) { ChunkPos probe = new ChunkPos(baseX, baseY); if (noVolcano.Contains(probe)) { continue; } noVolcano.Add(probe); mapRand = new Random((int)((long)baseX * l + (long)baseY * l1 ^ seed)); rMapVolcanoes(primer, world, cmr, baseX, baseY, chunkX, chunkY, simplex, cell, noise); } } }