From ab00b6d5a2e394ba08a53d073c7e862980df09d6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne <montagne29@wanadoo.fr> Date: Mon, 14 Oct 2013 15:00:20 +0000 Subject: [PATCH] More FBX fixes regarding UV/textures, found while investigating a potential issue with mifth on IRC: handling of default empty texture (when there are none real texture to export) was rather fuzzy/inconsistent. Note: not to be backported, not 100% sure this is now correct, and not a regression anyway. --- io_scene_fbx/export_fbx.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py index edc21692c..004d4ade1 100644 --- a/io_scene_fbx/export_fbx.py +++ b/io_scene_fbx/export_fbx.py @@ -1585,16 +1585,17 @@ def save_single(operator, scene, filepath="", t_pi = (d.image for d in uvtexture.data) # Can't use foreach_get here :( fw(',\n\t\t\t '.join(','.join('%d' % tex2idx[i] for i in chunk) for chunk in grouper_exact(t_pi, _nchunk_idx))) - else: - fw('\n\t\tLayerElementTexture: 0 {' - '\n\t\t\tVersion: 101' - '\n\t\t\tName: ""' - '\n\t\t\tMappingInformationType: "NoMappingInformation"' - '\n\t\t\tReferenceInformationType: "IndexToDirect"' - '\n\t\t\tBlendMode: "Translucent"' - '\n\t\t\tTextureAlpha: 1' - '\n\t\t\tTextureId: ') - fw('\n\t\t}') + fw('\n\t\t}') + if not do_textures: + fw('\n\t\tLayerElementTexture: 0 {' + '\n\t\t\tVersion: 101' + '\n\t\t\tName: ""' + '\n\t\t\tMappingInformationType: "NoMappingInformation"' + '\n\t\t\tReferenceInformationType: "IndexToDirect"' + '\n\t\t\tBlendMode: "Translucent"' + '\n\t\t\tTextureAlpha: 1' + '\n\t\t\tTextureId: ' + '\n\t\t}') del t_uv del t_pi @@ -1652,7 +1653,8 @@ def save_single(operator, scene, filepath="", '\n\t\t\t}') # Always write this - if do_textures: + #if do_textures: + if True: fw('\n\t\t\tLayerElement: {' '\n\t\t\t\tType: "LayerElementTexture"' '\n\t\t\t\tTypedIndex: 0' @@ -1667,7 +1669,7 @@ def save_single(operator, scene, filepath="", fw('\n\t\t}') if len(uvlayers) > 1: - for i in range(1, len(uvlayers)): # Why start at 1 (i.e. skip first UV layer)??? --mont29 + for i in range(1, len(uvlayers)): fw('\n\t\tLayer: %d {' '\n\t\t\tVersion: 100' '\n\t\t\tLayerElement: {' @@ -1679,6 +1681,11 @@ def save_single(operator, scene, filepath="", '\n\t\t\t\tType: "LayerElementTexture"' '\n\t\t\t\tTypedIndex: %d' '\n\t\t\t}' % i) + else: + fw('\n\t\t\tLayerElement: {' + '\n\t\t\t\tType: "LayerElementTexture"' + '\n\t\t\t\tTypedIndex: 0' + '\n\t\t\t}') fw('\n\t\t}') # XXX Col layers are written before UV ones above, why adding them after UV here??? -- GitLab