Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2018-12-18 23:31:29 +0300
committerJulien Duroure <julien.duroure@gmail.com>2018-12-18 23:31:29 +0300
commitbf867f50228505710c51eb7d76832415c36d9f74 (patch)
tree0bff37b29027c65fd0dcd9f333772c2619f80532 /io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
parent9aa6c8058b32675b2636632d6735f66baf6300b1 (diff)
glTF exporter: various fixes & enhancement
* Fix some Yup conversions * reading material from glTF node group material if exists * Fix normal export * Round transforms near 0 and 1 * Fix exporting from Edit mode * Various image format management
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
index c94f1528..6846128d 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
@@ -107,37 +107,40 @@ def __gather_output(channels: typing.Tuple[bpy.types.FCurve],
target_datapath = channels[0].data_path
- transform = Matrix.Identity(4)
+ transform = blender_object.matrix_parent_inverse
+
+ isYup = export_settings[gltf2_blender_export_keys.YUP]
if blender_object.type == "ARMATURE":
bone = blender_object.path_resolve(get_target_object_path(target_datapath))
if isinstance(bone, bpy.types.PoseBone):
- transform = bone.bone.matrix_local
if bone.parent is not None:
parent_transform = bone.parent.bone.matrix_local
- transform = gltf2_blender_math.multiply(parent_transform.inverted(), transform)
- # if not export_settings[gltf2_blender_export_keys.YUP]:
- # transform = gltf2_blender_math.multiply(gltf2_blender_math.to_zup(), transform)
+ transform = gltf2_blender_math.multiply(transform, parent_transform.inverted())
+ # if not isYup:
+ # transform = gltf2_blender_math.multiply(transform, gltf2_blender_math.to_zup())
else:
# only apply the y-up conversion to root bones, as child bones already are in the y-up space
- if export_settings[gltf2_blender_export_keys.YUP]:
- transform = gltf2_blender_math.multiply(gltf2_blender_math.to_yup(), transform)
+ if isYup:
+ transform = gltf2_blender_math.multiply(transform, gltf2_blender_math.to_yup())
+ local_transform = bone.bone.matrix_local
+ transform = gltf2_blender_math.multiply(transform, local_transform)
values = []
for keyframe in keyframes:
# Transform the data and extract
value = gltf2_blender_math.transform(keyframe.value, target_datapath, transform)
- if export_settings[gltf2_blender_export_keys.YUP] and not blender_object.type == "ARMATURE":
+ if isYup and not blender_object.type == "ARMATURE":
value = gltf2_blender_math.swizzle_yup(value, target_datapath)
keyframe_value = gltf2_blender_math.mathutils_to_gltf(value)
if keyframe.in_tangent is not None:
in_tangent = gltf2_blender_math.transform(keyframe.in_tangent, target_datapath, transform)
- if export_settings[gltf2_blender_export_keys.YUP] and not blender_object.type == "ARMATURE":
+ if isYup and not blender_object.type == "ARMATURE":
in_tangent = gltf2_blender_math.swizzle_yup(in_tangent, target_datapath)
keyframe_value = gltf2_blender_math.mathutils_to_gltf(in_tangent) + keyframe_value
if keyframe.out_tangent is not None:
out_tangent = gltf2_blender_math.transform(keyframe.out_tangent, target_datapath, transform)
- if export_settings[gltf2_blender_export_keys.YUP] and not blender_object.type == "ARMATURE":
+ if isYup and not blender_object.type == "ARMATURE":
out_tangent = gltf2_blender_math.swizzle_yup(out_tangent, target_datapath)
keyframe_value = keyframe_value + gltf2_blender_math.mathutils_to_gltf(out_tangent)
values += keyframe_value