diff --git a/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py b/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py index bb49cc7f9..d52526777 100644 --- a/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py +++ b/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py @@ -99,6 +99,8 @@ def get_component_type(attribute_component_type): "FLOAT_COLOR": gltf2_io_constants.ComponentType.Float, "FLOAT_VECTOR": gltf2_io_constants.ComponentType.Float, "FLOAT_VECTOR_4": gltf2_io_constants.ComponentType.Float, + "QUATERNION": gltf2_io_constants.ComponentType.Float, + "FLOAT4X4": gltf2_io_constants.ComponentType.Float, "INT": gltf2_io_constants.ComponentType.Float, # No signed Int in glTF accessor "FLOAT": gltf2_io_constants.ComponentType.Float, "BOOLEAN": gltf2_io_constants.ComponentType.Float, @@ -120,6 +122,8 @@ def get_data_type(attribute_component_type): "FLOAT_COLOR": gltf2_io_constants.DataType.Vec4, "FLOAT_VECTOR": gltf2_io_constants.DataType.Vec3, "FLOAT_VECTOR_4": gltf2_io_constants.DataType.Vec4, + "QUATERNION": gltf2_io_constants.DataType.Vec4, + "FLOAT4X4": gltf2_io_constants.DataType.Mat4, "INT": gltf2_io_constants.DataType.Scalar, "FLOAT": gltf2_io_constants.DataType.Scalar, "BOOLEAN": gltf2_io_constants.DataType.Scalar, @@ -133,6 +137,8 @@ def get_data_length(attribute_component_type): "FLOAT_COLOR": 4, "FLOAT_VECTOR": 3, "FLOAT_VECTOR_4": 4, + "QUATERNION": 4, + "FLOAT4X4": 16, "INT": 1, "FLOAT": 1, "BOOLEAN": 1 @@ -146,6 +152,8 @@ def get_numpy_type(attribute_component_type): "FLOAT_COLOR": np.float32, "FLOAT_VECTOR": np.float32, "FLOAT_VECTOR_4": np.float32, + "QUATERNION": np.float32, + "FLOAT4X4": np.float32, "INT": np.float32, #signed integer are not supported by glTF "FLOAT": np.float32, "BOOLEAN": np.float32, @@ -172,6 +180,10 @@ def get_attribute_type(component_type, data_type): gltf2_io_constants.ComponentType.UnsignedShort: "BYTE_COLOR", gltf2_io_constants.ComponentType.UnsignedByte: "BYTE_COLOR" # What is the best for compatibility? }.get(component_type, None) + elif gltf2_io_constants.DataType.num_elements(data_type) == 16: + return { + gltf2_io_constants.ComponentType.Float: "FLOAT4X4" + }.get(component_type, None) else: pass diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py index 84d8454ad..d2241457b 100644 --- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py +++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py @@ -1283,6 +1283,12 @@ def __get_layer_attribute(self, attr): elif attr['blender_data_type'] == "FLOAT_VECTOR": self.blender_mesh.attributes[attr['blender_attribute_index']].data.foreach_get('vector', data) data = data.reshape(-1, attr['len']) + elif attr['blender_data_type'] == "QUATERNION": + self.blender_mesh.attributes[attr['blender_attribute_index']].data.foreach_get('value', data) + data = data.reshape(-1, attr['len']) + elif attr['blender_data_type'] == "FLOAT4X4": + self.blender_mesh.attributes[attr['blender_attribute_index']].data.foreach_get('value', data) + data = data.reshape(-1, attr['len']) elif attr['blender_data_type'] == "FLOAT_VECTOR_4": # Specific case for tangent pass elif attr['blender_data_type'] == "INT":