Game Development Reference
In-Depth Information
//Must need a key at the end of the current list
ikey = new MORPHKEY[keytotal + 1];
if (!ikey){
TRACE(”CMorph::CreateKey>>Problem creating keys\n”);
return NULL;
memcpy(ikey, keys, sizeof(MORPHKEY)*keytotal);
ikey[keytotal].frame = frame;
for (i=0; i<objcount; i++) key->level[i] = morphitem[i].level;
ikey[keytotal].linear = 0;
ikey[keytotal].tn = 0.0;
ikey[keytotal].ct = 0.0;
ikey[keytotal].bs = 0.0;
if (keys) delete [] keys;
keys = ikey;
return &keys[keytotal-1];
Interpolating the morph targets
The only remaining task is to interpolate between two morph keys. This is
done in exactly the same way as the motion curves are handled for
keyframe animation. Instead of interpolating three position values, three
rotation values and three scale values, objcount morph level values are
interpolated. To check out the interpolation method, refer to Chapter 8 on
keyframing. Each morphitem represents a different channel and is
handled independently. When keyframing you must make a choice with
the way you handle your code. You could have a keyframe value and
store levels for each morph target at this keyframe. Alternatively, you
could assign a frame value and level to each channel. Independent
channels are a little more awkward to handle and when animating the
channels can sometimes seem more trouble than they are worth, but for
maximum flexibility this method is obviously preferable. You pays your
money and you takes your choice. If you want the flexibility that
independently interpolated channels allow without the hassle, then
another technique is to use morphing groups. This technique has a lot to
recommend it.
Search Nedrilad ::

Custom Search