mirror of
git://repo.or.cz/rocks.git
synced 2025-01-04 07:10:28 +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
|
-- 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 = {
|
local np_typ1 = {
|
||||||
offset = 0, octaves = 2, persist = 0.33,
|
offset = 0, octaves = 2, persist = 0.33,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
@ -36,20 +42,23 @@ rocksl.gensed = function (minp, maxp, seed)
|
|||||||
|
|
||||||
local chunksize = maxp.x - minp.x + 1
|
local chunksize = maxp.x - minp.x + 1
|
||||||
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||||
local pmapminpxz = {x = minp.x, y = minp.z}
|
local minpxz = {x = minp.x, y = minp.z}
|
||||||
local c_stone= minetest.get_content_id("rocks:mudstone")
|
local c_stone= minetest.get_content_id("default:stone")
|
||||||
local c_dwg= c_stone
|
local c_dwg= c_stone
|
||||||
--DEBUG: c_dwg= minetest.get_content_id("default:dirt_with_grass")
|
|
||||||
|
|
||||||
local n_tp1
|
local sla = {
|
||||||
local n_tp2
|
{min=18, sd=169},
|
||||||
local n_vc
|
{min=9, sd=324},
|
||||||
local n_sp
|
{min=0, sd=-230},
|
||||||
|
{min=-6, sd=850},
|
||||||
local layers = {
|
{min=-12, sd=-643},
|
||||||
|
{min=-18, sd=0},
|
||||||
|
}
|
||||||
|
if minp.y<(sla[#sla].min-10) then return end
|
||||||
|
local biomes = {
|
||||||
lava={ mod="default" },
|
lava={ mod="default" },
|
||||||
stone={ mod="default" },
|
nyancat={ mod="default" },
|
||||||
dirt={ mod="default" },
|
wood={ mod="default" },
|
||||||
gravel={ mod="default" },
|
gravel={ mod="default" },
|
||||||
sand={ mod="default" },
|
sand={ mod="default" },
|
||||||
sandstone={ mod="default" },
|
sandstone={ mod="default" },
|
||||||
@ -63,85 +72,93 @@ rocksl.gensed = function (minp, maxp, seed)
|
|||||||
lignite={ mod="rocks" },
|
lignite={ mod="rocks" },
|
||||||
anthracite={ 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)
|
v.ctx=v.ctx or minetest.get_content_id(v.mod..":"..k)
|
||||||
if stats and (stats[k]==nil) then stats[k]=0 end
|
if stats and (stats[k]==nil) then stats[k]=0 end
|
||||||
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
|
for z=minp.z, maxp.z do for x=minp.x, maxp.x do
|
||||||
|
nixz= nixz+1
|
||||||
-- loop
|
-- loop
|
||||||
|
local bi
|
||||||
local li
|
local li
|
||||||
local generated
|
for y=maxp.y, minp.y, -1 do
|
||||||
|
nixyz=nixyz+1
|
||||||
for y=minp.y, maxp.y do
|
|
||||||
local di=area:index(x,y,z)
|
local di=area:index(x,y,z)
|
||||||
if ((data[di]==c_stone)or(data[di]==c_dwg)) and (not generated) then
|
local yn=y +n_elv[nixz]
|
||||||
generated=true
|
if (data[di]==c_stone) and ((not bi)or(yn<sla[li].min)) then
|
||||||
if not n_tp1 then
|
-- go to deeper layer
|
||||||
n_tp1= minetest.get_perlin_map(np_typ1, pmapsize) : get2dMap_flat(pmapminpxz)
|
if not li then li=1 end
|
||||||
n_tp2= minetest.get_perlin_map(np_typ2, pmapsize) : get2dMap_flat(pmapminpxz)
|
while (li<=#sla)and(sla[li].min>yn) do
|
||||||
n_vc= minetest.get_perlin_map(np_vc, pmapsize) : get2dMap_flat(pmapminpxz)
|
li=li+1
|
||||||
n_sp= minetest.get_perlin_map(np_sp, pmapsize) : get2dMap_flat(pmapminpxz)
|
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
|
end
|
||||||
|
|
||||||
-- BEGIN geome resolution
|
-- BEGIN geome resolution
|
||||||
|
local vcva= math.abs(sla[li].n_vc[nixz])
|
||||||
local vcva= math.abs(n_vc[nixz])
|
local vcv= sla[li].n_vc[nixz]
|
||||||
local vcv= n_vc[nixz]
|
local spv= sla[li].n_sp[nixz]
|
||||||
local spv= n_sp[nixz]
|
|
||||||
local tp=1 --=particulates, 2=biosediments, 3=chemosediments, 4=vulcanosediments
|
local tp=1 --=particulates, 2=biosediments, 3=chemosediments, 4=vulcanosediments
|
||||||
if n_tp1[nixz]>0.2 then tp=2
|
if sla[li].n_tp1[nixz]>0.2 then tp=2
|
||||||
if n_tp2[nixz]>0.81 then tp=4 end
|
if sla[li].n_tp2[nixz]>0.81 then tp=4 end
|
||||||
elseif n_tp2[nixz]>0.76 then tp=3 end
|
elseif sla[li].n_tp2[nixz]>0.76 then tp=3 end
|
||||||
|
|
||||||
if tp==1 then
|
if tp==1 then
|
||||||
-- particulates
|
-- particulates
|
||||||
if vcva>0.453 then
|
if vcva>0.453 then
|
||||||
-- clay-(0,stone,slate)
|
-- clay-(0,stone,slate)
|
||||||
if spv>0.23 then li="slate"
|
if spv>0.23 then bi="slate"
|
||||||
elseif spv>-0.2 then li="claystone"
|
elseif spv>-0.2 then bi="claystone"
|
||||||
else li="clay" end
|
else bi="clay" end
|
||||||
elseif vcva>0.4 then
|
elseif vcva>0.4 then
|
||||||
li="mudstone"
|
bi="mudstone"
|
||||||
elseif vcva>0.2 then
|
elseif vcva>0.2 then
|
||||||
-- sand-(0,stone)
|
-- 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
|
else
|
||||||
-- gravel/conglomerate
|
-- 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?
|
-- breccia?
|
||||||
end
|
end
|
||||||
elseif tp==2 then
|
elseif tp==2 then
|
||||||
-- biosediments
|
-- biosediments
|
||||||
if vcv>0.72 then
|
if vcv>0.05 then
|
||||||
--ropa
|
bi="limestone"
|
||||||
li="lava"
|
elseif vcv>-0.1 then
|
||||||
elseif vcv>-0.24 then
|
|
||||||
li="limestone"
|
|
||||||
elseif vcv>-0.44 then
|
|
||||||
--ine
|
|
||||||
li="stone"
|
|
||||||
else
|
|
||||||
--uhlia
|
--uhlia
|
||||||
if spv>0.7 then li="anthracite"
|
if spv>0.7 then bi="anthracite"
|
||||||
elseif spv>0 then li="blackcoal"
|
elseif spv>0 then bi="blackcoal"
|
||||||
else li="lignite" end
|
else bi="lignite" end
|
||||||
|
else
|
||||||
|
--ine
|
||||||
|
bi="wood"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not li then li="dirt" end
|
|
||||||
|
|
||||||
-- END geome resolution
|
-- END geome resolution
|
||||||
|
|
||||||
|
if not bi then bi="nyancat" end
|
||||||
|
generated=true
|
||||||
end
|
end
|
||||||
if ((data[di]==c_stone)or(data[di]==c_dwg)) and li then
|
if (data[di]==c_stone) then
|
||||||
data[di]=layers[li].ctx
|
data[di]=biomes[bi].ctx
|
||||||
if stats then stats.total=stats.total+1 stats[li]=stats[li]+1 end
|
if stats then stats.total=stats.total+1 stats[bi]=stats[bi]+1 end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nixz= nixz+1
|
|
||||||
end end
|
end end
|
||||||
if n_tp1 then
|
if generated then
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:write_to_map(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
|
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