From 98bba5468aed6f7577eb749d6fa3176f3f8a4875 Mon Sep 17 00:00:00 2001 From: Mat Date: Sat, 14 Jun 2014 03:30:18 +0100 Subject: [PATCH] First commit --- README.txt | 4 ++ depends.txt | 1 + init.lua | 107 +++++++++++++++++++++++++++++++ license.txt | 14 ++++ textures/intersecting_luxore.png | Bin 0 -> 688 bytes 5 files changed, 126 insertions(+) create mode 100644 README.txt create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 license.txt create mode 100644 textures/intersecting_luxore.png diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..67c2943 --- /dev/null +++ b/README.txt @@ -0,0 +1,4 @@ +intersection 0.1.0 by paramat +For latest stable Minetest back to 0.4.8 +Depends default +Licenses: code WTFPL diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..25aead1 --- /dev/null +++ b/init.lua @@ -0,0 +1,107 @@ +-- intersecting 0.1.0 by paramat +-- For latest stable Minetest and back to 0.4.8 +-- Depends default +-- License: code WTFPL + +-- TODO +-- enables 1-3 fissures, isolated tunnels and intersecting tunnels, also isolated tunnel plus 1 fissure + +-- Parameters + +local TFIS = 0.02 + +-- 3D noise for + +local np_weba = { + offset = 0, + scale = 1, + spread = {x=192, y=192, z=192}, + seed = 5900033, + octaves = 3, + persist = 0.6 +} + +-- 3D noise for + +local np_webb = { + offset = 0, + scale = 1, + spread = {x=191, y=191, z=191}, + seed = 33, + octaves = 3, + persist = 0.6 +} + +-- 3D noise for + +local np_webc = { + offset = 0, + scale = 1, + spread = {x=190, y=190, z=190}, + seed = -18000001, + octaves = 3, + persist = 0.6 +} + +-- Stuff + +intersecting = {} + +-- On generated function + +minetest.register_on_generated(function(minp, maxp, seed) + if minp.y > 48 then + return + end + + local t1 = os.clock() + local x1 = maxp.x + local y1 = maxp.y + local z1 = maxp.z + local x0 = minp.x + local y0 = minp.y + local z0 = minp.z + + print ("[interasecting] chunk minp ("..x0.." "..y0.." "..z0..")") + + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} + local data = vm:get_data() + + local c_air = minetest.get_content_id("air") + + local sidelen = x1 - x0 + 1 + local chulens = {x=sidelen, y=sidelen, z=sidelen} + local minposxyz = {x=x0, y=y0, z=z0} + local minposxz = {x=x0, y=z0} + + local nvals_weba = minetest.get_perlin_map(np_weba, chulens):get3dMap_flat(minposxyz) + local nvals_webb = minetest.get_perlin_map(np_webb, chulens):get3dMap_flat(minposxyz) + local nvals_webc = minetest.get_perlin_map(np_webc, chulens):get3dMap_flat(minposxyz) + + local nixyz = 1 + for z = z0, z1 do -- for each xy plane progressing northwards + for y = y0, y1 do -- for each x row progressing upwards + local vi = area:index(x0, y, z) + for x = x0, x1 do -- for each node do + local nodid = data[vi] + local weba = math.abs(nvals_weba[nixyz]) < TFIS + local webb = math.abs(nvals_webb[nixyz]) < TFIS + local webc = math.abs(nvals_webc[nixyz]) < TFIS + if (weba and webb) or (weba and webc) + and nodid ~= c_water then + data[vi] = c_air + end + nixyz = nixyz + 1 + vi = vi + 1 + end + end + end + + vm:set_data(data) + vm:set_lighting({day=0, night=0}) + vm:calc_lighting() + vm:write_to_map(data) + local chugent = math.ceil((os.clock() - t1) * 1000) + print ("[intersecting] "..chugent.." ms") +end) diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..c73f8ae --- /dev/null +++ b/license.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/textures/intersecting_luxore.png b/textures/intersecting_luxore.png new file mode 100644 index 0000000000000000000000000000000000000000..d61338e0cfe38b04337669e145edd0851ecbbfac GIT binary patch literal 688 zcmV;h0#E&kP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RY1r8Sl6RPW7d;kCfLP~FF@SH@v~4O6*~-x5;{dd8TbHf9YFm8h5lKyXUV{jC40USQzc3zq%Nso zN$g5AB`>i9RN{7UY&GqXp7iv5-nrNJoTomVz7wSsN+|$Dgy-jHLV=pu=c1qEe|KBGhZOO#JBZg0I699v>dq*w~;@D4;%` zol4rS=Xs3B<79x4{cEXIqSx-z9dsCvMhM_)jWGuG>HV3^qX+~9K>)i@$cB`*ywhxQ zeSJ;dvaS!JztM)G|>v$s~OWt?=N>(l8J5kW+ zg=JY3i$xH@uU47QW?7+Jst8~gitydVri*7kRI z&(pL;^Er)XV`b`}zr8^zMY&vFIlmen^ZV(ETolK+uFI>P9qRQuQ54Y~bO7iMI?U(u z%!R+vYxjA%wMDLE+ZiFvdnytH0mhgW(G=Z5hw*q!&iDP56xz0pF@_)r0EpuSK@c(= ze*dpCM3Nw-?;ueP06}Y)+05`S(y*maZ%>ZpMc$&(Y^;39o-7bWadsvM_R^I&j`;&E WeI|9rbYNNl0000