From dfd80218086b73eccd567790db103865dbb3768e Mon Sep 17 00:00:00 2001 From: Vanic Date: Sat, 10 Jan 2026 17:12:06 +0300 Subject: [PATCH] Rewrite mapgen --- mods/CORE/MapGen/src/MapGen.lua | 271 ++++++++++++------ mods/CORE/MapGen/src/MapGen/Layer.lua | 84 +++++- mods/CORE/MapGen/src/MapGen/Peak.lua | 79 ++--- .../src/MapGen/Triangulation/FakePeak.lua | 3 +- .../mapGenerator/src/mapGenerator.lua | 41 +-- .../mapGenerator/textures/maps/map.ff | Bin 0 -> 2064 bytes 6 files changed, 283 insertions(+), 195 deletions(-) create mode 100644 mods/ENVIRONMENT/mapGenerator/textures/maps/map.ff diff --git a/mods/CORE/MapGen/src/MapGen.lua b/mods/CORE/MapGen/src/MapGen.lua index ef13178..87c6566 100644 --- a/mods/CORE/MapGen/src/MapGen.lua +++ b/mods/CORE/MapGen/src/MapGen.lua @@ -1,21 +1,23 @@ local mathAbs, mathRound, mathMin, mathMax, id = math.abs, math.round, math.min, math.max, core.get_content_id -local pastNoise2DCalc = { +---@class MapGen.PastCalcNoiseValue +local pastCalcNoiseValue = { ---@type MapGen.Triangle? triangle = nil, ---@type number? x = nil, ---@type number? - y = nil, - noiseValues = { - ---@type number? - height = nil, - ---@type number? - humidity = nil, - ---@type number? - temp = nil, - } + z = nil, + ---@type number? + noiseValue = nil, +} + +---@type table +local pastNoise2DCalc = { + landscape = pastCalcNoiseValue, + temp = pastCalcNoiseValue, + humidity = pastCalcNoiseValue } local modInfo = Mod.getInfo('smc__core__map_gen') @@ -44,7 +46,7 @@ local Cavern = require('MapGen.Cavern') ---@field layersList MapGen.Layer[] ---@field staticsByName table ---@field staticsList MapGen.StaticLayer[] ----@field peaksMultinoiseInitialized boolean Is the fractal noise of the peaks initialized? This is necessary for a one-time noise initialization. +---@field layersNoisesInitialized boolean Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization. ---@field cavernsNoiseInitialized boolean Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization. ---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work. ---@field nodeIDs table @@ -53,9 +55,9 @@ local MapGen = { layersList = {}, staticsByName = {}, staticsList = {}, - peaksMultinoiseInitialized = false, - cavernsNoiseInitialized = false, - isRunning = false, + layersNoisesInitialized = false, + cavernsNoiseInitialized = false, + isRunning = false, } ---Definition table for the `MapGen`. @@ -148,6 +150,19 @@ function MapGen:registerLayer(name, def) end) end +---@param layerName string +---@param category MapGen.Layer.Category TODO: описание +---@param color ColorString TODO: описание +---@param noiseParams NoiseParams +function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams) + ---@type MapGen.Layer + local layer = self.layersByName[layerName] + + assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName)) + + layer:addNoiseParamsColor(category, color, noiseParams) +end + ---Mark the world area between two heights as a `MapGen.StaticLayer`. --- ---Note: layers must not overlap. @@ -175,84 +190,83 @@ end ---Mark a world point as `MapGen.Peak` and assign it a specific noise that will affect the generation. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peak will be included. ----@param peakPos vector The coordinate where the peak will be placed. ----@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation ----@param groups table? Peak groups that may affect processing. -function MapGen:registerPeak(layerName, peakPos, multinoise, groups) +---@param layerName string The name of the layer in which the new peak will be included. +---@param category MapGen.Layer.Category TODO: описание +---@param def MapGen.PeakDef +function MapGen:registerPeak(layerName, category, def) ---@type MapGen.Layer local layer = self.layersByName[layerName] assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName)) - if not layer then - error('Invalid layer: ' .. layerName) - end - --TODO: добавить проверку, что координата пиков не совпадают ---@type MapGen.Peak - local peak = Peak:new(peakPos, multinoise, groups) + local peak = Peak:new(def) - layer:addPeak(peak) + layer:addPeak(category, peak) end ---Mark a world point as `MapGen.Peak` and assign it a specific noise that will affect the generation. ---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peak will be included. ----@param peakPos vector The coordinate where the peak will be placed. ----@param multinoise MapGen.Peak.MultinoiseParams Noise that will be assigned to the peak and that will influence map generation. ----@param groups table? Peak groups that may affect processing. -function MapGen:register2DPeak(layerName, peakPos, multinoise, groups) - local _peakPos = table.copy_with_metatables(peakPos) - _peakPos.y = 0 +---@param layerName string The name of the layer in which the new peak will be included. +---@param category MapGen.Layer.Category TODO: описание +---@param def MapGen.PeakDef +function MapGen:register2DPeak(layerName, category, def) + def = table.copy_with_metatables(def) - if groups == nil then - groups = {is2d = 1} + def.pos.y = 0 + + if def.groups == nil then + def.groups = {is2d = 1} else - groups.is2d = 1 + def.groups.is2d = 1 end - self:registerPeak(layerName, _peakPos, multinoise, groups) + self:registerPeak(layerName, category, def) end ---Mark the world points as `MapGen.Peak` and assign them all a specific noise that will affect generation. ---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peaks will be included. ----@param multinoise MapGen.Peak.MultinoiseParams The noise that will be assigned to each peak and will affect the map generation. ----@param peakPoses vector[] Set the coordinates where the peaks will be placed. ----@param groups table? Peak groups that may affect processing. -function MapGen:register2DPeaks(layerName, multinoise, peakPoses, groups) - for _, peakPos in ipairs(peakPoses) do - self:register2DPeak(layerName, peakPos, multinoise, groups) +---@param layerName string The name of the layer in which the new peaks will be included. +---@param category MapGen.Layer.Category TODO: описание +---@param defs MapGen.PeakDef[] +function MapGen:register2DPeaks(layerName,category, defs) + for _, def in ipairs(defs) do + self:register2DPeak(layerName, category, def) end end ---TODO: описание ----@alias PeakColors table?}> - ----TODO: описание ----@param layerName string The name of the layer in which the new peaks will be included. ----@param map string TODO ----@param zeroPos Position2d ----@param peakColors PeakColors TODO -function MapGen:register2DPeaksFromFile(layerName, map, zeroPos,peakColors) +---@param layerName string The name of the layer in which the new peaks will be included. +---@param map string TODO: описание +---@param scale number TODO: описание +---@param zeroPos Position2d TODO: описание +---@param category MapGen.Layer.Category TODO: описание +---@param groups? table +function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups) local modPath = core.get_modpath(core.get_current_modname()) local peaks = Api.ff2luat(modPath .. '/textures/maps/' .. map) + local mapSize = peaks.size peaks.size = nil - print(dump(peaks)) for color, peaksPos in pairs(peaks) do - local peakParams = peakColors[color] - assert(peakParams ~= nil, ('There are no generation settings declared for the color `%s`'):format(color)) - for _, peakPos in ipairs(peaksPos) do - self:register2DPeak(layerName, vector.new(peakPos.x - zeroPos.x, 0, peakPos.y - zeroPos.y), peakParams.noise, peakParams.groups) + ---@type MapGen.PeakDef + local def = { + pos = vector.new((peakPos.x - zeroPos.x) * scale, 0, (peakPos.y - zeroPos.y) * scale), + color = color, + groups = groups, + } + + print(peakPos.x, peakPos.y) + + self:register2DPeak(layerName, category, def) end end end @@ -293,8 +307,18 @@ end function MapGen:initLayersTriangultaion() ---@param layer MapGen.Layer for _, layer in ipairs(self.layersList) do - layer.trianglesList = Triangulation.triangulate(layer.peaksList) - -- layer.tetrahedronsList = Triangulation.tetrahedralize(layer.peaksList) + for category, peaks in pairs(layer.peaksList) do + + layer.trianglesList[category] = Triangulation.triangulate(peaks) + -- layer.tetrahedronsList = Triangulation.tetrahedralize(layer.peaksList) -- 3D not supported + end + end +end + +function MapGen:initLayersNoises() + ---@param layer MapGen.Layer + for _, layer in ipairs(self.layersList) do + layer:initNoises() end end @@ -306,22 +330,6 @@ function MapGen:initBiomesDiagram() end end - ----Initialize peak's noises. This should be called after the map object is loaded. -function MapGen:initPeaksMultinoise() - ---@param layer MapGen.Layer - for _, layer in ipairs(self.layersList) do - - ---@param peak MapGen.Peak - for _, peak in ipairs(layer.peaksList) do - peak:initMultinoise() - end - - end - - self.peaksMultinoiseInitialized = true -end - ---Initialize caverns's noises. This should be called after the map object is loaded. function MapGen:initCavernsNoise() ---@param layer MapGen.Layer @@ -507,6 +515,46 @@ local function pointInTriangle(px, pz, triangle) return (u >= 0) and (v >= 0) and (u + v <= 1) end +---Returns the weighted values of 2d noise. +---@param category MapGen.Layer.Category +---@param layer MapGen.Layer +---@param triangle MapGen.Triangle +---@param x number +---@param y number +---@param z number +---@return number +local function calcNoise2dValue(category, layer, triangle, x, y, z) + local peak1 = triangle.p1 + local peak2 = triangle.p2 + local peak3 = triangle.p3 + + local noise1 = layer:getNoiseByColor(category, peak1:getColor()) + local noise2 = layer:getNoiseByColor(category, peak2:getColor()) + local noise3 = layer:getNoiseByColor(category, peak3:getColor()) + + local noiseValue = 0.0 + + local totalWeight = 0.0 + + -- We calculate the noise value using the smoothing formula: + -- ( peak1 * weight1 + peak2 * weight2 + peak3 * weight3) / totalWeight, when + -- totalWeight = weight1 + weight2 + weight3 + local weight = calcWeight(triangle.h1, x, y, z) + noiseValue = noiseValue + noise1:get_2d({x = x, y = z}) * weight + totalWeight = totalWeight + weight + + weight = calcWeight(triangle.h2, x, y, z) + noiseValue = noiseValue + noise2:get_2d({x = x, y = z}) * weight + totalWeight = totalWeight + weight + + weight = calcWeight(triangle.h3, x, y, z) + noiseValue = noiseValue + noise3:get_2d({x = x, y = z}) * weight + totalWeight = totalWeight + weight + + return (noiseValue / totalWeight) +end + +--[[ ---Returns the weighted values of 2d noises. ---@param triangle MapGen.Triangle ---@param x number @@ -546,8 +594,55 @@ local function calcNoises2dValues(triangle, x, y, z) totalWeight = totalWeight + weight return noiseHeightValue / totalWeight, noiseTempValue / totalWeight, noiseHumidityValue / totalWeight +end--]] + +---Calculates a smoothed 2D noise value based on a preliminary space partitioning. +--- +---Returns `nil` if the point is not included in any triangle. +---@param category MapGen.Layer.Category +---@param layer MapGen.Layer +---@param x number +---@param y number +---@param z number +---@return number? +function MapGen:getNoises2dValue(category, layer, x, y, z) + ---@type MapGen.PastCalcNoiseValue + local pastCalc = pastNoise2DCalc[category] + + if (pastCalc.x ~= nil and pastCalc.z ~= nil) and (x == pastCalc.x and z == pastCalc.z) then + return pastCalc.noiseValue + end + + if pastCalc.triangle ~= nil and pointInTriangle(x, z, pastCalc.triangle) then + local noiseValue = calcNoise2dValue(category, layer, pastCalc.triangle, x, y, z) + + pastCalc.x = x + pastCalc.z = z + pastCalc.noiseValue = noiseValue + + return noiseValue + end + + ---@param triangle MapGen.Triangle + for _, triangle in ipairs(layer.trianglesList[category]) do + if pointInTriangle(x, z,triangle) then + local noiseValue = calcNoise2dValue(category, layer, triangle, x, y, z) + + pastCalc.triangle = triangle + pastCalc.x = x + pastCalc.z = z + pastCalc.noiseValue = noiseValue + + return noiseValue + end + end + + -- If the point does not fall within the triangle, it is impossible to calculate the height. + -- For debugging purposes only, may slow down generation: + --core.log('warning', string.format('The point %s %s %s does not fall within any triangle, calculating the noise value is impossible.', tostring(x), tostring(y), tostring(z))) end +--[[ ---Calculates a smoothed 2D noise value based on a preliminary space partitioning. --- ---Returns `nil` if the point is not included in any triangle. @@ -601,6 +696,7 @@ function MapGen:getNoises2dValues(layer, x, y, z) -- For debugging purposes only, may slow down generation: --core.log('warning', string.format('The point %s %s %s does not fall within any triangle, calculating the noise value is impossible.', tostring(x), tostring(y), tostring(z))) end +--]] --[[ 3D noise smoothing is too slow, so it was decided to stop using it. @@ -717,17 +813,18 @@ local function generatorHandler(mapGenerator, data, index, x, y, z) end -- Calculating landscape height - local noiseHeightValue, noiseTempValue, noiseHumidityValue = mapGenerator:getNoises2dValues(layer, x, y, z) - - -- If the height of the landscape is `nil`, + -- If the value of the noise is `nil`, -- then the point does not fall within any of the triangles. - if noiseHeightValue == nil then - noiseHeightValue = 0.0 - noiseTempValue = 0.0 - noiseHumidityValue = 0.0 - end + local noiseHeightValue = mapGenerator:getNoises2dValue('landscape', layer, x, y, z) or 0.0 + local noiseTempValue = mapGenerator:getNoises2dValue('temp', layer, x, y, z) or 0.0 + local noiseHumidityValue = mapGenerator:getNoises2dValue('humidity', layer, x, y, z) or 0.0 + + -- We recalculate the climate based on altitude. + noiseTempValue = layer:calcTemp(noiseTempValue, y) + noiseHumidityValue = layer:calcHumidity(noiseHumidityValue, y) + + --print(noiseHeightValue, noiseTempValue, noiseHumidityValue) - ---@diagnostic disable-next-line: param-type-not-match generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z) end @@ -742,8 +839,8 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed) local eMin, eMax = voxelManip:get_emerged_area() - if not self.peaksMultinoiseInitialized then - self:initPeaksMultinoise() + if not self.layersNoisesInitialized then + self:initLayersNoises() end if not self.cavernsNoiseInitialized then @@ -804,6 +901,10 @@ function MapGen:run() self:initLayersTriangultaion() MapGen.isRunning = true + + for _, peak in ipairs(self.layersList[1].peaksList["landscape"]) do + print(tostring(peak)) + end end return MapGen diff --git a/mods/CORE/MapGen/src/MapGen/Layer.lua b/mods/CORE/MapGen/src/MapGen/Layer.lua index 96aabb6..ed5551e 100644 --- a/mods/CORE/MapGen/src/MapGen/Layer.lua +++ b/mods/CORE/MapGen/src/MapGen/Layer.lua @@ -10,7 +10,8 @@ ---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number ---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number ---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]} ----@field colorsList {['landscape']:table,['temp']:table,['humidity']:table} +---@field noisesByColor {['landscape']:table,['temp']:table,['humidity']:table} +---@field noisesParamsByColor {['landscape']:table,['temp']:table,['humidity']:table} ---@field biomesByName table ---@field biomesList MapGen.Biome[] ---@field biomesDiagram table @@ -18,15 +19,20 @@ ---@field biomesVerticalScattering number ---@field cavernsByName table ---@field cavernsList MapGen.Cavern[] ----@field trianglesList MapGen.Triangle[] ----@field tetrahedronsList MapGen.Tetrahedron[] +---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]} +---@field tetrahedronsList MapGen.Tetrahedron[] **Not supported** local Layer = { peaksList = { landscape = {}, temp = {}, humidity = {}, }, - colorsList = { + noisesByColor = { + landscape = {}, + temp = {}, + humidity = {}, + }, + noisesParamsByColor = { landscape = {}, temp = {}, humidity = {}, @@ -36,7 +42,11 @@ local Layer = { biomesDiagram = {}, cavernsByName = {}, cavernsList = {}, - trianglesList = {}, + trianglesList = { + landscape = {}, + temp = {}, + humidity = {}, + }, tetrahedronsList = {}, } @@ -97,9 +107,11 @@ function Layer:new(name, def) return instance end +---@alias MapGen.Layer.Category 'landscape'|'temp'|'humidity' + ---Adds a peak to the `Layer.peaksList` ----@param category 'landscape'|'temp'|'humidity' ----@param peak MapGen.Peak +---@param category MapGen.Layer.Category TODO: описание +---@param peak MapGen.Peak TODO: описание function Layer:addPeak(category, peak) if category == 'landscape' then table.insert(self.peaksList.landscape, peak) @@ -112,20 +124,49 @@ function Layer:addPeak(category, peak) end end ----Adds a color to the `Layer.colorsList` ----@param category 'landscape'|'temp'|'humidity' ----@param color ColorString -function Layer:addColor(category, color) +---Adds a NoiseParams color to the `Layer.noisesParamsByColor` +---@param category MapGen.Layer.Category TODO: описание +---@param color ColorString TODO: описание +---@param noiseParams NoiseParams +function Layer:addNoiseParamsColor(category, color, noiseParams) color = core.colorspec_to_colorstring(core.colorspec_to_table(color)) + local noisesParams = self.noisesParamsByColor + if category == 'landscape' then - table.insert(self.colorsList.landscape, color) + assert(noisesParams.landscape[color] == nil, ('The color `%s` already exists.'):format(color)) + noisesParams.landscape[color] = noiseParams elseif category == 'temp' then - table.insert(self.colorsList.temp, color) + assert(noisesParams.temp[color] == nil, ('The color `%s` already exists.'):format(color)) + noisesParams.temp[color] = noiseParams elseif category == 'humidity' then - table.insert(self.colorsList.humidity, color) + assert(noisesParams.humidity[color] == nil, ('The color `%s` already exists.'):format(color)) + noisesParams.humidity[color] = noiseParams else - error(('There is no color category named %s.'):format(category)) + error(('There is no color category named `%s`.'):format(category)) + end +end + +---Returns noise corresponding to a color. +---@param category MapGen.Layer.Category TODO: описание +---@param color ColorString TODO: описание +---@return ValueNoise +function Layer:getNoiseByColor(category, color) + color = core.colorspec_to_colorstring(core.colorspec_to_table(color)) + + local noises = self.noisesByColor + + if category == 'landscape' then + assert(noises.landscape[color] ~= nil, ('`%s` color does not exist.'):format(color)) + return noises.landscape[color] + elseif category == 'temp' then + assert(noises.temp[color] ~= nil, ('`%s` color does not exist.'):format(color)) + return noises.temp[color] + elseif category == 'humidity' then + assert(noises.humidity[color] ~= nil, ('`%s` color does not exist.'):format(color)) + return noises.humidity[color] + else + error(('There is no color category named `%s`.'):format(category)) end end @@ -164,6 +205,19 @@ local function getBiomesNamesByHeight(height, biomesList) return biomesNames, biomes end +---Initializes noise for generation. +--- +---Should only be called after the mapgen object has been loaded. +function Layer:initNoises() + local noises = self.noisesByColor + + for category, noisesParams in pairs(self.noisesParamsByColor) do + for color, noiseParams in pairs(noisesParams) do + noises[category][color] = core.get_value_noise(noiseParams) + end + end +end + ---Initialization of the biome diagram using the Voronoi method. function Layer:initBiomesDiagram() local diagram = self.biomesDiagram diff --git a/mods/CORE/MapGen/src/MapGen/Peak.lua b/mods/CORE/MapGen/src/MapGen/Peak.lua index 3d1dc68..af9dc8d 100644 --- a/mods/CORE/MapGen/src/MapGen/Peak.lua +++ b/mods/CORE/MapGen/src/MapGen/Peak.lua @@ -1,56 +1,35 @@ ---@class MapGen.Peak ---@field id number ---@field getPeakPos fun():vector ----@field getMultinoiseParams fun():MapGen.Peak.MultinoiseParams ----@field getMultinoise fun():MapGen.Peak.Multinoise ----@field initMultinoise fun() +---@field getColor fun():ColorString ---@field getGroups fun():table local Peak = { id = 0, } --- --- Helpers functions --- - ----@param multinoiseParams MapGen.Peak.MultinoiseParams ----@return MapGen.Peak.Multinoise -local function multinoiseParamsToMultinoise(multinoiseParams) - ---@diagnostic disable-next-line: missing-fields - ---@type MapGen.Peak.Multinoise - local multinoise = {} - - for noiseName, noiseParams in pairs(multinoiseParams) do - multinoise[noiseName] = core.get_value_noise(noiseParams) - end - - return multinoise -end - - - -- --- Class registration --- ----@param peakPos vector ----@param multinoiseParams MapGen.Peak.MultinoiseParams ----@param groups? table ----@return MapGen.Peak -function Peak:new(peakPos, multinoiseParams, groups) - ---@type vector - local _peakPos = peakPos - ---@type MapGen.Peak.MultinoiseParams - local _multinoiseParams = multinoiseParams +---Definition table for the `MapGen.Peak`. +--- +---**Only for EmmyLua.** +---@class MapGen.PeakDef +---@field pos vector +---@field color ColorString +---@field groups? table +---@param def MapGen.PeakDef +---@return MapGen.Peak +function Peak:new(def) + local _pos = def.pos + local _color = def.color local _groups - if groups == nil then + if def.groups == nil then _groups = {} else - _groups = groups + _groups = def.groups end - ---@diagnostic disable-next-line: missing-fields - ---@type MapGen.Peak.Multinoise - local _multinoise = {} -- note: must be empty until luanti mapgen objects are loaded. - ---@type MapGen.Peak local instance = setmetatable({}, { @@ -60,35 +39,15 @@ function Peak:new(peakPos, multinoiseParams, groups) }) function instance:getPeakPos() - return vector.new(_peakPos.x, _peakPos.y, _peakPos.z) + return _pos:copy() end - function instance:getMultinoiseParams() - return _multinoiseParams - end - - function instance:getMultinoise() - if table.is_empty(_multinoise) then - error('Attempt to get `MapGen.Triangulation.FakePeak` noise (empty noise).') - end - - return _multinoise - end - - function instance:initMultinoise() - if not table.is_empty(_multinoise) then - Logger.warningLog('Multinoise has already been initialized. Re-initialization is not recommended.') - end - - if table.is_empty(_multinoiseParams) then - error('Attempt to initialize `MapGen.Triangulation.FakePeak` noise (noise parameter empty).') - end - - _multinoise = multinoiseParamsToMultinoise(_multinoiseParams) + function instance:getColor() + return _color end function instance:getGroups() - return _groups + return table.copy_with_metatables(_groups) end return instance diff --git a/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua b/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua index 000e2be..c12a183 100644 --- a/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua +++ b/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua @@ -17,8 +17,7 @@ local FakePeak = Class.extend(Peak, {}) ---@param peakPos vector ---@return MapGen.Peak function FakePeak:new(peakPos) - ---@diagnostic disable-next-line: missing-fields, param-type-not-match - local instance = Peak:new(peakPos, {}, 1) + local instance = Peak:new({pos = peakPos, color = '#000000'}) return instance end diff --git a/mods/ENVIRONMENT/mapGenerator/src/mapGenerator.lua b/mods/ENVIRONMENT/mapGenerator/src/mapGenerator.lua index 82a9ec9..d71e187 100644 --- a/mods/ENVIRONMENT/mapGenerator/src/mapGenerator.lua +++ b/mods/ENVIRONMENT/mapGenerator/src/mapGenerator.lua @@ -133,41 +133,16 @@ mapGenerator:register2DPeaks('midgard', v(200, 0, 100), v(-300, 0, -200), })--]] ---[[ -mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', {x=250, y=250}, { - ['#396FFFFF'] = {noise = { - landscapeNoise = land1, - tempNoise = climat2, - humidityNoise = climat2, - } - }, - ['#3FFF26FF'] = {noise = { - landscapeNoise = land2, - tempNoise = climat2, - humidityNoise = climat2, - } - } -})--]] -local N = 32 -for x = -10, 10 do - for z = - 10, 10 do - local land - if math.random(0,1) == 0 then - land = land1 - else - land = land2 - end - - print(x) - - mapGenerator:register2DPeak('midgard', vector.new(x*N, 0, z*N), { - landscapeNoise = land, - tempNoise = climat2, - humidityNoise = climat2, - }) - end +for _, c in ipairs({'landscape', 'temp', 'humidity'}) do + mapGenerator:registerLayerNoiseColor('midgard', c, '#4978c6', land1) + mapGenerator:registerLayerNoiseColor('midgard', c, '#77ea72', land2) end + +mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 64,{x=8, y=8}, 'landscape') +mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=8, y=8}, 'temp') +mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=8, y=8}, 'humidity') + --[[ mapGenerator:registerCavern('midgard', 'cavern1', { minY = -48, diff --git a/mods/ENVIRONMENT/mapGenerator/textures/maps/map.ff b/mods/ENVIRONMENT/mapGenerator/textures/maps/map.ff new file mode 100644 index 0000000000000000000000000000000000000000..dcbda9dae30f132153abf8ae7dbe4f9561c4ece6 GIT binary patch literal 2064 zcmdUqu?>Sj5Cp#jw?!GY43VQxphAkFiAN45S!s3m7%UN>(cbRuJ=3$krt$MGr98gh zJa1dAt=)yguq^A^n&a93;qEYZ_wb?1xjB2#<)V4-K6#k!&*rmz*&KJ3ZlByyU-#&9 z)cjGc{o12GT64Xc9;NHa=G?xUYcHBST8R(w(U3W0uEdWR?e+SaN9#M7E6M2`jjzQ2 X7xg~6_da{@*L`|m)R)agJy-iX=d66< literal 0 HcmV?d00001