Game Development Reference
In-Depth Information
var animationCache;
var frame;
var currentTime, unloopedCurrentTime;
var currentPoint, forwardPoint, angle;
We first calculate the current time by adding the elapsed time to it as shown in the
following code snippet:
this.currentTime += deltaTimeMS;
unloopedCurrentTime = this.currentTime;
The unloopedCurrentTime value is maintained to see if the current time does not
exceed the total animation time. If it is not a looping animation, then this variable
is checked to stop the animation. Then, we find the moduli of the current time to
eliminate the natural number from the current time.
currentTime=0.9;
currentTime(0.9) + elapsedTime(0.2) = unloopedCurrentTime(1.1);
currentTime(1.1)%1 = currentTime(0.1).
The unloopedCurrentTime value becomes greater than 1 . We remove the natural
number from the currentTime . At that time, the unloopedCurrentTime is not equal
to currentTime .
currentTime = this.currentTime =
this.currentTime % this.data.length;
We then iterate over all bones as follows:
for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) {
object = this.hierarchy[ h ];
animationCache = object.animationCache;
Iterate over types to get the key information for types ( pos , rot , and scl ) shown
as follows:
for ( var t = 0; t < 3; t ++ ) {
Get the current, previous, and next key frames for the bone and type from the
animation cache.
type = types[ t ];
prevKey = animationCache.prevKey[ type ];
nextKey = animationCache.nextKey[ type ];
 
Search WWH ::




Custom Search