Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Voxel Editor

edited May 2015 in Code Sharing Posts: 31

A voxel editor i made, with it you can make 3d models, like pixel art or minecraft.
Heres the code link
https://gist.github.com/Jaybob/a3d7e3730d4f75feaaa0/
And heres a bootstrap loader...

function setup()
    http.request("https://gist.githubusercontent.com/Jaybob/a3d7e3730d4"..
    "f75feaaa0/raw/fe618c6280d0f4a2660c2b15185c6f40642b7fc7/3dPixel",
    function(d,s)
        if s == 200 then local t,m = {},string.len(d)
            for v in string.gmatch(d,"--# %a+") do t[#t+1] = {n = v, s = string.find(d,v)} end
            for i = #t,1,-1 do t[i].e = m m = t[i].s - 1 end
            for k,v in ipairs(t) do saveProjectTab(string.sub(v.n,5),string.sub(d,v.s,v.e)) end close()
        end
    end)
end

If you use a texture with multiple images you can set the texCord range for each image in setup, then it will use those ranges when adding cubes, cycle through with the button next to the colors.

The mesh is saved to globalData using a given name, it removes unecesary data from the mesh.
You can then load it into a project with something like this

    data = loadstring(readGlobalData("Tree"))()
    m = mesh()
    m.vertices = data.vertices
    m.colors = data.colors
    m.texCoords = data.texCoords

Comments

  • Posts: 688

    That's really impressive well done (and some great code to learn from as well - thanks) :)

  • Posts: 2,020

    This is awesome. One minor issue I had, is that the left-hand stick sometimes registers input, for a frame or two, when I'm touching elsewhere on the screen.

  • Posts: 31

    Yeah the touches need a bit of work, if i get round to fixing it i will comment the code so its easier to understand, and maybe add a way to load saved models.

  • SimeonSimeon Admin Mod
    Posts: 4,933

    @Jaybob this is wonderful, loved playing with it.

Sign In or Register to comment.