@tnlogy Heres an example of a Sierpinski cube using the voxel color code you used above. Uncomment the color lines near the bottom of the code to see different color schemes.
viewer.mode=FULLSCREEN
function setup()
ss=27 -- cube size, powers of 3 only (3, 9, 27, 81)
fill(255)
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
scene = craft.scene()
scene.voxels.visibleRadius=90
scene.voxels:resize(vec3(30,1,30))
scene.voxels.coordinates = vec3(ss,ss,ss)
v=scene.camera:add(OrbitViewer,vec3(ss,ss,ss), ss*3, 0, 6000)
v.rx=45
v.ry=45
blank = scene.voxels.blocks:new("Blank")
blank.setTexture(ALL,"Blocks:Blank White")
blank.tinted=true
count=0
cube(0,0,0,ss)
end
function update(dt)
scene:update(dt)
end
function draw()
update(DeltaTime)
scene:draw()
text("Cube size "..ss.."x"..ss.."x"..ss.." = "..(ss^3).." cubes",WIDTH/2,HEIGHT-25)
text("Number of cubes drawn "..count,WIDTH/2,HEIGHT-50)
text("Sierpinski cube",WIDTH/2,HEIGHT-75)
end
function cube(x,y,z,size)
local s=size//3
for x1=-s,s,s do
for y1=-s,s,s do
for z1=-s,s,s do
if (y1~=0 or z1~=0) and (x1~=0 or z1~=0) and (x1~=0 or y1~=0) then
if size~=3 then
cube(x1+x,y1+y,z1+z,s)
else
count=count+1
r=255//(x1+s+1)
g=255//(y1+s+1)
b=255//(z1+s+1)
c=color(r,g,b)
--c=color(200,200,200)
--c=color(math.random(255),math.random(255),math.random(255))
scene.voxels:set((x1+x+ss),(y1+y+ss),(z1+z+ss),
"name","Blank","color", c)
end
end
end
end
end
end