com.threerings.opengl.model
Class Animation

java.lang.Object
  extended by com.threerings.expr.SimpleScope
      extended by com.threerings.opengl.model.Animation
All Implemented Interfaces:
ConfigUpdateListener<AnimationConfig>, Scope, ScopeUpdateListener

public class Animation
extends SimpleScope
implements ConfigUpdateListener<AnimationConfig>

An animation for an Articulated model.


Nested Class Summary
protected static class Animation.AnimationOp
          Animation op base class.
protected static class Animation.FrameExecutor
          Contains an executor to activate at a specific frame.
static class Animation.Implementation
          The actual animation implementation.
static class Animation.Imported
          An imported implementation.
static class Animation.Procedural
          A procedural implementation.
static class Animation.Sequential
          A sequential implementation.
protected static class Animation.StartedOp
          An ObserverList.ObserverOp that calls AnimationObserver.animationStarted(com.threerings.opengl.model.Animation).
protected static class Animation.StoppedOp
          An ObserverList.ObserverOp that calls AnimationObserver.animationStopped(com.threerings.opengl.model.Animation, boolean).
 
Field Summary
protected  AnimationConfig _config
          The configuration of this animation.
protected  GlContext _ctx
          The application context.
protected  MutableLong _epoch
          A container for the animation epoch.
protected  Animation.Implementation _impl
          The animation implementation.
protected  String _name
          The name of the animation.
protected  ObserverList<AnimationObserver> _observers
          The lazily-initialized list of animation observers.
protected  float _speed
          The speed at which to play the animation.
protected static Animation.StartedOp _startedOp
          Started op to reuse.
protected static Animation.StoppedOp _stoppedOp
          Stopped op to reuse.
static Animation[] EMPTY_ARRAY
          An empty array of animations.
protected static Animation.Implementation NULL_IMPLEMENTATION
          An implementation that does nothing.
 
Fields inherited from class com.threerings.expr.SimpleScope
_parentScope
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
Animation(GlContext ctx, Scope parentScope)
          Creates a new animation.
 
Method Summary
 void addObserver(AnimationObserver observer)
          Adds an observer to this animation.
protected static void applyStartedOp(ObserverList<? extends AnimationObserver> observers, Animation animation)
          Applies the _startedOp to the supplied list of observers.
protected static void applyStoppedOp(ObserverList<? extends AnimationObserver> observers, Animation animation, boolean completed)
          Applies the _stoppedOp to the supplied list of observers.
 void blendTransforms(int update)
          Blends in the influence of this animation.
 void configUpdated(ConfigEvent<AnimationConfig> event)
          Called when a configuration has been updated.
 void dispose()
          Releases the resources associated with this scope.
 String getName()
          Returns the name of the animation.
 int getPriority()
          Returns the priority of this animation.
 String getScopeName()
          Returns the name of this scope for purposes of qualification.
 float getSpeed()
          Returns the speed at which the animation is being played.
 boolean hasCompleted()
          Checks whether the animation has just completed, and thus should be removed from the playing list after a final update has been performed.
 boolean isPlaying()
          Determines whether this animation is playing.
 void removeObserver(AnimationObserver observer)
          Removes an observer from this animation.
protected  void resetEpoch()
          Resets the epoch value to the current time.
 void scopeUpdated(ScopeEvent event)
          Called when the scope has been updated.
 void setConfig(String name, AnimationConfig config)
          Sets the configuration of this animation.
 void setConfig(String name, ConfigReference<AnimationConfig> ref)
          Sets the configuration of this animation.
 void setConfig(String name, String config)
          Sets the configuration of this animation.
 void setConfig(String name, String config, String firstKey, Object firstValue, Object... otherArgs)
          Sets the configuration of this animation.
 void setSpeed(float speed)
          Sets the speed at which to play the animation.
 void start()
          Starts playing this animation.
protected  void started(float overrideBlendOut)
          Notes that the animation started.
 void stop()
          Stops playing this animation.
 void stop(float blendOut)
          Stops playing this animation, blending it out over the specified interval (as opposed to its default interval).
protected  void stopped(boolean completed)
          Notes that the animation stopped.
 boolean tick(float elapsed)
          Updates this animation based on the elapsed time in seconds.
 String toString()
           
protected  void updateFromConfig()
          Updates the animation to match its new or modified configuration.
 void updateTransforms()
          Updates the transforms directly from this animation.
 
Methods inherited from class com.threerings.expr.SimpleScope
addListener, get, getParentScope, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final Animation[] EMPTY_ARRAY
An empty array of animations.


_ctx

protected GlContext _ctx
The application context.


_name

protected String _name
The name of the animation.


_config

protected AnimationConfig _config
The configuration of this animation.


_speed

protected float _speed
The speed at which to play the animation.


_impl

protected Animation.Implementation _impl
The animation implementation.


_observers

protected ObserverList<AnimationObserver> _observers
The lazily-initialized list of animation observers.


_epoch

@Scoped
protected MutableLong _epoch
A container for the animation epoch.


_startedOp

protected static Animation.StartedOp _startedOp
Started op to reuse.


_stoppedOp

protected static Animation.StoppedOp _stoppedOp
Stopped op to reuse.


NULL_IMPLEMENTATION

protected static final Animation.Implementation NULL_IMPLEMENTATION
An implementation that does nothing.

Constructor Detail

Animation

public Animation(GlContext ctx,
                 Scope parentScope)
Creates a new animation.

Method Detail

setConfig

public void setConfig(String name,
                      String config)
Sets the configuration of this animation.


setConfig

public void setConfig(String name,
                      ConfigReference<AnimationConfig> ref)
Sets the configuration of this animation.


setConfig

public void setConfig(String name,
                      String config,
                      String firstKey,
                      Object firstValue,
                      Object... otherArgs)
Sets the configuration of this animation.


setConfig

public void setConfig(String name,
                      AnimationConfig config)
Sets the configuration of this animation.


getName

public String getName()
Returns the name of the animation.


setSpeed

public void setSpeed(float speed)
Sets the speed at which to play the animation.


getSpeed

public float getSpeed()
Returns the speed at which the animation is being played.


start

public void start()
Starts playing this animation.


stop

public void stop()
Stops playing this animation.


stop

public void stop(float blendOut)
Stops playing this animation, blending it out over the specified interval (as opposed to its default interval).


isPlaying

public boolean isPlaying()
Determines whether this animation is playing.


addObserver

public void addObserver(AnimationObserver observer)
Adds an observer to this animation.


removeObserver

public void removeObserver(AnimationObserver observer)
Removes an observer from this animation.


getPriority

public int getPriority()
Returns the priority of this animation.


tick

public boolean tick(float elapsed)
Updates this animation based on the elapsed time in seconds.

Returns:
true if the animation has completed.

hasCompleted

public boolean hasCompleted()
Checks whether the animation has just completed, and thus should be removed from the playing list after a final update has been performed.


updateTransforms

public void updateTransforms()
Updates the transforms directly from this animation.


blendTransforms

public void blendTransforms(int update)
Blends in the influence of this animation.

Parameters:
update - the current value of the update counter (used to determine which nodes have been touched on this update).

configUpdated

public void configUpdated(ConfigEvent<AnimationConfig> event)
Description copied from interface: ConfigUpdateListener
Called when a configuration has been updated.

Specified by:
configUpdated in interface ConfigUpdateListener<AnimationConfig>

getScopeName

public String getScopeName()
Description copied from interface: Scope
Returns the name of this scope for purposes of qualification. Can return null if qualified symbols cannot specifically address this scope.

Specified by:
getScopeName in interface Scope
Overrides:
getScopeName in class SimpleScope

scopeUpdated

public void scopeUpdated(ScopeEvent event)
Description copied from interface: ScopeUpdateListener
Called when the scope has been updated.

Specified by:
scopeUpdated in interface ScopeUpdateListener
Overrides:
scopeUpdated in class SimpleScope

dispose

public void dispose()
Description copied from class: SimpleScope
Releases the resources associated with this scope.

Overrides:
dispose in class SimpleScope

toString

public String toString()
Overrides:
toString in class Object

updateFromConfig

protected void updateFromConfig()
Updates the animation to match its new or modified configuration.


started

protected void started(float overrideBlendOut)
Notes that the animation started.

Parameters:
overrideBlendOut - if non-negative, an interval over which to blend out all animations currently playing at the same priority level as this one.

stopped

protected void stopped(boolean completed)
Notes that the animation stopped.


resetEpoch

protected void resetEpoch()
Resets the epoch value to the current time.


applyStartedOp

protected static void applyStartedOp(ObserverList<? extends AnimationObserver> observers,
                                     Animation animation)
Applies the _startedOp to the supplied list of observers.


applyStoppedOp

protected static void applyStoppedOp(ObserverList<? extends AnimationObserver> observers,
                                     Animation animation,
                                     boolean completed)
Applies the _stoppedOp to the supplied list of observers.