diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2022-03-29 18:44:36 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2022-03-29 18:44:36 +0300 |
commit | 564fdcdf7159013bc7087c9d12f2a034cfa3a945 (patch) | |
tree | 8ef27661b4c019c7a6ad9a6b2d4ac075531b9b79 /io_scene_gltf2/io/imp/gltf2_io_binary.py | |
parent | 1d5c8b54ee99433ff5c3ef416f1f9bc1fd8780ef (diff) |
glTF exporter: Manage skinning when some vertices are not weights at all
Diffstat (limited to 'io_scene_gltf2/io/imp/gltf2_io_binary.py')
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_binary.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index 21bbb41b..995fd3c9 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -77,6 +77,37 @@ class BinaryData(): return array + + @staticmethod + def decode_accessor_internal(accessor): + # Is use internally when accessor binary data is not yet in a glTF buffer_view + # MAT2/3 have special alignment requirements that aren't handled. But it + # doesn't matter because nothing uses them. + assert accessor.type not in ['MAT2', 'MAT3'] + + dtype = ComponentType.to_numpy_dtype(accessor.component_type) + component_nb = DataType.num_elements(accessor.type) + + buffer_data = accessor.buffer_view.data + + accessor_offset = accessor.byte_offset or 0 + buffer_data = buffer_data[accessor_offset:] + + bytes_per_elem = dtype(1).nbytes + default_stride = bytes_per_elem * component_nb + stride = default_stride + + array = np.frombuffer( + buffer_data, + dtype=np.dtype(dtype).newbyteorder('<'), + count=accessor.count * component_nb, + ) + array = array.reshape(accessor.count, component_nb) + + return array + + + @staticmethod def decode_accessor_obj(gltf, accessor): # MAT2/3 have special alignment requirements that aren't handled. But it |