Package com.jme3.anim

Class TransformTrack

java.lang.Object
com.jme3.anim.TransformTrack
All Implemented Interfaces:
AnimTrack<Transform>, Savable, JmeCloneable, Cloneable

public class TransformTrack extends Object implements AnimTrack<Transform>
An AnimTrack that transforms a Joint or Spatial using a list of transforms and times for keyframes.
  • 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 track
      times - the time for each keyframe, or null for none
      translations - the translation of the target for each keyframe (same length as times) or null for no translation
      rotations - the rotation of the target for each keyframe (same length as times) or null for no rotation
      scales - the scale of the target for each keyframe (same length as times) or null for no scaling
  • Method Details

    • getRotations

      public Quaternion[] getRotations()
      Copies the rotations.
      Returns:
      a new array, or null if no rotations
    • getScales

      public Vector3f[] 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

      public Vector3f[] 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

      public void setKeyframesTranslation(Vector3f[] translations)
      Sets the translations.
      Parameters:
      translations - the desired translation of the target for each keyframe (not null, same length as "times")
    • setKeyframesScale

      public void setKeyframesScale(Vector3f[] scales)
      Sets the scales.
      Parameters:
      scales - the desired scale of the target for each keyframe (not null, same length as "times")
    • setKeyframesRotation

      public void setKeyframesRotation(Quaternion[] rotations)
      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 unchanged
      translations - the desired translation of the target for each keyframe (same length as times) or null to leave the translations unchanged
      rotations - the desired rotation of the target for each keyframe (same length as times) or null to leave the rotations unchanged
      scales - 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.
      Specified by:
      getLength in interface AnimTrack<Transform>
      Returns:
      the duration (in seconds, ≥0)
    • getDataAtTime

      public void getDataAtTime(double t, Transform transform)
      Description copied from interface: AnimTrack
      Determine the track value for the specified time.
      Specified by:
      getDataAtTime in interface AnimTrack<Transform>
      Parameters:
      t - the track time (in seconds)
      transform - storage for the value (not null, modified)
    • getFrameInterpolator

      public FrameInterpolator getFrameInterpolator()
      Access the FrameInterpolator.
      Returns:
      the pre-existing instance or null
    • setFrameInterpolator

      public void setFrameInterpolator(FrameInterpolator interpolator)
      Replaces the frame interpolator.
      Parameters:
      interpolator - the interpolator to use (alias created)
    • getTarget

      public HasLocalTransform getTarget()
      Gives access to the target, which might be a Joint or a Spatial.
      Returns:
      the pre-existing instance
    • setTarget

      public void setTarget(HasLocalTransform target)
      Replaces the target, which might be a Joint or a Spatial.
      Parameters:
      target - the target to use (alias created)
    • write

      public void write(JmeExporter ex) throws IOException
      Serializes this track to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Parameters:
      ex - the exporter to write to (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      De-serializes this track from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Parameters:
      im - the importer to read from (not null)
      Throws:
      IOException - from the importer
    • jmeClone

      public TransformTrack 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 interface JmeCloneable
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      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 interface JmeCloneable
      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.