#3ds file: rot keyframes
4 messages in this thread
We are using the 3D Studio Release 3 File Toolkit to read in mesh and keyframe
info. Our model is rotating a small amount around the axis <1,0,0>. We
figured out that while the translations are absolute, the rotations are
incremental. Sometimes the axis is <1,0,0> and sometimes it is <-1,0,0>, but
the sign of the angle is not inverting. This is causing our animated model
suddenly change heading by 90 degrees. Is this in some way related to
quaternions?
To build a cumulative rotation matrix for each keyframe, I first construct a
quaternion from the axis and angle, construct a rotation matrix from the
quaternion, then concatenate it with the previous rotation matrices. Is this a
correct procedure given the format of the rotation keyframes, or am I
neglecting an important piece of data?
Thanks,
Mark Hodges
Gravity Inc.
Hi Mark,
>> Sometimes the axis is <1,0,0> and sometimes it is <-1,0,0>, but the sign of
the angle is not inverting. This is causing our animated model suddenly change
heading by 90 degrees. Is this in some way related to quaternions? <<
Is this happening on a key to key basis through a single motion path, or on
key zero? If you are talking about the variations on key zero, the following
information may help.
When objects are created in the editor, the signs on their Euler matrix will
vary depending on what viewport they were created in. These rotations are
assigned because when you create an object in the left viewport, its "front"
will be rotated to the left (Z axis rotation I think).
>> To build a cumulative rotation matrix for each keyframe, I first construct
a quaternion from the axis and angle, construct a rotation matrix from the
quaternion, then concatenate it with the previous rotation matrices.
Is this a correct procedure given the format of the rotation keyframes, or am
I neglecting an important piece of data? <<
I think you need to be interpolating the quaternians and then converting that
result into a Euler. Adding together Euler's won't give you the results you
want because of discontinuities in the tan function.
You may also want to take a look at Quatern.zip in the library. It's a
compilation of all the quaterian related threads over the last 2 years. It's
good stuff.
-Grant Blaha [ADESK]
Grant-
>> >> Sometimes the axis is <1,0,0> and sometimes it is <-1,0,0>, but the sign
of the angle is not inverting. This is causing our animated model suddenly
change heading by 90 degrees. Is this in some way related to quaternions? <<
<<
Whoops! I meant 180 degrees.
>> Is this happening on a key to key basis through a single motion path, or on
key zero? <<
It's happening on frames after zero on a key to key basis through a single
motion path.
>> I think you need to be interpolating the quaternians and then converting
that result into a Euler. Adding together Euler's won't give you the results
you want because of discontinuities in the tan function. <<
Actually, we are not currently doing any interpolation. We have 3D Studio spit
out keyframe information for every frame, and use that.
You may also want to take a look at Quatern.zip in the library. It's a
compilation of all the quaterian related threads over the last 2 years. It's
good stuff. <<
Yes, I suspect it is a quaternion quirk. I'll investigate your suggestion.
Thanks for all the great help!
Mark Hodges
Gravity Inc.
AAAAAHHHHHH! I found the solution!!!
PROBLEM STATEMENT: 3DS file keyframes are incremental. Find absolute
rotations for each keyframe.
BAD SOLUTION: Convert each rot keyframe to a 4×4 matrix. Find the accumulated
rotation by concatenating the new matrix with previous keyframe rotation
matrices. Convert the resulting matrix back into a quaternion.
This caused my model to pivot by 180 degrees whenever the rotation angle was
reversed in the middle of the animation. My guess is this may have something
to do with the fact that a rotation may be represented by 2 quaternions.
(Negate angle and axis to get the other quaternion.) I really haven't
investigated why this happens, though I am currious to know what the true
reason is.
CORRECT SOLUTION: Scap the intermediate matrices. Accumulate the rotations
with quaternions.
quatAccum *= quat[i]
Thanks again for the support!
Mark Hodges
Gravity Inc.