From a7a3c5a96aa4490d1868611a4bbbdaadc5b1f5d8 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Tue, 19 Apr 2022 19:01:25 +0200 Subject: [PATCH] new offset anim method 1.2.0 - changed: curve offset on base 100 (allow multiple action with same curve path animation range) - changed: offset animation extrapolated by default (for potential motion blur at start and continue after curves end) --- CHANGELOG.md | 5 +++++ OP_animate_path.py | 30 ++++++++++++++++-------------- OP_setup_curve_a_to_b.py | 2 +- __init__.py | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ad2c1..e6a527b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +1.2.0 + +- changed: curve offset on base 100 (allow multiple action with same curve path animation range) +- changed: offset animation extrapolated by default (for potential motion blur at start and continue after curves end) + 1.1.0 - added: another method to add curve placing character in two position diff --git a/OP_animate_path.py b/OP_animate_path.py index 6ae74f2..0c3872b 100644 --- a/OP_animate_path.py +++ b/OP_animate_path.py @@ -318,11 +318,12 @@ def anim_path_from_translate(): length = fn.get_curve_length(curve) + ## steps: number of repetitions (how many times the move distance fit in the lenght of the curve) steps = length / move_val + ## frame_duration: number of frame for the move multiplied by the step frame_duration = int(steps * move_frame) - const = root.constraints.get("Follow Path") if not const: return 'ERROR', f'No "Follow Path" constraint on bone "{root.name}"' @@ -333,29 +334,30 @@ def anim_path_from_translate(): if fcu: ob.animation_data.action.fcurves.remove(fcu) - - ## add eval time animation on curve anim_frame = settings.start_frame - curve.data.path_duration = frame_duration - - # curve.data.eval_time = 0 - # curve.data.keyframe_insert('eval_time', frame=anim_frame) # , options={'INSERTKEY_AVAILABLE'} - - const.offset = 0 - const.keyframe_insert('offset', frame=anim_frame) + # curve.data.path_duration = frame_duration # set only 100 + curve.data.path_duration = 100 - # curve.data.eval_time = frame_duration - # curve.data.keyframe_insert('eval_time', frame=anim_frame + frame_duration) + const.offset = 0 + const.keyframe_insert('offset', frame=anim_frame) # , options={'INSERTKEY_AVAILABLE'} - const.offset = -frame_duration # negative (offset time rewinding so character move forward) + ## negative (offset time rewinding so character move forward) + + # const.offset = -frame_duration # Valid when duration is set same as curve's path_duration + # const.offset = -(((move_frame * 100) / frame_duration) * steps) # works and slightly more precise but super convoluted + const.offset = -100 const.keyframe_insert('offset', frame=anim_frame + frame_duration) - ## all to linear (will be set to CONSTANT at the moment of sampling) + ## All to linear (will be set to CONSTANT at the moment of sampling) fcu = ob.animation_data.action.fcurves.find(offset_data_path) if fcu: for k in fcu.keyframe_points: k.interpolation = 'LINEAR' + # Set extrapolation to linear to avoid a stop # TODO: maybe expose choice ? + fcu.extrapolation = 'LINEAR' # default is 'CONSTANT' + # defaut to linear (avoid mothion blur problem if start is set exactly on scene.frame_start) + ## set all to constant # for k in t_fcu.keyframe_points: # k.interpolation = 'CONSTANT' diff --git a/OP_setup_curve_a_to_b.py b/OP_setup_curve_a_to_b.py index ccc0c8c..bc036fc 100644 --- a/OP_setup_curve_a_to_b.py +++ b/OP_setup_curve_a_to_b.py @@ -60,7 +60,7 @@ class UAC_OT_create_a_b_step(bpy.types.Operator): a = markers[0].location b = markers[1].location - a # remove a postion to get position in curve object space - + # Set the curve and constraint curve = fn.generate_curve(location=a, direction=b, name='curve_path', context=context) settings = context.scene.anim_cycle_settings diff --git a/__init__.py b/__init__.py index 026f1d7..7914b08 100644 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,7 @@ bl_info = { "name": "Unfold Anim Cycle", "description": "Anim tools to develop walk/run cycles along a curve", "author": "Samuel Bernou", - "version": (1, 1, 0), + "version": (1, 2, 0), "blender": (3, 0, 0), "location": "View3D", "warning": "",