public final class Animation
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.
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.
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!
keyframeCount - the number of keyframes for this animation
public void setCaching(boolean usesCache)
If enabled, animations will be processed faster, you'll get a higher
frame rate. However, it consumes some more memory. Default is true.
usesCache - should we?
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!
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.
seq - the sequence
public java.lang.String getName(int seq)
Returns the name of a sequence.
seq - a sequence
public int getSequenceBorders(int seq)
Gets the position of the start and the end frame of a sequence.
seq - the sequence
an int-array with the positions
public int getSequence(java.lang.String name)
Returns a sequence index for a given name. If non is found, -1 will be
Returns the key frames of an animation as an array of Mesh.
the key frames
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.
name - the name of this sequence
the number of this sequence
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.
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).