From f5ab056b388b856a70bca7a028b58a258532716f Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 13 Mar 2013 01:18:45 +0400 Subject: Liquid fine tuning --- games/minimal/mods/default/mapgen.lua | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'games/minimal/mods/default/mapgen.lua') diff --git a/games/minimal/mods/default/mapgen.lua b/games/minimal/mods/default/mapgen.lua index 115bb1458..74fc398b2 100644 --- a/games/minimal/mods/default/mapgen.lua +++ b/games/minimal/mods/default/mapgen.lua @@ -69,10 +69,19 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, end minetest.register_on_generated(function(minp, maxp, seed) - generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17) + generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17 ) + + if minetest.setting_getbool("underground_springs") then + generate_ore("default:water_source", "default:stone", minp, maxp, seed+4, 1/24/24/24, 12, -100, -11, 128) + generate_ore("default:water_source", "default:stone", minp, maxp, seed+5, 1/28/28/28, 8, -10000, -101, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+6, 1/38/38/38, 6, -500, -101, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+7, 1/30/30/30, 16, -5000, -501, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+8, 1/24/24/24, 20, -31000, -5001, 128) + end + -- Generate clay if maxp.y >= 2 and minp.y <= 0 then -- Assume X and Z lengths are equal @@ -110,11 +119,5 @@ minetest.register_on_generated(function(minp, maxp, seed) end end end - if minetest.setting_get("liquid_finite") then - generate_ore("default:water_source", "default:stone", minp, maxp, seed+42, 1/24/24/24, 4, -100, -10, 128) - generate_ore("default:water_source", "default:stone", minp, maxp, seed+42, 1/28/28/28, 3, -10000, -101, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+43, 1/38/38/38, 2, -500, -100, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+43, 1/30/30/30, 4, -31000, -501, 128) - end end) -- cgit v1.2.3 From f70378f7f57f293a2a0afcf35aec8ee67180a6c0 Mon Sep 17 00:00:00 2001 From: proller Date: Sun, 24 Mar 2013 03:40:15 +0400 Subject: Mapgen indev: float islands, larger far biomes --- games/minimal/mods/default/mapgen.lua | 3 + minetest.conf.example | 17 ++- src/defaultsettings.cpp | 13 +- src/mapgen_indev.cpp | 226 ++++++++++++++++++++++++++-------- src/mapgen_indev.h | 49 +++++--- src/mapgen_v6.cpp | 2 + src/mapgen_v6.h | 1 + 7 files changed, 233 insertions(+), 78 deletions(-) (limited to 'games/minimal/mods/default/mapgen.lua') diff --git a/games/minimal/mods/default/mapgen.lua b/games/minimal/mods/default/mapgen.lua index 74fc398b2..de6632d13 100644 --- a/games/minimal/mods/default/mapgen.lua +++ b/games/minimal/mods/default/mapgen.lua @@ -74,6 +74,9 @@ minetest.register_on_generated(function(minp, maxp, seed) generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5 ) generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17 ) + generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+4, 1/8/8/8, 5, 200, 31000 ) -- for float islands and far scaled mountains + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+5, 1/9/9/9, 5, 200, 31000 ) + if minetest.setting_getbool("underground_springs") then generate_ore("default:water_source", "default:stone", minp, maxp, seed+4, 1/24/24/24, 12, -100, -11, 128) generate_ore("default:water_source", "default:stone", minp, maxp, seed+5, 1/28/28/28, 8, -10000, -101, 128) diff --git a/minetest.conf.example b/minetest.conf.example index 5401f6aad..838987c33 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -341,8 +341,15 @@ #mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0 #mgv7_np_humidity = 50, 31.25, (750, 750, 750), 12094, 2, 0.6 -# Offset, scale, spread factor, seed offset, number of octaves, persistence, farscale -#mgindev_np_terrain_base = -4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10 -#mgindev_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 10 -#mgindev_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10 -#mgindev_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 1 +# Offset, scale, spread factor, seed offset, number of octaves, persistence, farscale, farspread +#mgindev_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10 +#mgindev_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10 +#mgindev_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2, 10 +#mgindev_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 1, 1 +#mgindev_np_float_islands1 = 0, 1, (64, 64, 64 ), 3683, 5, 0.5, 1, 1.5 +#mgindev_np_float_islands2 = 0, 1, (8, 8, 8 ), 9292, 2, 0.5, 1, 1.5 +#mgindev_np_float_islands3 = 0, 1, (256, 256, 256), 6412, 2, 0.5, 1, 0.5 +#mgindev_np_biome = 0, 1, (250, 250, 250), 9130, 3, 0.50, 1, 10 + +# Float islands starts from height, 0 to disable +#mgindev_float_islands = 500 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 25edffe32..592c6bcca 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -236,10 +236,15 @@ void set_default_settings(Settings *settings) settings->setDefault("mgv7_np_heat", "25, 50, (500, 500, 500), 35293, 1, 0"); settings->setDefault("mgv7_np_humidity", "50, 31.25, (750, 750, 750), 12094, 2, 0.6"); - settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10"); - settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10"); - settings->setDefault("mgindev_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10"); - settings->setDefault("mgindev_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55, 1"); + settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10"); + settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10"); + settings->setDefault("mgindev_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2, 10"); + settings->setDefault("mgindev_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55, 1, 1"); + settings->setDefault("mgindev_np_float_islands1", "0, 1, (64, 64, 64 ), 3683, 5, 0.5, 1, 1.5"); + settings->setDefault("mgindev_np_float_islands2", "0, 1, (8, 8, 8 ), 9292, 2, 0.5, 1, 1.5"); + settings->setDefault("mgindev_np_float_islands3", "0, 1, (256, 256, 256), 6412, 2, 0.5, 1, 0.5"); + settings->setDefault("mgindev_np_biome", "0, 1, (250, 250, 250), 9130, 3, 0.50, 1, 10"); + settings->setDefault("mgindev_float_islands", "500"); } diff --git a/src/mapgen_indev.cpp b/src/mapgen_indev.cpp index 4de4fd55f..6956fc63f 100644 --- a/src/mapgen_indev.cpp +++ b/src/mapgen_indev.cpp @@ -19,18 +19,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen_indev.h" #include "constants.h" +#include "map.h" +#include "main.h" #include "log.h" -/////////////////// Mapgen Indev perlin noise default values +/////////////////// Mapgen Indev perlin noise (default values - not used, from config or defaultsettings) -NoiseIndevParams nparams_indev_def_terrain_base - (-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 1); -NoiseIndevParams nparams_indev_def_terrain_higher - (20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 1); -NoiseIndevParams nparams_indev_def_steepness - (0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 1); -NoiseIndevParams nparams_indev_def_mud - (AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 1); +NoiseIndevParams nparams_indev_def; + +/* +NoiseIndevParams nparams_indev_def_terrain_base; +// (-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_terrain_higher; +// (20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_steepness; +// (0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 1); +NoiseIndevParams nparams_indev_def_mud; +// (AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 1); +NoiseIndevParams nparams_indev_def_float_islands; +// (1, 10.0, v3f(500.0, 500.0, 500.0), 32451, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_biome; +*/ /////////////////////////////////////////////////////////////////////////////// @@ -39,31 +48,32 @@ void NoiseIndev::init(NoiseIndevParams *np, int seed, int sx, int sy, int sz) { this->npindev = np; } - NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy) : Noise(np, seed, sx, sy) { init(np, seed, sx, sy, 1); } - NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz) : Noise(np, seed, sx, sy, sz) { init(np, seed, sx, sy, sz); } +float farscale(float scale, float z) { + return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 1 - (fabs(z)) ) / (MAP_GENERATION_LIMIT * 1) ) * (scale - 1) ); +} + +float farscale(float scale, float x, float z) { + return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 2 - (fabs(x) + fabs(z)) ) / (MAP_GENERATION_LIMIT * 2) ) * (scale - 1) ); +} float farscale(float scale, float x, float y, float z) { return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(x) + fabs(y) + fabs(z)) ) / (MAP_GENERATION_LIMIT * 3) ) * (scale - 1) ); } void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) { - // more correct use distantion from 0,0,0 via pow, but + is faster - //float farscale = ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(xx) + fabs(yy) + fabs(zz)) ) / (MAP_GENERATION_LIMIT * 3) ) * ((npindev)->farscale - 1) ); - // dstream << "TNM rs=" << farscale << " from=" << (npindev)->farscale << " x=" << xx << " y=" << yy <<" z=" << zz << std::endl; int i = 0; for (int z = 0; z != sz; z++) { for (int y = 0; y != sy; y++) { for (int x = 0; x != sx; x++) { - //result[i] = result[i] * npindev->scale * farscale + npindev->offset; - result[i] = result[i] * npindev->scale * farscale(npindev->farscale,xx,yy,zz) + npindev->offset; + result[i] = result[i] * npindev->scale * farscale(npindev->farscale, xx, yy, zz) + npindev->offset; i++; } } @@ -71,14 +81,17 @@ void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) { } MapgenIndev::MapgenIndev(int mapgenid, MapgenIndevParams *params) : MapgenV6(mapgenid, params) { - noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Y); - noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Y); - noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Y); + noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Z); + noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Z); + noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Z); // noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y); // noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y); - noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Y); + noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Z); // noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y); -// noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y); + noiseindev_float_islands1 = new NoiseIndev(params->npindev_float_islands1, seed, csize.X, csize.Y, csize.Z); + noiseindev_float_islands2 = new NoiseIndev(params->npindev_float_islands2, seed, csize.X, csize.Y, csize.Z); + noiseindev_float_islands3 = new NoiseIndev(params->npindev_float_islands3, seed, csize.X, csize.Z); + noiseindev_biome = new NoiseIndev(params->npindev_biome, seed, csize.X, csize.Z); } MapgenIndev::~MapgenIndev() { @@ -89,10 +102,12 @@ MapgenIndev::~MapgenIndev() { //delete noise_trees; delete noiseindev_mud; //delete noise_beach; - //delete noise_biome; + delete noiseindev_float_islands1; + delete noiseindev_float_islands2; + delete noiseindev_float_islands3; + delete noiseindev_biome; } - void MapgenIndev::calculateNoise() { int x = node_min.X; int y = node_min.Y; @@ -100,31 +115,49 @@ void MapgenIndev::calculateNoise() { // Need to adjust for the original implementation's +.5 offset... if (!(flags & MG_FLAT)) { noiseindev_terrain_base->perlinMap2D( - x + 0.5 * noiseindev_terrain_base->npindev->spread.X, - z + 0.5 * noiseindev_terrain_base->npindev->spread.Z); + x + 0.5 * noiseindev_terrain_base->npindev->spread.X * farscale(noiseindev_terrain_base->npindev->farspread, x, z), + z + 0.5 * noiseindev_terrain_base->npindev->spread.Z * farscale(noiseindev_terrain_base->npindev->farspread, x, z)); noiseindev_terrain_base->transformNoiseMapFarScale(x, y, z); - //noise_terrain_base->transformNoiseMap(); noiseindev_terrain_higher->perlinMap2D( - x + 0.5 * noiseindev_terrain_higher->npindev->spread.X, - z + 0.5 * noiseindev_terrain_higher->npindev->spread.Z); + x + 0.5 * noiseindev_terrain_higher->npindev->spread.X * farscale(noiseindev_terrain_higher->npindev->farspread, x, z), + z + 0.5 * noiseindev_terrain_higher->npindev->spread.Z * farscale(noiseindev_terrain_higher->npindev->farspread, x, z)); noiseindev_terrain_higher->transformNoiseMapFarScale(x, y, z); - //noise_terrain_higher->transformNoiseMap(); noiseindev_steepness->perlinMap2D( - x + 0.5 * noiseindev_steepness->npindev->spread.X, - z + 0.5 * noiseindev_steepness->npindev->spread.Z); + x + 0.5 * noiseindev_steepness->npindev->spread.X * farscale(noiseindev_steepness->npindev->farspread, x, z), + z + 0.5 * noiseindev_steepness->npindev->spread.Z * farscale(noiseindev_steepness->npindev->farspread, x, z)); noiseindev_steepness->transformNoiseMapFarScale(x, y, z); noise_height_select->perlinMap2D( x + 0.5 * noise_height_select->np->spread.X, z + 0.5 * noise_height_select->np->spread.Z); + + noiseindev_float_islands1->perlinMap3D( + x + 0.33 * noiseindev_float_islands1->npindev->spread.X * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z), + y + 0.33 * noiseindev_float_islands1->npindev->spread.Y * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z), + z + 0.33 * noiseindev_float_islands1->npindev->spread.Z * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z) + ); + noiseindev_float_islands1->transformNoiseMapFarScale(x, y, z); + + noiseindev_float_islands2->perlinMap3D( + x + 0.33 * noiseindev_float_islands2->npindev->spread.X * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z), + y + 0.33 * noiseindev_float_islands2->npindev->spread.Y * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z), + z + 0.33 * noiseindev_float_islands2->npindev->spread.Z * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z) + ); + noiseindev_float_islands2->transformNoiseMapFarScale(x, y, z); + + noiseindev_float_islands3->perlinMap2D( + x + 0.5 * noiseindev_float_islands3->npindev->spread.X * farscale(noiseindev_float_islands3->npindev->farspread, x, z), + z + 0.5 * noiseindev_float_islands3->npindev->spread.Z * farscale(noiseindev_float_islands3->npindev->farspread, x, z)); + noiseindev_float_islands3->transformNoiseMapFarScale(x, y, z); + } if (!(flags & MG_FLAT)) { noiseindev_mud->perlinMap2D( - x + 0.5 * noiseindev_mud->npindev->spread.X, - z + 0.5 * noiseindev_mud->npindev->spread.Z); + x + 0.5 * noiseindev_mud->npindev->spread.X * farscale(noiseindev_mud->npindev->farspread, x, y, z), + z + 0.5 * noiseindev_mud->npindev->spread.Z * farscale(noiseindev_mud->npindev->farspread, x, y, z)); noiseindev_mud->transformNoiseMapFarScale(x, y, z); } noise_beach->perlinMap2D( @@ -132,8 +165,8 @@ void MapgenIndev::calculateNoise() { z + 0.7 * noise_beach->np->spread.Z); noise_biome->perlinMap2D( - x + 0.6 * noise_biome->np->spread.X, - z + 0.2 * noise_biome->np->spread.Z); + x + 0.6 * noiseindev_biome->npindev->spread.X * farscale(noiseindev_biome->npindev->farspread, x, z), + z + 0.2 * noiseindev_biome->npindev->spread.Z * farscale(noiseindev_biome->npindev->farspread, x, z)); } bool MapgenIndevParams::readParams(Settings *settings) { @@ -147,17 +180,20 @@ bool MapgenIndevParams::readParams(Settings *settings) { np_trees = settings->getNoiseParams("mgv6_np_trees"); npindev_mud = settings->getNoiseIndevParams("mgindev_np_mud"); np_beach = settings->getNoiseParams("mgv6_np_beach"); - np_biome = settings->getNoiseParams("mgv6_np_biome"); + npindev_biome = settings->getNoiseIndevParams("mgindev_np_biome"); np_cave = settings->getNoiseParams("mgv6_np_cave"); + npindev_float_islands1 = settings->getNoiseIndevParams("mgindev_np_float_islands1"); + npindev_float_islands2 = settings->getNoiseIndevParams("mgindev_np_float_islands2"); + npindev_float_islands3 = settings->getNoiseIndevParams("mgindev_np_float_islands3"); bool success = npindev_terrain_base && npindev_terrain_higher && npindev_steepness && np_height_select && np_trees && npindev_mud && - np_beach && np_biome && np_cave; + np_beach && np_biome && np_cave && + npindev_float_islands1 && npindev_float_islands2 && npindev_float_islands3; return success; } - void MapgenIndevParams::writeParams(Settings *settings) { settings->setFloat("mgv6_freq_desert", freq_desert); settings->setFloat("mgv6_freq_beach", freq_beach); @@ -169,8 +205,11 @@ void MapgenIndevParams::writeParams(Settings *settings) { settings->setNoiseParams("mgv6_np_trees", np_trees); settings->setNoiseIndevParams("mgindev_np_mud", npindev_mud); settings->setNoiseParams("mgv6_np_beach", np_beach); - settings->setNoiseParams("mgv6_np_biome", np_biome); + settings->setNoiseIndevParams("mgindev_np_biome", npindev_biome); settings->setNoiseParams("mgv6_np_cave", np_cave); + settings->setNoiseIndevParams("mgindev_np_float_islands1", npindev_float_islands1); + settings->setNoiseIndevParams("mgindev_np_float_islands2", npindev_float_islands2); + settings->setNoiseIndevParams("mgindev_np_float_islands3", npindev_float_islands3); } @@ -191,7 +230,6 @@ float MapgenIndev::baseTerrainLevelFromNoise(v2s16 p) { steepness, height_select); } - float MapgenIndev::baseTerrainLevelFromMap(int index) { if (flags & MG_FLAT) return water_level; @@ -205,9 +243,7 @@ float MapgenIndev::baseTerrainLevelFromMap(int index) { steepness, height_select); } - -float MapgenIndev::getMudAmount(int index) -{ +float MapgenIndev::getMudAmount(int index) { if (flags & MG_FLAT) return AVERAGE_MUD_AMOUNT; @@ -218,25 +254,19 @@ float MapgenIndev::getMudAmount(int index) return noiseindev_mud->result[index]; } - void MapgenIndev::defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave) { cave.min_tunnel_diameter = 2; cave.max_tunnel_diameter = ps.range(2,6); cave.dswitchint = ps.range(1,14); - //cave.tunnel_routepoints = 0; - //cave.part_max_length_rs = 0; cave.flooded = large_cave && ps.range(0,4); if(large_cave){ cave.part_max_length_rs = ps.range(2,4); -//dstream<<"try:"<setDefault("mgindev_np_float_islands1", "-9.5, 10, (20, 50, 50 ), 45123, 5, 0.6, 1.5, 5"); +void MapgenIndev::generateFloatIslands(int min_y) { + if (node_min.Y < min_y) return; + v3s16 p0(node_min.X, node_min.Y, node_min.Z); + MapNode n1(c_stone), n2(c_desert_stone); + int xl = node_max.X - node_min.X; + int yl = node_max.Y - node_min.Y; + int zl = node_max.Z - node_min.Z; + u32 index = 0; + for (int x1 = 0; x1 <= xl; x1++) + { + //int x = x1 + node_min.Y; + for (int z1 = 0; z1 <= zl; z1++) + { + //int z = z1 + node_min.Z; + for (int y1 = 0; y1 <= yl; y1++, index++) + { + //int y = y1 + node_min.Y; + float noise = noiseindev_float_islands1->result[index]; + //dstream << " y1="<((x), "f,f,v3,s32,s32,f,f") -#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f", (y)) +#define getNoiseIndevParams(x) getStruct((x), "f,f,v3,s32,s32,f,f,f") +#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", (y)) class NoiseIndev : public Noise { public: @@ -59,6 +61,8 @@ class NoiseIndev : public Noise { void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0); }; +extern NoiseIndevParams nparams_indev_def; +/* extern NoiseIndevParams nparams_indev_def_terrain_base; extern NoiseIndevParams nparams_indev_def_terrain_higher; extern NoiseIndevParams nparams_indev_def_steepness; @@ -66,9 +70,10 @@ extern NoiseIndevParams nparams_indev_def_steepness; //extern NoiseIndevParams nparams_indev_def_trees; extern NoiseIndevParams nparams_indev_def_mud; //extern NoiseIndevParams nparams_indev_def_beach; -//extern NoiseIndevParams nparams_indev_def_biome; +extern NoiseIndevParams nparams_indev_def_biome; //extern NoiseIndevParams nparams_indev_def_cave; - +extern NoiseIndevParams nparams_indev_def_float_islands; +*/ struct MapgenIndevParams : public MapgenV6Params { NoiseIndevParams *npindev_terrain_base; @@ -78,21 +83,28 @@ struct MapgenIndevParams : public MapgenV6Params { //NoiseParams *np_trees; NoiseIndevParams *npindev_mud; //NoiseParams *np_beach; - //NoiseParams *np_biome; + NoiseIndevParams *npindev_biome; //NoiseParams *np_cave; + NoiseIndevParams *npindev_float_islands1; + NoiseIndevParams *npindev_float_islands2; + NoiseIndevParams *npindev_float_islands3; MapgenIndevParams() { //freq_desert = 0.45; //freq_beach = 0.15; - npindev_terrain_base = &nparams_indev_def_terrain_base; - npindev_terrain_higher = &nparams_indev_def_terrain_higher; - npindev_steepness = &nparams_indev_def_steepness; + npindev_terrain_base = &nparams_indev_def; //&nparams_indev_def_terrain_base; + npindev_terrain_higher = &nparams_indev_def; //&nparams_indev_def_terrain_higher; + npindev_steepness = &nparams_indev_def; //&nparams_indev_def_steepness; //np_height_select = &nparams_v6_def_height_select; //np_trees = &nparams_v6_def_trees; - npindev_mud = &nparams_indev_def_mud; + npindev_mud = &nparams_indev_def; //&nparams_indev_def_mud; //np_beach = &nparams_v6_def_beach; - //np_biome = &nparams_v6_def_biome; + npindev_biome = &nparams_indev_def; //&nparams_indev_def_biome; //np_cave = &nparams_v6_def_cave; + npindev_float_islands1 = &nparams_indev_def; //&nparams_indev_def_float_islands; + npindev_float_islands2 = &nparams_indev_def; //&nparams_indev_def_float_islands; + npindev_float_islands3 = &nparams_indev_def; //&nparams_indev_def_float_islands; + } bool readParams(Settings *settings); @@ -108,8 +120,11 @@ class MapgenIndev : public MapgenV6 { //NoiseIndev *noise_trees; NoiseIndev *noiseindev_mud; //NoiseIndev *noise_beach; - //NoiseIndev *noise_biome; + NoiseIndev *noiseindev_biome; //NoiseIndevParams *np_cave; + NoiseIndev *noiseindev_float_islands1; + NoiseIndev *noiseindev_float_islands2; + NoiseIndev *noiseindev_float_islands3; MapgenIndev(int mapgenid, MapgenIndevParams *params); ~MapgenIndev(); @@ -119,6 +134,9 @@ class MapgenIndev : public MapgenV6 { float baseTerrainLevelFromMap(int index); float getMudAmount(int index); void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave); + void generateSomething(); + + void generateFloatIslands(int min_y); }; struct MapgenFactoryIndev : public MapgenFactoryV6 { @@ -131,5 +149,4 @@ struct MapgenFactoryIndev : public MapgenFactoryV6 { }; }; - #endif diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index 59a4d49fc..1efa3ad74 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -422,6 +422,8 @@ void MapgenV6::makeChunk(BlockMakeData *data) { // Generate general ground level to full area stone_surface_max_y = generateGround(); + generateSomething(); + const s16 max_spread_amount = MAP_BLOCKSIZE; // Limit dirt flow area by 1 because mud is flown into neighbors. s16 mudflow_minpos = -max_spread_amount + 1; diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 5b3ea9d27..89a3324cd 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -167,6 +167,7 @@ public: virtual void defineCave(Cave &cave, PseudoRandom ps, v3s16 node_min, bool large_cave); void generateCaves(int max_stone_y); + virtual void generateSomething() {}; //for next mapgen }; struct MapgenFactoryV6 : public MapgenFactory { -- cgit v1.2.3 From 650d706d35d93f93e5c86f6045f026594ec71753 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sun, 24 Mar 2013 21:20:36 +0100 Subject: Use minetest.register_ore() in minimal --- games/minimal/mods/default/mapgen.lua | 118 ++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 54 deletions(-) (limited to 'games/minimal/mods/default/mapgen.lua') diff --git a/games/minimal/mods/default/mapgen.lua b/games/minimal/mods/default/mapgen.lua index de6632d13..478567d0a 100644 --- a/games/minimal/mods/default/mapgen.lua +++ b/games/minimal/mods/default/mapgen.lua @@ -27,64 +27,74 @@ minetest.register_alias("mapgen_mese", "default:mese") -- Ore generation -- -local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max, param2) - if maxp.y < height_min or minp.y > height_max then - return - end - local y_min = math.max(minp.y, height_min) - local y_max = math.min(maxp.y, height_max) - local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1) - local pr = PseudoRandom(seed) - local num_chunks = math.floor(chunks_per_volume * volume) - local chunk_size = 3 - if ore_per_chunk <= 4 then - chunk_size = 2 - end - local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk) - --print("generate_ore num_chunks: "..dump(num_chunks)) - for i=1,num_chunks do - local y0 = pr:next(y_min, y_max-chunk_size+1) - if y0 >= height_min and y0 <= height_max then - local x0 = pr:next(minp.x, maxp.x-chunk_size+1) - local z0 = pr:next(minp.z, maxp.z-chunk_size+1) - local p0 = {x=x0, y=y0, z=z0} - for x1=0,chunk_size-1 do - for y1=0,chunk_size-1 do - for z1=0,chunk_size-1 do - if pr:next(1,inverse_chance) == 1 then - local x2 = x0+x1 - local y2 = y0+y1 - local z2 = z0+z1 - local p2 = {x=x2, y=y2, z=z2} - if minetest.env:get_node(p2).name == wherein then - minetest.env:set_node(p2, {name=name, param2=param2}) - end - end - end - end - end - end - end - --print("generate_ore done") -end +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_coal", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 5, + clust_size = 3, + height_min = -31000, + height_max = 64, +}) -minetest.register_on_generated(function(minp, maxp, seed) - generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64 ) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7 ) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5 ) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17 ) +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_iron", + wherein = "default:stone", + clust_scarcity = 16*16*16, + clust_num_ores = 5, + clust_size = 3, + height_min = -5, + height_max = 7, +}) - generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+4, 1/8/8/8, 5, 200, 31000 ) -- for float islands and far scaled mountains - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+5, 1/9/9/9, 5, 200, 31000 ) +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_iron", + wherein = "default:stone", + clust_scarcity = 12*12*12, + clust_num_ores = 5, + clust_size = 3, + height_min = -16, + height_max = -5, +}) - if minetest.setting_getbool("underground_springs") then - generate_ore("default:water_source", "default:stone", minp, maxp, seed+4, 1/24/24/24, 12, -100, -11, 128) - generate_ore("default:water_source", "default:stone", minp, maxp, seed+5, 1/28/28/28, 8, -10000, -101, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+6, 1/38/38/38, 6, -500, -101, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+7, 1/30/30/30, 16, -5000, -501, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+8, 1/24/24/24, 20, -31000, -5001, 128) - end +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_iron", + wherein = "default:stone", + clust_scarcity = 9*9*9, + clust_num_ores = 5, + clust_size = 3, + height_min = -31000, + height_max = -17, +}) +-- for float islands and far scaled +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_coal", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 5, + clust_size = 3, + height_min = 200, + height_max = 31000, +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_iron", + wherein = "default:stone", + clust_scarcity = 9*9*9, + clust_num_ores = 5, + clust_size = 3, + height_min = 200, + height_max = 31000, +}) + +minetest.register_on_generated(function(minp, maxp, seed) -- Generate clay if maxp.y >= 2 and minp.y <= 0 then -- Assume X and Z lengths are equal -- cgit v1.2.3