diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 35380dd9d994485be20dcaa978df5940c5026e41..e1a808621c9dde588b65410bcdafc9c190084f96 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, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (1, 4, 18), + "version": (1, 4, 19), 'blender': (2, 90, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index 5346d9f5cfc78acc6737cad6336ad7b0a4484525..fddc8030f6439d6fb9a4050f34b9e8f266798abb 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -16,6 +16,7 @@ import struct import numpy as np from ..com.gltf2_io import Accessor +from ..com.gltf2_io_constants import ComponentType, DataType class BinaryData(): @@ -93,14 +94,8 @@ class BinaryData(): # doesn't matter because nothing uses them. assert accessor.type not in ['MAT2', 'MAT3'] - dtype = { - 5120: np.int8, - 5121: np.uint8, - 5122: np.int16, - 5123: np.uint16, - 5125: np.uint32, - 5126: np.float32, - }[accessor.component_type] + dtype = ComponentType.to_numpy_dtype(accessor.component_type) + component_nb = DataType.num_elements(accessor.type) if accessor.buffer_view is not None: bufferView = gltf.data.buffer_views[accessor.buffer_view] @@ -109,9 +104,7 @@ class BinaryData(): accessor_offset = accessor.byte_offset or 0 buffer_data = buffer_data[accessor_offset:] - component_nb = gltf.component_nb_dict[accessor.type] bytes_per_elem = dtype(1).nbytes - default_stride = bytes_per_elem * component_nb stride = bufferView.byte_stride or default_stride @@ -146,7 +139,6 @@ class BinaryData(): else: # No buffer view; initialize to zeros - component_nb = gltf.component_nb_dict[accessor.type] array = np.zeros((accessor.count, component_nb), dtype=dtype) if accessor.sparse: diff --git a/io_scene_gltf2/io/imp/gltf2_io_gltf.py b/io_scene_gltf2/io/imp/gltf2_io_gltf.py index 49eee2d540752d1d6a5bae5ec6a46777345a4dcb..1607979a258880df973ed119c1b3e4684d578000 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_gltf.py +++ b/io_scene_gltf2/io/imp/gltf2_io_gltf.py @@ -51,24 +51,6 @@ class glTFImporter(): 'KHR_mesh_quantization', ] - # TODO : merge with io_constants - self.fmt_char_dict = {} - self.fmt_char_dict[5120] = 'b' # Byte - self.fmt_char_dict[5121] = 'B' # Unsigned Byte - self.fmt_char_dict[5122] = 'h' # Short - self.fmt_char_dict[5123] = 'H' # Unsigned Short - self.fmt_char_dict[5125] = 'I' # Unsigned Int - self.fmt_char_dict[5126] = 'f' # Float - - self.component_nb_dict = {} - self.component_nb_dict['SCALAR'] = 1 - self.component_nb_dict['VEC2'] = 2 - self.component_nb_dict['VEC3'] = 3 - self.component_nb_dict['VEC4'] = 4 - self.component_nb_dict['MAT2'] = 4 - self.component_nb_dict['MAT3'] = 9 - self.component_nb_dict['MAT4'] = 16 - @staticmethod def bad_json_value(val): """Bad Json value."""