Game Development Reference
In-Depth Information
(anim[channel][key + 2].time - anim[channel][key].
time);
T2 = S2 * (1.0 - anim[channel][key + 1].tn) *
(1.0 + anim[channel][key + 1].ct) *
(1.0 - anim[channel][key + 1].bs) * mag +
(1.0 - anim[channel][key].tn) *
(1.0 - anim[channel][key].ct) *
(1.0 + anim[channel][key].bs);
(anim[channel][key + 2].value - anim[channel[key + 1].
value);
}
result = h0 * anim[channel][key] +
h1 * anim[channel][key + 1].value + h2 * T1 + h3 * T2;
}
SetChannel(channel,result);
}
Using quaternions to interpolate the orientation
If we choose to use Euler angles as the storage parameter for orientation
but we want to use quaternions for the interpolation, then we need a way
to swap between Euler angles and quaternions. The benefit is that this
type of interpolation results in a smoother animation of the orientation of
an object than using Hermite curve fitting, justifying the additional work.
The quaternion derived from Euler angles is given by:
q = qh qp qb
where
qh = [cos( h /2), (sin( h /2), 0, 0)]
qp = [cos( p /2), (0, sin( p /2), 0)]
qb = [cos( b /2), (0, 0, sin( b /2))]
Now we can create a function that converts Euler angles to a
quaternion. First we need to define a structure to hold a quaternion:
typedef struct stQUATERNION{
double w, x,y, z;
}QUATERNION;
Search Nedrilad ::




Custom Search