grid stub

This commit is contained in:
BuckarooBanzay 2022-03-26 16:10:02 +01:00
parent 0503f1ca51
commit 7b9112ad6e
4 changed files with 24 additions and 15 deletions

View File

@ -1,8 +1,7 @@
function mtscad.Context:cube(x, y, z)
-- TODO: deal with negative sizes
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
-- TODO: prevent negative sizes
local pos1 = vector.copy(self.pos)
pos1, pos2 = mtscad.sort_pos(pos1, pos2)
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
for xi=pos1.x,pos2.x do
for yi=pos1.y,pos2.y do

20
context/grid.lua Normal file
View File

@ -0,0 +1,20 @@
function mtscad.Context:grid(x, y, z)
-- TODO: prevent negative sizes
local pos1 = vector.copy(self.pos)
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
-- TODO: lines between outer positions
for xi=pos1.x,pos2.x,x-1 do
for yi=pos1.y,pos2.y,y-1 do
for zi=pos1.z,pos2.z,z-1 do
local ipos = { x=xi, y=yi, z=zi }
local tpos = mtscad.transform_pos(pos1, ipos, self.rotation)
local tnode = mtscad.transform_node(self.node, self.rotation)
minetest.set_node(tpos, tnode)
end
end
end
return self
end

View File

@ -8,6 +8,7 @@ dofile(MP .. "/context/execute.lua")
dofile(MP .. "/context/translate.lua")
dofile(MP .. "/context/rotate.lua")
dofile(MP .. "/context/cube.lua")
dofile(MP .. "/context/grid.lua")
dofile(MP .. "/context/slope.lua")
dofile(MP .. "/util.lua")
dofile(MP .. "/test.lua")

View File

@ -1,15 +1,4 @@
local function cube_outliers(ctx, size)
ctx
:cube(size, 1, 1)
:cube(1, size, 1)
:cube(1, 1, size)
:translate(size-1, 0, size-1)
:cube(-size, 1, 1)
:cube(1, size, 1)
:cube(1, 1, -size)
end
local function rot_test(ctx)
ctx
:with({ name="wool:red" })
@ -43,7 +32,7 @@ local function test_code(ctx)
ctx
:with({ name="default:copperblock" })
:translate(2,2,2)
:execute(cube_outliers, 5)
:grid(5, 5, 5)
end
minetest.register_chatcommand("test", {