Obj to Codea mesh format function

Edit: bug figured out. Thank you @Ignatz!

function convert(string)
    local str=string .. "\
    str=string.gsub(str,"v ","vec3(")
    str=string.gsub(str," ",",")
","), ")
    str="function convert() tab={" .. str .. "} end"
    for i,v in pairs(tab) do

vec3 rather than vec2?

Thanks @Ignatz, noted. I edited the above code, but still get the same bug.

  1. put the final ]] on the next line (you need a
    before it)

  2. get rid of the function call, instead

str="tab={" .. str .. "}"

Thank you Ignatz! That worked for me. :smiley:

When working with meshes converted from .obj format as my function deals with, I realized that unless I run them through Blender the vertices are rarely ever triangulated. It is a pain to have to run every .obj file through Blender and then email the .obj file to myself, so I was wondering if anyone had created a function that would take an array of vec3’s and triangulate them, or at least could point me in the right direction for writing one myself. Thank you! :smiley: