summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bck_export.py11
-rw-r--r--bck_import.py10
-rw-r--r--math_funcs.py10
3 files changed, 24 insertions, 7 deletions
diff --git a/bck_export.py b/bck_export.py
index 06a8658..4ed7d4e 100644
--- a/bck_export.py
+++ b/bck_export.py
@@ -84,7 +84,7 @@ def export_bck_func(options, context):
# rotation (Euler [all its combinations], Quaternions, Axis angle)
elif (fcurve.data_path == bone_data_path_str + bone_rot_mode_str):
# check if it is Euler in the euler order selected, if not, select the curves for later conversion
- if (bone_rot_mode_str == "rotation_euler" and bone_rot_euler_order_str == options.euler_mode):
+ if (bone_rot_mode_str == "rotation_euler" and pose_bone.rotation_mode == options.euler_mode):
bone_fcurves[int((3 * fcurve.array_index) + 1)] = fcurve
else:
foreign_fcurves[fcurve.array_index] = fcurve
@@ -280,7 +280,8 @@ def export_bck_func(options, context):
# get the best fit interpolation result
interp_result = math_funcs.find_best_cubic_hermite_spline_fit(options.first_frame,
bck_anim.anim_data[i].comp[j].value,
- options.angle_limit)
+ options.angle_limit,
+ options.max_concavity_changes)
# set the rounding digit
rounding = options.rounding_vec[0] # scale
if (j == 1 or j == 4 or j == 7): # rotation
@@ -371,6 +372,12 @@ class export_bck(Operator, ExportHelper):
min = 0,
max = 180,
)
+ max_concavity_changes = IntProperty(
+ name = "Max concavity changes",
+ description = "Number of concavity changes determined in an animation curve that when reached will trigger the generation of a keyframe. For export option \"Find Best Interpolator\"",
+ default = 1,
+ min = 1,
+ )
first_frame = IntProperty(
name = "First frame",
description = "Value used to specify the first frame of the animation",
diff --git a/bck_import.py b/bck_import.py
index 47e99ad..398f18d 100644
--- a/bck_import.py
+++ b/bck_import.py
@@ -458,7 +458,9 @@ def import_bck_func(context, options):
for i in range(lowest_anim_frame, greatest_anim_frame + 1):
values.append(fcurve.evaluate(i))
print(fcurve.data_path)
- new_kfs = math_funcs.find_best_cubic_hermite_spline_fit(lowest_anim_frame, values, options.angle_limit)
+ new_kfs = math_funcs.find_best_cubic_hermite_spline_fit(lowest_anim_frame, values,
+ options.angle_limit,
+ options.max_concavity_changes)
print(new_kfs)
# remove all keyframe points and add the new ones
@@ -548,6 +550,12 @@ class import_bck(Operator, ExportHelper):
min = 0,
max = 180,
)
+ max_concavity_changes = IntProperty(
+ name = "Max concavity changes",
+ description = "Number of concavity changes determined in an animation curve that when reached will trigger the generation of a keyframe. For Import Mode \"Keep Rest Pose - Find Best Interpolator\"",
+ default = 1,
+ min = 1,
+ )
euler_mode = EnumProperty(
name = "Euler order",
description = "Import rotation animations in the specified Euler angles order",
diff --git a/math_funcs.py b/math_funcs.py
index db8c44b..8a16d55 100644
--- a/math_funcs.py
+++ b/math_funcs.py
@@ -142,9 +142,7 @@ class best_chs_fits:
# each frame of the animation (start_frame indicates the start frame, integer)
# the function will return the above structure
# it will be in the general cubic hermite spline form (t0 < tf)
-
-# make it so that keyframe trigger variables can be modified
-def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
+def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit, max_concavity_changes):
# check
if ((type(start_frame) != int)
@@ -205,6 +203,7 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
new_concavity = None
generate_keyframe = None
small_time_dif = 0.000001
+ concavity_change_count = 0
# generate the keyframes
i = 0
while (i < len(values)):
@@ -258,7 +257,9 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
# check concavity changes
if (numpy.sign(old_concavity) != numpy.sign(new_concavity)):
- generate_keyframe = True
+ concavity_change_count += 1
+ if (concavity_change_count >= max_concavity_changes):
+ generate_keyframe = True
# scale the values up and check if the slope change is too violent with vector angles
# the scaling is done to be able to visually see the angle changes, it is the same thing
@@ -302,6 +303,7 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
# reset these variables for the next iteration
start_index = i
generate_keyframe = False
+ concavity_change_count = 0
# increment i
i += 1