Last night's work
This commit is contained in:
parent
a260c4a33a
commit
1708e2d461
45 changed files with 1359 additions and 1347 deletions
|
@ -1,155 +0,0 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- Voxelis - Voxel survival sandbox for Luanti
|
||||
-- Copyright (C) 2024 Mad Star Studio LLC
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
vox_mapgen_core = {}
|
||||
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Configuration: Noise Parameters
|
||||
-- -------------------------------------------------------------- --
|
||||
local noise_heat = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 1234,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
local noise_humidity = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5678,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
local noise_altitude = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 91011,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
local biome_size_noise = {
|
||||
offset = 0,
|
||||
scale = 10,
|
||||
spread = {x = 2000, y = 2000, z = 2000},
|
||||
seed = 78910,
|
||||
octaves = 2,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
-- Apply noise parameters to the map generator
|
||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||
minetest.set_mapgen_setting_noiseparams("heat", noise_heat, true)
|
||||
minetest.set_mapgen_setting_noiseparams("humidity", noise_humidity, true)
|
||||
minetest.set_mapgen_setting_noiseparams("altitude", noise_altitude, true)
|
||||
end)
|
||||
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Biome Assignment Logic
|
||||
-- -------------------------------------------------------------- --
|
||||
local function get_biome(heat, humidity, altitude)
|
||||
if heat > 70 and humidity < 30 then
|
||||
return "desert"
|
||||
elseif heat > 70 and humidity > 50 then
|
||||
if altitude > 100 then
|
||||
return "volcanic_fields"
|
||||
end
|
||||
return "savannah"
|
||||
elseif heat > 50 and humidity > 70 then
|
||||
return "tropical_rainforest"
|
||||
elseif heat < 30 and humidity > 60 then
|
||||
return "boreal_forest"
|
||||
elseif heat < 10 and humidity > 40 then
|
||||
return "frozen_tundra"
|
||||
elseif altitude > 256 then
|
||||
return "jade_cliffs"
|
||||
else
|
||||
return "grassland" -- Default biome
|
||||
end
|
||||
end
|
||||
|
||||
local function blend_biomes(current_biome, neighbor_biome, distance)
|
||||
if distance < 10 and math.random() < 0.5 then
|
||||
return neighbor_biome
|
||||
end
|
||||
return current_biome
|
||||
end
|
||||
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Map Generation Logic
|
||||
-- -------------------------------------------------------------- --
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
-- Generate noise maps
|
||||
local heat_map = minetest.get_perlin_map(noise_heat, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local humidity_map = minetest.get_perlin_map(noise_humidity, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local altitude_map = minetest.get_perlin_map(noise_altitude, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local biome_size_map = minetest.get_perlin_map(biome_size_noise, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
|
||||
local heat = heat_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local humidity = humidity_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local altitude = altitude_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local biome_sizes = biome_size_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
local index2d = (z - minp.z) * (maxp.x - minp.x + 1) + (x - minp.x + 1)
|
||||
local h = heat[index2d]
|
||||
local hum = humidity[index2d]
|
||||
local alt = altitude[index2d]
|
||||
local biome_size = biome_sizes[index2d]
|
||||
|
||||
local current_biome = get_biome(h, hum, alt)
|
||||
local neighbor_biome = get_biome(h + 5, hum + 5, alt)
|
||||
current_biome = blend_biomes(current_biome, neighbor_biome, biome_size)
|
||||
|
||||
-- Fetch biome properties
|
||||
local node_top = core.get_biome_top_node(current_biome) or "vox_worldblocks:grass"
|
||||
local node_filler = core.get_biome_filler_node(current_biome) or "vox_worldblocks:dirt"
|
||||
local depth_top = core.get_biome_depth_top(current_biome) or 1
|
||||
local depth_filler = core.get_biome_depth_filler(current_biome) or 3
|
||||
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = area:index(x, y, z)
|
||||
|
||||
if y == minp.y then
|
||||
data[vi] = minetest.get_content_id("vox_worldblocks:bedrock")
|
||||
elseif y < -10001 then
|
||||
data[vi] = minetest.get_content_id("air")
|
||||
elseif y <= minp.y + depth_top then
|
||||
data[vi] = minetest.get_content_id(node_top)
|
||||
elseif y <= minp.y + depth_top + depth_filler then
|
||||
data[vi] = minetest.get_content_id(node_filler)
|
||||
else
|
||||
data[vi] = minetest.get_content_id("air")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
end)
|
|
@ -1,2 +0,0 @@
|
|||
name = vox_mapgen_core
|
||||
description = Voxelis - MapGen Core
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
|
||||
-- Clay
|
||||
minetest.register_ore({
|
||||
ore_type = "blob",
|
||||
ore = "vox"
|
||||
})
|
|
@ -13,7 +13,4 @@
|
|||
|
||||
vox_overworld = {}
|
||||
|
||||
dofile(core.get_modpath(core.get_current_modname()) .. "/registry.lua")
|
||||
|
||||
-- Ensure vox_mapgen_core is loaded
|
||||
--local mapgen_core = assert(vox_mapgen_core, "vox_mapgen_core must be loaded before vox_overworld")
|
||||
--dofile(core.get_modpath(core.get_current_modname()) .. "/registry.lua")
|
||||
|
|
|
@ -10,182 +10,88 @@
|
|||
-- BIOMES
|
||||
-- -------------------------------------------------------------- --
|
||||
|
||||
-- Helper Function: Register Default Biome Properties
|
||||
local function register_biome(params)
|
||||
-- Set defaults for biome parameters
|
||||
params.node_river_water = params.node_river_water or "vox_worldblocks:water_source"
|
||||
params.depth_riverbed = params.depth_riverbed or 2
|
||||
params.height_min = params.height_min or 1
|
||||
params.height_max = params.height_max or 256
|
||||
params.node_stone = params.node_stone or "vox_worldblocks:stone"
|
||||
|
||||
core.register_biome(params)
|
||||
end
|
||||
|
||||
-- Grasslands
|
||||
register_biome({
|
||||
-- Grassland
|
||||
-- Typical Blocks: Grass Block, Dirt, Stone
|
||||
core.register_biome({
|
||||
name = "grassland",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
|
||||
--node_dust = "vox_main:dirt",
|
||||
-- Node dropped onto upper surface after all else is generated
|
||||
|
||||
node_top = "vox_main:grass_block",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
-- Node forming surface layer of biome and thickness of this layer
|
||||
|
||||
node_filler = "vox_main:dirt",
|
||||
depth_filler = 3,
|
||||
heat_point = 35,
|
||||
humidity_point = 50,
|
||||
})
|
||||
-- Node forming lower layer of biome and thickness of this layer
|
||||
|
||||
-- Desert
|
||||
register_biome({
|
||||
name = "desert",
|
||||
node_top = "vox_worldblocks:sand",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sandstone",
|
||||
depth_filler = 5,
|
||||
heat_point = 80,
|
||||
humidity_point = 20,
|
||||
})
|
||||
node_stone = "vox_main:stone",
|
||||
-- Node that replaces all stone nodes between roughly y_min and y_max.
|
||||
|
||||
-- Boreal Forest
|
||||
register_biome({
|
||||
name = "boreal_forest",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
depth_filler = 4,
|
||||
heat_point = 20,
|
||||
humidity_point = 60,
|
||||
})
|
||||
node_water_top = "vox_main:sand",
|
||||
depth_water_top = 10,
|
||||
-- Node forming a surface layer in seawater with the defined thickness
|
||||
|
||||
-- Frozen Tundra
|
||||
register_biome({
|
||||
name = "frozen_tundra",
|
||||
node_top = "vox_worldblocks:snow",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:packed_snow",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:ice",
|
||||
heat_point = 5,
|
||||
humidity_point = 40,
|
||||
height_max = 150,
|
||||
})
|
||||
node_water = "",
|
||||
-- Node that replaces all seawater nodes not in the surface layer
|
||||
|
||||
node_river_water = "vox_main:sand",
|
||||
-- Node that replaces river water in mapgens that use
|
||||
-- vox_main:river_water
|
||||
|
||||
node_riverbed = "vox_main:gravel",
|
||||
depth_riverbed = 2,
|
||||
-- Node placed under river water and thickness of this layer
|
||||
|
||||
node_cave_liquid = "vox_main:lava_source",
|
||||
node_cave_liquid = {"vox_main:water_source", "vox_main:lava_source"},
|
||||
-- Nodes placed inside 50% of the medium size caves.
|
||||
-- Multiple nodes can be specified, each cave will use a randomly
|
||||
-- chosen node from the list.
|
||||
-- If this field is left out or 'nil', cave liquids fall back to
|
||||
-- classic behavior of lava and water distributed using 3D noise.
|
||||
-- For no cave liquid, specify "air".
|
||||
|
||||
node_dungeon = "vox_main:cobblestone",
|
||||
-- Node used for primary dungeon structure.
|
||||
-- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
|
||||
-- alias, if that is also absent, dungeon nodes fall back to the biome
|
||||
-- 'node_stone'.
|
||||
-- If present, the following two nodes are also used.
|
||||
|
||||
node_dungeon_alt = "vox_main:mossycobble",
|
||||
-- Node used for randomly-distributed alternative structure nodes.
|
||||
-- If alternative structure nodes are not wanted leave this absent.
|
||||
|
||||
node_dungeon_stair = "vox_structural:cobblestone_stairs",
|
||||
-- Node used for dungeon stairs.
|
||||
-- If absent, stairs fall back to 'node_dungeon'.
|
||||
|
||||
y_max = 31000,
|
||||
y_min = 1,
|
||||
-- Upper and lower limits for biome.
|
||||
-- Alternatively you can use xyz limits as shown below.
|
||||
|
||||
max_pos = {x = 31000, y = 128, z = 31000},
|
||||
min_pos = {x = -31000, y = 9, z = -31000},
|
||||
-- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
|
||||
-- Biome is limited to a cuboid defined by these positions.
|
||||
-- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
|
||||
-- 31000 in 'max_pos'.
|
||||
|
||||
vertical_blend = 8,
|
||||
|
||||
-- Rocky Badlands
|
||||
register_biome({
|
||||
name = "rocky_badlands",
|
||||
node_top = "vox_worldblocks:stone",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:gravel",
|
||||
depth_filler = 4,
|
||||
heat_point = 50,
|
||||
humidity_point = 30,
|
||||
height_min = 50,
|
||||
height_max = 180,
|
||||
})
|
||||
|
||||
-- Savannah
|
||||
register_biome({
|
||||
name = "savannah",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
depth_filler = 3,
|
||||
heat_point = 70,
|
||||
humidity_point = 30,
|
||||
height_max = 512,
|
||||
})
|
||||
|
||||
-- Mangrove Forest
|
||||
register_biome({
|
||||
name = "mangrove_forest",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:mud",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:mud",
|
||||
heat_point = 75,
|
||||
humidity_point = 80,
|
||||
height_min = -5,
|
||||
height_max = 100,
|
||||
})
|
||||
|
||||
-- Volcanic Fields
|
||||
register_biome({
|
||||
name = "volcanic_fields",
|
||||
node_top = "vox_worldblocks:volcanic_rock",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:basalt",
|
||||
depth_filler = 5,
|
||||
node_riverbed = "vox_worldblocks:lava_source",
|
||||
node_river_water = "vox_worldblocks:lava_source",
|
||||
heat_point = 90,
|
||||
humidity_point = 10,
|
||||
height_min = 50,
|
||||
height_max = 512,
|
||||
})
|
||||
|
||||
-- Salt Flats
|
||||
register_biome({
|
||||
name = "salt_flats",
|
||||
node_top = "vox_worldblocks:salt_crystal",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sand",
|
||||
depth_filler = 3,
|
||||
heat_point = 80,
|
||||
humidity_point = 20,
|
||||
height_max = 100,
|
||||
})
|
||||
|
||||
-- Jade Cliffs
|
||||
register_biome({
|
||||
name = "jade_cliffs",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:stone",
|
||||
depth_filler = 5,
|
||||
node_stone = "vox_worldblocks:granite",
|
||||
node_riverbed = "vox_worldblocks:gravel",
|
||||
heat_point = 55,
|
||||
humidity_point = 65,
|
||||
height_min = 128,
|
||||
height_max = 1024,
|
||||
})
|
||||
|
||||
-- Painted Canyons
|
||||
register_biome({
|
||||
name = "painted_canyons",
|
||||
node_top = "vox_worldblocks:terracotta_red",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:terracotta_orange",
|
||||
depth_filler = 4,
|
||||
node_riverbed = "vox_worldblocks:terracotta_yellow",
|
||||
heat_point = 65,
|
||||
humidity_point = 25,
|
||||
height_min = 10,
|
||||
height_max = 256,
|
||||
})
|
||||
|
||||
-- Iceberg Fields
|
||||
register_biome({
|
||||
name = "iceberg_fields",
|
||||
node_top = "vox_worldblocks:ice",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:snow",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:ice",
|
||||
heat_point = -10,
|
||||
humidity_point = 50,
|
||||
height_min = -100,
|
||||
height_max = 100,
|
||||
})
|
||||
-- Characteristic temperature and humidity for the biome.
|
||||
-- These values create 'biome points' on a voronoi diagram with heat and
|
||||
-- humidity as axes. The resulting voronoi cells determine the
|
||||
-- distribution of the biomes.
|
||||
-- Heat and humidity have average values of 50, vary mostly between
|
||||
-- 0 and 100 but can exceed these values.
|
||||
|
||||
-- Black Sand Beach
|
||||
register_biome({
|
||||
name = "black_sand_beach",
|
||||
node_top = "vox_worldblocks:basalt",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sand",
|
||||
depth_filler = 3,
|
||||
heat_point = 65,
|
||||
humidity_point = 80,
|
||||
height_min = -5,
|
||||
height_max = 5,
|
||||
})
|
||||
weight = 1.0,
|
||||
-- Relative weight of the biome in the Voronoi diagram.
|
||||
-- A value of 0 (or less) is ignored and equivalent to 1.0.
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- Voxelis - Voxel survival sandbox for Luanti
|
||||
-- Copyright (C) 2024 Mad Star Studio LLC
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
vox_terrain_features = { }
|
|
@ -1,2 +0,0 @@
|
|||
name = vox_terrain_features
|
||||
description = Voxelis - Terrain Features
|
Loading…
Add table
Add a link
Reference in a new issue