Vary walls of the Fracture
Added code to make the walls of the rift uneven... some of the time. Still WIP, but best results so far are here. Removed code for finite bottom, as it is no longer used. Commented out lines 53-56 to enable wall varying.
This commit is contained in:
parent
bd6f0c5e62
commit
e3fcaa70a9
@ -4,8 +4,8 @@
|
|||||||
--- constants
|
--- constants
|
||||||
---
|
---
|
||||||
|
|
||||||
local fracrift_width=20 --how wide the rift will be
|
local fracrift_width=80 --how wide the rift will be
|
||||||
local fracrift_depth_air=33000 --how deep before the water
|
--local fracrift_depth_air=33000 --how deep before the water
|
||||||
local fracrift_depth_water=20 --how deep the water will be
|
local fracrift_depth_water=20 --how deep the water will be
|
||||||
local fracrift_top=100 --max height to scan for land to remove
|
local fracrift_top=100 --max height to scan for land to remove
|
||||||
local fracrift_bottomsmooth=0.995 --odds of bottom being smooth
|
local fracrift_bottomsmooth=0.995 --odds of bottom being smooth
|
||||||
@ -23,7 +23,15 @@ local fracrift_waterstart=-(fracrift_depth_air+1)
|
|||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
|
|
||||||
|
-- 3D noise for rift walls
|
||||||
|
local np_walls = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=192, y=512, z=512}, -- squashed 2:1
|
||||||
|
seed = 133742, --a LEET answer to life, the universe, and everything
|
||||||
|
octaves = 3,
|
||||||
|
persist = 0.67
|
||||||
|
}
|
||||||
|
|
||||||
--FRACTURE GENERATION
|
--FRACTURE GENERATION
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
@ -42,10 +50,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local z0 = minp.z
|
local z0 = minp.z
|
||||||
|
|
||||||
--no need to scan outside the rift
|
--no need to scan outside the rift
|
||||||
if x0 < -fracrift_edge then x0=-fracrift_edge end
|
--if x0 < -fracrift_edge then x0=-fracrift_edge end
|
||||||
if x1 > fracrift_edge then x1=fracrift_edge end
|
--if x1 > fracrift_edge then x1=fracrift_edge end
|
||||||
if y0 < fracrift_depth then y0=fracrift_depth end
|
--if y0 < fracrift_depth then y0=fracrift_depth end
|
||||||
if y1 > fracrift_top then y1=fracrift_top end
|
--if y1 > fracrift_top then y1=fracrift_top end
|
||||||
|
|
||||||
print ("[fracrift_ure_gen] chunk minp ("..x0.." "..y0.." "..z0..")") --tell people you are generating a chunk
|
print ("[fracrift_ure_gen] chunk minp ("..x0.." "..y0.." "..z0..")") --tell people you are generating a chunk
|
||||||
|
|
||||||
@ -54,37 +62,44 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
|
local sidelen = x1 - x0 + 1 --length of a mapblock
|
||||||
|
local chulens = {x=sidelen, y=sidelen, z=sidelen} --table of chunk edges
|
||||||
|
local minposxyz = {x=x0, y=y0, z=z0} --bottom corner
|
||||||
|
|
||||||
|
local nvals_walls = minetest.get_perlin_map(np_walls, chulens):get3dMap_flat(minposxyz) -- Get the noise map for the rift walls
|
||||||
|
|
||||||
local changed=false
|
local changed=false
|
||||||
|
|
||||||
|
local nixyz = 1 --3D node index
|
||||||
|
|
||||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||||
for y = y0, y1 do -- for each x row progressing upwards
|
for y = y0, y1 do -- for each x row progressing upwards
|
||||||
for x = x0, x1 do -- for each node do
|
for x = x0, x1 do -- for each node do
|
||||||
local vi = area:index(x, y, z) -- This accesses the node at a given position
|
local vi = area:index(x, y, z) -- This accesses the node at a given position
|
||||||
|
|
||||||
if x > -fracrift_edge and x < fracrift_edge then
|
if x > -fracrift_edge and x < fracrift_edge then
|
||||||
if y > fracrift_depth then
|
local grad = math.abs(x / (fracrift_edge * 1.5))
|
||||||
if y < fracrift_waterstart then -- air or water based on y
|
if ((math.abs(nvals_walls[nixyz]) + grad) > 0.6) and (x < -fracrift_edge/3 or x > fracrift_edge/3) then
|
||||||
if data[vi] ~= c_water then --not water
|
if data[vi] ~= c_air then
|
||||||
if y > (fracrift_depth+1) then
|
data[vi] = fracrift_material
|
||||||
data[vi]=c_water
|
end
|
||||||
changed=true
|
else
|
||||||
--roughen up very bottom layer a little bit
|
data[vi] = c_air
|
||||||
elseif math.random() < fracrift_bottomsmooth then
|
end
|
||||||
--leave a FEW bumps sticking up
|
|
||||||
data[vi]=c_water
|
changed = true
|
||||||
changed=true
|
|
||||||
end -- if y > (fracrift_depth+1)
|
|
||||||
end -- if data[vi] ~= c_water
|
|
||||||
elseif y < fracrift_top and data[vi] ~= c_air then
|
|
||||||
data[vi]=c_air
|
|
||||||
changed=true
|
|
||||||
end --if y < fracrift_waterstart
|
|
||||||
end -- if y > -fracrift_depth
|
|
||||||
end -- if x > -fracrift_edge and x < fracrift_edge
|
end -- if x > -fracrift_edge and x < fracrift_edge
|
||||||
|
|
||||||
if x == -fracrift_edge or x == fracrift_edge then -- x is on edge
|
if x == -fracrift_edge or x == fracrift_edge then -- x is on edge
|
||||||
if data[vi] == c_water and math.random() < fracrift_waterfallchance then
|
if data[vi] == c_water and math.random() < fracrift_waterfallchance then
|
||||||
data[vi]=fracrift_material
|
data[vi]=fracrift_material
|
||||||
changed=true
|
changed=true
|
||||||
end -- change water to stone on edge
|
end -- change water to stone on edge
|
||||||
end -- if x == -fracrift_edge or x == fracrift_edge
|
end -- if x == -fracrift_edge or x == fracrift_edge
|
||||||
|
|
||||||
|
nixyz = nixyz + 1
|
||||||
|
|
||||||
end -- end 'x' loop
|
end -- end 'x' loop
|
||||||
end -- end 'y' loop
|
end -- end 'y' loop
|
||||||
end -- end 'z' loop
|
end -- end 'z' loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user