unc.cdva.graphics.animations
Class Animation

java.lang.Object
  extended by unc.cdva.graphics.animations.Animation

public class Animation
extends java.lang.Object

Represents animations, and is used to actually display animations as well. Main job is to interpolate between key frames, thus an animation is defined as a base object, and a list of keyframes. Once an animation is started, it will go through all of it's keyframes, and will end after the last keyframe has been rendered.

Author:
Guillaume Conte

Constructor Summary
Animation()
          Default constructor, data is uninitialized.
Animation(java.lang.String name, StaticListObject object, java.util.Vector<KeyFrame> keyFrames, boolean showBaseObject, boolean repeat)
          Animation constructor, inits an animation object.
 
Method Summary
 void advanceInTime(long delta)
          Advances the animation.
 Animation clone()
          Returns a cloned copy of the animation.
 int getCurrentKeyFrame()
           
 java.util.Vector<KeyFrame> getKeyFrames()
           
 java.lang.String getName()
           
 StaticListObject getObject()
           
 long getRunningTime()
           
static long getSerialVersionUID()
           
 javax.vecmath.Vector3f interpolateVector(long currentTime, long nextTime, javax.vecmath.Vector3f current, javax.vecmath.Vector3f next)
          Do the linear interpolation of a vector between two keyframes at time runningTime
 float interpolation(float a, float b, float c, float fOfA, float fOfB)
          Linear interpolation method.
 boolean isRepeat()
           
 boolean isRunning()
           
 boolean isShowBaseObject()
           
 void render(javax.media.opengl.GL gl)
          Draws the animation.
 void setCurrentKeyFrame(int currentKeyFrame)
           
 void setKeyFrames(java.util.Vector<KeyFrame> keyFrames)
           
 void setName(java.lang.String name)
           
 void setObject(StaticListObject object)
           
 void setRepeat(boolean repeat)
           
 void setRunningTime(long runningTime)
           
 void setShowBaseObject(boolean showBaseObject)
           
 void startAnimation()
          Starts the animation.
 void stopAnimation()
          Stops the animation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Animation

public Animation()
Default constructor, data is uninitialized. Use setters to initialize the object's internal data.


Animation

public Animation(java.lang.String name,
                 StaticListObject object,
                 java.util.Vector<KeyFrame> keyFrames,
                 boolean showBaseObject,
                 boolean repeat)
Animation constructor, inits an animation object.

Parameters:
name - the name to be given to the animation.
object - The object to be animated.
keyFrames - Keyframes that will be used to animate the object.
showBaseObject - Whether the first key frame should be shown or not.
repeat - If the animation is to be looped.
Method Detail

startAnimation

public void startAnimation()
Starts the animation.


stopAnimation

public void stopAnimation()
Stops the animation.


isRunning

public boolean isRunning()
Returns:
True if the last keyframe has not been rendered. False if the animation has rendered all of it's keyframes, or if it has been stopped via stopAnimation().

advanceInTime

public void advanceInTime(long delta)
Advances the animation.

Parameters:
delta - How long (in ms) to advance the rendering.

interpolation

public float interpolation(float a,
                           float b,
                           float c,
                           float fOfA,
                           float fOfB)
Linear interpolation method. Interpolate f(c) using a, b, c, f(a), and f(b)

Parameters:
a - current value
b - next value
c - value to interpolate
fOfA - resulting current value
fOfB - resulting next value
Returns:
interpolated value of f(c)

interpolateVector

public javax.vecmath.Vector3f interpolateVector(long currentTime,
                                                long nextTime,
                                                javax.vecmath.Vector3f current,
                                                javax.vecmath.Vector3f next)
Do the linear interpolation of a vector between two keyframes at time runningTime

Parameters:
currentTime - time index of the current keyframe
nextTime - time index of the nex keyframe
current - current vector
next - next vector
Returns:
interpolated vector at time runningTime

render

public void render(javax.media.opengl.GL gl)
Draws the animation.

Parameters:
gl - A gl object to be drawn to.

clone

public Animation clone()
Returns a cloned copy of the animation.

Overrides:
clone in class java.lang.Object
Returns:
cloned copy of the animation with the same values

isShowBaseObject

public boolean isShowBaseObject()
Returns:
Returns the showBaseModel.

setShowBaseObject

public void setShowBaseObject(boolean showBaseObject)
Parameters:
showBaseObject - The showBaseModel to set.

getSerialVersionUID

public static long getSerialVersionUID()
Returns:
the serialVersionUID

getCurrentKeyFrame

public int getCurrentKeyFrame()
Returns:
the currentKeyFrame

getKeyFrames

public java.util.Vector<KeyFrame> getKeyFrames()
Returns:
the keyFrames

getObject

public StaticListObject getObject()
Returns:
the object

isRepeat

public boolean isRepeat()
Returns:
the repeat

getRunningTime

public long getRunningTime()
Returns:
the runningTime

setCurrentKeyFrame

public void setCurrentKeyFrame(int currentKeyFrame)
Parameters:
currentKeyFrame - the currentKeyFrame to set

setKeyFrames

public void setKeyFrames(java.util.Vector<KeyFrame> keyFrames)
Parameters:
keyFrames - the keyFrames to set

setObject

public void setObject(StaticListObject object)
Parameters:
object - the object to set

setRepeat

public void setRepeat(boolean repeat)
Parameters:
repeat - the repeat to set

setRunningTime

public void setRunningTime(long runningTime)
Parameters:
runningTime - the runningTime to set

getName

public java.lang.String getName()
Returns:
the name

setName

public void setName(java.lang.String name)
Parameters:
name - the name to set