Skip to content

Commit

Permalink
Merge pull request #2296 from KhronosGroup/new_attribute_type
Browse files Browse the repository at this point in the history
New Attribute type
  • Loading branch information
julienduroure authored Aug 30, 2024
2 parents 2ff2d8f + 9606d74 commit 43b060d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addons/io_scene_gltf2/blender/com/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions addons/io_scene_gltf2/blender/exp/primitive_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 43b060d

Please sign in to comment.