diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-08-09 20:41:10 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-08-09 20:56:13 +0300 |
commit | a238b0325d2f7063e94df1a2e6e525ea3c43796f (patch) | |
tree | 517e21d8dbe3d58a594b68b539364a170c7c9a6d /io_scene_gltf2 | |
parent | 89da5a6d3ab8c236657418397e66c622b53512c1 (diff) |
glTF importer: check when texture file is not found
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py index 6479a809..16c6dbf1 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py @@ -128,12 +128,14 @@ class BlenderPbr(): mapping = node_tree.nodes.new('ShaderNodeMapping') mapping.location = -1500, 500 mapping.vector_type = 'POINT' - tex_transform = text_node.image['tex_transform'][str(pypbr.base_color_texture.index)] - mapping.translation[0] = texture_transform_gltf_to_blender(tex_transform)['offset'][0] - mapping.translation[1] = texture_transform_gltf_to_blender(tex_transform)['offset'][1] - mapping.rotation[2] = texture_transform_gltf_to_blender(tex_transform)['rotation'] - mapping.scale[0] = texture_transform_gltf_to_blender(tex_transform)['scale'][0] - mapping.scale[1] = texture_transform_gltf_to_blender(tex_transform)['scale'][1] + if text_node.image is not None: # Sometimes images can't be retrieved (bad gltf file ...) + print("OK") + tex_transform = text_node.image['tex_transform'][str(pypbr.base_color_texture.index)] + mapping.translation[0] = texture_transform_gltf_to_blender(tex_transform)['offset'][0] + mapping.translation[1] = texture_transform_gltf_to_blender(tex_transform)['offset'][1] + mapping.rotation[2] = texture_transform_gltf_to_blender(tex_transform)['rotation'] + mapping.scale[0] = texture_transform_gltf_to_blender(tex_transform)['scale'][0] + mapping.scale[1] = texture_transform_gltf_to_blender(tex_transform)['scale'][1] uvmap = node_tree.nodes.new('ShaderNodeUVMap') @@ -193,12 +195,14 @@ class BlenderPbr(): else: mapping.location = -1500, 500 mapping.vector_type = 'POINT' - tex_transform = text_node.image['tex_transform'][str(pypbr.base_color_texture.index)] - mapping.translation[0] = texture_transform_gltf_to_blender(tex_transform)['offset'][0] - mapping.translation[1] = texture_transform_gltf_to_blender(tex_transform)['offset'][1] - mapping.rotation[2] = texture_transform_gltf_to_blender(tex_transform)['rotation'] - mapping.scale[0] = texture_transform_gltf_to_blender(tex_transform)['scale'][0] - mapping.scale[1] = texture_transform_gltf_to_blender(tex_transform)['scale'][1] + if text_node.image is not None: # Sometimes images can't be retrieved (bad gltf file ...) + print("OK") + tex_transform = text_node.image['tex_transform'][str(pypbr.base_color_texture.index)] + mapping.translation[0] = texture_transform_gltf_to_blender(tex_transform)['offset'][0] + mapping.translation[1] = texture_transform_gltf_to_blender(tex_transform)['offset'][1] + mapping.rotation[2] = texture_transform_gltf_to_blender(tex_transform)['rotation'] + mapping.scale[0] = texture_transform_gltf_to_blender(tex_transform)['scale'][0] + mapping.scale[1] = texture_transform_gltf_to_blender(tex_transform)['scale'][1] uvmap = node_tree.nodes.new('ShaderNodeUVMap') if vertex_color: |