Game Development Reference
In-Depth Information
if (keytotal[channel] == 1){
//Set directly no interpolation require if only one key
SetChannel(channel, anim[channel][0].value);
return;
}
if (time < anim[channel][0].time){
//Set directly no interpolation require if time is before first
//key
SetChannel(channel, anim[channel][0].value);
return;
}
if (time > anim[channel][keytotal[channel] - 1].time){
//Set directly no interpolation required if time after last key
SetChannel(channel,
anim[channel][keytotal[channel] - 1]->value);
return;
}
//Must be within range lets find the section under consideration
int key=0;
for (int i = 0;i < keytotal[channel]; i++){
if (time <= anim[channel][i].time){
key = i;
break;
}
}
if (time == anim[channel][key].time){
//Set directly no interpolation require if at a key time
SetChannel(channel, anim[channel][key].value);
return;
}
--key;
//Interpolation required
double t, tt, ttt, h0, h1, h2, h3, T1, T2;
double dur, mag, S1, S2;
//Calculate the section duration and magnitude for key and key + 1
dur = anim[channel][key + 1].time - anim[channel][key].time;
mag = anim[channel][key + 1].value - anim[channel][key].value;
Search Nedrilad ::




Custom Search