public class AnimationFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected class |
AnimationFactory.Rotation
Inner Rotation type class to kep track on a rotation Euler angle
|
Modifier and Type | Field and Description |
---|---|
protected float |
duration
Animation duration in seconds
|
protected int |
fps
frames per seconds
|
protected AnimationFactory.Rotation[] |
keyFramesRotation |
protected Vector3f[] |
keyFramesScale |
protected Vector3f[] |
keyFramesTranslation
The map of keyFrames to compute the animation.
|
protected java.lang.String |
name
Name of the animation
|
protected Quaternion[] |
rotations
rotation array for this animation
|
protected Vector3f[] |
scales
scales array for this animation
|
protected float[] |
times
Time array for this animation
|
protected int |
totalFrames
total number of frames
|
protected float |
tpf
time per frame
|
protected Vector3f[] |
translations
Translation array for this animation
|
Constructor and Description |
---|
AnimationFactory(float duration,
java.lang.String name)
Creates and AnimationHelper
|
AnimationFactory(float duration,
java.lang.String name,
int fps)
Creates and AnimationHelper
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyFrameRotation(int keyFrameIndex,
Quaternion rotation)
Adds a key frame for the given rotation at the given keyFrame index
This can't be used if the interpolated angle is higher than PI (180°) Use addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z) instead that uses Euler angles rotations. |
void |
addKeyFrameRotationAngles(int keyFrameIndex,
float x,
float y,
float z)
Adds a key frame for the given rotation at the given key frame index.
Rotation is expressed by Euler angles values in radians. Note that the generated rotation will be stored as a quaternion and interpolated using a spherical linear interpolation (slerp) Hence, this method may create intermediate keyFrames if the interpolation angle is higher than PI to ensure continuity in animation |
void |
addKeyFrameScale(int keyFrameIndex,
Vector3f scale)
Adds a key frame for the given scale at the given keyFrame index
|
void |
addKeyFrameTransform(int keyFrameIndex,
Transform transform)
Adds a key frame for the given Transform at the given keyFrame index
|
void |
addKeyFrameTranslation(int keyFrameIndex,
Vector3f translation)
Adds a key frame for the given translation at the given keyFrame index
|
void |
addTimeRotation(float time,
Quaternion rotation)
Adds a key frame for the given rotation at the given time
This can't be used if the interpolated angle is higher than PI (180°) Use addTimeRotationAngles(float time, float x, float y, float z) instead that uses Euler angles rotations.* |
void |
addTimeRotationAngles(float time,
float x,
float y,
float z)
Adds a key frame for the given rotation at the given time.
Rotation is expressed by Euler angles values in radians. Note that the generated rotation will be stored as a quaternion and interpolated using a spherical linear interpolation (slerp) Hence, this method may create intermediate keyFrames if the interpolation angle is higher than PI to ensure continuity in animation |
void |
addTimeScale(float time,
Vector3f scale)
Adds a key frame for the given scale at the given time
|
void |
addTimeTransform(float time,
Transform transform)
Adds a key frame for the given Transform at the given time
|
void |
addTimeTranslation(float time,
Vector3f translation)
Adds a key frame for the given translation at the given time
|
Animation |
buildAnimation()
Creates an Animation based on the keyFrames previously added to the helper.
|
protected java.lang.String name
protected int fps
protected float duration
protected int totalFrames
protected float tpf
protected float[] times
protected Vector3f[] translations
protected Quaternion[] rotations
protected Vector3f[] scales
protected Vector3f[] keyFramesTranslation
protected Vector3f[] keyFramesScale
protected AnimationFactory.Rotation[] keyFramesRotation
public AnimationFactory(float duration, java.lang.String name)
duration
- the desired duration for the resulting animationname
- the name of the resulting animationpublic AnimationFactory(float duration, java.lang.String name, int fps)
duration
- the desired duration for the resulting animationname
- the name of the resulting animationfps
- the number of frames per second for this animation (default is 30)public void addTimeTransform(float time, Transform transform)
time
- the time at which the keyFrame must be insertedtransform
- the transforms to use for this keyFramepublic void addKeyFrameTransform(int keyFrameIndex, Transform transform)
keyFrameIndex
- the index at which the keyFrame must be insertedtransform
- the transforms to use for this keyFramepublic void addTimeTranslation(float time, Vector3f translation)
time
- the time at which the keyFrame must be insertedtranslation
- the translation to use for this keyFramepublic void addKeyFrameTranslation(int keyFrameIndex, Vector3f translation)
keyFrameIndex
- the index at which the keyFrame must be insertedtranslation
- the translation to use for this keyFramepublic void addTimeRotation(float time, Quaternion rotation)
addTimeRotationAngles(float time, float x, float y, float z)
instead that uses Euler angles rotations.time
- the time at which the keyFrame must be insertedrotation
- the rotation Quaternion to use for this keyFrameaddTimeRotationAngles(float time, float x, float y, float z)
public void addKeyFrameRotation(int keyFrameIndex, Quaternion rotation)
addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)
instead that uses Euler angles rotations.keyFrameIndex
- the index at which the keyFrame must be insertedrotation
- the rotation Quaternion to use for this keyFrameaddKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)
public void addTimeRotationAngles(float time, float x, float y, float z)
time
- the time at which the keyFrame must be insertedx
- the rotation around the x axis (aka yaw) in radiansy
- the rotation around the y axis (aka roll) in radiansz
- the rotation around the z axis (aka pitch) in radianspublic void addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)
keyFrameIndex
- the index at which the keyFrame must be insertedx
- the rotation around the x axis (aka yaw) in radiansy
- the rotation around the y axis (aka roll) in radiansz
- the rotation around the z axis (aka pitch) in radianspublic void addTimeScale(float time, Vector3f scale)
time
- the time at which the keyFrame must be insertedscale
- the scale to use for this keyFramepublic void addKeyFrameScale(int keyFrameIndex, Vector3f scale)
keyFrameIndex
- the index at which the keyFrame must be insertedscale
- the scale to use for this keyFramepublic Animation buildAnimation()