glTF: Manage Quaternion and Matrix attribute types for custom attributes
This commit is contained in:
parent
58141b7396
commit
5122255739
@ -5,7 +5,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": (4, 3, 18),
|
||||
"version": (4, 3, 19),
|
||||
'blender': (4, 2, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
@ -93,6 +93,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,
|
||||
@ -116,6 +118,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,
|
||||
@ -130,6 +134,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
|
||||
@ -144,6 +150,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,
|
||||
@ -171,6 +179,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
|
||||
|
||||
|
@ -1332,6 +1332,12 @@ class PrimitiveCreator:
|
||||
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":
|
||||
|
Loading…
Reference in New Issue
Block a user