Game Development Reference
In-Depth Information
positions is described as interpolating. One curve that is suited to the
problem is a Hermite, named after the mathematician. Again, we need to
consider this in a piecewise fashion, joining just two key positions with
each curve. We want to have control over the key position tangents, so
the variant of a Hermite curve that we will use is the Kochanek-Bartels or
TCB form. TCB stands for tension, continuity and bias. Any readers
familiar with Lightwave 3D will know that this form was the only motion
curve available until version 6. Adjusting the TCB parameters has the
effect of altering the tangent for the curve at the key positions. Now to find
a point P at time t on the curve between key positions K 1 and K 2, we find
tangent vectors T 1 for the beginning of the curve and T 2 for the end of the
curve. To find these tangent vectors, we first calculate scale factors
relating the interval to the sum of the interval and the preceding interval
and the sum of the interval and the following interval.
S 1=( K 2.time - K 1.time)/( K 2.time - K 0.time)
S 2=( K 2.time - K 1.time)/( K 3.time - K 1.time)
T 1= S 1 * (1 - K 1 * tn )(1 + K 1 * bs )(1 + K 1 * ct )( K 1.value - K 0.value)
+ (1 - K 1 * tn )(1 - K 1 * bs )(1 - K 1 * ct )( K 2.value - K 1.value)
T 2 = (1 - K 2 * tn )(1 + K 2 * bs )(1 - K 2 * ct )( K 2.value - K 1.value)
+ S 2 * (1 - K 2 * tn )(1 - K 2 * bs )(1 + K 2 * ct )( K 3.value - K 2.value)
If K 1 is the first key position then K 0 does not exist. In this case T 1 is
T 1 = (1 - K 1 * tn )(1 - K 1 * bs )(1 - K 1 * ct )( K 2.value - K 1.value)
If K 2 is the last key position then T 2 becomes
T 2 = (1 - K 2 * tn )(1 + K 2 * bs )(1 - K 2 * ct )( K 2.value - K 1.value)
The next stage of our curve-fitting procedure is to calculate the Hermite
coefficients at the actual time. We are dealing here with a parametric
curve where the parameter t varies between 0 and 1. Now you may well
have two key positions with time values of 6.3 and 9.87. But we need to
scale this interval to 1.0. This is very easily done. Suppose we want to
know the value for t at time 7.8. First, we subtract the start time of the
interval and then calculate the segment duration.
t
= 7.8 - 6.3 = 1.5
dur = 9.87 - 6.3 = 3.57
Search Nedrilad ::




Custom Search