After reading loads of threads and also googled about meshes, I am trying ( not very well) to generate some hexagon meshes circle a center hex. The code below generates the hexes but try as I can I can not get them to be drawn on the screen all together. Mod the code to generate one and it displays but not all will display.
Please can some one point me in the direction I am going wrong.
Thanks
-- hexagon grid test
-- mesh testing 2
supportedOrientations(LANDSCAPE_ANY)
function setup()
mtab = {}
X={} -- x coord table
Y={} -- y coord table
s=30 -- size of hex 30 its finger size
w = s*2 -- width of hex
h = math.sqrt(3)/2*w -- height of hex
hor = w+10
ver = h+10
cx=376 -- start position of x
cy=384 -- start position of y
mtab={}
--m = mesh()
--for j=1,7 do
j= math.random(1,7)
m = mesh()
ctx={cx,cx+ver,cx+ver,cx-ver,cx-ver,cx-ver,cx+ver}
cty={cy,cy,cy+hor,cy+hor,cy,cy-hor,cy+hor}
cxx=ctx[j]
cyy=cty[j]
for i = 1,6 do
print ("center = ",cxx,cyy)
angle = 2 * math.pi/ 6 * i
xx = cxx + s * math.cos(angle)
table.insert(X,xx)
yy = cyy + s * math.sin(angle)
table.insert(Y,yy)
end
m.vertices= {
vec2(cxx,cyy),vec2(X[1],Y[1]),vec2(X[2],Y[2]),
vec2(cxx,cyy),vec2(X[2],Y[2]),vec2(X[3],Y[3]),
vec2(cxx,cyy),vec2(X[3],Y[3]),vec2(X[4],Y[4]),
vec2(cxx,cyy),vec2(X[4],Y[4]),vec2(X[5],Y[5]),
vec2(cxx,cyy),vec2(X[5],Y[5]),vec2(X[6],Y[6]),
vec2(cxx,cyy),vec2(X[6],Y[6]),vec2(X[1],Y[1])}
table.insert(mtab,m.vertices)
--end
end
function draw()
background(78, 78, 94, 255)
for i,v in ipairs(mtab) do
m:draw()
end
end