shout3d.core
Class KeyframeInterpolator

java.lang.Object
  |
  +--shout3d.core.Node
        |
        +--shout3d.core.Interpolator
              |
              +--shout3d.core.KeyframeInterpolator
Direct Known Subclasses:
BezierScalarInterpolator, BezierVecInterpolator, BooleanArrayStepInterp, BooleanStepInterp, CoordinateInterpolator, CoordinateNodeInterpolator, CurrentTimeStepInterp, DoubleArrayStepInterp, DoubleStepInterp, FloatArrayStepInterp, FloatStepInterp, IntArrayStepInterp, IntStepInterp, NodeArrayStepInterp, NodeStepInterp, OrientationInterpolator, PositionInterpolator, ScalarInterpolator, StringArrayStepInterp, StringStepInterp, TCBInterpolator

public class KeyframeInterpolator
extends Interpolator

A KeyframeInterpolator


Field Summary
 FloatArrayField key
           
 FloatField timeScale
          The timeScale field specifies a scaling for the values in the key field.
 
Fields inherited from class shout3d.core.Interpolator
fraction
 
Constructor Summary
KeyframeInterpolator()
          Constructs a default ScalarInterpolator
 
Method Summary
 int getKeyIndexBeforeOrAt(float fraction)
          Returns the index of the key value that falls before or at the given fraction.
 float getRampedKey(float fraction, int keyInd0, int keyInd1)
          Returns the interpolated value of the key field.
 
Methods inherited from class shout3d.core.Interpolator
onFieldChange, update
 
Methods inherited from class shout3d.core.Node
cleanUp, getDEFName, getField, getFieldByIndex, getFieldName, getNumFields, getTypeName, getViewer, isOfType, setDEFName, setViewer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeScale

public final FloatField timeScale
The timeScale field specifies a scaling for the values in the key field. All values in the key field are expected to lie in the range [0, timeScale] inclusive. When the value is 1 (the default) then the animation is considered normalized and keys are interpreted exactly as they are in VRML97. Other values may be chosen to make it easier to think about the animation in terms of frames or seconds. For example, a 240 frame animation with keyframes at frames 0, 60, 120, and 240 may be expressed with the following values: timeScale 240 key [0, 60, 120, 240] Note that this is equivalent to specifying the animation in VRML97 style: timeScale 1 key [0, .25, .5, 1.0] or in seconds, which would appear as follows given 24 frames per second: timeScale 10 key [0, 2.5, 5, 10] When a KeyframeInterpolator is evaluated, the incoming fraction is always expressed as a fraction of the whole. Hence, all of the above examples would behave exactly the same if their fractions were routed from the same source.

key

public final FloatArrayField key
Constructor Detail

KeyframeInterpolator

public KeyframeInterpolator()
Constructs a default ScalarInterpolator
Method Detail

getKeyIndexBeforeOrAt

public int getKeyIndexBeforeOrAt(float fraction)
Returns the index of the key value that falls before or at the given fraction. If the fraction is less than the first key value, 0 is returned. If the fraction is greater than the last key value, then the index of the last key is returned. If the key field is null or empty, returns 0
Parameters:
fraction - the fraction whose key index is sought
Returns:
the index of the key before or at the given fraction.

getRampedKey

public float getRampedKey(float fraction,
                          int keyInd0,
                          int keyInd1)
Returns the interpolated value of the key field. Fraction ranges [0,1], as given in the fraction field. keyInd0 and keyInd1 are indices into the key field. The returned value is calculated as follows: 1 - the input fraction is scaled by the value of the timeScale field to get scaledFraction. 2 - the returned value is given as: (scaledFraction - key.getValue()[keyInd0]) ------------------------------------------ (key.getValue()[keyInd1] - key.getValue()[keyInd0]) A value of 0 is returned if either keyInd0 or keyInd1 is out of range as an index for the key field.