Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.threed.jpct
Class Animation

    java.lang.Object
      com.threed.jpct.Animation

All Implemented Interfaces:
  java.io.Serializable

public final class Animation
extends java.lang.Object
implements java.io.Serializable

Animation provides a keyframe animation implementation. An animation sequence can be defined and added to an object. Several interpolation methods for keyframe interpolation are supported. Remember that other kinds of animation like rotations and translations (moving objects around) usually isn't done using keyframe animation but by rotating and translating the objects directly. Both types of animation can be combined.

See Also:
  Serialized Form

Field Summary
`static int` | `BICUBIC` Use bicubic interpolation between keyframes.
`static int` | `COSINE` Use cosine interpolation between keyframes.
`static int` | `HERMITE` Use hermite interpolation between keyframes.
`static int` | `KEYFRAMESONLY` Use no interpolation between keyframes.
`static int` | `LINEAR` Use linear interpolation between keyframes.
`static int` | `USE_CLAMPING` Use clamping when the interpolation reaches the end of a sub-sequence.
`static int` | `USE_WRAPPING` Use wrapping when the interpolation reaches the end of a sub-sequence.

Constructor Summary
`Animation(int keyframeCount)` Creates a new animation sequence that consist of keyframeCount keyframes.

Method Summary
`void` | `addKeyFrame(Mesh keyFrame)` Add a keyframe to a animation sequence.
`int` | `createSubSequence(java.lang.String name)` Creates a new sub-sequence.
`Mesh[]` | `getKeyFrames()` Returns the key frames of an animation as an array of Mesh.
`java.lang.String` | `getName(int seq)` Returns the name of a sequence.
`int` | `getSequence(java.lang.String name)` Returns a sequence index for a given name.
`int[]` | `getSequenceBorders(int seq)` Gets the position of the start and the end frame of a sequence.
`int` | `getSequenceCount()` Returns the number of sequences used.
`void` | `remove(int seq)` Removes data of a sequence from an animation.
`void` | `setClampingMode(int mode)` Sets the clamping mode for animations.
`void` | `setHermiteParameter(float bias, float tension)` Changes the bias and tension parameters used for hermite interpolation.
`void` | `setInterpolationMethod(int method)` Sets the method that should be used to interpolate vertices between keyframes.
`void` | `strip()` Removes triangle information from this animation's meshes.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LINEAR

    public static final int LINEAR

  Use linear interpolation between keyframes. This kind of interpolation is the fastest.

  See Also:
    Constant Field Values

### COSINE

    public static final int COSINE

  Use cosine interpolation between keyframes. This interpolation method is a little bit slower than linear interpolation but still very fast. cosine interpolation tends to "pronounce" the keyframes more than the interpolated frames between them, so that the animation looks a little bit "robotic".

  See Also:
    Constant Field Values

### BICUBIC

    public static final int BICUBIC

  Use bicubic interpolation between keyframes. This provides a kind of "smooth" interpolation but it's slower than linear and cosine interpolation. It may look better in some cases but it doesn't have to.

  See Also:
    Constant Field Values

### HERMITE

    public static final int HERMITE

  Use hermite interpolation between keyframes. This provides a kind of "smooth" interpolation but it's slower than any other interpolation offered. It may look better in some cases but it doesn't have to. In addition, some parameters may be modified to influence interpolation outcome.

  See Also:
    `setHermiteParameter(float, float)`, Constant Field Values

### KEYFRAMESONLY

    public static final int KEYFRAMESONLY

  Use no interpolation between keyframes. This is the fastest possibility for displaying Animations but it looks very ugly. It should only be used for special effects or debugging of animations.

  See Also:
    Constant Field Values

### USE_WRAPPING

    public static final int USE_WRAPPING

  Use wrapping when the interpolation reaches the end of a sub-sequence. Using this mode, going from position 1 (last frame) to position 0 (first frame) in a sub-sequence should look seamless. This is default.

  See Also:
    Constant Field Values

### USE_CLAMPING

    public static final int USE_CLAMPING

  Use clamping when the interpolation reaches the end of a sub-sequence. Using this mode, the interpolation won't start off at the beginning of a sub-sequence if the end is reached (and vice versa).

  See Also:
    Constant Field Values

Constructor Detail

### Animation

    public Animation(int keyframeCount)

  Creates a new animation sequence that consist of keyframeCount keyframes. Albeit it isn't absolutly needed that every keyframe reserved here is used, it is advised to do so. In other words: Don't reserve more frames than you need!

Parameters:
  `keyframeCount` - the number of keyframes for this animation

Method Detail

### strip

    public void strip()

  Removes triangle information from this animation's meshes. This is useful to save some memory for meshes that are used for keyframing only (triangle information are not needed in that case). For any other meshes: Don't call this method. It will break your mesh!

### remove

    public void remove(int seq)

  Removes data of a sequence from an animation. The actual sequence is still there, just without any data. Accessing it will cause a crash. This is useful to save memory on animations that doesn't use all sequences.

  Parameters:
    `seq` - the sequence

### getName

    public java.lang.String getName(int seq)

  Returns the name of a sequence.

  Parameters:
    `seq` - a sequence
  Returns:
    the name

### getSequenceBorders

    public int[] getSequenceBorders(int seq)

  Gets the position of the start and the end frame of a sequence.

  Parameters:
    `seq` - the sequence
  Returns:
    the positions

### getSequence

    public int getSequence(java.lang.String name)

  Returns a sequence index for a given name. If non is found, -1 will be returned.

  Parameters:
    `name` - the sequence's name
  Returns:
    the index or -1

### getKeyFrames

    public Mesh[] getKeyFrames()

  Returns the key frames of an animation as an array of Mesh.

  Returns:
    the key frames

### createSubSequence

    public int createSubSequence(java.lang.String name)

  Creates a new sub-sequence. A sub-sequence is a part of the complete animation that can be played stand-alone (like running, jumping etc.). Using the sub-sequence concept, it is possible to store all sub-animations for an object into one animation, so that switching (and maybe interaction) between them is fast and comfortable. Before adding the first keyframe you have to create a sub-sequence. The sub-sequence will be numbered starting from 1. 0 is a special case as is represents the animation as a whole.

  Parameters:
    `name` - the name of this sequence
  Returns:
    the number of this sequence

### getSequenceCount

    public int getSequenceCount()

  Returns the number of sequences used. Sequence 0 is implicit as it stands for the animation as a whole. So a return value of 2 means, that you may play sub-sequence 1 or 2...or the whole animation using 0.

  Returns:
    the number of sequences

### setClampingMode

    public void setClampingMode(int mode)

  Sets the clamping mode for animations.

  Parameters:
    `mode` - the clamping mode
  See Also:
    `USE_WRAPPING`, `USE_CLAMPING`

### addKeyFrame

    public void addKeyFrame(Mesh keyFrame)

  Add a keyframe to a animation sequence. A keyframe is simply a mesh. A mesh can be obtained from an object by calling its getMesh()-method. Don't add a mesh as a keyframe that is already bound to an object that should use this animation, because this will result in the object to animate it's own mesh instead of the keyframes. If you want to use a mesh from such an object, don't add the mesh from getMesh() directly but make a copy of it using cloneMesh(). It's a good way to generate meshes by getting them from temporary objects. Don't forget to calc the bounding box and the normals for these meshes (for example by calling build() for the temporary object). All the meshes of an animation have to have the same mesh-size (as well as the object that should use this animation).

  Parameters:
    `keyFrame` - the mesh of this keyframe
  See Also:
    `Object3D.calcBoundingBox()`, `Object3D.getMesh()`, `Object3D.calcNormals()`, `Mesh.cloneMesh(boolean)`

### setInterpolationMethod

    public void setInterpolationMethod(int method)

  Sets the method that should be used to interpolate vertices between keyframes.

  Parameters:
    `method` - the method
  See Also:
    `LINEAR`, `COSINE`, `BICUBIC`, `HERMITE`

### setHermiteParameter

    public void setHermiteParameter(float bias,
                                    float tension)

  Changes the bias and tension parameters used for hermite interpolation. Other interpolation methods are not affected by these settings.

  Parameters:
    `bias` - the value for bias (0 is default)
    `tension` - the value for tension (0 is default)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD