Add texture coordinate export.
This commit is contained in:
parent
1c8d9cc4a9
commit
d04e488273
@ -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()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user