Here is a function/module that returns a cube. So that noone else has to write this monstrosity.
Code: Select all
local function cube(s,uv,col)
local s = s or 1
local uv = uv or {0,0, 1,0, 0,1, 1,1}
local col = col or {255,255,255,255}
return {
{-0.5 * s, -0.5 * s, -0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, -0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, -0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, -0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, 0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, 0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, -0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, 0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, -0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, -0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, -0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, -0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, -0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, -0.5 * s, -0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, -0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, -0.5 * s, uv[7], uv[8], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{0.5 * s, 0.5 * s, 0.5 * s, uv[5], uv[6], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, 0.5 * s, uv[1], uv[2], col[1], col[2], col[3], col[4]},
{-0.5 * s, 0.5 * s, -0.5 * s, uv[3], uv[4], col[1], col[2], col[3], col[4]},
}
end
return cube