org.jagatoo.loaders.models.cal3d.core
Class CalMixer

java.lang.Object
  extended by org.jagatoo.loaders.models.cal3d.core.CalMixer

public class CalMixer
extends java.lang.Object

The mixer handles two tasks: scheduling and blending. Scheduling refers to everything related to time such as when an animation must run or when it must stop. Blending defines how concurrent animations influence each other: for instance walking and waving.


Field Summary
 java.util.List<CalAnimationRelative> additiveAnimationCycles
           
protected  float animationDuration
           
protected  float animationTime
           
 java.util.List<CalAnimationAction> listAnimationAction
           
 java.util.List<CalAnimationCycle> listAnimationCycle
           
 java.util.Map<java.lang.String,CalAnimation> mapAnimation
           
 CalModel model
           
 float timeFactor
           
 
Constructor Summary
CalMixer(CalModel model)
          Constructs the mixer instance.
 
Method Summary
 CalAnimation applyAdditiveCycle(java.lang.String id, float time)
          Applies an additive animation cycle to the skeleton.
 CalAnimation applyAdditiveCycle(java.lang.String id, java.lang.String baseId, float time)
          Applies an additive animation cycle to the skeleton.
 CalAnimationCycle blendCycle(java.lang.String id, float weight, float delay)
          Blends an animation cycle in.
 void clearAction(java.lang.String id)
          Clears an active animation action.
 void clearAdditiveCycle(java.lang.String id)
           
 void clearAllAnims()
          An abrupt way to clear all animations - actions or cycles.
 void clearCycle(java.lang.String id, float delay)
          Fades an animation cycle out.
 CalAnimationAction executeAction(java.lang.String id, float delayIn, float delayOut)
          Executes an animation action.
 CalAnimationAction executeAction(java.lang.String id, float delayIn, float delayOut, float weightTarget, boolean autoLock)
          Executes an animation action.
 CalAnimation scrubToPosition(java.lang.String id, float position)
          Scrubs an animation cycle to a position (fraction through animation).
 CalAnimation scrubToPosition(java.lang.String id, float position, float weight)
          Scrubs an animation cycle to a position (fraction through animation).
 CalAnimation scrubToTime(java.lang.String id, float time)
          Scrubs an animation cycle to a specific time.
 CalAnimation scrubToTime(java.lang.String id, float time, float weight)
          Scrubs an animation cycle to a specific time.
 void updateAnimation(float deltaTime)
          Updates all active animations.
 void updateSkeleton()
          Updates the skeleton of the corresponding CalModel to match the current animation state (as updated by the last call to updateAnimation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

public CalModel model

mapAnimation

public java.util.Map<java.lang.String,CalAnimation> mapAnimation

listAnimationAction

public java.util.List<CalAnimationAction> listAnimationAction

listAnimationCycle

public java.util.List<CalAnimationCycle> listAnimationCycle

additiveAnimationCycles

public java.util.List<CalAnimationRelative> additiveAnimationCycles

animationTime

protected float animationTime

animationDuration

protected float animationDuration

timeFactor

public float timeFactor
Constructor Detail

CalMixer

public CalMixer(CalModel model)
Constructs the mixer instance. This function is the default constructor of the mixer instance.

Parameters:
model - the model that should be managed with this mixer instance.
Method Detail

blendCycle

public CalAnimationCycle blendCycle(java.lang.String id,
                                    float weight,
                                    float delay)
Blends an animation cycle in. This function interpolates the weight of an animation cycle to a new value in a given amount of time. If the specified animation cycle is not active yet, it is activated.

Parameters:
id - The ID of the animation cycle that should be blended.
weight - The weight to interpolate the animation cycle to.
delay - The time in seconds until the new weight should be reached.

scrubToPosition

public final CalAnimation scrubToPosition(java.lang.String id,
                                          float position)
Scrubs an animation cycle to a position (fraction through animation). This is achieved internally using an animation cycle.


scrubToPosition

public CalAnimation scrubToPosition(java.lang.String id,
                                    float position,
                                    float weight)
Scrubs an animation cycle to a position (fraction through animation). This is achieved internally using an animation cycle.


scrubToTime

public final CalAnimation scrubToTime(java.lang.String id,
                                      float time)
Scrubs an animation cycle to a specific time. This is achieved internally using an animation cycle.


scrubToTime

public CalAnimation scrubToTime(java.lang.String id,
                                float time,
                                float weight)
Scrubs an animation cycle to a specific time. This is achieved internally using an animation cycle.


applyAdditiveCycle

public CalAnimation applyAdditiveCycle(java.lang.String id,
                                       float time)
Applies an additive animation cycle to the skeleton. Behaves like a scrub so it doesn't need to interact with the CalMixer's update... This is experimental!


applyAdditiveCycle

public CalAnimation applyAdditiveCycle(java.lang.String id,
                                       java.lang.String baseId,
                                       float time)
Applies an additive animation cycle to the skeleton. Behaves like a scrub so it doesn't need to interact with the CalMixer's update... This is experimental!


clearCycle

public void clearCycle(java.lang.String id,
                       float delay)
Fades an animation cycle out. This function fades an animation cycle out in a given amount of time.

Parameters:
id - The ID of the animation cycle that should be faded out.
delay - The time in seconds until the the animation cycle is completely removed.

clearAdditiveCycle

public void clearAdditiveCycle(java.lang.String id)

clearAllAnims

public void clearAllAnims()
An abrupt way to clear all animations - actions or cycles.


executeAction

public CalAnimationAction executeAction(java.lang.String id,
                                        float delayIn,
                                        float delayOut)
Executes an animation action. This function executes an animation action.

Parameters:
id - The ID of the animation cycle that should be blended.
delayIn - The time in seconds until the animation action reaches the full weight from the beginning of its execution.
delayOut - The time in seconds in which the animation action reaches zero weight at the end of its execution.

executeAction

public CalAnimationAction executeAction(java.lang.String id,
                                        float delayIn,
                                        float delayOut,
                                        float weightTarget,
                                        boolean autoLock)
Executes an animation action. This function executes an animation action.

Parameters:
id - The ID of the animation cycle that should be blended.
delayIn - The time in seconds until the animation action reaches the full weight from the beginning of its execution.
delayOut - The time in seconds in which the animation action reaches zero weight at the end of its execution.
weightTarget - The weight to interpolate the animation action to.
autoLock - This prevents the Action from being reset and removed

clearAction

public void clearAction(java.lang.String id)
Clears an active animation action. This function removes an animation action from the blend list. This is particularly useful with auto-locked actions on their last frame.

Parameters:
id - The ID of the animation action that should be removed.

updateAnimation

public void updateAnimation(float deltaTime)
Updates all active animations. Notifies the instance that updateAnimation was last called deltaTime seconds ago. The internal scheduler of the instance will terminate animations and update the timing information of active animations accordingly. It does not blend animations together or otherwise modify the CalModel associated to these animations. The CalModel.update() method will call updateSkeleton immediately after updateAnimation

Parameters:
deltaTime - The elapsed time in seconds since the last call.

updateSkeleton

public void updateSkeleton()
Updates the skeleton of the corresponding CalModel to match the current animation state (as updated by the last call to updateAnimation). The tracks of each active animation are blended to compute the position and orientation of each bone of the skeleton. The updateAnimation method should be called just before calling updateSkeleton to define the set of active animations. The CalModel.update() method will call updateSkeleton immediately after updateAnimation