I have to triangulate the object's mesh because the format I export to only understands triangles. Now I not only want to export geometry but also the uv-mappings for the mesh. Let's call the uv_texture uvTex
. The context object is obj
What I have done so far:
import bmesh
bm = bmesh.new()
bm.from_mesh(obj.data)
bmesh.ops.triangulate(bm, faces=bm.faces)
# everything is fine so far
Now the problem is that you access the uv-data by iterating through the faces and then through their vertices. So for example uvTex.data[0]
belongs to obj.data.faces[0]."vertices[0]"
(quotes because it's not really a vertex in this context, it's just an index but you get what I mean).
Triangulating the mesh has changed the order of the vertices so my question is now:
How does one export a triangulated version of an object's mesh, including uv-mappings, without changing the objects geometry, etc.?