mirror of
git://repo.or.cz/rocks.git
synced 2025-01-01 14:00:30 +01:00
Multiple sedimentary layers.
This commit is contained in:
parent
b193a9825b
commit
7574b0f463
127
rocks/gensed.lua
127
rocks/gensed.lua
@ -1,5 +1,11 @@
|
||||
-- experimental sedimentary layer generator
|
||||
|
||||
local np_elv = {
|
||||
offset = 0, octaves = 2, persist = 0.4,
|
||||
scale = 8,
|
||||
spread = {x=25, y=25, z=25},
|
||||
seed = -546,
|
||||
}
|
||||
local np_typ1 = {
|
||||
offset = 0, octaves = 2, persist = 0.33,
|
||||
scale = 1,
|
||||
@ -36,20 +42,23 @@ rocksl.gensed = function (minp, maxp, seed)
|
||||
|
||||
local chunksize = maxp.x - minp.x + 1
|
||||
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||
local pmapminpxz = {x = minp.x, y = minp.z}
|
||||
local c_stone= minetest.get_content_id("rocks:mudstone")
|
||||
local minpxz = {x = minp.x, y = minp.z}
|
||||
local c_stone= minetest.get_content_id("default:stone")
|
||||
local c_dwg= c_stone
|
||||
--DEBUG: c_dwg= minetest.get_content_id("default:dirt_with_grass")
|
||||
|
||||
local n_tp1
|
||||
local n_tp2
|
||||
local n_vc
|
||||
local n_sp
|
||||
|
||||
local layers = {
|
||||
local sla = {
|
||||
{min=18, sd=169},
|
||||
{min=9, sd=324},
|
||||
{min=0, sd=-230},
|
||||
{min=-6, sd=850},
|
||||
{min=-12, sd=-643},
|
||||
{min=-18, sd=0},
|
||||
}
|
||||
if minp.y<(sla[#sla].min-10) then return end
|
||||
local biomes = {
|
||||
lava={ mod="default" },
|
||||
stone={ mod="default" },
|
||||
dirt={ mod="default" },
|
||||
nyancat={ mod="default" },
|
||||
wood={ mod="default" },
|
||||
gravel={ mod="default" },
|
||||
sand={ mod="default" },
|
||||
sandstone={ mod="default" },
|
||||
@ -63,85 +72,93 @@ rocksl.gensed = function (minp, maxp, seed)
|
||||
lignite={ mod="rocks" },
|
||||
anthracite={ mod="rocks" },
|
||||
}
|
||||
for k,v in pairs(layers) do
|
||||
for k,v in pairs(biomes) do
|
||||
v.ctx=v.ctx or minetest.get_content_id(v.mod..":"..k)
|
||||
if stats and (stats[k]==nil) then stats[k]=0 end
|
||||
end
|
||||
n_elv= minetest.get_perlin_map(np_elv, pmapsize) : get2dMap_flat(minp)
|
||||
|
||||
local nixz= 1
|
||||
local generated
|
||||
local nixz= 0
|
||||
local nixyz= 0
|
||||
for z=minp.z, maxp.z do for x=minp.x, maxp.x do
|
||||
nixz= nixz+1
|
||||
-- loop
|
||||
local bi
|
||||
local li
|
||||
local generated
|
||||
|
||||
for y=minp.y, maxp.y do
|
||||
for y=maxp.y, minp.y, -1 do
|
||||
nixyz=nixyz+1
|
||||
local di=area:index(x,y,z)
|
||||
if ((data[di]==c_stone)or(data[di]==c_dwg)) and (not generated) then
|
||||
generated=true
|
||||
if not n_tp1 then
|
||||
n_tp1= minetest.get_perlin_map(np_typ1, pmapsize) : get2dMap_flat(pmapminpxz)
|
||||
n_tp2= minetest.get_perlin_map(np_typ2, pmapsize) : get2dMap_flat(pmapminpxz)
|
||||
n_vc= minetest.get_perlin_map(np_vc, pmapsize) : get2dMap_flat(pmapminpxz)
|
||||
n_sp= minetest.get_perlin_map(np_sp, pmapsize) : get2dMap_flat(pmapminpxz)
|
||||
local yn=y +n_elv[nixz]
|
||||
if (data[di]==c_stone) and ((not bi)or(yn<sla[li].min)) then
|
||||
-- go to deeper layer
|
||||
if not li then li=1 end
|
||||
while (li<=#sla)and(sla[li].min>yn) do
|
||||
li=li+1
|
||||
end
|
||||
-- create noises for this layer
|
||||
if li>#sla then break end -- break y loop if too low
|
||||
if (not sla[li].n_tp1) then
|
||||
local altminpxz={ x=minp.x+sla[li].sd,
|
||||
y=minp.z-sla[li].sd}
|
||||
sla[li].n_tp1= minetest.get_perlin_map(np_typ1, pmapsize) : get2dMap_flat(altminpxz)
|
||||
sla[li].n_tp2= minetest.get_perlin_map(np_typ2, pmapsize) : get2dMap_flat(altminpxz)
|
||||
sla[li].n_vc= minetest.get_perlin_map(np_vc, pmapsize) : get2dMap_flat(altminpxz)
|
||||
sla[li].n_sp= minetest.get_perlin_map(np_sp, pmapsize) : get2dMap_flat(altminpxz)
|
||||
end
|
||||
|
||||
-- BEGIN geome resolution
|
||||
|
||||
local vcva= math.abs(n_vc[nixz])
|
||||
local vcv= n_vc[nixz]
|
||||
local spv= n_sp[nixz]
|
||||
local vcva= math.abs(sla[li].n_vc[nixz])
|
||||
local vcv= sla[li].n_vc[nixz]
|
||||
local spv= sla[li].n_sp[nixz]
|
||||
local tp=1 --=particulates, 2=biosediments, 3=chemosediments, 4=vulcanosediments
|
||||
if n_tp1[nixz]>0.2 then tp=2
|
||||
if n_tp2[nixz]>0.81 then tp=4 end
|
||||
elseif n_tp2[nixz]>0.76 then tp=3 end
|
||||
if sla[li].n_tp1[nixz]>0.2 then tp=2
|
||||
if sla[li].n_tp2[nixz]>0.81 then tp=4 end
|
||||
elseif sla[li].n_tp2[nixz]>0.76 then tp=3 end
|
||||
|
||||
if tp==1 then
|
||||
-- particulates
|
||||
if vcva>0.453 then
|
||||
-- clay-(0,stone,slate)
|
||||
if spv>0.23 then li="slate"
|
||||
elseif spv>-0.2 then li="claystone"
|
||||
else li="clay" end
|
||||
if spv>0.23 then bi="slate"
|
||||
elseif spv>-0.2 then bi="claystone"
|
||||
else bi="clay" end
|
||||
elseif vcva>0.4 then
|
||||
li="mudstone"
|
||||
bi="mudstone"
|
||||
elseif vcva>0.2 then
|
||||
-- sand-(0,stone)
|
||||
if spv>-0.3 then li="sandstone" else li="sand" end
|
||||
if spv>-0.3 then bi="sandstone" else bi="sand" end
|
||||
else
|
||||
-- gravel/conglomerate
|
||||
if spv>-0.34 then li="conglomerate" else li="gravel" end
|
||||
if spv>-0.34 then bi="conglomerate" else bi="gravel" end
|
||||
-- breccia?
|
||||
end
|
||||
elseif tp==2 then
|
||||
-- biosediments
|
||||
if vcv>0.72 then
|
||||
--ropa
|
||||
li="lava"
|
||||
elseif vcv>-0.24 then
|
||||
li="limestone"
|
||||
elseif vcv>-0.44 then
|
||||
--ine
|
||||
li="stone"
|
||||
else
|
||||
if vcv>0.05 then
|
||||
bi="limestone"
|
||||
elseif vcv>-0.1 then
|
||||
--uhlia
|
||||
if spv>0.7 then li="anthracite"
|
||||
elseif spv>0 then li="blackcoal"
|
||||
else li="lignite" end
|
||||
if spv>0.7 then bi="anthracite"
|
||||
elseif spv>0 then bi="blackcoal"
|
||||
else bi="lignite" end
|
||||
else
|
||||
--ine
|
||||
bi="wood"
|
||||
end
|
||||
end
|
||||
if not li then li="dirt" end
|
||||
|
||||
-- END geome resolution
|
||||
|
||||
if not bi then bi="nyancat" end
|
||||
generated=true
|
||||
end
|
||||
if ((data[di]==c_stone)or(data[di]==c_dwg)) and li then
|
||||
data[di]=layers[li].ctx
|
||||
if stats then stats.total=stats.total+1 stats[li]=stats[li]+1 end
|
||||
if (data[di]==c_stone) then
|
||||
data[di]=biomes[bi].ctx
|
||||
if stats then stats.total=stats.total+1 stats[bi]=stats[bi]+1 end
|
||||
end
|
||||
end
|
||||
nixz= nixz+1
|
||||
end end
|
||||
if n_tp1 then
|
||||
if generated then
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
if stats then for k,v in pairs(stats) do print("stat: "..k..": "..((v/stats.total)*100).."%") end end
|
||||
|
Loading…
Reference in New Issue
Block a user