I am having a bit of a problem with my camera interpolations. I am using a catmull-rom interpolation between several camera transforms. The transforms have different locations and quaternion rotations. The catmull-rom works perfectly for the locations, and nearly perfectly for the quaternions, except when the cameras need to rotate around something in a full circle, then there is always a point at which a full backward rotation occurs, instead of the short path (after the 3/4 circle rotation point).
I am using the DirectXMath library, which has a XMQuaternionSquad method, which has the exact same parameter list that the XMVectorCatmullRom has, but for quaternions. It makes use of quaternion slerp functions in its implementation. Using this, the animation starts out somewhat good, but quickly breaks (jumps) when the chain of rotations is stepped (I have a big array of camera transforms, but only 4 of them are interpolated at once, so when the interpolation factor is > 1, then the transform chain is offset by 1).
The MSDN documentation for the Quaternion Squad function also says that the XMQuaternionSquadSetup function needs to be used before this. But I had no success, the animation rotation keeps breaking when the chain is offset.
This is how I am trying right now:
(a, b, c, d are the transforms on the spline, t is a float between 0 and 1. With catmull-rom, the result location is always between b and c)
XMVECTOR Q1, Q2, Q3;
XMQuaternionSquadSetup(
&Q1, &Q2, &Q3,
XMLoadFloat4(&a->rotation),
XMLoadFloat4(&b->rotation),
XMLoadFloat4(&c->rotation),
XMLoadFloat4(&d->rotation)
);
XMVECTOR R = XMQuaternionSquad(
XMQuaternionNormalize(XMLoadFloat4(&a->rotation)),
XMQuaternionNormalize(Q1),
XMQuaternionNormalize(Q2),
XMQuaternionNormalize(Q3),
t
);
R = XMQuaternionNormalize(R);
Anyone had any luck getting this to work?