This is sort of related to http://www.twolivesleft.com/Codea/Talk/discussion/754/modifying-mesh-vertices, but not quite. I’d like a way to add vertices piecemeal to a mesh. The mesh:vertex()
method talked about in the linked discussion works - so far as I can tell - only on existing mesh vertices.
I’m using a single mesh to render a conglomeration of objects. This seemed to me to be the most efficient method. So I add the objects to the mesh by constructing a huge list of triangles and then assigning it to the mesh. That’s fine in setup()
(though with my meshes it takes a non-trivial amount of time!), but if I want to add or delete one of those objects mid-program, I have to rebuild the entire list of mesh vertices - so far as I can tell. I’d quite like to be able to simply erase a segment and add a segment of vertices. Something like what the mesh:addRect()
method currently does, but more flexibly (as that seems limited to genuine rectangles in some plane). Deleting vertices might be a bit of a minefield (especially with keeping track of indices), but certainly adding shouldn’t be an issue, and for extras I’d like mesh:addVertex()
to be able to take a list of vertices (don’t mind if it is mesh:addVertex({a,b,c,d})
or mesh:addVertex(a,b,c,d)
) and return one of the indices of the added vertices (not sure if the first or last would be more useful).
Could this be added, or if it is already there and I’ve missed it … where is it?