From d04e4882730ddea67af1a92d492da1f969c9e243 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 19 Sep 2014 10:41:33 +0300 Subject: [PATCH] Add texture coordinate export. --- intern/cycles/app/io_export_cycles_xml.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py index e310d928b26..ad8fb9d3dd3 100644 --- a/intern/cycles/app/io_export_cycles_xml.py +++ b/intern/cycles/app/io_export_cycles_xml.py @@ -111,19 +111,29 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper): # generate mesh node nverts = "" verts = "" + uvs = "" P = "" for v in mesh.vertices: P += "%f %f %f " % (v.co[0], v.co[1], v.co[2]) - for i, f in enumerate(mesh.tessfaces): - nverts += str(len(f.vertices)) + " " + verts_and_uvs = zip(mesh.tessfaces, mesh.tessface_uv_textures.active.data) + + for f, uvf in verts_and_uvs: + vcount = len(f.vertices) + nverts += str(vcount) + " " for v in f.vertices: verts += str(v) + " " - verts += " " + + uvs += str(uvf.uv1[0]) + " " + str(uvf.uv1[1]) + " " + uvs += str(uvf.uv2[0]) + " " + str(uvf.uv2[1]) + " " + uvs += str(uvf.uv3[0]) + " " + str(uvf.uv3[1]) + " " + if vcount==4: + uvs += " " + str(uvf.uv4[0]) + " " + str(uvf.uv4[1]) + " " + - node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P}) + node = etree.Element('mesh', attrib={'nverts': nverts.strip(), 'verts': verts.strip(), 'P': P, 'UV' : uvs.strip()}) # write to file write(node, filepath) @@ -139,3 +149,4 @@ def unregister(): if __name__ == "__main__": register() +