Game Development Reference
In-Depth Information
if (anim[channel][key + 1].linear){
//Straight linear interpolation
result = anim[channel][key].value +t * mag;
}else{
//Hermite interpolation required
//Calculate 0 <=t <= 1
t=(time - anim[channel][key].time) / dur;
//Calculatet squared as tt, andt cubed as ttt
tt=t*t; ttt=t*tt;
//Calculate the Hermite coefficients
h0 = 2 * ttt - 3 * tt + 1.0;
h1 = -2 * ttt + 3 * tt;
h2 = ttt - 2*tt +t;
h3 = ttt - tt;
//Calculate tangents
if (key==0){
//First key
T1 = (1.0 - anim[channel][key].tn) *
(1.0 - anim[channel][key].ct) *
(1.0 - anim[channel][key].bs) * mag;
}else{
S1 = dur /
(anim[channel][key + 1].time - anim[channel][key -
1].time)
T1 = S1 * (1.0 - anim[channel][key].tn) *
(1.0 + anim[channel][key].ct) *
(1.0 + anim[channel][key].bs) *
(anim[channel][key].value - anim[channel[key - 1].value) +
(1.0 - anim[channel][key].tn) *
(1.0 - anim[channel][key].ct) *
(1.0 - anim[channel][key].bs) * mag;
}
if (key == (keytotal[channel] - 3)){
//last section
T2 = (1.0 - anim[channel][key + 1].tn) *
(1.0 + anim[channel][key + 1].ct) *
(1.0 - anim[channel][key + 1].bs) * mag;
}else{
S2 = dur /
Search Nedrilad ::




Custom Search