Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Attribute type #2296

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading