diff options
author | “Humming-Owl” <“isaclien9752@gmail.com”> | 2023-08-29 01:59:50 -0400 |
---|---|---|
committer | “Humming-Owl” <“isaclien9752@gmail.com”> | 2023-08-29 01:59:50 -0400 |
commit | 4f8872265b483f0e6c6568dcb423b3638d5dee51 (patch) | |
tree | 20d45b689f470cb783019d3457aa5d0a0334d5b3 | |
parent | c16097bbf4230bc761e0f60be238b3362ef89c2b (diff) | |
download | blenxy-4f8872265b483f0e6c6568dcb423b3638d5dee51.tar.gz blenxy-4f8872265b483f0e6c6568dcb423b3638d5dee51.zip |
some minor edits
-rw-r--r-- | csv_anim_bck_import.py | 21 | ||||
-rw-r--r-- | my_functions.py | 29 |
2 files changed, 13 insertions, 37 deletions
diff --git a/csv_anim_bck_import.py b/csv_anim_bck_import.py index b9c5bbf..db65dd5 100644 --- a/csv_anim_bck_import.py +++ b/csv_anim_bck_import.py @@ -2,6 +2,8 @@ CSV importer for the BCK animation type CSVs that come from the j3d animation editor program animations for now will be imported with linear interpolation +seems to me that the majority of the animations just use linear +as the interpolation method between keyframes of animation rows ''' # Notes (AFAIK): @@ -10,15 +12,8 @@ animations for now will be imported with linear interpolation # - In all the Mario CSV BCKs I've seen from J3D Animation # Editor the "smooth" interpolation type isn't used at all # for animation rows that contain more than the first frame value -# or JAE just converts the animation to linear timing for easier -# processing -# - smooth interpolation uses the cubic hermite spline to get in-between -# keyframe values for the animation transition (I am not sure about this) -# - "tangent out" is the "symmetric" tangent mode explained on the link above -# (I am not sure about this) -# - "tangent in-out" is the "piece-wise" tangent mode explained on the link above -# (I am also not sure about this) -# - all "smooth" frame calculations will assume the upper assumptions +# it could be that JAE just converts the animation to linear +# timing for easier processing but I am not certain import bpy, math, re from mathutils import Matrix @@ -513,9 +508,7 @@ def read_csv_bck(context, filepath, import_type): # rest pose (irp) transformation matrix (T * R * S) ################################################### - anim_irp_mat = calc_translation_matrix(anim_temp[6], anim_temp[7], anim_temp[8]) - * calc_rotation_matrix(anim_temp[3], anim_temp[4], anim_temp[5]) - * calc_scale_matrix(anim_temp[0], anim_temp[1], anim_temp[2]) + anim_irp_mat = calc_translation_matrix(anim_temp[6], anim_temp[7], anim_temp[8]) * calc_rotation_matrix(anim_temp[3], anim_temp[4], anim_temp[5]) * calc_scale_matrix(anim_temp[0], anim_temp[1], anim_temp[2]) ######################################################### # calculate the animation matrix related to the rest pose @@ -526,9 +519,7 @@ def read_csv_bck(context, filepath, import_type): if (bone_number == 0): anim_rp_mat = anim_irp_mat else: - anim_rp_mat = (data_bone.parent.matrix_local.inverted() - * data_bone.matrix_local).inverted() - * anim_irp_mat + anim_rp_mat = (data_bone.parent.matrix_local.inverted() * data_bone.matrix_local).inverted() * anim_irp_mat ##################################### # extract calculated animation values diff --git a/my_functions.py b/my_functions.py index 1f76b82..49dc87d 100644 --- a/my_functions.py +++ b/my_functions.py @@ -94,28 +94,13 @@ def calc_translation_matrix(x_translation, y_translation, z_translation): ############################################################## # interpolate function -# used to find a value in an inte -rval with the specified mode. +# used to find a value in an interval with the specified mode. # So that it is clear that the values are points that have 2 # coordinates I will treat the input as they are (x,y) points # the function will either return m_x or m_y depending on -# which of the middle point value - -s is provided to the function +# which of the middle point values is provided to the function # (set None to the variable going to be returned by the -# function). Smooth will use the Cubic Hermite Spline -# interpolation method and will be the one using the point's -# derivatives/tangent. -# -# IMPORTANT (FOR SMOOTH INTERPOLA -TION): -# -# As I don't really have information on how to define -# tangent-out or tangent in/out interpolation (as JAE has -# already done those calculations) I will use the same -# interpolation method to both tangent-out or tangent in/out -# CSV files. If someone knows about this better please open -# an issue on blenxy's repository +# function). Only linear interpolation is supported for now. # # l_x (float) --> left point X axis component # l_y (float) --> left point Y axis component @@ -124,7 +109,6 @@ TION): # m_x (float) --> middle point X axis component # m_y (float) --> middle point Y axis component # interp_type (string) --> "linear" for linear interpolation -# "smooth" for smooth interpolation ############################################################## def interpolate(l_x, l_y, r_x, r_y, m_x, m_y, interp_type): # @@ -141,16 +125,17 @@ def interpolate(l_x, l_y, r_x, r_y, m_x, m_y, interp_type): ############################### # m_x is the one to be returned if (m_x == None): + + # linear interpolation if (interp_type == "linear"): m_x = (((r_x - l_x) / (r_y - l_y)) * (m_y - r_y)) + r_x result = m_x - else: # interpolation type is "smooth" - - ############################### # m_y is the one to be returned if (m_y == None): + + # linear interpolation if (interp_type == "linear"): m_y = (((r_y - l_y) / (r_x - l_x)) * (m_x - r_x)) + r_y result = m_y |