Help with InterpSetting class (Part 2: Bezier Easing Curves)
Posted: Mon Sep 26, 2022 2:02 pm
I have a rather complex question regarding the InterpSetting class (follow up to Part 1 about the component parameter). This is a code excerpt that sets a custom Bezier easing curve on a keyframe:
In short, I have two keyframes and want to draw a custom easing curve between them. I could plot the two Bezier control points relative to the points if Moho used something like cubic-bezier() in CSS (example: https://easings.net/#easeOutQuart) but Moho seems to use a different approach ... not so much for the percentage values but for the angles.
Through experimentation, I've learned that:
Hope this question makes sense to someone!
Thanks,
Dave
Code: Select all
local interpNew = MOHO.InterpSetting:new_local()
interpNew.interpMode = MOHO.INTERP_BEZIER
-- component = 0|1|2, corresponding to the x|y|z subchannels of the given channel
interpNew:SetBezierOutAngle(component, outA)
interpNew:SetBezierOutPercentage(component, outP)
interpNew:SetBezierInAngle(component, inA)
interpNew:SetBezierInPercentage(component, inP)
chan:SetKeyInterp(frameNum, interpNew)
Through experimentation, I've learned that:
- The Bezier easing parameters applied to a keyframe affect the tween between that keyframe and the following one, where "Out" refers to the control point on the first keyframe and "In" refers to the control point on the second keyframe (opposite of the "in"/"out" terminology used in Moho's UI)
- The SetBezierOutPercentage() and SetBezierInPercentage() methods govern where each keyframe's Bezier handle lies as a percentage (from 0 to 1) of the distance from that keyframe to the other
- The SetBezierOutAngle() and SetBezierInAngle() methods use radians, ranging from 0 indicating a handle that extends horizontally from the keyframe, to ±1.57 (±π/2), with positive being up from the first (out) keyframe or down from the second (in) keyframe.
- The SetBezierOutAngle() and SetBezierInAngle() angles relate to both the change in time (number of frames between keyframe 2 and keyframe 1) and change in distance (difference in subchannel value between keyframes 2 and 1).
Hope this question makes sense to someone!
Thanks,
Dave