Mapgen: write SuperUltraSigmaMapgen part 3,2
This commit is contained in:
@@ -48,9 +48,9 @@ local Biome = require("MapGen.Biome")
|
|||||||
local Triangulation = require("MapGen.Triangulation")
|
local Triangulation = require("MapGen.Triangulation")
|
||||||
|
|
||||||
---@class MapGen
|
---@class MapGen
|
||||||
---@field layersByName table
|
---@field layersByName table<string, MapGen.Layer>
|
||||||
---@field layersList table
|
---@field layersList MapGen.Layer[]
|
||||||
---@field biomesList table
|
---@field biomesList MapGen.Biome[]
|
||||||
---@field biomesDiagram table
|
---@field biomesDiagram table
|
||||||
---@field multinoiseInitialized boolean Is the fractal noise of the peaks initialized? This is necessary for a one-time noise initialization.
|
---@field multinoiseInitialized boolean Is the fractal noise of the peaks 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 isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||||
@@ -118,10 +118,16 @@ function MapGen:RegisterLayer(name, minY, maxY)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGen:initLayersTrianglesList()
|
function MapGen:initLayersTrianglesTetrahedronsLists()
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
for _, layer in ipairs(self.layersList) do
|
for _, layer in ipairs(self.layersList) do
|
||||||
layer.trianglesList = Triangulation.triangulate(layer.peaksList)
|
layer.trianglesList = Triangulation.triangulate(layer.peaksList)
|
||||||
|
layer.tetrahedrons = Triangulation.tetrahedralize(layer.peaksList)
|
||||||
|
print('--debug--')
|
||||||
|
for _, t in ipairs(layer.tetrahedrons) do
|
||||||
|
print(tostring(t))
|
||||||
|
end
|
||||||
|
print('--debug--')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -132,9 +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 peakIs2D boolean? If true, the transmitted Y coordinate will be overwritten by the layer boundaries.
|
---@param groups table<string, number> TODO: описание
|
||||||
---@param weightFactor number? The coefficient by which the reduction in the impact of peakal noise on generation will be calculated. If 0, there will be no reduction.
|
function MapGen:RegisterPeak(layerName, peakPos, multinoise, groups)
|
||||||
function MapGen:RegisterPeak(layerName, peakPos, multinoise, peakIs2D, weightFactor)
|
|
||||||
---@type MapGen.Layer
|
---@type MapGen.Layer
|
||||||
local layer = self.layersByName[layerName]
|
local layer = self.layersByName[layerName]
|
||||||
|
|
||||||
@@ -142,21 +147,11 @@ function MapGen:RegisterPeak(layerName, peakPos, multinoise, peakIs2D, weightFac
|
|||||||
error("Invalid layer: " .. layerName)
|
error("Invalid layer: " .. layerName)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: вероятно стоит убрать 2D ячейки
|
|
||||||
if peakIs2D then
|
|
||||||
peakPos.y = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--TODO: добавить проверку, что координата ячейки не совпадают
|
--TODO: добавить проверку, что координата ячейки не совпадают
|
||||||
--TODO: Добавить проверку, что координата ячейки не выходит за границы слоя
|
--TODO: Добавить проверку, что координата ячейки не выходит за границы слоя
|
||||||
|
|
||||||
-- TODO: вероятно стоит убрать вес
|
|
||||||
if weightFactor == nil then
|
|
||||||
weightFactor = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
---@type MapGen.Peak
|
---@type MapGen.Peak
|
||||||
local peak = Peak:new(peakPos, multinoise, weightFactor)
|
local peak = Peak:new(peakPos, multinoise, groups)
|
||||||
|
|
||||||
layer:addPeak(peak)
|
layer:addPeak(peak)
|
||||||
|
|
||||||
@@ -494,7 +489,7 @@ function MapGen:run()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
self:initBiomesDiagram()
|
self:initBiomesDiagram()
|
||||||
self:initLayersTrianglesList()
|
self:initLayersTrianglesTetrahedronsLists()
|
||||||
|
|
||||||
MapGen.isRunning = true
|
MapGen.isRunning = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ local mathSqrt = math.sqrt
|
|||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field peaksList MapGen.Peak[]
|
---@field peaksList MapGen.Peak[]
|
||||||
---@field trianglesList MapGen.Triangle[]
|
---@field trianglesList MapGen.Triangle[]
|
||||||
|
---@field tetrahedrons MapGen.Tetrahedron[]
|
||||||
local Layer = {
|
local Layer = {
|
||||||
peaksList = {},
|
peaksList = {},
|
||||||
trianglesList = {},
|
trianglesList = {},
|
||||||
|
tetrahedrons = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
@@ -29,7 +31,6 @@ end
|
|||||||
---@param peak MapGen.Peak
|
---@param peak MapGen.Peak
|
||||||
function Layer:addPeak(peak)
|
function Layer:addPeak(peak)
|
||||||
table.insert(self.peaksList, peak)
|
table.insert(self.peaksList, peak)
|
||||||
print(dump(self.peaksList))
|
|
||||||
-- TODO: добавить сортировку массива для оптимизации.
|
-- TODO: добавить сортировку массива для оптимизации.
|
||||||
-- Вероятно будет лучше в отдельной фунции и засунуть её в MapGen.run
|
-- Вероятно будет лучше в отдельной фунции и засунуть её в MapGen.run
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
---@field getMultinoiseParams fun():MapGen.Peak.MultinoiseParams
|
---@field getMultinoiseParams fun():MapGen.Peak.MultinoiseParams
|
||||||
---@field getMultinoise fun():MapGen.Peak.Multinoise
|
---@field getMultinoise fun():MapGen.Peak.Multinoise
|
||||||
---@field initMultinoise fun()
|
---@field initMultinoise fun()
|
||||||
---@field getWeightFactor fun():number
|
---@field getGroups fun():table<string, number>
|
||||||
local Peak = {
|
local Peak = {
|
||||||
id = 0,
|
id = 0,
|
||||||
}
|
}
|
||||||
@@ -25,16 +25,20 @@ end
|
|||||||
|
|
||||||
---@param peakPos vector
|
---@param peakPos vector
|
||||||
---@param multinoiseParams MapGen.Peak.MultinoiseParams
|
---@param multinoiseParams MapGen.Peak.MultinoiseParams
|
||||||
---@param weightFactor number TODO: возможно этот параметр не пригодится
|
---@param groups? table<string, number>
|
||||||
---@return MapGen.Peak
|
---@return MapGen.Peak
|
||||||
function Peak:new(peakPos, multinoiseParams, weightFactor)
|
function Peak:new(peakPos, multinoiseParams, groups)
|
||||||
---@type vector
|
---@type vector
|
||||||
local _peakPos = peakPos
|
local _peakPos = peakPos
|
||||||
---@type MapGen.Peak.MultinoiseParams
|
---@type MapGen.Peak.MultinoiseParams
|
||||||
local _multinoiseParams = multinoiseParams
|
local _multinoiseParams = multinoiseParams
|
||||||
|
|
||||||
if weightFactor < 0 then
|
local _groups
|
||||||
weightFactor = 1
|
|
||||||
|
if groups == nil then
|
||||||
|
_groups = {}
|
||||||
|
else
|
||||||
|
_groups = groups
|
||||||
end
|
end
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
@@ -50,7 +54,7 @@ function Peak:new(peakPos, multinoiseParams, weightFactor)
|
|||||||
})
|
})
|
||||||
|
|
||||||
function instance:getPeakPos()
|
function instance:getPeakPos()
|
||||||
return _peakPos
|
return vector.new(_peakPos.x, _peakPos.y, _peakPos.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
function instance:getMultinoiseParams()
|
function instance:getMultinoiseParams()
|
||||||
@@ -69,8 +73,8 @@ function Peak:new(peakPos, multinoiseParams, weightFactor)
|
|||||||
_multinoise = multinoiseParamsToMultinoise(_multinoiseParams)
|
_multinoise = multinoiseParamsToMultinoise(_multinoiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
function instance.getWeightFactor()
|
function instance.getGroups()
|
||||||
return weightFactor
|
return _groups
|
||||||
end
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
@@ -79,7 +83,8 @@ end
|
|||||||
---Returns a string describing the object in a readable form.
|
---Returns a string describing the object in a readable form.
|
||||||
---@return string
|
---@return string
|
||||||
function Peak:toString()
|
function Peak:toString()
|
||||||
return ('Peak (%s) x: %.2f y: %.2f'):format( self.id, self:getPeakPos().x, self:getPeakPos().y )
|
local pos = self:getPeakPos()
|
||||||
|
return ('Peak (%s) x: %.2f y: %.2f z: %.2f'):format( self.id, pos.x, pos.y, pos.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param other MapGen.Peak
|
---@param other MapGen.Peak
|
||||||
@@ -91,27 +96,4 @@ function Peak:eq( other )
|
|||||||
return pos1.x == pos2.x and pos1.z == pos2.z
|
return pos1.x == pos2.x and pos1.z == pos2.z
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param p MapGen.Peak
|
|
||||||
function Peak:dist2(p)
|
|
||||||
local pos1 = self:getPeakPos()
|
|
||||||
local pos2 = p:getPeakPos()
|
|
||||||
|
|
||||||
local dx, dy = (pos1.x - pos2.x), (pos1.z - pos2.z)
|
|
||||||
return dx * dx + dy * dy
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param p MapGen.Peak
|
|
||||||
function Peak:dist(p)
|
|
||||||
return math.sqrt(self:dist2(p))
|
|
||||||
end
|
|
||||||
|
|
||||||
function Peak:isInCircle(cx, cy, r)
|
|
||||||
local pos = self:getPeakPos()
|
|
||||||
|
|
||||||
local dx = (cx - pos.x)
|
|
||||||
local dy = (cy - pos.z)
|
|
||||||
|
|
||||||
return ((dx * dx + dy * dy) <= (r * r))
|
|
||||||
end
|
|
||||||
|
|
||||||
return Peak
|
return Peak
|
||||||
|
|||||||
@@ -20,28 +20,33 @@ local function quatCross(a, b, c)
|
|||||||
return mathSqrt(p)
|
return mathSqrt(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Cross product (p1-p2, p2-p3)
|
---Checks if points p1, p2, p3 are collinear (angle p1-p2-p3 is 180 degrees)
|
||||||
---@param p1 MapGen.Peak
|
|
||||||
---@param p2 MapGen.Peak
|
|
||||||
---@param p3 MapGen.Peak
|
|
||||||
---@return number
|
|
||||||
local function crossProduct(p1, p2, p3)
|
|
||||||
local pos1 = p1:getPeakPos()
|
|
||||||
local pos2 = p2:getPeakPos()
|
|
||||||
local pos3 = p3:getPeakPos()
|
|
||||||
|
|
||||||
local x1, x2 = pos2.x - pos1.x, pos3.x - pos2.x
|
|
||||||
local y1, y2 = pos2.z - pos1.z, pos3.z - pos2.z
|
|
||||||
return x1 * y2 - y1 * x2
|
|
||||||
end
|
|
||||||
|
|
||||||
---Checks if angle (p1-p2-p3) is flat
|
|
||||||
---@param p1 MapGen.Peak
|
---@param p1 MapGen.Peak
|
||||||
---@param p2 MapGen.Peak
|
---@param p2 MapGen.Peak
|
||||||
---@param p3 MapGen.Peak
|
---@param p3 MapGen.Peak
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function isFlatAngle(p1, p2, p3)
|
local function isFlatAngle(p1, p2, p3)
|
||||||
return (crossProduct(p1, p2, p3) == 0)
|
local pos1 = p1:getPeakPos()
|
||||||
|
local pos2 = p2:getPeakPos()
|
||||||
|
local pos3 = p3:getPeakPos()
|
||||||
|
|
||||||
|
local vec1 = pos1 - pos2 -- Vector from p2 to p1
|
||||||
|
local vec2 = pos3 - pos2 -- Vector from p2 to p3
|
||||||
|
|
||||||
|
-- Normalize vectors
|
||||||
|
local len1 = vec1:length()
|
||||||
|
local len2 = vec2:length()
|
||||||
|
|
||||||
|
if len1 < 0 or len2 < 0 then
|
||||||
|
return true -- Degenerate case: points are too close
|
||||||
|
end
|
||||||
|
|
||||||
|
vec1 = vec1 / len1
|
||||||
|
vec2 = vec2 / len2
|
||||||
|
|
||||||
|
-- If dot product is -1, vectors are opposite (180° angle)
|
||||||
|
local dot = vec1:dot(vec2)
|
||||||
|
return math.abs(dot + 1.0) < 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Class registration --
|
-- Class registration --
|
||||||
@@ -79,7 +84,8 @@ function Triangle:new( p1, p2, p3 )
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
__index = self,
|
__index = self,
|
||||||
__tostring = self.toString
|
__tostring = self.toString,
|
||||||
|
__eq = self.eq
|
||||||
})
|
})
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
@@ -88,8 +94,43 @@ end
|
|||||||
---Returns a string describing the object in a readable form.
|
---Returns a string describing the object in a readable form.
|
||||||
---@return string
|
---@return string
|
||||||
function Triangle:toString()
|
function Triangle:toString()
|
||||||
return (('Triangle: \n %s\n %s\n %s')
|
return ('Triangle: \n %s\n %s\n %s'):format(
|
||||||
:format(tostring(self.p1.getPeakPos()), tostring(self.p2.getPeakPos()), tostring(self.p3.getPeakPos())))
|
tostring(self.p1.getPeakPos()),
|
||||||
|
tostring(self.p2.getPeakPos()),
|
||||||
|
tostring(self.p3.getPeakPos())
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param other MapGen.Triangle
|
||||||
|
---@return boolean
|
||||||
|
function Triangle:eq( other )
|
||||||
|
return self.p1 == other.p1 and self.p2 == other.p2 and self.p3 == other.p3
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param other MapGen.Triangle
|
||||||
|
---@return boolean
|
||||||
|
function Triangle:same(other)
|
||||||
|
return (self.p1 == other.p1 and self.p2 == other.p2 and self.p3 == other.p3)
|
||||||
|
or (self.p1 == other.p2 and self.p2 == other.p3 and self.p3 == other.p1)
|
||||||
|
or (self.p1 == other.p3 and self.p2 == other.p1 and self.p3 == other.p2)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns the coordinates of the center
|
||||||
|
---@return vector
|
||||||
|
function Triangle:getCenter()
|
||||||
|
local pos1 = self.p1:getPeakPos()
|
||||||
|
local pos2 = self.p2:getPeakPos()
|
||||||
|
local pos3 = self.p3:getPeakPos()
|
||||||
|
|
||||||
|
return (pos1 + pos2 + pos3) / 3
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns the area
|
||||||
|
---@return number
|
||||||
|
function Triangle:getArea()
|
||||||
|
local a, b, c = self:getSidesLength()
|
||||||
|
|
||||||
|
return (quatCross(a, b, c) / 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the length of the perpendicular
|
---Returns the length of the perpendicular
|
||||||
@@ -116,16 +157,32 @@ function Triangle:getHeight(p1, p2, p3)
|
|||||||
return Edge:new(p1, FakePeak:new(posP))
|
return Edge:new(p1, FakePeak:new(posP))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Checks if the triangle is defined clockwise (sequence p1-p2-p3)
|
---Returns the length of the perpendicular
|
||||||
---@return boolean
|
---from Peak1 to the line Peak2-Peak3
|
||||||
function Triangle:isCW()
|
---@param p1 MapGen.Peak
|
||||||
return (crossProduct(self.p1, self.p2, self.p3) < 0)
|
---@param p2 MapGen.Peak
|
||||||
end
|
---@param p3 MapGen.Peak
|
||||||
|
---@return MapGen.Triangulation.Edge
|
||||||
|
function Triangle:getHeight2D(p1, p2, p3)
|
||||||
|
local pos1 = p1:getPeakPos()
|
||||||
|
local pos2 = p2:getPeakPos()
|
||||||
|
local pos3 = p3:getPeakPos()
|
||||||
|
|
||||||
---Checks if the triangle is defined counter-clockwise (sequence p1-p2-p3)
|
pos1.y = 0
|
||||||
---@return boolean
|
pos2.y = 0
|
||||||
function Triangle:isCCW()
|
pos3.y = 0
|
||||||
return (crossProduct(self.p1, self.p2, self.p3) > 0)
|
|
||||||
|
local v = pos3 - pos2
|
||||||
|
---@type vector
|
||||||
|
local w = pos1 - pos2
|
||||||
|
|
||||||
|
-- Formula: (w * v) / (v * v)
|
||||||
|
-- When * the dot product.
|
||||||
|
local t = w:dot(v) / v:dot(v)
|
||||||
|
|
||||||
|
local posP = pos2 + v * t
|
||||||
|
|
||||||
|
return Edge:new(p1, FakePeak:new(posP))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the length of the edges
|
---Returns the length of the edges
|
||||||
@@ -134,19 +191,29 @@ function Triangle:getSidesLength()
|
|||||||
return self.e1:length(), self.e2:length(), self.e3:length()
|
return self.e1:length(), self.e2:length(), self.e3:length()
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the coordinates of the center
|
---Returns the length of the edges
|
||||||
---@return vector
|
---
|
||||||
function Triangle:getCenter()
|
---Note: This function does not take into account the Y-coordinate,
|
||||||
|
---that is, the calculation is performed on the projection of the triangle XZ
|
||||||
|
---@return number, number, number
|
||||||
|
function Triangle:getSidesLength2D()
|
||||||
local pos1 = self.p1:getPeakPos()
|
local pos1 = self.p1:getPeakPos()
|
||||||
local pos2 = self.p2:getPeakPos()
|
local pos2 = self.p2:getPeakPos()
|
||||||
local pos3 = self.p3:getPeakPos()
|
local pos3 = self.p3:getPeakPos()
|
||||||
|
|
||||||
return (pos1 + pos2 + pos3) / 3
|
pos1.y = 0
|
||||||
|
pos2.y = 0
|
||||||
|
pos3.y = 0
|
||||||
|
|
||||||
|
return (pos2 - pos1):length(), (pos3 - pos2):length(), (pos1 - pos3):length()
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the coordinates of the circumcircle center
|
---Returns the coordinates of the circumcircle center
|
||||||
---@return number, number
|
---
|
||||||
function Triangle:getCircumCenter()
|
---Note: This function does not take into account the Y-coordinate,
|
||||||
|
---that is, the calculation is performed on the projection of the triangle XZ
|
||||||
|
---@return vector
|
||||||
|
function Triangle:getCircumCenter2D()
|
||||||
local pos1 = self.p1:getPeakPos()
|
local pos1 = self.p1:getPeakPos()
|
||||||
local pos2 = self.p2:getPeakPos()
|
local pos2 = self.p2:getPeakPos()
|
||||||
local pos3 = self.p3:getPeakPos()
|
local pos3 = self.p3:getPeakPos()
|
||||||
@@ -161,39 +228,46 @@ function Triangle:getCircumCenter()
|
|||||||
( pos2.x * pos2.x + pos2.z * pos2.z) * (pos1.x - pos3.x) +
|
( pos2.x * pos2.x + pos2.z * pos2.z) * (pos1.x - pos3.x) +
|
||||||
( pos3.x * pos3.x + pos3.z * pos3.z) * (pos2.x - pos1.x))
|
( pos3.x * pos3.x + pos3.z * pos3.z) * (pos2.x - pos1.x))
|
||||||
|
|
||||||
return (x / D), (z / D)
|
return vector.new(x / D, 0, z / D)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the radius of the circumcircle
|
---Returns the radius of the circumcircle
|
||||||
|
---
|
||||||
|
---Note: This function does not take into account the Y-coordinate,
|
||||||
|
---that is, the calculation is performed on the projection of the triangle XZ
|
||||||
---@return number
|
---@return number
|
||||||
function Triangle:getCircumRadius()
|
function Triangle:getCircumRadius2D()
|
||||||
local a, b, c = self:getSidesLength()
|
local a, b, c = self:getSidesLength2D()
|
||||||
|
|
||||||
return ((a * b * c) / quatCross(a, b, c))
|
return ((a * b * c) / quatCross(a, b, c))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns the coordinates of the circumcircle center and its radius
|
---Returns the coordinates of the circumcircle center and its radius
|
||||||
---@return number, number, number
|
---
|
||||||
function Triangle:getCircumCircle()
|
---Note: This function does not take into account the Y-coordinate,
|
||||||
local x, z = self:getCircumCenter()
|
---that is, the calculation is performed on the projection of the triangle XZ
|
||||||
local r = self:getCircumRadius()
|
---@return vector, number
|
||||||
|
function Triangle:getCircumCircle2D()
|
||||||
|
local c = self:getCircumCenter2D()
|
||||||
|
local r = self:getCircumRadius2D()
|
||||||
|
|
||||||
return x, z, r
|
return c, r
|
||||||
end
|
|
||||||
|
|
||||||
---Returns the area
|
|
||||||
---@return number
|
|
||||||
function Triangle:getArea()
|
|
||||||
local a, b, c = self:getSidesLength()
|
|
||||||
|
|
||||||
return (quatCross(a, b, c) / 4)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Checks if a given point lies into the triangle circumcircle
|
---Checks if a given point lies into the triangle circumcircle
|
||||||
|
---
|
||||||
|
---Note: This function does not take into account the Y-coordinate,
|
||||||
|
---that is, the calculation is performed on the projection of the triangle XZ
|
||||||
---@param p MapGen.Peak
|
---@param p MapGen.Peak
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Triangle:inCircumCircle(p)
|
function Triangle:inCircumCircle2D(p)
|
||||||
return p:isInCircle(self:getCircumCircle())
|
local pos = p:getPeakPos()
|
||||||
|
|
||||||
|
local c, r = self:getCircumCircle2D()
|
||||||
|
|
||||||
|
local distance = (c - pos):length()
|
||||||
|
|
||||||
|
return distance <= r
|
||||||
end
|
end
|
||||||
|
|
||||||
return Triangle
|
return Triangle
|
||||||
@@ -21,9 +21,21 @@ local Triangulation = {
|
|||||||
convexMultiplier = 1e3,
|
convexMultiplier = 1e3,
|
||||||
}
|
}
|
||||||
|
|
||||||
---Triangulates a set of given vertices
|
---The Delaunay method divides a plane into triangles based on a list of their vertices.
|
||||||
|
---
|
||||||
|
---Doesn't take into account the Y coordinate of the vertices.
|
||||||
|
---That is, all triangles that don't lie in the XZ plane will be projected onto it.
|
||||||
|
---
|
||||||
|
---Vertices that do not have a `is2d` group will not participate in the triangulation.
|
||||||
---@param vertices table<integer, MapGen.Peak>
|
---@param vertices table<integer, MapGen.Peak>
|
||||||
function Triangulation.triangulate( vertices )
|
function Triangulation.triangulate( vertices )
|
||||||
|
-- Only peaks with a `is2d` group can be triangulated.
|
||||||
|
--[[for i, vertex in ipairs(vertices) do
|
||||||
|
if vertex:getGroups().is2d == nil then
|
||||||
|
table.remove(vertices, i)
|
||||||
|
end
|
||||||
|
end--]]
|
||||||
|
|
||||||
local nvertices = #vertices
|
local nvertices = #vertices
|
||||||
|
|
||||||
assert( nvertices > 2, "Cannot triangulate, needs more than 3 vertices" )
|
assert( nvertices > 2, "Cannot triangulate, needs more than 3 vertices" )
|
||||||
@@ -32,11 +44,11 @@ function Triangulation.triangulate( vertices )
|
|||||||
return {Triangle:new(vertices[1], vertices[2], vertices[3])}
|
return {Triangle:new(vertices[1], vertices[2], vertices[3])}
|
||||||
end
|
end
|
||||||
|
|
||||||
local trmax = nvertices * 4
|
local minPos = vertices[1].getPeakPos()
|
||||||
local minX, minY = vertices[1].getPeakPos().x, vertices[1].getPeakPos().z
|
local minX, minY = minPos.x, minPos.z
|
||||||
local maxX, maxY = minX, minY
|
local maxX, maxY = minX, minY
|
||||||
|
|
||||||
for i = 1, #vertices do
|
for i = 1, nvertices do
|
||||||
local vertex = vertices[i]
|
local vertex = vertices[i]
|
||||||
local vertexPos = vertex.getPeakPos()
|
local vertexPos = vertex.getPeakPos()
|
||||||
vertex.id = i
|
vertex.id = i
|
||||||
@@ -63,6 +75,7 @@ function Triangulation.triangulate( vertices )
|
|||||||
local dx, dy = (maxX - minX) * convex_mult, (maxY - minY) * convex_mult
|
local dx, dy = (maxX - minX) * convex_mult, (maxY - minY) * convex_mult
|
||||||
local deltaMax = mathMax(dx, dy)
|
local deltaMax = mathMax(dx, dy)
|
||||||
local midx, midy = (minX + maxX) * 0.5, (minY + maxY) * 0.5
|
local midx, midy = (minX + maxX) * 0.5, (minY + maxY) * 0.5
|
||||||
|
|
||||||
local p1 = FakePeak:new(vector.new( midx - 2 * deltaMax,0, midy - deltaMax ))
|
local p1 = FakePeak:new(vector.new( midx - 2 * deltaMax,0, midy - deltaMax ))
|
||||||
local p2 = FakePeak:new(vector.new(midx,0, midy + 2 * deltaMax ))
|
local p2 = FakePeak:new(vector.new(midx,0, midy + 2 * deltaMax ))
|
||||||
local p3 = FakePeak:new( vector.new(midx + 2 * deltaMax,0, midy - deltaMax ))
|
local p3 = FakePeak:new( vector.new(midx + 2 * deltaMax,0, midy - deltaMax ))
|
||||||
@@ -72,17 +85,17 @@ function Triangulation.triangulate( vertices )
|
|||||||
|
|
||||||
---@type MapGen.Triangle[]
|
---@type MapGen.Triangle[]
|
||||||
local triangles = {Triangle:new( vertices[nvertices + 1], vertices[nvertices + 2], vertices[nvertices + 3] )}
|
local triangles = {Triangle:new( vertices[nvertices + 1], vertices[nvertices + 2], vertices[nvertices + 3] )}
|
||||||
print('Tria:', tostring(triangles[1]))
|
|
||||||
|
|
||||||
|
print('uu:', tostring(triangles[1]))
|
||||||
for i = 1, nvertices do
|
for i = 1, nvertices do
|
||||||
---@type MapGen.Triangulation.Edge[]
|
---@type MapGen.Triangulation.Edge[]
|
||||||
local edges = {}
|
local edges = {}
|
||||||
local ntriangles = #triangles
|
|
||||||
|
|
||||||
|
-- Finding bad triangles.
|
||||||
for j = #triangles, 1, -1 do
|
for j = #triangles, 1, -1 do
|
||||||
local curTriangle = triangles[j]
|
local curTriangle = triangles[j]
|
||||||
|
|
||||||
if curTriangle:inCircumCircle(vertices[i]) then
|
if curTriangle:inCircumCircle2D(vertices[i]) then
|
||||||
edges[#edges + 1] = curTriangle.e1
|
edges[#edges + 1] = curTriangle.e1
|
||||||
edges[#edges + 1] = curTriangle.e2
|
edges[#edges + 1] = curTriangle.e2
|
||||||
edges[#edges + 1] = curTriangle.e3
|
edges[#edges + 1] = curTriangle.e3
|
||||||
@@ -90,6 +103,7 @@ function Triangulation.triangulate( vertices )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Removing duplicate edges.
|
||||||
for j = #edges - 1, 1, -1 do
|
for j = #edges - 1, 1, -1 do
|
||||||
for k = #edges, j + 1, -1 do
|
for k = #edges, j + 1, -1 do
|
||||||
if edges[j] and edges[k] and edges[j]:same(edges[k]) then
|
if edges[j] and edges[k] and edges[j]:same(edges[k]) then
|
||||||
@@ -99,13 +113,13 @@ function Triangulation.triangulate( vertices )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Create new triangles.
|
||||||
for j = 1, #edges do
|
for j = 1, #edges do
|
||||||
local n = #triangles
|
triangles[#triangles + 1] = Triangle:new(edges[j].p1, edges[j].p2, vertices[i])
|
||||||
assert(n <= trmax, "Generated more than needed triangles")
|
|
||||||
triangles[n + 1] = Triangle:new(edges[j].p1, edges[j].p2, vertices[i])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove tetrahedra associated with the vertices of a supertriangle.
|
||||||
for i = #triangles, 1, -1 do
|
for i = #triangles, 1, -1 do
|
||||||
local triangle = triangles[i]
|
local triangle = triangles[i]
|
||||||
if triangle.p1.id > nvertices or triangle.p2.id > nvertices or triangle.p3.id > nvertices then
|
if triangle.p1.id > nvertices or triangle.p2.id > nvertices or triangle.p3.id > nvertices then
|
||||||
@@ -113,6 +127,7 @@ function Triangulation.triangulate( vertices )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Removing the vertices of a super supertriangle.
|
||||||
for _ = 1,3 do
|
for _ = 1,3 do
|
||||||
tableRemove( vertices )
|
tableRemove( vertices )
|
||||||
end
|
end
|
||||||
@@ -120,4 +135,238 @@ function Triangulation.triangulate( vertices )
|
|||||||
return triangles
|
return triangles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- DEV ---
|
||||||
|
|
||||||
|
local modInfo = Mod.getInfo()
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
---@type MapGen.Triangle
|
||||||
|
local Triangle = require('MapGen.Triangle')
|
||||||
|
---@type MapGen.Triangulation.FakePeak
|
||||||
|
local FakePeak = require('MapGen.Triangulation.FakePeak')
|
||||||
|
|
||||||
|
-- Класс Тетраэдр
|
||||||
|
---@class MapGen.Tetrahedron
|
||||||
|
---@field p1 MapGen.Peak
|
||||||
|
---@field p2 MapGen.Peak
|
||||||
|
---@field p3 MapGen.Peak
|
||||||
|
---@field p4 MapGen.Peak
|
||||||
|
---@field f1 MapGen.Triangle
|
||||||
|
---@field f2 MapGen.Triangle
|
||||||
|
---@field f3 MapGen.Triangle
|
||||||
|
---@field f4 MapGen.Triangle
|
||||||
|
local Tetrahedron = {}
|
||||||
|
|
||||||
|
---@param p1 MapGen.Peak
|
||||||
|
---@param p2 MapGen.Peak
|
||||||
|
---@param p3 MapGen.Peak
|
||||||
|
---@param p4 MapGen.Peak
|
||||||
|
---@return MapGen.Tetrahedron
|
||||||
|
function Tetrahedron:new(p1, p2, p3, p4)
|
||||||
|
local instance = setmetatable({
|
||||||
|
p1 = p1,
|
||||||
|
p2 = p2,
|
||||||
|
p3 = p3,
|
||||||
|
p4 = p4,
|
||||||
|
f1 = Triangle:new(p1, p2, p3),
|
||||||
|
f2 = Triangle:new(p1, p2, p4),
|
||||||
|
f3 = Triangle:new(p1, p3, p4),
|
||||||
|
f4 = Triangle:new(p2, p3, p4),
|
||||||
|
}, {
|
||||||
|
__index = self,
|
||||||
|
__tostring = self.toString
|
||||||
|
})
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns a string describing the object in a readable form.
|
||||||
|
---@return string
|
||||||
|
function Tetrahedron:toString()
|
||||||
|
return ('Tetrahedron: \n %s\n %s\n %s\n %s'):format(
|
||||||
|
tostring(self.p1.getPeakPos()),
|
||||||
|
tostring(self.p2.getPeakPos()),
|
||||||
|
tostring(self.p3.getPeakPos()),
|
||||||
|
tostring(self.p4.getPeakPos())
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns the center of the circumscribed sphere.
|
||||||
|
---@return vector
|
||||||
|
function Tetrahedron:getCircumSphereCenter()
|
||||||
|
local pos1 = self.p1.getPeakPos()
|
||||||
|
local pos2 = self.p2.getPeakPos()
|
||||||
|
local pos3 = self.p3.getPeakPos()
|
||||||
|
local pos4 = self.p4.getPeakPos()
|
||||||
|
|
||||||
|
local a = pos2 - pos1
|
||||||
|
local b = pos3 - pos1
|
||||||
|
local c = pos4 - pos1
|
||||||
|
|
||||||
|
local a2 = a:dot(a)
|
||||||
|
local b2 = b:dot(b)
|
||||||
|
local c2 = c:dot(c)
|
||||||
|
|
||||||
|
local cross_bc = b:cross(c)
|
||||||
|
local cross_ca = c:cross(a)
|
||||||
|
local cross_ab = a:cross(b)
|
||||||
|
|
||||||
|
local det = a:dot(b:cross(c)) * 2
|
||||||
|
|
||||||
|
if math.abs(det) < 0 then
|
||||||
|
return (pos1 + pos2 + pos3 + pos4) / 4
|
||||||
|
end
|
||||||
|
|
||||||
|
local center = pos1 + (cross_bc * a2 + cross_ca * b2 + cross_ab * c2) / det
|
||||||
|
|
||||||
|
return center
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns the radius of the circumscribed sphere.
|
||||||
|
---@return number
|
||||||
|
function Tetrahedron:getCircumSphereRadius()
|
||||||
|
local center = self:getCircumSphereCenter()
|
||||||
|
local pos1 = self.p1.getPeakPos()
|
||||||
|
return (pos1 - center):length()
|
||||||
|
end
|
||||||
|
|
||||||
|
---Checks whether a given point lies within the circumscribed sphere of a tetrahedron.
|
||||||
|
---@param p MapGen.Peak
|
||||||
|
function Tetrahedron:inCircumSphere(p)
|
||||||
|
local pos = p.getPeakPos()
|
||||||
|
local c = self:getCircumSphereCenter()
|
||||||
|
local r = self:getCircumSphereRadius()
|
||||||
|
|
||||||
|
local distance = (pos - c):length()
|
||||||
|
return distance <= r
|
||||||
|
end
|
||||||
|
|
||||||
|
---The Delaunay method divides space into tetrahedra based on a list of their vertices.
|
||||||
|
---
|
||||||
|
---Vertices that do not have a `is3d` group will not participate in the triangulation.
|
||||||
|
---@param vertices table<integer, MapGen.Peak>
|
||||||
|
function Triangulation.tetrahedralize(vertices)
|
||||||
|
--[[vertices = table.copy(vertices)
|
||||||
|
|
||||||
|
-- Only peaks with a `is3d` group can be triangulated.
|
||||||
|
for i, vertex in ipairs(vertices) do
|
||||||
|
if vertex:getGroups().is3d == nil then
|
||||||
|
table.remove(vertices, i)
|
||||||
|
end
|
||||||
|
end--]]
|
||||||
|
|
||||||
|
print(dump(vertices))
|
||||||
|
|
||||||
|
local nvertices = #vertices
|
||||||
|
|
||||||
|
assert(nvertices > 3, "Cannot tetrahedralize, needs more than 4 vertices")
|
||||||
|
|
||||||
|
if nvertices == 4 then
|
||||||
|
return {Tetrahedron:new(vertices[1], vertices[2], vertices[3], vertices[4])}
|
||||||
|
end
|
||||||
|
|
||||||
|
local minPos = vertices[1].getPeakPos()
|
||||||
|
local minX, minY, minZ = minPos.x, minPos.y, minPos.z
|
||||||
|
local maxX, maxY, maxZ = minX, minY, minZ
|
||||||
|
|
||||||
|
for i = 1, nvertices do
|
||||||
|
local vertex = vertices[i]
|
||||||
|
local vertexPos = vertex.getPeakPos()
|
||||||
|
vertex.id = i
|
||||||
|
|
||||||
|
if vertexPos.x < minX then
|
||||||
|
minX = vertexPos.x
|
||||||
|
end
|
||||||
|
|
||||||
|
if vertexPos.y < minY then
|
||||||
|
minY = vertexPos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
if vertexPos.z < minZ then
|
||||||
|
minZ = vertexPos.z
|
||||||
|
end
|
||||||
|
|
||||||
|
if vertexPos.x > maxX then
|
||||||
|
maxX = vertexPos.x
|
||||||
|
end
|
||||||
|
|
||||||
|
if vertexPos.y > maxY then
|
||||||
|
maxY = vertexPos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
if vertexPos.z > maxZ then
|
||||||
|
maxZ = vertexPos.z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Finding the vertices of a supertetrahedron
|
||||||
|
local convex_mult = Triangulation.convexMultiplier
|
||||||
|
local dx, dy, dz = (maxX - minX) * convex_mult, (maxY - minY) * convex_mult, (maxZ - minZ) * convex_mult
|
||||||
|
local deltaMax = mathMax(dx, dy, dz)
|
||||||
|
local midx, midy, midz = (minX + maxX) * 0.5, (minY + maxY) * 0.5, (minZ + maxZ) * 0.5
|
||||||
|
|
||||||
|
local p1 = FakePeak:new(vector.new(midx - 2 * deltaMax, midy - deltaMax, midz - deltaMax))
|
||||||
|
local p2 = FakePeak:new(vector.new(midx + 2 * deltaMax, midy - deltaMax, midz - deltaMax))
|
||||||
|
local p3 = FakePeak:new(vector.new(midx, midy + 2 * deltaMax, midz - deltaMax))
|
||||||
|
local p4 = FakePeak:new(vector.new(midx, midy, midz + 2 * deltaMax))
|
||||||
|
|
||||||
|
p1.id, p2.id, p3.id, p4.id = nvertices + 1, nvertices + 2, nvertices + 3, nvertices + 4
|
||||||
|
vertices[p1.id], vertices[p2.id], vertices[p3.id], vertices[p4.id] = p1, p2, p3, p4
|
||||||
|
|
||||||
|
---@type MapGen.Tetrahedron[]
|
||||||
|
local tetrahedrons = {Tetrahedron:new(p1, p2, p3, p4)}
|
||||||
|
|
||||||
|
for i = 1, nvertices do
|
||||||
|
print(vertices[i]:toString())
|
||||||
|
---@type MapGen.Triangle[]
|
||||||
|
local faces = {}
|
||||||
|
|
||||||
|
-- Finding bad tetrahedrons.
|
||||||
|
for j = #tetrahedrons, 1, -1 do
|
||||||
|
local curTetrahedron = tetrahedrons[j]
|
||||||
|
|
||||||
|
if curTetrahedron:inCircumSphere(vertices[i]) then
|
||||||
|
faces[#faces + 1] = curTetrahedron.f1
|
||||||
|
faces[#faces + 1] = curTetrahedron.f2
|
||||||
|
faces[#faces + 1] = curTetrahedron.f3
|
||||||
|
faces[#faces + 1] = curTetrahedron.f4
|
||||||
|
tableRemove(tetrahedrons, j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Removing duplicate faces.
|
||||||
|
for j = #faces - 1, 1, -1 do
|
||||||
|
for k = #faces, j + 1, -1 do
|
||||||
|
if faces[j] and faces[k] and faces[j]:same(faces[k]) then
|
||||||
|
tableRemove( faces, j )
|
||||||
|
tableRemove( faces, k-1 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create new tetrahedrons.
|
||||||
|
for j = 1, #faces do
|
||||||
|
tetrahedrons[#tetrahedrons + 1] = Tetrahedron:new(faces[j].p1, faces[j].p2, faces[j].p3, vertices[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
print('aboba')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remove tetrahedra associated with the vertices of a supertetrahedron.
|
||||||
|
for i = #tetrahedrons, 1, -1 do
|
||||||
|
local tetrahedron = tetrahedrons[i]
|
||||||
|
if tetrahedron.p1.id > nvertices or tetrahedron.p2.id > nvertices or tetrahedron.p3.id > nvertices or tetrahedron.p4.id > nvertices then
|
||||||
|
tableRemove( tetrahedrons, i )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Removing the vertices of a supertetrahedron.
|
||||||
|
for i = 1, 4 do
|
||||||
|
tableRemove( vertices )
|
||||||
|
end
|
||||||
|
|
||||||
|
return tetrahedrons
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Triangulation
|
return Triangulation
|
||||||
@@ -28,17 +28,20 @@ end
|
|||||||
|
|
||||||
---@param other MapGen.Triangulation.Edge
|
---@param other MapGen.Triangulation.Edge
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Edge:eq( other )
|
function Edge:eq(other)
|
||||||
return self.p1 == other.p1 and self.p2 == other.p2
|
return self.p1 == other.p1 and self.p2 == other.p2
|
||||||
end
|
end
|
||||||
|
|
||||||
function Edge:same(otherEdge)
|
---@param other MapGen.Triangulation.Edge
|
||||||
return ((self.p1 == otherEdge.p1) and (self.p2 == otherEdge.p2))
|
---@return boolean
|
||||||
or ((self.p1 == otherEdge.p2) and (self.p2 == otherEdge.p1))
|
function Edge:same(other)
|
||||||
|
return (self.p1 == other.p1 and self.p2 == other.p2)
|
||||||
|
or (self.p1 == other.p2 and self.p2 == other.p1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return number
|
||||||
function Edge:length()
|
function Edge:length()
|
||||||
return self.p1:dist(self.p2)
|
return (self.p1.getPeakPos() - self.p2.getPeakPos()):length()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return vector
|
---@return vector
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ local a = mapGenerator:RegisterPeak("world",
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
true, 1.0)
|
{is3d = 1})
|
||||||
|
|
||||||
local b = mapGenerator:RegisterPeak("world",
|
local b = mapGenerator:RegisterPeak("world",
|
||||||
vector.new(-100,0,0),
|
vector.new(0,50,0),
|
||||||
{
|
{
|
||||||
landscapeNoise = {
|
landscapeNoise = {
|
||||||
offset = 30,
|
offset = 30,
|
||||||
@@ -49,10 +49,10 @@ local b = mapGenerator:RegisterPeak("world",
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
true, 1.0)
|
{is3d = 1})
|
||||||
|
|
||||||
local c = mapGenerator:RegisterPeak("world",
|
local c = mapGenerator:RegisterPeak("world",
|
||||||
vector.new(0,0,-100),
|
vector.new(50,0,0),
|
||||||
{
|
{
|
||||||
landscapeNoise = {
|
landscapeNoise = {
|
||||||
offset = 30,
|
offset = 30,
|
||||||
@@ -64,10 +64,9 @@ local c = mapGenerator:RegisterPeak("world",
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
true, 1.0)
|
{is3d = 1, is2d = 1})
|
||||||
|
--[[local d = mapGenerator:RegisterPeak("world",
|
||||||
local d = mapGenerator:RegisterPeak("world",
|
vector.new(50,50,0),
|
||||||
vector.new(-100,0,-100),
|
|
||||||
{
|
{
|
||||||
landscapeNoise = {
|
landscapeNoise = {
|
||||||
offset = 30,
|
offset = 30,
|
||||||
@@ -79,13 +78,13 @@ local d = mapGenerator:RegisterPeak("world",
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
true, 1.0)
|
{is3d = 1, is2d = 1})--]]
|
||||||
|
|
||||||
local e = mapGenerator:RegisterPeak("world",
|
local e = mapGenerator:RegisterPeak("world",
|
||||||
vector.new(-50,0,-50),
|
vector.new(25,25,25),
|
||||||
{
|
{
|
||||||
landscapeNoise = {
|
landscapeNoise = {
|
||||||
offset = -10,
|
offset = 10,
|
||||||
scale = 2,
|
scale = 2,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
spread = {x = 10, y = 10, z = 10},
|
||||||
seed = 47,
|
seed = 47,
|
||||||
@@ -94,7 +93,22 @@ local e = mapGenerator:RegisterPeak("world",
|
|||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
true, 1.0)
|
{is3d = 1, is2d = 1})
|
||||||
|
|
||||||
|
mapGenerator:RegisterPeak("world",
|
||||||
|
vector.new(25,25,-25),
|
||||||
|
{
|
||||||
|
landscapeNoise = {
|
||||||
|
offset = 20,
|
||||||
|
scale = 2,
|
||||||
|
spread = {x = 10, y = 10, z = 10},
|
||||||
|
seed = 47,
|
||||||
|
octaves = 8,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{is3d = 1, is2d = 1})
|
||||||
--[[
|
--[[
|
||||||
local e = mapGenerator:RegisterPeak("world",
|
local e = mapGenerator:RegisterPeak("world",
|
||||||
vector.new(-50,0,50),
|
vector.new(-50,0,50),
|
||||||
|
|||||||
Reference in New Issue
Block a user