Package com.jme3.anim
Class AnimFactory
java.lang.Object
com.jme3.anim.AnimFactory
A convenience class to smoothly animate a Spatial using translation,
 rotation, and scaling.
 Add keyframes for translation, rotation, and scaling. Invoking
 
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 intermediate rotation keyframes.
 Inspired by Nehon's AnimationFactory.- 
Constructor Summary
ConstructorsConstructorDescriptionAnimFactory(float duration, String name, float fps) Instantiate an AnimFactory with an identity transform at t=0. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyFrameRotation(int keyFrameIndex, Quaternion rotation) Add a keyframe for the specified rotation at the specified index.voidaddKeyFrameScale(int keyFrameIndex, Vector3f scale) Add a keyframe for the specified scaling at the specified index.voidaddKeyFrameTransform(int keyFrameIndex, Transform transform) Add a keyframe for the specified Transform at the specified index.voidaddKeyFrameTranslation(int keyFrameIndex, Vector3f offset) Add a keyframe for the specified translation at the specified index.voidaddTimeRotation(float time, float xAngle, float yAngle, float zAngle) Add a keyframe for the specified rotation at the specified time, based on Tait-Bryan angles.voidaddTimeRotation(float time, Quaternion rotation) Add a keyframe for the specified rotation at the specified time.voidaddTimeScale(float time, Vector3f scale) Add a keyframe for the specified scale at the specified time.voidaddTimeTransform(float time, Transform transform) Add a keyframe for the specified Transform at the specified time.voidaddTimeTranslation(float time, Vector3f offset) Add a keyframe for the specified translation at the specified time.buildAnimation(HasLocalTransform target) Create an AnimClip based on the keyframes added to this factory. 
- 
Constructor Details
- 
AnimFactory
Instantiate an AnimFactory with an identity transform at t=0.- Parameters:
 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)
 
 - 
 - 
Method Details
- 
addKeyFrameRotation
Add a keyframe for the specified rotation at the specified index.- Parameters:
 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)
 - 
addKeyFrameScale
Add a keyframe for the specified scaling at the specified index.- Parameters:
 keyFrameIndex- the keyframe in which full scaling should be achieved (≥0)scale- the local scaling to apply to the target (not null, unaffected)
 - 
addKeyFrameTransform
Add a keyframe for the specified Transform at the specified index.- Parameters:
 keyFrameIndex- the keyframe in which the full Transform should be achieved (≥0)transform- the local Transform to apply to the target (not null, unaffected)
 - 
addKeyFrameTranslation
Add a keyframe for the specified translation at the specified index.- Parameters:
 keyFrameIndex- the keyframe in which full translation should be achieved (≥0)offset- the local translation to apply to the target (not null, unaffected)
 - 
addTimeRotation
Add a keyframe for the specified rotation at the specified time.- Parameters:
 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)
 - 
addTimeRotation
public 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. Note that this is NOT equivalent toAnimationFactory.addTimeRotationAngles(float, float, float, float).- Parameters:
 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)
 - 
addTimeScale
Add a keyframe for the specified scale at the specified time.- Parameters:
 time- the animation time when full scaling should be achieved (≥0, ≤duration)scale- the local scaling to apply to the target (not null, unaffected)
 - 
addTimeTransform
Add a keyframe for the specified Transform at the specified time.- Parameters:
 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)
 - 
addTimeTranslation
Add a keyframe for the specified translation at the specified time.- Parameters:
 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)
 - 
buildAnimation
Create an AnimClip based on the keyframes added to this factory.- Parameters:
 target- the target for this clip (which is typically a Spatial)- Returns:
 - a new clip
 
 
 -