Package com.jme3.anim
Class TransformTrack
java.lang.Object
com.jme3.anim.TransformTrack
- All Implemented Interfaces:
AnimTrack<Transform>
,Savable
,JmeCloneable
,Cloneable
An AnimTrack that transforms a Joint or Spatial
using a list of transforms and times for keyframes.
-
Constructor Summary
ModifierConstructorDescriptionprotected
Serialization-only.TransformTrack
(HasLocalTransform target, float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) Creates a transform track for the given target. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.void
getDataAtTime
(double t, Transform transform) Determine the track value for the specified time.Access the FrameInterpolator.double
Determine the duration of the track.Copies the rotations.Vector3f[]
Copies the scales.Gives access to the target, which might be a Joint or a Spatial.float[]
getTimes()
Gives access to the keyframe times.Vector3f[]
Copies the translations.jmeClone()
Performs a regular shallow clone of the object.void
read
(JmeImporter im) De-serializes this track from the specified importer, for example when loading from a J3O file.void
setFrameInterpolator
(FrameInterpolator interpolator) Replaces the frame interpolator.void
setKeyframes
(float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) Sets the translations, rotations, and/or scales.void
setKeyframesRotation
(Quaternion[] rotations) Sets the rotations.void
setKeyframesScale
(Vector3f[] scales) Sets the scales.void
setKeyframesTranslation
(Vector3f[] translations) Sets the translations.void
setTarget
(HasLocalTransform target) Replaces the target, which might be a Joint or a Spatial.void
setTimes
(float[] times) Sets the keyframe times.void
write
(JmeExporter ex) Serializes this track to the specified exporter, for example when saving to a J3O file.
-
Constructor Details
-
TransformTrack
protected TransformTrack()Serialization-only. Do not use. -
TransformTrack
public TransformTrack(HasLocalTransform target, float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) Creates a transform track for the given target.- Parameters:
target
- the target Joint or Spatial of the new tracktimes
- the time for each keyframe, or null for nonetranslations
- the translation of the target for each keyframe (same length as times) or null for no translationrotations
- the rotation of the target for each keyframe (same length as times) or null for no rotationscales
- the scale of the target for each keyframe (same length as times) or null for no scaling
-
-
Method Details
-
getRotations
Copies the rotations.- Returns:
- a new array, or null if no rotations
-
getScales
Copies the scales.- Returns:
- a new array, or null if no scales
-
getTimes
public float[] getTimes()Gives access to the keyframe times.- Returns:
- the pre-existing array
-
getTranslations
Copies the translations.- Returns:
- a new array, or null if no translations
-
setTimes
public void setTimes(float[] times) Sets the keyframe times.- Parameters:
times
- the desired keyframe times (alias created, not null, not empty)
-
setKeyframesTranslation
Sets the translations.- Parameters:
translations
- the desired translation of the target for each keyframe (not null, same length as "times")
-
setKeyframesScale
Sets the scales.- Parameters:
scales
- the desired scale of the target for each keyframe (not null, same length as "times")
-
setKeyframesRotation
Sets the rotations.- Parameters:
rotations
- the desired rotation of the target for each keyframe (not null, same length as "times")
-
setKeyframes
public void setKeyframes(float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) Sets the translations, rotations, and/or scales.- Parameters:
times
- the desired time for each keyframe, or null to leave the times unchangedtranslations
- the desired translation of the target for each keyframe (same length as times) or null to leave the translations unchangedrotations
- the desired rotation of the target for each keyframe (same length as times) or null to leave the rotations unchangedscales
- the desired scale of the target for each keyframe (same length as times) or null to leave the scales unchanged
-
getLength
public double getLength()Description copied from interface:AnimTrack
Determine the duration of the track. -
getDataAtTime
Description copied from interface:AnimTrack
Determine the track value for the specified time.- Specified by:
getDataAtTime
in interfaceAnimTrack<Transform>
- Parameters:
t
- the track time (in seconds)transform
- storage for the value (not null, modified)
-
getFrameInterpolator
Access the FrameInterpolator.- Returns:
- the pre-existing instance or null
-
setFrameInterpolator
Replaces the frame interpolator.- Parameters:
interpolator
- the interpolator to use (alias created)
-
getTarget
Gives access to the target, which might be a Joint or a Spatial.- Returns:
- the pre-existing instance
-
setTarget
Replaces the target, which might be a Joint or a Spatial.- Parameters:
target
- the target to use (alias created)
-
write
Serializes this track to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Parameters:
ex
- the exporter to write to (not null)- Throws:
IOException
- from the exporter
-
read
De-serializes this track from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Parameters:
im
- the importer to read from (not null)- Throws:
IOException
- from the importer
-
jmeClone
Description copied from interface:JmeCloneable
Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.
- Specified by:
jmeClone
in interfaceJmeCloneable
- Returns:
- a new instance
-
cloneFields
Description copied from interface:JmeCloneable
Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.
- Specified by:
cloneFields
in interfaceJmeCloneable
- Parameters:
cloner
- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.original
- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
-