I made a maze game (2d) with a level generator and I would have liked to make it a 3d one (with g3d), and for that it would therefore be necessary (I suppose) that I generate a mesh of this entire maze, so I try a lot of hack and tried to compare with existing functions in opengl but i can't even add multiple vertices to a mesh.
So I first tried like this:
Code: Select all
local mapVertices = {}
local i, s = 0, 5
for x, rows in pairs(map) do
for y, value in pairs(rows) do
i = i + s
if value == 1 then
mapVertices[i] = { --wall
{-s + i, -s + i, 0},
{-s + i, 0 + i, 0},
{-s + i, -s + i, s},
{-s + i, 0 + i, s},
{0 + i, -s + i, 0},
{0 + i, 0 + i, 0},
{0 + i, -s + i, s},
{0 + i, 0 + i, s}
}
elseif value == 2 then
mapVertices[i] = { --ground
{-s + i, -s + i, 0},
{-s + i, 0 + i, 0},
{-s + i, -s + i, s},
{-s + i, 0 + i, s}
}
end
Code: Select all
local wallsVertices, groundVertices = {}, {}
local i, s, iwall, iground = 0, 5, 0, 0
for x, rows in pairs(map) do
for y, value in pairs(rows) do
i = i + s
if value == 1 then
iwall = iwall + 8
wallsVertices[iwall - 7] = {-s + i, -s + i, 0}
wallsVertices[iwall - 6] = {-s + i, 0 + i, 0}
wallsVertices[iwall - 5] = {-s + i, -s + i, s}
wallsVertices[iwall - 4] = {-s + i, 0 + i, s}
wallsVertices[iwall - 3] = {0 + i, -s + i, 0}
wallsVertices[iwall - 2] = {0 + i, 0 + i, 0}
wallsVertices[iwall - 1] = {0 + i, -s + i, s}
wallsVertices[iwall] = {0 + i, 0 + i, s}
elseif value == 2 then
iground = iground + 4
wallsVertices[iground - 3] = {-s + i, -s + i, 0}
wallsVertices[iground - 2] = {-s + i, 0 + i, 0}
wallsVertices[iground - 1] = {-s + i, -s + i, s}
wallsVertices[iground] = {-s + i, 0 + i, s}
end
end
end
Code: Select all
Number of vertex attribute components must be between 1 and 4 (got 576)
Thanks in advance !