[Bf-blender-cvs] [d04e488] master: Add texture coordinate export.

Nathan Letwory noreply at git.blender.org
Fri Sep 19 09:45:01 CEST 2014


Commit: d04e4882730ddea67af1a92d492da1f969c9e243
Author: Nathan Letwory
Date:   Fri Sep 19 10:41:33 2014 +0300
Branches: master
https://developer.blender.org/rBd04e4882730ddea67af1a92d492da1f969c9e243

Add texture coordinate export.

===================================================================

M	intern/cycles/app/io_export_cycles_xml.py

===================================================================

diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py
index e310d92..ad8fb9d 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 += " "
-
-        node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P})
+            
+            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.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()
 
+




More information about the Bf-blender-cvs mailing list