OpenGL (the model's final destination) only accepts per-vertex UVs, so it is a must to use per-vertex and not "per face-vertex" UVs. The question isn't about OGL, that's just my reasoning. The OBJ format stores UVs per-vertex, proving that it is possible. I also have checked the code of the default OBJ exporter. However, it's UV exporting code is completely reliant on the rest of it's code making it very difficult to read and understand the default OBJ exporter script.
Current code for exporting UVs:
for face in mesh.polygons: for vert, loop in zip(face.vertices, face.loop_indices): if (vert in usedverts): print("duplicate") else: for z in (mesh.uv_layers.active.data[loop].uv if mesh.uv_layers.active is not None else (0.0, 0.0)): f.write(struct.pack('f', z))
It doesn't export them correctly, whether or not I use the
if (vert in usedverts):. I think because when removing duplicates, they end up in the wrong order or something like that. Maybe someone has a better example of per vertex UV exporting [than the confusing default obj exporter]?