mirror of
git://repo.or.cz/rocks.git
synced 2025-05-24 12:10:31 +02:00
Rewrite igneous layer.
This commit is contained in:
parent
cd3c2b2586
commit
21d2a4779d
@ -1,126 +0,0 @@
|
|||||||
local CcHard=3
|
|
||||||
local CcStrong=3
|
|
||||||
local CcMed=3
|
|
||||||
local CcSoft=3
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Main rocks (top to bottom)
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Granite In/Felsic hard Very common, below sed on land
|
|
||||||
minetest.register_node( "rocks:granite", {
|
|
||||||
description = S("Granite"),
|
|
||||||
tiles = { "rocks_Granite.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
groups = {cracky=CcStrong, stone=1},
|
|
||||||
})
|
|
||||||
rocks.register_layer( "granite",{ gain=20, height=-22, limit=2, seed=1 }, "rocks:granite")
|
|
||||||
|
|
||||||
-- Diorite In/Inter vhard Below granite
|
|
||||||
minetest.register_node( "rocks:diorite", {
|
|
||||||
description = S("Diorite"),
|
|
||||||
tiles = { "rocks_Diorite.png" },
|
|
||||||
groups = {cracky=CcHard, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "diorite",{ gain=20, height=-55, limit=2, seed=2 }, "rocks:diorite")
|
|
||||||
|
|
||||||
-- Basalt Ex/Mafic hard same as diorite, byt limit=0.5
|
|
||||||
minetest.register_node( "rocks:basalt", {
|
|
||||||
description = S("Basalt"),
|
|
||||||
tiles = { "rocks_Basalt.png" },
|
|
||||||
groups = {cracky=CcStrong, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "basalt",{ gain=20, height=-60, limit=-0.7, seed=2 }, "rocks:basalt")
|
|
||||||
|
|
||||||
-- Gabbro In/Mafic vhard Below basalt/diorite (mtns, ocean)
|
|
||||||
minetest.register_node( "rocks:gabbro", {
|
|
||||||
description = S("Gabbro"),
|
|
||||||
tiles = { "rocks_Gabbro.png" },
|
|
||||||
groups = {cracky=CcHard, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "gabbro",{ gain=20, height=-70, limit=2, seed=3 }, "rocks:gabbro")
|
|
||||||
|
|
||||||
-- Peridotite In/UMafic vhard Rarely under gabbro
|
|
||||||
minetest.register_node( "rocks:peridotite", {
|
|
||||||
description = S("Peridotite"),
|
|
||||||
tiles = { "rocks_Peridotite.png" },
|
|
||||||
groups = {cracky=CcStrong, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "peridotite",{ gain=20, height=-120, limit=-0.8, seed=4 }, "rocks:peridotite")
|
|
||||||
|
|
||||||
-- Komatiite Ex/UMafic - Too deep
|
|
||||||
minetest.register_node( "rocks:komatiite", {
|
|
||||||
description = S("Komatiite"),
|
|
||||||
tiles = { "default_stone.png" }, -- no texture, yet
|
|
||||||
groups = {cracky=CcHard, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "komatiite",{ gain=20, height=-130, limit=2, seed=5 }, "rocks:komatiite")
|
|
||||||
|
|
||||||
--
|
|
||||||
-- top sedimentary rocks
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Mudstone Sed soft Ocean, beach, river, glaciers
|
|
||||||
minetest.register_node( "rocks:mudstone", {
|
|
||||||
description = S("Mudstone"),
|
|
||||||
tiles = { "rocks_Mudstone.png" },
|
|
||||||
groups = {cracky=CcSoft, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "mudstone",{ gain=10, height=10, limit=2, seed=4 }, "rocks:mudstone")
|
|
||||||
|
|
||||||
-- Slate MM/barro med Under mud/clay/siltstone
|
|
||||||
minetest.register_node( "rocks:slate", {
|
|
||||||
description = S("slate"),
|
|
||||||
tiles = { "rocks_Slate.png" },
|
|
||||||
groups = {cracky=CcMed, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
-- rocks.register_layer( "slate",{ gain=10, height=-7, limit=2, seed=5 }, "rocks:slate")
|
|
||||||
|
|
||||||
-- Schist MM/barro med Under slate, sometimes igneous
|
|
||||||
minetest.register_node( "rocks:schist", {
|
|
||||||
description = S("schist"),
|
|
||||||
tiles = { "rocks_Schist.png" },
|
|
||||||
groups = {cracky=CcMed, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "schist",{ gain=10, height=-15, limit=2, seed=5 }, "rocks:schist")
|
|
||||||
|
|
||||||
-- Gneiss MM/barro hard Under schist, sometimes igneous
|
|
||||||
minetest.register_node( "rocks:gneiss", {
|
|
||||||
description = S("gneiss"),
|
|
||||||
tiles = { "rocks_Gneiss.png" },
|
|
||||||
groups = {cracky=CcStrong, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "gneiss",{ gain=10, height=-19, limit=2, seed=6 }, "rocks:gneiss")
|
|
||||||
|
|
||||||
--
|
|
||||||
-- peak rocks
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Rhyolite Ex/Felsic hard Mountains, top
|
|
||||||
minetest.register_node( "rocks:rhyolite", {
|
|
||||||
description = S("Rhyolite"),
|
|
||||||
tiles = { "rocks_Rhyolite.png" },
|
|
||||||
groups = {cracky=CcHard, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "rhyolite",{ gain=8, height=80, limit=2, seed=4 }, "rocks:rhyolite")
|
|
||||||
|
|
||||||
-- Andesite Ex/Inter hard Mountains, below rhyolite
|
|
||||||
minetest.register_node( "rocks:andesite", {
|
|
||||||
description = S("Andesite"),
|
|
||||||
tiles = { "rocks_Andesite.png" },
|
|
||||||
groups = {cracky=CcHard, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
rocks.register_layer( "andesite",{ gain=8, height=22, limit=2, seed=4 }, "rocks:andesite")
|
|
||||||
|
|
||||||
print("[rocks/geologicaLayers] loaded.")
|
|
@ -1,75 +0,0 @@
|
|||||||
local CcHard=3
|
|
||||||
local CcStrong=3
|
|
||||||
local CcMed=3
|
|
||||||
local CcSoft=3
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Sedimentary
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Claystone Sed soft in mudstone
|
|
||||||
rocks.register_vein("clay",{
|
|
||||||
spread = {x=30, y=10, z=30},
|
|
||||||
treshold=0.26, -- clay should be plenty
|
|
||||||
seed = 9,
|
|
||||||
layers={ "mudstone" },
|
|
||||||
})
|
|
||||||
rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } )
|
|
||||||
|
|
||||||
-- Breccia Mixture soft in mudstone
|
|
||||||
-- Conglomerate Sed soft in mudstone
|
|
||||||
|
|
||||||
-- Coal Ocean, inland 2x swamp
|
|
||||||
rocks.register_vein("coal",{
|
|
||||||
spread = {x=20, y=10, z=20},
|
|
||||||
treshold=0.48, -- coal shold be less
|
|
||||||
seed = 10,
|
|
||||||
layers={ "mudstone" },
|
|
||||||
})
|
|
||||||
rocks.register_ore( "coal", "default:stone_with_coal", {treshold=0, chance=85 } )
|
|
||||||
|
|
||||||
-- Pyrolusite Swamp
|
|
||||||
-- Diatomite Volcanic, desert
|
|
||||||
-- Glauconite Ocean 20% sandstone
|
|
||||||
-- Apatite Any Metamorphic depth
|
|
||||||
-- Zeolite Volcanic
|
|
||||||
-- Fuller's Earth Desert
|
|
||||||
-- Kaolinite Tropics
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Misc rocks
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Limestone Sed med in Rhyolite, Andesite in mountains
|
|
||||||
minetest.register_node( "rocks:limestone", {
|
|
||||||
description = S("Limestone"),
|
|
||||||
tiles = { "rocks_Limestone.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
groups = {cracky=CcMed, stone=1},
|
|
||||||
})
|
|
||||||
rocks.register_vein("limestone",{
|
|
||||||
spread = {x=60, y=60, z=60},
|
|
||||||
treshold=0.4,
|
|
||||||
seed = 10,
|
|
||||||
layers={ "rhyolite", "andesite" },
|
|
||||||
})
|
|
||||||
rocks.register_ore( "limestone", "rocks:limestone", {treshold=0, chance=100} )
|
|
||||||
|
|
||||||
-- Dolomite Sed med in Rhyolite, Andesite in mountains
|
|
||||||
minetest.register_node( "rocks:dolomite", {
|
|
||||||
description = S("Dolomite"),
|
|
||||||
tiles = { "rocks_Dolomite.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
groups = {cracky=CcMed, stone=1},
|
|
||||||
})
|
|
||||||
rocks.register_vein("dolomite",{
|
|
||||||
spread = {x=60, y=60, z=60},
|
|
||||||
treshold=0.4,
|
|
||||||
seed = 11,
|
|
||||||
layers={ "rhyolite", "andesite" },
|
|
||||||
})
|
|
||||||
rocks.register_ore( "dolomite", "rocks:dolomite", {treshold=0, chance=100} )
|
|
||||||
|
|
||||||
-- Quartzite MM/contact vhard sandstone
|
|
||||||
|
|
||||||
print("[rocks/geologicaStrata] loaded.")
|
|
@ -1,15 +0,0 @@
|
|||||||
local CcHard=3
|
|
||||||
local CcStrong=3
|
|
||||||
local CcMed=3
|
|
||||||
local CcSoft=3
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Veins
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Skarn MM/contact med in rhyo/ande in mountains
|
|
||||||
-- Hornfels MM/contact vhard in skarn
|
|
||||||
-- Marble MM/contact hard in skarn
|
|
||||||
-- Limestone Sed med in skarn
|
|
||||||
|
|
||||||
print("[rocks/geologicaVeins] loaded.")
|
|
124
ign.lua
124
ign.lua
@ -2,112 +2,68 @@
|
|||||||
-- Igneous Layer
|
-- Igneous Layer
|
||||||
--
|
--
|
||||||
|
|
||||||
local layer={
|
local ign={
|
||||||
top={
|
top={
|
||||||
offset = -13, scale = 0,
|
offset = -10, scale = 0,
|
||||||
spread = {x=80, y=80, z=80},
|
spread = {x=80, y=80, z=80},
|
||||||
octaves = 0, persist = 0 },
|
octaves = 0, persist = 0 },
|
||||||
bot={
|
bot={
|
||||||
offset = -180, scale = 10, seed=100,
|
offset = -180, scale = 10, seed=rocksl.GetNextSeed(),
|
||||||
spread = {x=80, y=80, z=80},
|
spread = {x=80, y=80, z=80},
|
||||||
octaves = 2, persist = 0.7 },
|
octaves = 2, persist = 0.7 },
|
||||||
primary={ name="rocks:basalt" },
|
primary={ name="rocks:basalt" },
|
||||||
localized={},
|
localized={},
|
||||||
seedseq=100,
|
stats={ count=0, total=0, node={}, totalnodes=0 },
|
||||||
stats={ count=0, total=0, node={}, totalnodes=0 }
|
debugging=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Basalt Ex/Mafic hard same as diorite, byt limit=0.5
|
||||||
|
minetest.register_node( "rocks:basalt", {
|
||||||
|
description = S("Basalt"),
|
||||||
|
tiles = { "rocks_Basalt.png" },
|
||||||
|
groups = {cracky=3, stone=1},
|
||||||
|
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
-- more rock defs
|
-- more rock defs
|
||||||
|
minetest.register_node( "rocks:granite", {
|
||||||
|
description = S("Granite"),
|
||||||
|
tiles = { "rocks_Granite.png" },
|
||||||
|
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
||||||
|
groups = {cracky=3, stone=1},
|
||||||
|
})
|
||||||
|
minetest.register_node( "rocks:diorite", {
|
||||||
|
description = S("Diorite"),
|
||||||
|
tiles = { "rocks_Diorite.png" },
|
||||||
|
groups = {cracky=3, stone=1},
|
||||||
|
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
||||||
|
minetest.register_node( "rocks:gabbro", {
|
||||||
|
description = S("Gabbro"),
|
||||||
|
tiles = { "rocks_Gabbro.png" },
|
||||||
|
groups = {cracky=3, stone=1},
|
||||||
|
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
local reg=function(name,param)
|
local reg=function(name,param)
|
||||||
layer.localized[name]={
|
rocksl.register_blob(ign,name,param)
|
||||||
spread=(param.spread or 20),
|
|
||||||
height=(param.height or 15),
|
|
||||||
treshold=(param.treshold or 0.85),
|
|
||||||
secondary=(param.secondary),
|
|
||||||
seed=seedseq,
|
|
||||||
}
|
|
||||||
layer.stats.node[name]=0
|
|
||||||
layer.seedseq=layer.seedseq+1
|
|
||||||
end
|
end
|
||||||
rocks.register_igneous=reg
|
rocks.register_igneous=reg
|
||||||
|
|
||||||
-- rock registration
|
-- rock registration
|
||||||
--eg: reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 })
|
reg("rocks:granite", { spread=40, height=32, treshold=0.04})
|
||||||
|
reg("rocks:diorite", { spread=40, height=32, treshold=0.24})
|
||||||
|
reg("rocks:gabbro", { spread=40, height=32, treshold=0.33})
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if ( (layer.top.offset+layer.top.scale)>minp.y )
|
rocksl.layergen(ign,minp,maxp,seed)
|
||||||
and ( (layer.bot.offset-layer.bot.scale)<maxp.y )
|
|
||||||
then
|
|
||||||
stone_ctx= minetest.get_content_id("default:stone")
|
|
||||||
air_ctx= minetest.get_content_id("air")
|
|
||||||
dirt_ctx= minetest.get_content_id("default:dirt")
|
|
||||||
layer.primary.ctx= minetest.get_content_id(layer.primary.name)
|
|
||||||
local timebefore=os.clock();
|
|
||||||
local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
local nodes = manipulator:get_data()
|
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
||||||
local side_length = (maxp.x - minp.x) + 1
|
|
||||||
local map_lengths_xyz = {x=side_length, y=side_length, z=side_length}
|
|
||||||
-- noises:
|
|
||||||
local bottom=minetest.get_perlin_map(layer.bot,map_lengths_xyz):get2dMap_flat({x=minp.x, y=minp.z})
|
|
||||||
local localized={}
|
|
||||||
for name,loc in pairs(layer.localized) do
|
|
||||||
--defaults and overrides
|
|
||||||
local np={ offset = 0, scale = 1, octaves = 1, persist = 0.7,
|
|
||||||
spread = {x=loc.spread, y=loc.height, z=loc.spread} }
|
|
||||||
--get noise and content ids
|
|
||||||
table.insert(localized,
|
|
||||||
{
|
|
||||||
noise=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp),
|
|
||||||
treshold=loc.treshold,
|
|
||||||
ctx= minetest.get_content_id(name),
|
|
||||||
ndn=name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
local noise2d_ix = 1
|
|
||||||
local noise3d_ix = 1
|
|
||||||
print("[rocks] igneous gen1 "..os.clock()-timebefore)
|
|
||||||
for z=minp.z,maxp.z,1 do
|
|
||||||
for y=minp.y,maxp.y,1 do
|
|
||||||
for x=minp.x,maxp.x,1 do
|
|
||||||
local pos = area:index(x, y, z)
|
|
||||||
if (y>bottom[noise2d_ix])
|
|
||||||
and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx))
|
|
||||||
then
|
|
||||||
layer.stats.totalnodes=layer.stats.totalnodes+1
|
|
||||||
if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --layer.primary.ctx
|
|
||||||
for k,loc in pairs(localized) do
|
|
||||||
if ( loc.noise[noise3d_ix] > loc.treshold) then
|
|
||||||
nodes[pos]=loc.ctx
|
|
||||||
layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix+1
|
|
||||||
noise3d_ix=noise3d_ix+1
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix-side_length
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix+side_length
|
|
||||||
end
|
|
||||||
manipulator:set_data(nodes)
|
|
||||||
--manipulator:calc_lighting()
|
|
||||||
manipulator:set_lighting({day=15,night=15})
|
|
||||||
--manipulator:update_liquids()
|
|
||||||
manipulator:write_to_map()
|
|
||||||
print("[rocks] igneous gen2 "..os.clock()-timebefore)
|
|
||||||
layer.stats.count=layer.stats.count+1
|
|
||||||
layer.stats.total=layer.stats.total+(os.clock()-timebefore)
|
|
||||||
layer.stats.side=side_length
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
print("[rocks](ign) on_shutdown: generated total "..layer.stats.count.." chunks in "..layer.stats.total.." seconds ("..(layer.stats.total/layer.stats.count).." seconds per "..layer.stats.side.."^3 chunk)")
|
if (ign.stats.count==0) then print("[rocks](ign) stats not available, no chunks generated") return end
|
||||||
for name,total in pairs(layer.stats.node) do
|
print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)")
|
||||||
print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(layer.stats.count*layer.stats.totalnodes).." %)")
|
for name,total in pairs(ign.stats.node) do
|
||||||
|
print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
10
init.lua
10
init.lua
@ -1,3 +1,5 @@
|
|||||||
|
print("[rocks] mod initializing")
|
||||||
|
|
||||||
-- Load translation library if intllib is installed
|
-- Load translation library if intllib is installed
|
||||||
|
|
||||||
if (minetest.get_modpath("intllib")) then
|
if (minetest.get_modpath("intllib")) then
|
||||||
@ -8,16 +10,14 @@ if (minetest.get_modpath("intllib")) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
rocks={}
|
rocks={}
|
||||||
|
rocksl={}
|
||||||
|
|
||||||
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
print("[rocks] begin")
|
dofile(modpath.."/mapgen.lua")
|
||||||
|
|
||||||
dofile(modpath.."/sed.lua")
|
dofile(modpath.."/sed.lua")
|
||||||
|
dofile(modpath.."/ign.lua")
|
||||||
|
|
||||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||||
-- todo: disable caves and ores
|
-- todo: disable caves and ores
|
||||||
print("[rocks] mapgen initalized ")
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
print("[rocks] done")
|
|
99
mapgen.lua
Normal file
99
mapgen.lua
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
--
|
||||||
|
-- layer generator
|
||||||
|
--
|
||||||
|
|
||||||
|
rocksl.seedseq=0
|
||||||
|
rocksl.GetNextSeed=function()
|
||||||
|
rocksl.seedseq=rocksl.seedseq+20
|
||||||
|
print("seed "..rocksl.seedseq)
|
||||||
|
return rocksl.seedseq
|
||||||
|
end
|
||||||
|
|
||||||
|
rocksl.register_blob=function(layer,name,param)
|
||||||
|
layer.localized[name]={
|
||||||
|
spread=(param.spread or 20),
|
||||||
|
height=(param.height or 15),
|
||||||
|
treshold=(param.treshold or 0.85),
|
||||||
|
secondary=param.secondary,
|
||||||
|
seed=(rocksl.GetNextSeed()),
|
||||||
|
}
|
||||||
|
layer.stats.node[name]=0
|
||||||
|
end
|
||||||
|
|
||||||
|
rocksl.layergen=function(layer, minp, maxp, seed)
|
||||||
|
if ( (layer.top.offset+layer.top.scale)>minp.y )
|
||||||
|
and ( (layer.bot.offset-layer.bot.scale)<maxp.y )
|
||||||
|
then
|
||||||
|
stone_ctx= minetest.get_content_id("default:stone")
|
||||||
|
air_ctx= minetest.get_content_id("air")
|
||||||
|
dirt_ctx= minetest.get_content_id("default:dirt")
|
||||||
|
if layer.debugging then
|
||||||
|
layer.primary.ctx= air_ctx
|
||||||
|
else
|
||||||
|
layer.primary.ctx= minetest.get_content_id(layer.primary.name)
|
||||||
|
end
|
||||||
|
local timebefore=os.clock();
|
||||||
|
local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
|
local nodes = manipulator:get_data()
|
||||||
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
|
local side_length = (maxp.x - minp.x) + 1
|
||||||
|
local map_lengths_xyz = {x=side_length, y=side_length, z=side_length}
|
||||||
|
-- noises:
|
||||||
|
local bottom=minetest.get_perlin_map(layer.bot,map_lengths_xyz):get2dMap_flat({x=minp.x, y=minp.z})
|
||||||
|
local localized={}
|
||||||
|
for name,loc in pairs(layer.localized) do
|
||||||
|
--defaults and overrides
|
||||||
|
local np={ offset = 0, scale = 1, octaves = 1, persist = 0.7,
|
||||||
|
spread = {x=loc.spread, y=loc.height, z=loc.spread}, seed=loc.seed}
|
||||||
|
--get noise and content ids
|
||||||
|
table.insert(localized,
|
||||||
|
{
|
||||||
|
noise=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp),
|
||||||
|
treshold=loc.treshold,
|
||||||
|
ctx= minetest.get_content_id(name),
|
||||||
|
ndn=name
|
||||||
|
})
|
||||||
|
end
|
||||||
|
local noise2d_ix = 1
|
||||||
|
local noise3d_ix = 1
|
||||||
|
print("after noise: "..(os.clock()-timebefore))
|
||||||
|
for z=minp.z,maxp.z,1 do
|
||||||
|
for y=minp.y,maxp.y,1 do
|
||||||
|
for x=minp.x,maxp.x,1 do
|
||||||
|
local pos = area:index(x, y, z)
|
||||||
|
if (y>bottom[noise2d_ix])
|
||||||
|
and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx))
|
||||||
|
then
|
||||||
|
layer.stats.totalnodes=layer.stats.totalnodes+1
|
||||||
|
if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end
|
||||||
|
for k,loc in pairs(localized) do
|
||||||
|
if ( loc.noise[noise3d_ix] > loc.treshold) then
|
||||||
|
nodes[pos]=loc.ctx
|
||||||
|
layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
noise2d_ix=noise2d_ix+1
|
||||||
|
noise3d_ix=noise3d_ix+1
|
||||||
|
end
|
||||||
|
noise2d_ix=noise2d_ix-side_length
|
||||||
|
end
|
||||||
|
noise2d_ix=noise2d_ix+side_length
|
||||||
|
end
|
||||||
|
print("after loop: "..(os.clock()-timebefore))
|
||||||
|
manipulator:set_data(nodes)
|
||||||
|
--manipulator:calc_lighting()
|
||||||
|
--manipulator:update_liquids()
|
||||||
|
if layer.debugging then
|
||||||
|
manipulator:set_lighting({day=15,night=15})
|
||||||
|
end
|
||||||
|
manipulator:write_to_map()
|
||||||
|
print("after commit: "..(os.clock()-timebefore))
|
||||||
|
layer.stats.count=layer.stats.count+1
|
||||||
|
layer.stats.total=layer.stats.total+(os.clock()-timebefore)
|
||||||
|
layer.stats.side=side_length
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ~ Tomas Brod
|
96
sed.lua
96
sed.lua
@ -8,20 +8,20 @@ local sed={
|
|||||||
spread = {x=80, y=80, z=80},
|
spread = {x=80, y=80, z=80},
|
||||||
octaves = 0, persist = 0 },
|
octaves = 0, persist = 0 },
|
||||||
bot={
|
bot={
|
||||||
offset = -22, scale = 10, seed=1,
|
offset = -16, scale = 10, seed=rocksl.GetNextSeed(),
|
||||||
spread = {x=80, y=80, z=80},
|
spread = {x=80, y=80, z=80},
|
||||||
octaves = 2, persist = 0.7 },
|
octaves = 2, persist = 0.7 },
|
||||||
primary={ name="rocks:mudstone" },
|
primary={ name="rocks:mudstone" },
|
||||||
localized={},
|
localized={},
|
||||||
seedseq=2,
|
stats={ count=0, total=0, node={}, totalnodes=0 },
|
||||||
stats={ count=0, total=0, node={}, totalnodes=0 }
|
debugging=nil
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Mudstone Sed soft Ocean, beach, river, glaciers
|
-- Mudstone Sed soft Ocean, beach, river, glaciers
|
||||||
minetest.register_node( "rocks:mudstone", {
|
minetest.register_node( "rocks:mudstone", {
|
||||||
description = S("Mudstone"),
|
description = S("Mudstone"),
|
||||||
tiles = { "rocks_Mudstone.png" },
|
tiles = { "rocks_Mudstone.png" },
|
||||||
groups = {cracky=1, crumbly=1},
|
groups = {cracky=1, crumbly=3},
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -35,16 +35,9 @@ minetest.register_node( "rocks:limestone", {
|
|||||||
|
|
||||||
|
|
||||||
local reg=function(name,param)
|
local reg=function(name,param)
|
||||||
sed.localized[name]={
|
rocksl.register_blob(sed,name,param)
|
||||||
spread=(param.spread or 20),
|
|
||||||
height=(param.height or 15),
|
|
||||||
treshold=(param.treshold or 0.85),
|
|
||||||
secondary=(param.secondary),
|
|
||||||
seed=seedseq,
|
|
||||||
}
|
|
||||||
sed.stats.node[name]=0
|
|
||||||
sed.seedseq=sed.seedseq+1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rocks.register_sedimentary=reg
|
rocks.register_sedimentary=reg
|
||||||
|
|
||||||
-- Sedimentary rock hardness and distribution
|
-- Sedimentary rock hardness and distribution
|
||||||
@ -54,84 +47,21 @@ rocks.register_sedimentary=reg
|
|||||||
--Conglomerate Weak Localized continental, folded
|
--Conglomerate Weak Localized continental, folded
|
||||||
-->Limestone Medium Localized continental, folded; primary oceanic, hills
|
-->Limestone Medium Localized continental, folded; primary oceanic, hills
|
||||||
-->Coal - Large beds, twice as common in swamps
|
-->Coal - Large beds, twice as common in swamps
|
||||||
reg("rocks:limestone", { spread=64, height=32, treshold=0.56 })
|
reg("rocks:limestone", { spread=64, height=32, treshold=0.36 })
|
||||||
--reg("rocks:breccia", { spread=64, height=32, treshold=0.6 })
|
--reg("rocks:breccia", { spread=64, height=32, treshold=0.6 })
|
||||||
--reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 })
|
--reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 })
|
||||||
reg("default:clay",{ spread=24, height=16, treshold=0.63 })
|
reg("default:clay",{ spread=48, height=14, treshold=0.50 })
|
||||||
reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 })
|
reg("default:stone_with_coal", { spread=48, height=14, treshold=0.40 })
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if ( (sed.top.offset+sed.top.scale)>minp.y )
|
rocksl.layergen(sed,minp,maxp,seed)
|
||||||
and ( (sed.bot.offset-sed.bot.scale)<maxp.y )
|
|
||||||
then
|
|
||||||
stone_ctx= minetest.get_content_id("default:stone")
|
|
||||||
air_ctx= minetest.get_content_id("air")
|
|
||||||
dirt_ctx= minetest.get_content_id("default:dirt")
|
|
||||||
sed.primary.ctx= minetest.get_content_id(sed.primary.name)
|
|
||||||
local timebefore=os.clock();
|
|
||||||
local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
local nodes = manipulator:get_data()
|
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
||||||
local side_length = (maxp.x - minp.x) + 1
|
|
||||||
local map_lengths_xyz = {x=side_length, y=side_length, z=side_length}
|
|
||||||
-- noises:
|
|
||||||
local bottom=minetest.get_perlin_map(sed.bot,map_lengths_xyz):get2dMap_flat({x=minp.x, y=minp.z})
|
|
||||||
local localized={}
|
|
||||||
for name,loc in pairs(sed.localized) do
|
|
||||||
--defaults and overrides
|
|
||||||
local np={ offset = 0, scale = 1, octaves = 1, persist = 0.7,
|
|
||||||
spread = {x=loc.spread, y=loc.height, z=loc.spread} }
|
|
||||||
--get noise and content ids
|
|
||||||
table.insert(localized,
|
|
||||||
{
|
|
||||||
noise=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp),
|
|
||||||
treshold=loc.treshold,
|
|
||||||
ctx= minetest.get_content_id(name),
|
|
||||||
ndn=name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
local noise2d_ix = 1
|
|
||||||
local noise3d_ix = 1
|
|
||||||
print("[rocks] sedimentary gen1 "..os.clock()-timebefore)
|
|
||||||
for z=minp.z,maxp.z,1 do
|
|
||||||
for y=minp.y,maxp.y,1 do
|
|
||||||
for x=minp.x,maxp.x,1 do
|
|
||||||
local pos = area:index(x, y, z)
|
|
||||||
if (y>bottom[noise2d_ix])
|
|
||||||
and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx))
|
|
||||||
then
|
|
||||||
sed.stats.totalnodes=sed.stats.totalnodes+1
|
|
||||||
if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --sed.primary.ctx
|
|
||||||
for k,loc in pairs(localized) do
|
|
||||||
if ( loc.noise[noise3d_ix] > loc.treshold) then
|
|
||||||
nodes[pos]=loc.ctx
|
|
||||||
sed.stats.node[loc.ndn]=sed.stats.node[loc.ndn]+1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix+1
|
|
||||||
noise3d_ix=noise3d_ix+1
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix-side_length
|
|
||||||
end
|
|
||||||
noise2d_ix=noise2d_ix+side_length
|
|
||||||
end
|
|
||||||
manipulator:set_data(nodes)
|
|
||||||
--manipulator:calc_lighting()
|
|
||||||
manipulator:set_lighting({day=15,night=15})
|
|
||||||
--manipulator:update_liquids()
|
|
||||||
manipulator:write_to_map()
|
|
||||||
print("[rocks] sedimentary gen2 "..os.clock()-timebefore)
|
|
||||||
sed.stats.count=sed.stats.count+1
|
|
||||||
sed.stats.total=sed.stats.total+(os.clock()-timebefore)
|
|
||||||
sed.stats.side=side_length
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
print("[rocks](sed) on_shutdown: generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)")
|
if (sed.stats.count==0) then print("[rocks](sed) stats not available, no chunks generated") return end
|
||||||
|
print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)")
|
||||||
for name,total in pairs(sed.stats.node) do
|
for name,total in pairs(sed.stats.node) do
|
||||||
print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.count*sed.stats.totalnodes).." %)")
|
print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
12
testing.lua
12
testing.lua
@ -1,12 +0,0 @@
|
|||||||
rocks.register_layer("testl", { gain=20, height=-55, limit=2, seed=1 }, "default:wood")
|
|
||||||
|
|
||||||
rocks.register_vein("clay",{
|
|
||||||
spread = {x=30, y=10, z=30},
|
|
||||||
treshold=0.2, -- clay should be plenty
|
|
||||||
seed = 9,
|
|
||||||
hmin=-8, hmax=nil,
|
|
||||||
layers={ "mudstone" },
|
|
||||||
})
|
|
||||||
|
|
||||||
rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } )
|
|
||||||
rocks.register_ore( "clay", "default:torch", {treshold=0, chance=15 } )
|
|
Loading…
x
Reference in New Issue
Block a user