From fb0a659c9ca3479fd6799325498b11f074689936 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Mon, 2 Apr 2012 14:57:31 -0700 Subject: -Namespaced all RDGE javascript. -Removed the following unused files from the build script /core/script/fx/blur.js /core/script/fx/ssao.js /core/script/animation.js - Fully removed the following from the build and from source control as they are unused or no longer needed /core/script/util/dbgpanel.js /core/script/util/fpsTracker.js /core/script/util/statTracker.js /core/script/input.js /core/script/TextureManager.js /core/script/ubershader.js --- .../RDGE/src/core/script/animation.js | 191 ++++++++++----------- 1 file changed, 95 insertions(+), 96 deletions(-) (limited to 'js/helper-classes/RDGE/src/core/script/animation.js') diff --git a/js/helper-classes/RDGE/src/core/script/animation.js b/js/helper-classes/RDGE/src/core/script/animation.js index 63eca0a2..c82a0e76 100755 --- a/js/helper-classes/RDGE/src/core/script/animation.js +++ b/js/helper-classes/RDGE/src/core/script/animation.js @@ -4,8 +4,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var g_numChannels = new stat( "animation", "numChannels", 0, null, false ); -var g_numTracks = new stat( "animation", "numTracks", 0, null, false ); +// RDGE namespaces +var RDGE = RDGE || {}; +RDGE.animation = RDGE.animation || {}; /** * channelController @@ -18,68 +19,68 @@ var g_numTracks = new stat( "animation", "numTracks", 0, null, false ); * @param _channel - the channel id * */ -channelController = function(_animation, _channel) { - /** - * this.interpolate - Enable/Disable interpolation between animation frames. - * Typically this should be enabled for smoother looking animation. However, - * there may be applications where interpolation is undesireable. - */ +RDGE.animation.channelController = function (_animation, _channel) { + /** + * this.interpolate - Enable/Disable interpolation between animation frames. + * Typically this should be enabled for smoother looking animation. However, + * there may be applications where interpolation is undesireable. + */ this.interpolate = false; - + /** - * this.animation - the animation resource. - * This is where the keyframes for the channel are stored. - */ + * this.animation - the animation resource. + * This is where the keyframes for the channel are stored. + */ this.animation = _animation; - + /** - * this.channel - the channel id. This is used to look up the keyframe data for this channel. - */ + * this.channel - the channel id. This is used to look up the keyframe data for this channel. + */ this.channel = _channel; - + /** - * this.localTime - the current time, relative to the start time. - */ + * this.localTime - the current time, relative to the start time. + */ this.localTime = 0.0; - + /** - * this.startTime - the start time of the animation clip window. - */ + * this.startTime - the start time of the animation clip window. + */ this.startTime = this.animation.clipStart / this.animation.framesPerSec; /** - * this.endTime - the end time of the animation clip window. - */ + * this.endTime - the end time of the animation clip window. + */ this.endTime = this.animation.clipEnd / this.animation.framesPerSec; - + /** - * this.cachedFrame - cached frame index, this optimizes best case scenario computeFrame calls. - */ + * this.cachedFrame - cached frame index, this optimizes best case scenario computeFrame calls. + */ this.cachedFrame = -1; - + /** - * oneFrameInSecs - stores the interval of a single frame in seconds. This is used for internal calculations. - */ + * oneFrameInSecs - stores the interval of a single frame in seconds. This is used for internal calculations. + */ oneFrameInSecs = 1.0 / _animation.framesPerSec; - /** - * this.channel.timeline - stores the animation timeline. - * Currently this is calculated based on the framePerSec settings of the animation. - * Eventually the timeline should be exported with the animation. Individual channels - * may have different timelines depending on which frames are keyed. - */ + /** + * this.channel.timeline - stores the animation timeline. + * Currently this is calculated based on the framePerSec settings of the animation. + * Eventually the timeline should be exported with the animation. Individual channels + * may have different timelines depending on which frames are keyed. + */ this.channel.timeline = new Array(this.channel.numKeys + 1); for (i = 0; i <= this.channel.numKeys; ++i) { this.channel.timeline[i] = i / this.animation.framesPerSec; } - /** this.computeFrame - * Calculates the current frame index of the animation at the current time. - * In the worst case, this function will perform a binary search for the frame - * whose time is closest to and less than the current time. In the best case, - * the current frame is near the most recently cached frame, or it remains unchanged. - */ - this.computeFrame = function() { + /** this.computeFrame + * Calculates the current frame index of the animation at the current time. + * In the worst case, this function will perform a binary search for the frame + * whose time is closest to and less than the current time. In the best case, + * the current frame is near the most recently cached frame, or it remains unchanged. + */ + this.computeFrame = function () { var absTime = this.localTime + this.startTime; var start = this.animation.clipStart; var end = this.animation.clipEnd; @@ -134,21 +135,21 @@ channelController = function(_animation, _channel) { this.cachedFrame = start; return start; - } + }; - /* this.sampleBool - Sample a boolean at the current frame, booleans are not interpolated. - * This function is used internally. - */ - this.sampleBool = function() { + /* this.sampleBool - Sample a boolean at the current frame, booleans are not interpolated. + * This function is used internally. + */ + this.sampleBool = function () { // no interpolation on flags... var index = this.computeFrame(); return this.channel.keys[index]; - } + }; - /* this.sampleQuat - Sample a quaternion at the current frame. - * if this.interpolate == true, quaternions are interpolated inbetween frames using spherical linear interpolation (SLERP). - */ - this.sampleQuat = function() { + /* this.sampleQuat - Sample a quaternion at the current frame. + * if this.interpolate == true, quaternions are interpolated inbetween frames using spherical linear interpolation (SLERP). + */ + this.sampleQuat = function () { var frame0 = this.computeFrame(); var frame1 = frame0 + 1; @@ -162,16 +163,16 @@ channelController = function(_animation, _channel) { var t = (absTime - k0) / (k1 - k0); var a = [this.channel.keys[index0 + 0], this.channel.keys[index0 + 1], this.channel.keys[index0 + 2], this.channel.keys[index0 + 3]]; var b = [this.channel.keys[index1 + 0], this.channel.keys[index1 + 1], this.channel.keys[index1 + 2], this.channel.keys[index1 + 3]]; - return quat.slerp(a, b, t); + return RDGE.quat.slerp(a, b, t); } return [this.channel.keys[index0 + 0], this.channel.keys[index0 + 1], this.channel.keys[index0 + 2], this.channel.keys[index0 + 3]]; - } + }; - /* this.sampleVec3 - Sample a vector3 at the current frame. - * if this.interpolate == true, vectors are interpolated inbetween frames using linear interpolation (LERP). - */ - this.sampleVec3 = function() { + /* this.sampleVec3 - Sample a vector3 at the current frame. + * if this.interpolate == true, vectors are interpolated inbetween frames using linear interpolation (LERP). + */ + this.sampleVec3 = function () { var frame0 = this.computeFrame(); var frame1 = frame0 + 1; @@ -186,14 +187,14 @@ channelController = function(_animation, _channel) { var a = [this.channel.keys[index0 + 0], this.channel.keys[index0 + 1], this.channel.keys[index0 + 2]]; var b = [this.channel.keys[index1 + 0], this.channel.keys[index1 + 1], this.channel.keys[index1 + 2]]; - return vec3.lerp(a, b, t); + return RDGE.vec3.lerp(a, b, t); } return [this.channel.keys[index0 + 0], this.channel.keys[index0 + 1], this.channel.keys[index0 + 2]]; - } + }; - /* this.setTime - set the current time. - */ - this.setTime = function(t) { + /* this.setTime - set the current time. + */ + this.setTime = function (t) { this.localTime = t; if (this.localTime < 0.0) { this.localTime = 0.0; @@ -201,23 +202,23 @@ channelController = function(_animation, _channel) { if (this.localTime > this.animation.duration - oneFrameInSecs) { this.localTime = this.animation.duration - oneFrameInSecs; } - } + }; - /* this.setProgress - set the current time as a percentage of the duration. - */ - this.setProgress = function(f) { + /* this.setProgress - set the current time as a percentage of the duration. + */ + this.setProgress = function (f) { this.setTime(f * this.animation.duration); - } - - /* this.setFrame - set the current time by frame number. - */ - this.setFrame = function(f) { + }; + + /* this.setFrame - set the current time by frame number. + */ + this.setFrame = function (f) { this.setTime(f / this.animation.framesPerSec); - } + }; - /* this.step - advance time by the given timestep and wrap if looping. - */ - this.step = function(_dt) { + /* this.step - advance time by the given timestep and wrap if looping. + */ + this.step = function (_dt) { this.localTime += _dt; if (this.animation.looping) { while (this.localTime < 0.0) { @@ -234,8 +235,8 @@ channelController = function(_animation, _channel) { this.localTime = this.animation.duration; } } - } -} + }; +}; /** * track @@ -246,17 +247,16 @@ channelController = function(_animation, _channel) { * @param _node - the scene node * */ -track = function(_animation, _track, _node) { +RDGE.animation.track = function (_animation, _track, _node) { this.track = _track; this.node = _node; this.channelControllers = new Array(); for (ch in _track) { - this.channelControllers[ch] = new channelController(_animation, _track[ch]); - g_numChannels.value++; + this.channelControllers[ch] = new RDGE.animation.channelController(_animation, _track[ch]); } - this.step = function(_dt) { + this.step = function (_dt) { for (cc in this.channelControllers) { this.channelControllers[cc].step(_dt); } @@ -268,15 +268,15 @@ track = function(_animation, _track, _node) { this.node.hide = !vis; } - var m = mat4.identity(); - m = mat4.scale(m, scale); - m = mat4.mul(m, quat.toMatrix(rotate)); - m = mat4.translate(m, translate); - this.node.local = m; + var m = RDGE.mat4.identity(); + m = RDGE.mat4.scale(m, scale); + m = RDGE.mat4.mul(m, RDGE.quat.toMatrix(rotate)); + m = RDGE.mat4.translate(m, translate); + this.node.local = m; } -} +}; -animation = function(_scene, _clipStart, _clipEnd, _loop) { +RDGE.animation.animation = function (_scene, _clipStart, _clipEnd, _loop) { this.animation = _scene.scene.animation; this.clipStart = _clipStart; // this is a little hacky, but it works for now. @@ -300,23 +300,22 @@ animation = function(_scene, _clipStart, _clipEnd, _loop) { // creating a mapping here to make binding tracks a little more // straightforward. mapping = new Array(); - mapping.process = function(trNode, parent) { + mapping.process = function (trNode, parent) { mapping[trNode.name] = trNode; } - - g_Engine.getContext().getScene().Traverse(mapping); + + RDGE.globals.engine.getContext().getScene().Traverse(mapping); //g_sg.Traverse(mapping); for (tr in this.animation) { if (mapping[tr] !== undefined) { - this.tracks.push(new track(this, this.animation[tr], mapping[tr])); - g_numTracks.value++; + this.tracks.push(new RDGE.animation.track(this, this.animation[tr], mapping[tr])); } } - this.step = function(_dt) { + this.step = function (_dt) { for (tr in this.tracks) { this.tracks[tr].step(g_animationRate * this.rate * _dt); } } -} \ No newline at end of file +}; \ No newline at end of file -- cgit v1.2.3