Game Development Reference
InDepth Information
movement in the
x
axis with the six keyframes that will be created, rather
than using just two keys for the
x
movement.
Interpolating by frame and time
Every single one of our objects, whether they are in motion or not, will
need a keyframe defining for all motion channels at time zero. We will
define a key channel as
typedef struct stKEYCHANNEL{
float time;
float value; //Actual magnitude
float tn, bs, ct; //Tension, bias and continuity
int linear;
//Flag to indicate that the key is linear
}KEYCHANNEL
If we can consider each channel independently then the code problem
becomes how to interpolate a single channel. Suppose a particular
channel has five key positions. We have five values for time and five
floatingpoint values. Figure 8.2 shows a plot of these five points; the
points are joined using straight lines. This method of linear interpolation is
extremely easy to do. Between any two keyframes,
K
1 and
K
2, the value
of a point
P
at time
t
is given by
P
=
K
1.value + ((
t

K
1.time)/(
K
2.time 
K
1.time))
*
(
K
2.value 
K
1.value)
Figure 8.2 Linear interpolation of five key values against time.
Search Nedrilad ::
Custom Search