@piinthesky Your post looked interesting, so I thought I’d see what I could come up with. I tried to keep it simple and still use 3D spheres. This runs at about 16 FPS on my iPad Air. This could probable be speeded up more, but I’m not going to try now. Just thought I’d post it just in case you see anything you could use.
EDIT: Added code to randomly change the color of some of the spheres.
EDIT: Modified the code. It now runs at approx 56 FPS on iPad Air with 320 spheres.
EDIT: Added the white verticle posts, FPS now about 52.
supportedOrientations(LANDSCAPE_ANY)
function setup()
FPS=60
parameter.integer("ex",-100,1000,150)
parameter.integer("ey",-100,1000,30)
parameter.integer("ez",-100,1000,160)
-- creare x,y,z 3d sphere coordinates
tab={}
lim=13
for n=0,lim do
tab[n]={}
for m=0,lim do
x=math.sin(math.pi*m/lim)*math.cos(2*math.pi*n/lim)
y=math.sin(math.pi*m/lim)*math.sin(2*math.pi*n/lim)
z=math.cos(math.pi*m/lim)
tab[n][m]=vec3(x,y,z)
end
end
-- create sphere triangles using x,y,x coord.
sph={}
for n=0,lim-1 do
for m=0,lim-1 do
table.insert(sph,tab[n][m])
table.insert(sph,tab[n][m+1])
table.insert(sph,tab[n+1][m+1])
table.insert(sph,tab[n][m])
table.insert(sph,tab[n+1][m])
table.insert(sph,tab[n+1][m+1])
end
end
sphere=mesh()
sphere.vertices=sph
sphere:setColors(255,0,0,255)
sphere1=mesh()
sphere1.vertices=sph
sphere1:setColors(255,255,0)
cnt=10
end
function rnd()
cnt=cnt+1
if cnt<5 then
return
end
cnt=0
col={}
for x=1,4 do
col[x]={}
for y=1,30 do
col[x][y]={}
for z=1,4 do
col[x][y][z]={}
col[x][y][z]=0
if math.random(100)>80 then
col[x][y][z]=1
end
end
end
end
end
function draw()
rnd()
background(40, 40, 50)
FPS=0.9*FPS+0.1/DeltaTime
text(FPS//1,WIDTH/2,HEIGHT-10)
perspective()
camera(ex,ey,ez,0,0,0)
-- draw base
fill(86, 161, 231, 255)
stroke(255)
strokeWidth(1)
pushMatrix()
rotate(90,1,0,0)
rect(20,20,110,110)
popMatrix()
-- draw lines on base
pushMatrix()
rotate(90,1,0,0)
stroke(0)
translate(0,0,-1)
for x=30,120,30 do
for y=30,120,30 do
line(x,30,x,120)
line(30,y,120,y)
end
end
popMatrix()
-- draw verticle posts
stroke(255)
for x=1,4 do
for y=1,4 do
pushMatrix()
translate(x*30,0,y*30)
line(0,0,0,80)
popMatrix()
end
end
-- draw multiple spheres
stroke(255)
for x=1,4 do
for y=1,20 do
for z=1,4 do
pushMatrix()
translate(x*30,y*4,z*30)
if col[x][y][z]==1 then
sphere1:draw()
else
sphere:draw()
end
popMatrix()
end
end
end
end