Changeset View
Changeset View
Standalone View
Standalone View
mocap/mocap_tools.py
| Show First 20 Lines • Show All 901 Lines • ▼ Show 20 Lines | if enduser_obj.parent: | ||||
| actionBStrip = actionBTrack.strips.new(TrackNamesB.stride_action, stitch_settings.blend_frame, bpy.data.actions[TrackNamesB.stride_action]) | actionBStrip = actionBTrack.strips.new(TrackNamesB.stride_action, stitch_settings.blend_frame, bpy.data.actions[TrackNamesB.stride_action]) | ||||
| actionBStrip.action_frame_start += stitch_settings.second_offset | actionBStrip.action_frame_start += stitch_settings.second_offset | ||||
| actionBStrip.action_frame_end += stitch_settings.second_offset | actionBStrip.action_frame_end += stitch_settings.second_offset | ||||
| actionBStrip.extrapolation = "NOTHING" | actionBStrip.extrapolation = "NOTHING" | ||||
| #we need to change the stride_bone's action to add the offset | #we need to change the stride_bone's action to add the offset | ||||
| aStrideCurves = [fcurve for fcurve in bpy.data.actions[TrackNamesA.stride_action].fcurves if fcurve.data_path == "location"] | aStrideCurves = [fcurve for fcurve in bpy.data.actions[TrackNamesA.stride_action].fcurves if fcurve.data_path == "location"] | ||||
| bStrideCurves = [fcurve for fcurve in bpy.data.actions[TrackNamesB.stride_action].fcurves if fcurve.data_path == "location"] | bStrideCurves = [fcurve for fcurve in bpy.data.actions[TrackNamesB.stride_action].fcurves if fcurve.data_path == "location"] | ||||
| scene.frame_set(stitch_settings.blend_frame - 1) | scene.frame_set(stitch_settings.blend_frame - 1) | ||||
| desired_pos = (enduser_obj.matrix_world * selected_bone.matrix.to_translation()) | desired_pos = (enduser_obj.matrix_world @ selected_bone.matrix.to_translation()) | ||||
| scene.frame_set(stitch_settings.blend_frame) | scene.frame_set(stitch_settings.blend_frame) | ||||
| actual_pos = (enduser_obj.matrix_world * selected_bone.matrix.to_translation()) | actual_pos = (enduser_obj.matrix_world @ selected_bone.matrix.to_translation()) | ||||
| print(desired_pos, actual_pos) | print(desired_pos, actual_pos) | ||||
| offset = Vector(actual_pos) - Vector(desired_pos) | offset = Vector(actual_pos) - Vector(desired_pos) | ||||
| for i, fcurve in enumerate(bStrideCurves): | for i, fcurve in enumerate(bStrideCurves): | ||||
| print(offset[i], i, fcurve.array_index) | print(offset[i], i, fcurve.array_index) | ||||
| for pt in fcurve.keyframe_points: | for pt in fcurve.keyframe_points: | ||||
| pt.co.y -= offset[i] | pt.co.y -= offset[i] | ||||
| pt.handle_left.y -= offset[i] | pt.handle_left.y -= offset[i] | ||||
| Show All 20 Lines | |||||