diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-08-09 20:43:24 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-08-09 20:56:13 +0300 |
commit | 5a937edabb313e4924ba66c21a745ab142e9b5ef (patch) | |
tree | 7a6d782dde10bed8bbd587b115314b2de91f4c69 | |
parent | a238b0325d2f7063e94df1a2e6e525ea3c43796f (diff) |
glTF importer: manage escaped uri for texture files
-rwxr-xr-x | io_scene_gltf2/__init__.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_image.py | 5 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_binary.py | 7 |
4 files changed, 8 insertions, 8 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 1dfd167d..b09561db 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (0, 9, 45), + "version": (0, 9, 46), 'blender': (2, 80, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_image.py b/io_scene_gltf2/blender/imp/gltf2_blender_image.py index 4d352362..546aa7e3 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_image.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_image.py @@ -16,6 +16,7 @@ import bpy import os import tempfile from os.path import dirname, join, isfile, basename +from urllib.parse import unquote from ...io.imp.gltf2_io_binary import BinaryData @@ -40,8 +41,8 @@ class BlenderImage(): if idx != -1: return False, None, None - if isfile(join(dirname(gltf.filename), pyimage.uri)): - return True, join(dirname(gltf.filename), pyimage.uri), basename(join(dirname(gltf.filename), pyimage.uri)) + if isfile(join(dirname(gltf.filename), unquote(pyimage.uri))): + return True, join(dirname(gltf.filename), unquote(pyimage.uri)), basename(join(dirname(gltf.filename), unquote(pyimage.uri))) else: gltf.log.error("Missing file (index " + str(img_idx) + "): " + pyimage.uri) return False, None, None diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py index 16c6dbf1..62c3fb62 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py @@ -129,7 +129,6 @@ class BlenderPbr(): mapping.location = -1500, 500 mapping.vector_type = 'POINT' 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] @@ -196,7 +195,6 @@ class BlenderPbr(): mapping.location = -1500, 500 mapping.vector_type = 'POINT' 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] diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index 498d49e8..92450672 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -15,6 +15,7 @@ import struct import base64 from os.path import dirname, join, isfile, basename +from urllib.parse import unquote class BinaryData(): @@ -159,9 +160,9 @@ class BinaryData(): data = pyimage.uri[idx + len(sep):] return base64.b64decode(data), image_name - if isfile(join(dirname(gltf.filename), pyimage.uri)): - with open(join(dirname(gltf.filename), pyimage.uri), 'rb') as f_: - return f_.read(), basename(join(dirname(gltf.filename), pyimage.uri)) + if isfile(join(dirname(gltf.filename), unquote(pyimage.uri))): + with open(join(dirname(gltf.filename), unquote(pyimage.uri)), 'rb') as f_: + return f_.read(), basename(join(dirname(gltf.filename), unquote(pyimage.uri))) else: gltf.log.error("Missing file (index " + str(img_idx) + "): " + pyimage.uri) return None, None |