diff options
Diffstat (limited to 'io_scene_gltf2/blender/com/gltf2_blender_conversion.py')
-rwxr-xr-x | io_scene_gltf2/blender/com/gltf2_blender_conversion.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/io_scene_gltf2/blender/com/gltf2_blender_conversion.py b/io_scene_gltf2/blender/com/gltf2_blender_conversion.py index ecb91c8f..85ab654a 100755 --- a/io_scene_gltf2/blender/com/gltf2_blender_conversion.py +++ b/io_scene_gltf2/blender/com/gltf2_blender_conversion.py @@ -2,6 +2,8 @@ # Copyright 2018-2021 The glTF-Blender-IO authors. from math import sin, cos +import numpy as np +from io_scene_gltf2.io.com import gltf2_io_constants def texture_transform_blender_to_gltf(mapping_transform): """ @@ -48,3 +50,55 @@ def get_target(property): "scale": "scale", "value": "weights" }.get(property) + +def get_component_type(attribute_component_type): + return { + "INT8": gltf2_io_constants.ComponentType.Float, + "BYTE_COLOR": gltf2_io_constants.ComponentType.UnsignedShort, + "FLOAT2": gltf2_io_constants.ComponentType.Float, + "FLOAT_COLOR": gltf2_io_constants.ComponentType.Float, + "FLOAT_VECTOR": gltf2_io_constants.ComponentType.Float, + "FLOAT_VECTOR_4": 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 + }.get(attribute_component_type) + +def get_data_type(attribute_component_type): + return { + "INT8": gltf2_io_constants.DataType.Scalar, + "BYTE_COLOR": gltf2_io_constants.DataType.Vec4, + "FLOAT2": gltf2_io_constants.DataType.Vec2, + "FLOAT_COLOR": gltf2_io_constants.DataType.Vec4, + "FLOAT_VECTOR": gltf2_io_constants.DataType.Vec3, + "FLOAT_VECTOR_4": gltf2_io_constants.DataType.Vec4, + "INT": gltf2_io_constants.DataType.Scalar, + "FLOAT": gltf2_io_constants.DataType.Scalar, + "BOOLEAN": gltf2_io_constants.DataType.Scalar, + }.get(attribute_component_type) + +def get_data_length(attribute_component_type): + return { + "INT8": 1, + "BYTE_COLOR": 4, + "FLOAT2": 2, + "FLOAT_COLOR": 4, + "FLOAT_VECTOR": 3, + "FLOAT_VECTOR_4": 4, + "INT": 1, + "FLOAT": 1, + "BOOLEAN": 1 + }.get(attribute_component_type) + +def get_numpy_type(attribute_component_type): + return { + "INT8": np.float32, + "BYTE_COLOR": np.float32, + "FLOAT2": np.float32, + "FLOAT_COLOR": np.float32, + "FLOAT_VECTOR": np.float32, + "FLOAT_VECTOR_4": np.float32, + "INT": np.float32, #signed integer are not supported by glTF + "FLOAT": np.float32, + "BOOLEAN": np.float32 + }.get(attribute_component_type) |