public class AnimFactory
extends java.lang.Object
buildAnimation(com.jme3.anim.util.HasLocalTransform)
will then
generate an AnimClip that interpolates among the keyframes.
By default, the first keyframe (index=0) has an identity Transform. You can
override this by replacing the first keyframe with different Transform.
For a loop animation, make sure the final transform matches the starting one.
Because of a heuristic used by
Quaternion.slerp(com.jme3.math.Quaternion, com.jme3.math.Quaternion, float)
,
it's possible for
buildAnimation(com.jme3.anim.util.HasLocalTransform)
to negate the
final rotation. To prevent an unwanted rotation at the end of the loop, you
may need to add intemediate rotation keyframes.
Inspired by Nehon's AnimationFactory
.Constructor and Description |
---|
AnimFactory(float duration,
java.lang.String name,
float fps)
Instantiate an AnimFactory with an identity transform at t=0.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyFrameRotation(int keyFrameIndex,
Quaternion rotation)
Add a keyframe for the specified rotation at the specified index.
|
void |
addKeyFrameScale(int keyFrameIndex,
Vector3f scale)
Add a keyframe for the specified scaling at the specified index.
|
void |
addKeyFrameTransform(int keyFrameIndex,
Transform transform)
Add a keyframe for the specified Transform at the specified index.
|
void |
addKeyFrameTranslation(int keyFrameIndex,
Vector3f offset)
Add a keyframe for the specified translation at the specified index.
|
void |
addTimeRotation(float time,
float xAngle,
float yAngle,
float zAngle)
Add a keyframe for the specified rotation at the specified time, based on
Tait-Bryan angles.
|
void |
addTimeRotation(float time,
Quaternion rotation)
Add a keyframe for the specified rotation at the specified time.
|
void |
addTimeScale(float time,
Vector3f scale)
Add a keyframe for the specified scale at the specified time.
|
void |
addTimeTransform(float time,
Transform transform)
Add a keyframe for the specified Transform at the specified time.
|
void |
addTimeTranslation(float time,
Vector3f offset)
Add a keyframe for the specified translation at the specified time.
|
AnimClip |
buildAnimation(HasLocalTransform target)
Create an AnimClip based on the keyframes added to this factory.
|
public AnimFactory(float duration, java.lang.String name, float fps)
duration
- the duration for the clip (in seconds, >0)name
- the name for the resulting clipfps
- the frame rate for the clip (in frames per second, >0)public void addKeyFrameRotation(int keyFrameIndex, Quaternion rotation)
keyFrameIndex
- the keyframe in which full rotation should be
achieved (≥0)rotation
- the local rotation to apply to the target (not null,
non-zero norm, unaffected)public void addKeyFrameScale(int keyFrameIndex, Vector3f scale)
keyFrameIndex
- the keyframe in which full scaling should be
achieved (≥0)scale
- the local scaling to apply to the target (not null,
unaffected)public void addKeyFrameTransform(int keyFrameIndex, Transform transform)
keyFrameIndex
- the keyframe in which the full Transform should be
achieved (≥0)transform
- the local Transform to apply to the target (not null,
unaffected)public void addKeyFrameTranslation(int keyFrameIndex, Vector3f offset)
keyFrameIndex
- the keyframe in which full translation should be
achieved (≥0)offset
- the local translation to apply to the target (not null,
unaffected)public void addTimeRotation(float time, Quaternion rotation)
time
- the animation time when full rotation should be achieved
(≥0, ≤duration)rotation
- the local rotation to apply to the target (not null,
non-zero norm, unaffected)public void addTimeRotation(float time, float xAngle, float yAngle, float zAngle)
AnimationFactory.addTimeRotationAngles(float, float, float, float)
.time
- the animation time when full rotation should be achieved
(≥0, ≤duration)xAngle
- the X angle (in radians)yAngle
- the Y angle (in radians)zAngle
- the Z angle (in radians)public void addTimeScale(float time, Vector3f scale)
time
- the animation time when full scaling should be achieved
(≥0, ≤duration)scale
- the local scaling to apply to the target (not null,
unaffected)public void addTimeTransform(float time, Transform transform)
time
- the animation time when the full Transform should be achieved
(≥0, ≤duration)transform
- the local Transform to apply to the target (not null,
unaffected)public void addTimeTranslation(float time, Vector3f offset)
time
- the animation time when the full translation should be
achieved (≥0, ≤duration)offset
- the local translation to apply to the target (not null,
unaffected)public AnimClip buildAnimation(HasLocalTransform target)
target
- the target for this clip (which is typically a Spatial)