acaciatree, pinetree nodes. bugix spawn function. biome blend

This commit is contained in:
paramat 2014-04-14 06:01:05 +01:00
parent b1f138c74c
commit 903acd2ae0
9 changed files with 56 additions and 68 deletions

View File

@ -1,4 +1,4 @@
watershed 0.3.7 by paramat watershed 0.3.8 by paramat
For latest stable Minetest back to 0.4.8 For latest stable Minetest back to 0.4.8
Depends default bucket Depends default bucket
Licenses: code WTFPL, textures CC BY-SA Licenses: code WTFPL, textures CC BY-SA

View File

@ -30,7 +30,7 @@ function watershed_appletree(x, y, z, area, data)
end end
function watershed_pinetree(x, y, z, area, data) function watershed_pinetree(x, y, z, area, data)
local c_tree = minetest.get_content_id("default:tree") local c_wspitree = minetest.get_content_id("watershed:pinetree")
local c_wsneedles = minetest.get_content_id("watershed:needles") local c_wsneedles = minetest.get_content_id("watershed:needles")
local c_snowblock = minetest.get_content_id("default:snowblock") local c_snowblock = minetest.get_content_id("default:snowblock")
for j = -4, 14 do for j = -4, 14 do
@ -75,7 +75,7 @@ function watershed_pinetree(x, y, z, area, data)
end end
end end
local vit = area:index(x, y + j, z) local vit = area:index(x, y + j, z)
data[vit] = c_tree data[vit] = c_wspitree
end end
local vil = area:index(x, y + 15, z) local vil = area:index(x, y + 15, z)
local vila = area:index(x, y + 16, z) local vila = area:index(x, y + 16, z)
@ -129,8 +129,8 @@ function watershed_jungletree(x, y, z, area, data)
end end
function watershed_acaciatree(x, y, z, area, data) function watershed_acaciatree(x, y, z, area, data)
local c_tree = minetest.get_content_id("default:tree") local c_wsactree = minetest.get_content_id("watershed:acaciatree")
local c_wsaccleaf = minetest.get_content_id("watershed:acacialeaf") local c_wsacleaf = minetest.get_content_id("watershed:acacialeaf")
for j = -3, 6 do for j = -3, 6 do
if j == 6 then if j == 6 then
for i = -4, 4 do for i = -4, 4 do
@ -138,7 +138,7 @@ function watershed_acaciatree(x, y, z, area, data)
if not (i == 0 or k == 0) then if not (i == 0 or k == 0) then
if math.random(7) ~= 2 then if math.random(7) ~= 2 then
local vil = area:index(x + i, y + j, z + k) local vil = area:index(x + i, y + j, z + k)
data[vil] = c_wsaccleaf data[vil] = c_wsacleaf
end end
end end
end end
@ -147,7 +147,7 @@ function watershed_acaciatree(x, y, z, area, data)
for i = -2, 2, 4 do for i = -2, 2, 4 do
for k = -2, 2, 4 do for k = -2, 2, 4 do
local vit = area:index(x + i, y + j, z + k) local vit = area:index(x + i, y + j, z + k)
data[vit] = c_tree data[vit] = c_wsactree
end end
end end
elseif j == 4 then elseif j == 4 then
@ -155,13 +155,13 @@ function watershed_acaciatree(x, y, z, area, data)
for k = -1, 1 do for k = -1, 1 do
if math.abs(i) + math.abs(k) == 2 then if math.abs(i) + math.abs(k) == 2 then
local vit = area:index(x + i, y + j, z + k) local vit = area:index(x + i, y + j, z + k)
data[vit] = c_tree data[vit] = c_wsactree
end end
end end
end end
else else
local vit = area:index(x, y + j, z) local vit = area:index(x, y + j, z)
data[vit] = c_tree data[vit] = c_wsactree
end end
end end
end end
@ -247,15 +247,7 @@ if SINGLENODE then
spread = {x=512, y=512, z=512}, spread = {x=512, y=512, z=512},
seed = 593, seed = 593,
octaves = 6, octaves = 6,
persist = 0.3 persist = 0.4
}
local np_fault = {
offset = 0,
scale = 1,
spread = {x=512, y=1024, z=512},
seed = 14440002,
octaves = 6,
persist = 0.5
} }
local np_base = { local np_base = {
offset = 0, offset = 0,
@ -273,23 +265,7 @@ if SINGLENODE then
octaves = 3, octaves = 3,
persist = 0.4 persist = 0.4
} }
local np_temp = { for chunk = 1, 64 do
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 9130,
octaves = 2,
persist = 0.5
}
local np_humid = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = -55500,
octaves = 2,
persist = 0.5
}
for chunk = 1, 32 do
print ("[watershed] searching for spawn "..chunk) print ("[watershed] searching for spawn "..chunk)
local x0 = 80 * math.random(-24, 24) - 32 local x0 = 80 * math.random(-24, 24) - 32
local z0 = 80 * math.random(-24, 24) - 32 local z0 = 80 * math.random(-24, 24) - 32
@ -305,9 +281,6 @@ if SINGLENODE then
local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz) local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz)
local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz) local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz)
local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz)
local nvals_temp = minetest.get_perlin_map(np_temp, chulens):get3dMap_flat(minposxyz)
local nvals_humid = minetest.get_perlin_map(np_humid, chulens):get3dMap_flat(minposxyz)
local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz) local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz)
local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz) local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
@ -317,22 +290,12 @@ if SINGLENODE then
for z = z0, z1 do for z = z0, z1 do
for y = y0, y1 do for y = y0, y1 do
for x = x0, x1 do for x = x0, x1 do
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
local n_base = nvals_base[nixz] local n_base = nvals_base[nixz]
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
local terblen = math.max(1 - math.abs(n_base), 0) local terblen = math.max(1 - math.abs(n_base), 0)
local n_temp = nvals_temp[nixyz] local density = densitybase
local n_humid = nvals_humid[nixyz] + math.abs(nvals_rough[nixyz] * terblen + nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP
local density
if nvals_fault[nixyz] >= 0 then
density = densitybase
+ math.abs(nvals_rough[nixyz] * terblen
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_temp * 0.5)
else
density = densitybase
+ math.abs(nvals_rough[nixyz] * terblen
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_humid * 0.5)
end
if y >= 1 and density > -0.01 and density < 0 then if y >= 1 and density > -0.01 and density < 0 then
ysp = y + 1 ysp = y + 1
xsp = x xsp = x
@ -372,9 +335,11 @@ end
-- ABM -- ABM
-- update luxore light
minetest.register_abm({ minetest.register_abm({
nodenames = {"watershed:luxoreoff"}, nodenames = {"watershed:luxoreoff"},
interval = 7, interval = 13,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
minetest.remove_node(pos) minetest.remove_node(pos)

View File

@ -1,12 +1,16 @@
-- watershed 0.3.7 by paramat -- watershed 0.3.8 by paramat
-- For latest stable Minetest and back to 0.4.8 -- For latest stable Minetest and back to 0.4.8
-- Depends default bucket -- Depends default bucket
-- License: code WTFPL, textures CC BY-SA -- License: code WTFPL, textures CC BY-SA
-- Red cobble texture CC BY-SA by brunob.santos minetestbr.blogspot.com -- Red cobble texture CC BY-SA by brunob.santos minetestbr.blogspot.com
-- thicker layer of redstone in deserts -- pine, acacia tree trunks
-- ice thicker with lower temperature -- bugfix spawning function
-- papyrus on riverbank not beach -- temperature / humidity randomness for biome blend
-- TODO
-- pine wood
-- acacia wood
-- better appletree design with branches
-- Parameters -- Parameters
@ -28,7 +32,7 @@ local TSTONE = 0.02 -- Density threshold for stone, depth of soil at TERCEN
local TRIV = -0.02 -- Maximum densitybase threshold for river water local TRIV = -0.02 -- Maximum densitybase threshold for river water
local TSAND = -0.025 -- Maximum densitybase threshold for river sand local TSAND = -0.025 -- Maximum densitybase threshold for river sand
local TLAVA = 2.3 -- Maximum densitybase threshold for lava, small because grad is non-linear local TLAVA = 2.3 -- Maximum densitybase threshold for lava, small because grad is non-linear
local FISEXP = 0.02 -- Fissure expansion rate under surface local FISEXP = 0.03 -- Fissure expansion rate under surface
local ORETHI = 0.002 -- Ore seam thickness tuner local ORETHI = 0.002 -- Ore seam thickness tuner
local SEAMT = 0.2 -- Seam threshold, width of seams local SEAMT = 0.2 -- Seam threshold, width of seams
local ICETHI = 32 -- Controls maximum ice thickness local ICETHI = 32 -- Controls maximum ice thickness
@ -38,19 +42,20 @@ local LOTET = -0.35 -- Low ..
local ICETET = -0.7 -- Ice .. local ICETET = -0.7 -- Ice ..
local HIHUT = 0.35 -- High humidity threshold local HIHUT = 0.35 -- High humidity threshold
local LOHUT = -0.35 -- Low .. local LOHUT = -0.35 -- Low ..
local BLEND = 0.03 -- Biome blend randomness
local PINCHA = 36 -- Pine tree 1/x chance per node local PINCHA = 36 -- Pine tree 1/x chance per node
local APTCHA = 36 -- Appletree local APTCHA = 36 -- Appletree
local FLOCHA = 36 -- Flower local FLOCHA = 36 -- Flower
local FOGCHA = 9 -- Forest grass local FOGCHA = 9 -- Forest grass
local GRACHA = 3 -- Grassland grasses local GRACHA = 4 -- Grassland grasses
local JUTCHA = 16 -- Jungletree local JUTCHA = 16 -- Jungletree
local JUGCHA = 9 -- Junglegrass local JUGCHA = 9 -- Junglegrass
local CACCHA = 841 -- Cactus local CACCHA = 841 -- Cactus
local DRYCHA = 169 -- Dry shrub local DRYCHA = 169 -- Dry shrub
local PAPCHA = 2 -- Papyrus local PAPCHA = 2 -- Papyrus
local ACACHA = 529 -- Acacia tree local ACACHA = 529 -- Acacia tree
local GOGCHA = 3 -- Golden grass local GOGCHA = 4 -- Golden grass
-- 3D noise for rough terrain -- 3D noise for rough terrain
@ -70,7 +75,7 @@ local np_smooth = {
scale = 1, scale = 1,
spread = {x=512, y=512, z=512}, spread = {x=512, y=512, z=512},
seed = 593, seed = 593,
octaves = 5, octaves = 6,
persist = 0.4 persist = 0.4
} }
@ -266,20 +271,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
local n_rough = nvals_rough[nixyz] -- noise values for node local n_rough = nvals_rough[nixyz] -- noise values for node
local n_smooth = nvals_smooth[nixyz] local n_smooth = nvals_smooth[nixyz]
local n_fissure = nvals_fissure[nixyz] local n_fissure = nvals_fissure[nixyz]
local n_temp = nvals_temp[nixyz] local n_temp = nvals_temp[nixyz] + (math.random() - 0.5) * BLEND
local n_humid = nvals_humid[nixyz] local n_humid = nvals_humid[nixyz] + (math.random() - 0.5) * BLEND
local n_seam = nvals_seam[nixyz] local n_seam = nvals_seam[nixyz]
local n_strata = nvals_strata[nixyz] local n_strata = nvals_strata[nixyz]
local n_base = nvals_base[nixz] local n_base = nvals_base[nixz]
local n_xlscale = nvals_xlscale[nixz] local n_xlscale = nvals_xlscale[nixz]
local n_magma = nvals_magma[nixz] local n_magma = nvals_magma[nixz]
-- get densitybase and density
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP -- get densitybase and density local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP -- vertical density gradient
local densitybase = (1 - math.abs(n_base)) * BASAMP + n_xlscale * XLSAMP + grad local densitybase = (1 - math.abs(n_base)) * BASAMP + n_xlscale * XLSAMP + grad -- base terrain or ridge networks
local terblen = math.max(1 - math.abs(n_base), 0) local terblen = math.max(1 - math.abs(n_base), 0) -- terrain blend rough and smooth
local density = densitybase local density = densitybase
+ math.abs(n_rough * terblen + n_smooth * (1 - terblen)) ^ CANEXP * CANAMP + math.abs(n_rough * terblen + n_smooth * (1 - terblen)) ^ CANEXP * CANAMP -- add canyon terrain
local triv = TRIV * (1 - terblen) -- other values local triv = TRIV * (1 - terblen) -- other values
local tsand = TSAND * (1 - terblen) local tsand = TSAND * (1 - terblen)

View File

@ -13,13 +13,22 @@ minetest.register_node("watershed:acacialeaf", {
description = "WS Acacia Leaves", description = "WS Acacia Leaves",
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
tiles = {"default_leaves.png"}, tiles = {"watershed_acacialeaf.png"},
paramtype = "light", paramtype = "light",
is_ground_content = false, is_ground_content = false,
groups = {snappy=3, flammable=2, leaves=1}, groups = {snappy=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
minetest.register_node("watershed:acaciatree", {
description = "WS Acacia Tree",
tiles = {"watershed_acaciatreetop.png", "watershed_acaciatreetop.png", "watershed_acaciatree.png"},
paramtype2 = "facedir",
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("watershed:needles", { minetest.register_node("watershed:needles", {
description = "WS Pine Needles", description = "WS Pine Needles",
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
@ -31,6 +40,15 @@ minetest.register_node("watershed:needles", {
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
minetest.register_node("watershed:pinetree", {
description = "WS Pine Tree",
tiles = {"watershed_pinetreetop.png", "watershed_pinetreetop.png", "watershed_pinetree.png"},
paramtype2 = "facedir",
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("watershed:jungleleaf", { minetest.register_node("watershed:jungleleaf", {
description = "WS Jungletree Leaves", description = "WS Jungletree Leaves",
drawtype = "allfaces_optional", drawtype = "allfaces_optional",

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B