Mapgen: write SuperUltraSigmaMapgen part 5.4
This commit is contained in:
@@ -138,8 +138,8 @@ end
|
|||||||
---@param layerName string The name of the layer in which the new peak will be included.
|
---@param layerName string The name of the layer in which the new peak will be included.
|
||||||
---@param peakPos vector
|
---@param peakPos vector
|
||||||
---@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation
|
---@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation
|
||||||
---@param groups table<string, number> TODO: описание
|
---@param groups table<string, number>? TODO: описание
|
||||||
function MapGen:RegisterPeak(layerName, peakPos, multinoise, groups)
|
function MapGen:registerPeak(layerName, peakPos, multinoise, groups)
|
||||||
---@type MapGen.Layer
|
---@type MapGen.Layer
|
||||||
local layer = self.layersByName[layerName]
|
local layer = self.layersByName[layerName]
|
||||||
|
|
||||||
@@ -158,6 +158,35 @@ function MapGen:RegisterPeak(layerName, peakPos, multinoise, groups)
|
|||||||
return peak --TODO: временно?
|
return peak --TODO: временно?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---TODO: описание
|
||||||
|
---@param layerName string The name of the layer in which the new peak will be included.
|
||||||
|
---@param peakPos vector
|
||||||
|
---@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation
|
||||||
|
---@param groups table<string, number>? TODO: описание
|
||||||
|
function MapGen:register2DPeak(layerName, peakPos, multinoise, groups)
|
||||||
|
local _peakPos = table.copy_with_metatables(peakPos)
|
||||||
|
_peakPos.y = 0
|
||||||
|
|
||||||
|
if groups == nil then
|
||||||
|
groups = {is2d = 1}
|
||||||
|
else
|
||||||
|
groups.is2d = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
self:registerPeak(layerName, _peakPos, multinoise, groups)
|
||||||
|
end
|
||||||
|
|
||||||
|
---TODO: описание
|
||||||
|
---@param layerName string The name of the layer in which the new peak will be included.
|
||||||
|
---@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation
|
||||||
|
---@param peakPoses vector[]
|
||||||
|
---@param groups table<string, number>? TODO: описание
|
||||||
|
function MapGen:register2DPeaks(layerName, multinoise, peakPoses, groups)
|
||||||
|
for _, peakPos in ipairs(peakPoses) do
|
||||||
|
self:register2DPeak(layerName, peakPos, multinoise, groups)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Initialize peak noise. This should be called after the map object is loaded.
|
---Initialize peak noise. This should be called after the map object is loaded.
|
||||||
function MapGen:initPeaksMultinoise()
|
function MapGen:initPeaksMultinoise()
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
@@ -245,7 +274,42 @@ local function generateRock(ids, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---DEV noises
|
||||||
|
---@type NoiseParams
|
||||||
|
local caveNoiseParams1 = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x = 25, y = 25, z = 25},
|
||||||
|
seed = 5934,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.5,
|
||||||
|
lacunarity = 2.0
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type NoiseParams
|
||||||
|
local caveNoiseParams2 = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x = 50, y = 10, z = 50}, -- Y меньше для горизонтального вытягивания
|
||||||
|
seed = -1034,
|
||||||
|
octaves = 2,
|
||||||
|
persistence = 0.6,
|
||||||
|
lacunarity = 2.0
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type ValueNoise, ValueNoise
|
||||||
|
local caveNoise1, caveNoise2
|
||||||
|
local function isCave(layer, x, y, z)
|
||||||
|
if caveNoise1 == nil or caveNoise2 == nil then
|
||||||
|
caveNoise1 = core.get_value_noise(caveNoiseParams1)
|
||||||
|
caveNoise2 = core.get_value_noise(caveNoiseParams2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return caveNoise1:get_3d({x = x, y = y, z = z}) * caveNoise2:get_3d({x = x, y = y, z = z}) * 0.3 > 0.05
|
||||||
|
end
|
||||||
|
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param layer MapGen.Layer
|
||||||
---@param hight number
|
---@param hight number
|
||||||
---@param temp number
|
---@param temp number
|
||||||
---@param humidity number
|
---@param humidity number
|
||||||
@@ -254,22 +318,31 @@ end
|
|||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local function generateNode(mapGenerator, hight, temp, humidity, data, index, x, y, z)
|
local function generateNode(mapGenerator, layer, hight, temp, humidity, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
|
|
||||||
temp = mathMin(100, mathMax(0, temp))
|
local m = math.random(-10, 10)
|
||||||
humidity = mathMin(100, mathMax(0, humidity))
|
|
||||||
|
temp = mathMin(100, mathMax(0, temp + m))
|
||||||
|
humidity = mathMin(100, mathMax(0, humidity + m))
|
||||||
|
|
||||||
local biome = mapGenerator.biomesDiagram[mathRound(temp)][mathRound(humidity)]
|
local biome = mapGenerator.biomesDiagram[mathRound(temp)][mathRound(humidity)]
|
||||||
|
|
||||||
if y > hight and y > 0 then
|
if y > hight and y > 0 then
|
||||||
data[index] = ids.air
|
data[index] = ids.air
|
||||||
elseif y == hight and y > 0 then
|
elseif y > hight and y <= 0 then
|
||||||
generateSoil(biome, data, index, x, y, z)
|
|
||||||
elseif y < hight then
|
|
||||||
generateRock(ids, data, index, x, y, z)
|
|
||||||
else
|
|
||||||
data[index] = ids.water
|
data[index] = ids.water
|
||||||
|
elseif y <= hight then
|
||||||
|
if isCave(layer, x, y, z) then
|
||||||
|
data[index] = ids.air
|
||||||
|
elseif y == hight then
|
||||||
|
generateSoil(biome, data, index, x, y, z)
|
||||||
|
else
|
||||||
|
generateRock(ids, data, index, x, y, z)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
data[index] = ids.air
|
||||||
|
-- TODO: добавить error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -538,7 +611,7 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@diagnostic disable-next-line: param-type-not-match
|
---@diagnostic disable-next-line: param-type-not-match
|
||||||
generateNode(mapGenerator, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
|
generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param minPos table
|
---@param minPos table
|
||||||
@@ -570,9 +643,10 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed)
|
|||||||
|
|
||||||
-- We make changes back to LVM and recalculate light & liquids
|
-- We make changes back to LVM and recalculate light & liquids
|
||||||
voxelManip:set_data(data)
|
voxelManip:set_data(data)
|
||||||
-- voxelManip:set_param2_data(param2_data)
|
--voxelManip:set_param2_data()
|
||||||
voxelManip:update_liquids()
|
voxelManip:set_lighting({ day = 0, night = 0})
|
||||||
voxelManip:calc_lighting()
|
voxelManip:calc_lighting()
|
||||||
|
voxelManip:update_liquids()
|
||||||
|
|
||||||
voxelManip:write_to_map()
|
voxelManip:write_to_map()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ local mapGenerator = Core.MapGen.Class:new({
|
|||||||
mapGenerator:RegisterLayer("world", -1000, 500)
|
mapGenerator:RegisterLayer("world", -1000, 500)
|
||||||
|
|
||||||
local land1 = {
|
local land1 = {
|
||||||
offset = -10,
|
offset = -20,
|
||||||
scale = 2,
|
scale = 5,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
spread = {x = 10, y = 10, z = 10},
|
||||||
seed = 47,
|
seed = 47,
|
||||||
octaves = 8,
|
octaves = 3,
|
||||||
persistence = 0.4,
|
persistence = 0.4,
|
||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
local land2 = {
|
local land2 = {
|
||||||
offset = 20,
|
offset = 20,
|
||||||
scale = 2,
|
scale = 5,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
spread = {x = 10, y = 10, z = 10},
|
||||||
seed = 47,
|
seed = 47,
|
||||||
octaves = 8,
|
octaves = 3,
|
||||||
persistence = 0.4,
|
persistence = 0.4,
|
||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
}
|
}
|
||||||
@@ -71,51 +71,39 @@ local climat0 = {
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
---LAND
|
local v = vector.new
|
||||||
mapGenerator:RegisterPeak("world",
|
|
||||||
vector.new(0,0,0),
|
|
||||||
{
|
|
||||||
landscapeNoise = land2,
|
|
||||||
tempNoise = climat2,
|
|
||||||
humidityNoise = climat2,
|
|
||||||
},
|
|
||||||
{is2d = 1, is3d = 1})
|
|
||||||
|
|
||||||
mapGenerator:RegisterPeak("world",
|
mapGenerator:register2DPeaks("world",
|
||||||
vector.new(25,0,25),
|
{
|
||||||
{
|
landscapeNoise = land1,
|
||||||
landscapeNoise = land2,
|
tempNoise = climat2,
|
||||||
tempNoise = climat1,
|
humidityNoise = climat2,
|
||||||
humidityNoise = climat1,
|
},{
|
||||||
},
|
v(500, 0, 500),
|
||||||
{is2d = 1, is3d = 1})
|
v(-500, 0, -500),
|
||||||
|
v(-500, 0, 500),
|
||||||
|
v(500, 0, -500),
|
||||||
|
})
|
||||||
|
|
||||||
mapGenerator:RegisterPeak("world",
|
mapGenerator:register2DPeaks("world",
|
||||||
vector.new(-25,0,-25),
|
{
|
||||||
{
|
landscapeNoise = land2,
|
||||||
landscapeNoise = land2,
|
tempNoise = climat1,
|
||||||
tempNoise = climat2,
|
humidityNoise = climat1,
|
||||||
humidityNoise = climat2,
|
},{
|
||||||
},
|
v(-300, 0, 300),
|
||||||
{is2d = 1, is3d = 1})
|
v(200, 0, -400),
|
||||||
|
})
|
||||||
|
|
||||||
mapGenerator:RegisterPeak("world",
|
mapGenerator:register2DPeaks("world",
|
||||||
vector.new(25,0, -25),
|
{
|
||||||
{
|
landscapeNoise = land2,
|
||||||
landscapeNoise = land2,
|
tempNoise = climat2,
|
||||||
tempNoise = climat1,
|
humidityNoise = climat2,
|
||||||
humidityNoise = climat1,
|
},{
|
||||||
},
|
v(200, 0, 100),
|
||||||
{is2d = 1, is3d = 1})
|
v(-300, 0, -200),
|
||||||
|
})
|
||||||
mapGenerator:RegisterPeak("world",
|
|
||||||
vector.new(-25,0,25),
|
|
||||||
{
|
|
||||||
landscapeNoise = land2,
|
|
||||||
tempNoise = climat1,
|
|
||||||
humidityNoise = climat1,
|
|
||||||
},
|
|
||||||
{is2d = 1, is3d = 1})
|
|
||||||
|
|
||||||
mapGenerator:RegisterBiome("biome1", 0, 0, {
|
mapGenerator:RegisterBiome("biome1", 0, 0, {
|
||||||
soil = "soils:clay_soil_baren",
|
soil = "soils:clay_soil_baren",
|
||||||
|
|||||||
Reference in New Issue
Block a user