|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Keyframe Interpolation using Euler Angles
|
|
|
I’m trying to implement a keyframe animation based on the Euler angles that I get from the rotation curves. Just interpolating the angles and constructing the matrix does not work due to the angles wrapping around 180.
My question is this:
How are the matrices created from the Euler angles in between key frames?
Given two key frames
t0
Sx0 Sy0 Sz0
Rx0 Ry0 Rz0
Tx0 Ty0 Tx0
t1
Sx1 Sy1 Sz1
Rx1 Ry1 Rz1
Tx1 Ty1 Tz1
How do I construct the matrix at time ‘t’? where (t0 <= t <= t1)
|
|
|
|
Quaternion works better for rotation interpolation, especially for angles wrapping around 180 problem, how about convert the Euler angles to quaternion first, then do the interpolation?
Also, I think you need to take account of different interpolation mode (constant, linear or cubic, etc.), which will give out different curve.
Jiayang Xu
Maya Data Platform
Autodesk
|
|
|
|
|
I agree that quats are better, but I’m trying to match Maya/FBX. How does Maya or FBX do keyframe interpolation? Are the Euler angles converted to quats?
If quaternions are better, why are the keyframes exported as Euler angles?
Also, how would you do the different interpolation modes on quats?
Author: Doug Rogers
|
| Replied: 26 April 2010 04:23 AM
|
|
|
|
|
OK, I think you can use SDK to do interpolation in this way:
1. Create Animation Curves for each element of the transform matrix. It is an empty animcurve now.
2. Set keys on each animation curves. For each moment t0 and t1, set key value, key tangent type, and interpolation mode. There are some keys on the curves now.
3. Call KFbxAnimCurve.Evaluate(KTime pTime) to get the interpolation values between t0 and t1.
/** Evaluate animation curve value at a given time.
* \param pTime Time of evaluation.
* If time falls between two keys, animation curve value is
* interpolated according to previous key interpolation type and
* tangent mode if relevant.
Please refer to AnimLayersAndStack sample in the 2011.2 SDK for more implementation details.
Thanks.
Jiayang Xu
Maya Data Platform
Autodesk
|
|
|
|
|
What I am trying to do is to recreate the interpolation that Maya/FBX is doing, not using the SDK to do the interpolation.
So my question still stands, how does Maya/FBX do the keyframe interpolation? Is there some code snippet you can post?
Author: Doug Rogers
|
| Replied: 27 April 2010 03:07 AM
|
|
|
|
|
|
I am afraid that we are not allowed to post internal code, and it is way too much than just a code snippet.
May I ask why you have to recreate the interpolation other than use SDK functions?
I did not go through the whole interpolation code but I believe there is no such thing as “transform matrix interpolation” in SDK, it is also interpolating the Euler angles and then constructing the matrix when necessary, for the problem that angles wrapping around 180, there are some curve filter called unroll filter to handle that.
And Maya is using a similar way to do Euler interpolation, the followings are from Maya’s document:
“When Euler angles are used to interpolate the animated rotations of an object, the object’s orientation about its individual axes is evaluated one axis at a time. This is why Euler-angled rotation is prone to artifacts such as gimbal lock and flipping.
If gimbal lock or flipping occurs, you may be able to correct this behavior using the Euler Filter. For example, you can use the Euler Filter to normalize the mangled rotation curves from corrupted motion capture animation data. You can access the Euler Filter from the Curves menu in the Graph Editor or Dope Sheet. For more information on the Euler filter, see Euler angle filtering and filterCurve. “
Author: Jiayang Xu
|
| Replied: 27 April 2010 03:29 PM
|
|
|
|
May I ask why you have to recreate the interpolation other than use SDK functions?
Because the animation is going to be imported into another system where the SDK functions will not be available.
I am at least hoping that you have an overview of the Euler interpolation algorithm so that the method can be reconstructed.
It’s a real shame that an interpolation algorithm is that complicated so that it cannot be recreated outside the SDK environment. It’s unfortunate that the only thing you can offer is the SDK or quaternions; and quaternions cannot reproduce the same animation types and are not even exported by the SDK.
|
|
|
|
|
Hi, Doug, the Euler interpolation algorithm is not very complicated, for sure you can re-create it outside of FBXSDK, we are using the common interpolation algorithm that you can find easily on web, for example, for cubic interpolation:
http://en.wikipedia.org/wiki/Cubic_interpolation
For constant and linear interpolation mode, the algorithm is even easiler, and I am pretty sure you know that already and may already implemented them.
Next, the unroll curve filter part is a little bit more tricky, but the basic idea is simple, to ensure an continuous rotation. You can re-sample the rotation curve and during the re-sample process, compare each new key with the previous one to see if its change is too dramatic according to certain standard, if so, unroll it.
I understand these codes could save you a lot of time, but hi, you are kinda asking for partial open-source here, that is some decision out of FBX team’s control. But we are all willing to discuss SDK usage, mathematical and algorithm problems with you, please feel free to ask here if you run into specific problems during the implementation.
Thank you.
Author: Jiayang Xu
|
| Replied: 27 April 2010 09:45 PM
|
|
|
|
|
Thanks. I am familiar with the various interpolation methods but:
a) you cannot apply them to the individual component of Euler angles then reconstruct the rotation.
Specifically, I do not believe you can interpolate the Rx,Ry,Rz Euler angles using any method, then combine the interpolated angles to make a rotation because of the 180 wrap around.
There need to be some addition handling of the +/-180 angle which is what I am asking for.
b) they do not work on quaternions
So how are the Euler angles interpolated and recombined to form the final rotation that is obtained through GetR()?
I’m not asking for source, just the method used to interpolate and reconstruct the rotation and any give time to address the Euler issues.
Thanks.
|
|
|
|
|
Hi, Doug, sorry for the late reply.
FBX SDK does not do interpolation on the whole rotation matrix, but do interpolation on each channel, that is Rx, Ry, Rz Euler angles.
After the interpolation, for each channel(Euler angle), there will be a rotation animation curve.
Then post-process the -180/+180 problem by something called unroll filter on the 3 rotation animation together, as I mentioned above.
The basic idea of unroll filter is to compare the interpolation value at time T with the previous interpolation value to detect if there is any dramatic change like 180/-180 jump rotation.
If so, regulate the interpolation value at time T to make sure rotation curves changes continuously and smoothly.
So more interpolation values to describe the rotation curve, more effective the unroll filter.
But to make sure, I will confirm this with Viviane who is more familar with unroll filter.
Author: Jiayang Xu
|
| Replied: 09 May 2010 07:10 PM
|
|
|
|
|
Can you at least tell me how FBX/Maya handle the -180/+180 issue interpolating Euler angles?
|
|
|
|
Hi Doug,
As Jiayang mentionned, we use the Unroll filter to prevent those gimble problems.
The Unroll filter works with a set of 3 rotation curves, or it can also be passed a KFbxAnimCurveNode. The curves are expected to be in the order X,Y,Z, regardless of the node’s rotation order. The rotation curves are unrolled with priority on the Y axis… or whichever curve is in the second position.
When the Unroll filter is applied, an interpolation quality factor is computed. If the quality is lower than this threshold, the Unroll filter will keep the original value for the treated key. The default value for tolerance is 0.25, and can be set with SetQualityTolerance(). This value is only used if you set SetTestForPath() to true.
Here is how to use the Unroll filter:
KFbxAnimCurve* lCurve [3]; lCurve[0] = curveX; lCurve[1] = curveY; lCurve[2] = curveZ; KFbxKFCurveFilterUnroll* lFilter = KFbxKFCurveFilterUnroll::Create(mFbxSdkManager,"")
lFilter->Reset()
double lPrecision = 0.25; lFilter->SetTestForPath(true)
lFilter->SetQualityTolerance(lPrecision)
lFilter->Apply((KFbxAnimCurve**)lCurve, 3)
Finally, it should be noted that the filter performance’s increases when the curves are oversampled.
Viviane, FBX Team
Viviane Rochon
Maya Data Platform
Autodesk
|
|
|
|
|
Thanks, but I would like to be able to reproduce the same behavior outside of the FBX SDK. Can provide some pseudo code for what the interpolation is actually doing when it does the unrolling?
Thanks.
-Doug
Author: Doug Rogers
|
| Replied: 10 May 2010 04:07 AM
|
|
|
|
|
|
Double post again
Author: Doug Rogers
|
| Replied: 10 May 2010 06:04 AM
|
|
|
|
|
Hi Doug,
Basically, the idea is that an axis (Y) is priviledged for the rotations to be unrolled. Instead of being limited to (-180, 180), the values of the keys for this axis’ curve are unrolled as needed, as high or as low as needed. The other two axis’ curves are adjusted accordingly.
Here is an example that comes from the 3ds Max FBX Plug-in documentation.
Viviane
Viviane Rochon
Maya Data Platform
Autodesk
| Attachment
|
|
|
|
|
|
|
Ah, I see. That is what I needed. I’ll give it a go.
Thanks.
Author: Doug Rogers
|
| Replied: 10 May 2010 02:41 PM
|
|
|
|
|