Package jme3utilities

Class MyAnimation

java.lang.Object
jme3utilities.MyAnimation

public final class MyAnimation extends Object
Utility methods for manipulating animations, clips, and tracks. All methods should be static.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.jme3.math.Quaternion[]
    copyRotations(com.jme3.animation.Track track)
    Copy the keyframe rotations for the specified bone/spatial track.
    static com.jme3.math.Vector3f[]
    copyScales(com.jme3.animation.Track track)
    Copy the keyframe scales for the specified bone/spatial track.
    static com.jme3.math.Vector3f[]
    copyTranslations(com.jme3.animation.Track track)
    Copy the translations for the specified bone/spatial track.
    static <T extends com.jme3.animation.Track>
    int
    countTracks(com.jme3.animation.Animation animation, Class<T> trackType)
    Count all tracks of the specified type in the specified Animation.
    static String
    describe(com.jme3.anim.AnimClip clip, com.jme3.anim.AnimComposer composer)
    Describe an AnimClip.
    static String
    describe(com.jme3.anim.AnimTrack track)
    Describe an AnimTrack.
    static String
    describe(com.jme3.animation.Animation animation, com.jme3.animation.AnimControl animControl)
    Describe an Animation.
    static String
    describe(com.jme3.animation.Track track, com.jme3.animation.AnimControl animControl)
    Describe an animation track in the context of its Animation.
    static char
    Describe a track's type with a single character.
    static com.jme3.animation.BoneTrack
    findBoneTrack(com.jme3.animation.Animation animation, int boneIndex)
    Find a BoneTrack in a specified Animation that targets the indexed Bone.
    static com.jme3.anim.TransformTrack
    findJointTrack(com.jme3.anim.AnimClip clip, int jointIndex)
    Find a TransformTrack in a specified AnimClip that targets the indexed Joint.
    static int
    findKeyframeIndex(com.jme3.anim.TransformTrack track, float time)
    Find the index of the keyframe (if any) at the specified time in the specified TransformTrack.
    static int
    findKeyframeIndex(com.jme3.animation.Track track, float time)
    Find the index of the keyframe (if any) at the specified time in the specified Track.
    static float
    findLastKeyframe(com.jme3.animation.Animation animation)
    Find the time of the keyframe in the specified Animation with the latest time.
    static int
    findPreviousKeyframeIndex(com.jme3.anim.TransformTrack track, float time)
    Find the index of the last keyframe at or before the specified time in the specified TransformTrack.
    static int
    findPreviousKeyframeIndex(com.jme3.animation.Track track, float time)
    Find the index of the last keyframe at or before the specified time in the specified Track.
    static com.jme3.animation.SpatialTrack
    findSpatialTrack(com.jme3.animation.AnimControl animControl, com.jme3.animation.Animation animation, com.jme3.scene.Spatial spatial)
    Find a SpatialTrack in the specified animation for the specified spatial.
    static int
    findTrackIndex(com.jme3.animation.Animation animation, com.jme3.animation.Track track)
    Find the specified Track in the specified Animation.
    static com.jme3.anim.TransformTrack
    findTransformTrack(com.jme3.anim.AnimClip clip, int jointIndex)
    Find a TransformTrack in a specified AnimClip for the indexed Joint.
    static float[]
    Access the time array of the specified track.
    static com.jme3.math.Quaternion[]
    getRotations(com.jme3.animation.Track track)
    static com.jme3.math.Vector3f[]
    getScales(com.jme3.animation.Track track)
    static String
    getTargetName(com.jme3.anim.util.HasLocalTransform target)
    Determine the name of the specified animation target.
    static String
    getTargetName(com.jme3.animation.Track track, com.jme3.animation.AnimControl animControl)
    Read the name of the target of the specified bone/spatial track in the specified AnimControl.
    static com.jme3.math.Vector3f[]
    getTranslations(com.jme3.animation.Track track)
    static boolean
    hasTrackForBone(com.jme3.animation.Animation animation, int boneIndex)
    Test whether the specified Animation includes a BoneTrack for the indexed Bone.
    static boolean
    isJointTrack(com.jme3.anim.AnimTrack<?> track)
    Test whether the specified AnimTrack targets a Joint.
    static com.jme3.animation.BoneTrack
    newBoneTrack(int boneIndex, float[] frameTimes, com.jme3.math.Transform transform)
    Create a BoneTrack in which all keyframes have the same Transform.
    static com.jme3.animation.BoneTrack
    newBoneTrack(int boneIndex, float[] times, com.jme3.math.Vector3f[] translations, com.jme3.math.Quaternion[] rotations, com.jme3.math.Vector3f[] scales)
    Create a new BoneTrack, with or without scales.
    static com.jme3.animation.BoneTrack
    newBoneTrack(int boneIndex, com.jme3.math.Vector3f translation, com.jme3.math.Quaternion rotation, com.jme3.math.Vector3f scale)
    Create a BoneTrack consisting of a single keyframe at t=0.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • copyRotations

      public static com.jme3.math.Quaternion[] copyRotations(com.jme3.animation.Track track)
      Copy the keyframe rotations for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • copyScales

      public static com.jme3.math.Vector3f[] copyScales(com.jme3.animation.Track track)
      Copy the keyframe scales for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • copyTranslations

      public static com.jme3.math.Vector3f[] copyTranslations(com.jme3.animation.Track track)
      Copy the translations for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • countTracks

      public static <T extends com.jme3.animation.Track> int countTracks(com.jme3.animation.Animation animation, Class<T> trackType)
      Count all tracks of the specified type in the specified Animation.
      Type Parameters:
      T - subclass of Track
      Parameters:
      animation - the Animation to search (may be null, unaffected)
      trackType - the subclass of Track to search for
      Returns:
      the number of tracks found (≥0)
    • describe

      public static String describe(com.jme3.animation.Animation animation, com.jme3.animation.AnimControl animControl)
      Describe an Animation.
      Parameters:
      animation - the Animation to describe (not null, unaffected)
      animControl - the Control that contains the Animation (not null, unaffected)
      Returns:
      textual description (not null, not empty)
    • describe

      public static String describe(com.jme3.anim.AnimClip clip, com.jme3.anim.AnimComposer composer)
      Describe an AnimClip.
      Parameters:
      clip - the AnimClip to describe (not null, unaffected)
      composer - the Control that contains the clip (not null, unaffected)
      Returns:
      textual description (not null, not empty)
    • describe

      public static String describe(com.jme3.anim.AnimTrack track)
      Describe an AnimTrack.
      Parameters:
      track - the AnimTrack to describe (not null, unaffected)
      Returns:
      a textual description (not null, not empty)
    • describe

      public static String describe(com.jme3.animation.Track track, com.jme3.animation.AnimControl animControl)
      Describe an animation track in the context of its Animation.
      Parameters:
      track - the Track to describe (not null, unaffected)
      animControl - an AnimControl that contains the Track (not null, unaffected)
      Returns:
      a textual description (not null, not empty)
    • describeTrackType

      public static char describeTrackType(Object track)
      Describe a track's type with a single character.
      Parameters:
      track - the track to describe (may be null, unaffected)
      Returns:
      a mnemonic character
    • findBoneTrack

      public static com.jme3.animation.BoneTrack findBoneTrack(com.jme3.animation.Animation animation, int boneIndex)
      Find a BoneTrack in a specified Animation that targets the indexed Bone.
      Parameters:
      animation - which Animation (not null, unaffected)
      boneIndex - which Bone (≥0)
      Returns:
      the pre-existing instance, or null if none found
    • findJointTrack

      public static com.jme3.anim.TransformTrack findJointTrack(com.jme3.anim.AnimClip clip, int jointIndex)
      Find a TransformTrack in a specified AnimClip that targets the indexed Joint.
      Parameters:
      clip - which AnimClip (not null, unaffected)
      jointIndex - which Joint (≥0)
      Returns:
      the pre-existing instance, or null if none found
    • findKeyframeIndex

      public static int findKeyframeIndex(com.jme3.animation.Track track, float time)
      Find the index of the keyframe (if any) at the specified time in the specified Track.
      Parameters:
      track - which Track to search (not null, unaffected)
      time - the track time (in seconds, ≥0)
      Returns:
      the keyframe's index (≥0) or -1 if no keyframe at that time
    • findKeyframeIndex

      public static int findKeyframeIndex(com.jme3.anim.TransformTrack track, float time)
      Find the index of the keyframe (if any) at the specified time in the specified TransformTrack.
      Parameters:
      track - the TransformTrack to search (not null, unaffected)
      time - the track time (in seconds, ≥0)
      Returns:
      the keyframe's index (≥0) or -1 if no keyframe at that time
    • findLastKeyframe

      public static float findLastKeyframe(com.jme3.animation.Animation animation)
      Find the time of the keyframe in the specified Animation with the latest time.
      Parameters:
      animation - the input (not null, unaffected)
      Returns:
      the track time (in seconds, ≥0)
    • findPreviousKeyframeIndex

      public static int findPreviousKeyframeIndex(com.jme3.animation.Track track, float time)
      Find the index of the last keyframe at or before the specified time in the specified Track.
      Parameters:
      track - the Track to search (not null, unaffected)
      time - the track time (in seconds, ≥0)
      Returns:
      the keyframe's index (≥0)
    • findPreviousKeyframeIndex

      public static int findPreviousKeyframeIndex(com.jme3.anim.TransformTrack track, float time)
      Find the index of the last keyframe at or before the specified time in the specified TransformTrack.
      Parameters:
      track - the TransformTrack to search (not null, unaffected)
      time - the track time (in seconds, ≥0)
      Returns:
      the keyframe's index (≥0)
    • findSpatialTrack

      public static com.jme3.animation.SpatialTrack findSpatialTrack(com.jme3.animation.AnimControl animControl, com.jme3.animation.Animation animation, com.jme3.scene.Spatial spatial)
      Find a SpatialTrack in the specified animation for the specified spatial.
      Parameters:
      animControl - the AnimControl containing the Animation (not null, unaffected)
      animation - which Animation to search (not null, unaffected)
      spatial - which Spatial to find (unaffected)
      Returns:
      the pre-existing instance, or null if not found
    • findTrackIndex

      public static int findTrackIndex(com.jme3.animation.Animation animation, com.jme3.animation.Track track)
      Find the specified Track in the specified Animation.
      Parameters:
      animation - the Animation containing the Track (not null, unaffected)
      track - which Track to find (unaffected)
      Returns:
      the track index (≥0) or -1 if not found
    • findTransformTrack

      public static com.jme3.anim.TransformTrack findTransformTrack(com.jme3.anim.AnimClip clip, int jointIndex)
      Find a TransformTrack in a specified AnimClip for the indexed Joint.
      Parameters:
      clip - which AnimClip (not null, unaffected)
      jointIndex - which Joint (≥0)
      Returns:
      the pre-existing instance, or null if not found
    • getKeyFrameTimes

      public static float[] getKeyFrameTimes(Object object)
      Access the time array of the specified track.
      Parameters:
      object - the input track (a MorphTrack, TransformTrack, or Track)
      Returns:
      the pre-existing array (not null, length>0)
    • getRotations

      @Deprecated public static com.jme3.math.Quaternion[] getRotations(com.jme3.animation.Track track)
      Copy the keyframe rotations for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • getScales

      public static com.jme3.math.Vector3f[] getScales(com.jme3.animation.Track track)
      Copy the keyframe scales for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • getTargetName

      public static String getTargetName(com.jme3.anim.util.HasLocalTransform target)
      Determine the name of the specified animation target.
      Parameters:
      target - the target to analyze (not null, unaffected)
      Returns:
      the name of target joint/spatial
    • getTargetName

      public static String getTargetName(com.jme3.animation.Track track, com.jme3.animation.AnimControl animControl)
      Read the name of the target of the specified bone/spatial track in the specified AnimControl.
      Parameters:
      track - the bone/spatial track (not null, unaffected)
      animControl - the Control that contains the Track (not null, unaffected)
      Returns:
      the name of target bone/spatial
    • getTranslations

      public static com.jme3.math.Vector3f[] getTranslations(com.jme3.animation.Track track)
      Copy the translations for the specified bone/spatial track.
      Parameters:
      track - which Track (not null, unaffected)
      Returns:
      a new array or null
    • hasTrackForBone

      public static boolean hasTrackForBone(com.jme3.animation.Animation animation, int boneIndex)
      Test whether the specified Animation includes a BoneTrack for the indexed Bone.
      Parameters:
      animation - the Animation to test (not null, unaffected)
      boneIndex - which Bone (≥0)
      Returns:
      true if a track exists, otherwise false
    • isJointTrack

      public static boolean isJointTrack(com.jme3.anim.AnimTrack<?> track)
      Test whether the specified AnimTrack targets a Joint.
      Parameters:
      track - the AnimTrack to test (not null, unaffected)
      Returns:
      true if it targets a Joint, otherwise false
    • newBoneTrack

      public static com.jme3.animation.BoneTrack newBoneTrack(int boneIndex, com.jme3.math.Vector3f translation, com.jme3.math.Quaternion rotation, com.jme3.math.Vector3f scale)
      Create a BoneTrack consisting of a single keyframe at t=0.
      Parameters:
      boneIndex - which Bone (≥0)
      translation - relative to bind pose (not null, unaffected)
      rotation - relative to bind pose (not null, unaffected)
      scale - relative to bind pose (not null, unaffected)
      Returns:
      a new bone track
    • newBoneTrack

      public static com.jme3.animation.BoneTrack newBoneTrack(int boneIndex, float[] times, com.jme3.math.Vector3f[] translations, com.jme3.math.Quaternion[] rotations, com.jme3.math.Vector3f[] scales)
      Create a new BoneTrack, with or without scales.
      Parameters:
      boneIndex - (≥0)
      times - (not null, alias created)
      translations - (not null, same length as times)
      rotations - (not null, same length as times)
      scales - (either null or same length as times)
      Returns:
      a new bone track
    • newBoneTrack

      public static com.jme3.animation.BoneTrack newBoneTrack(int boneIndex, float[] frameTimes, com.jme3.math.Transform transform)
      Create a BoneTrack in which all keyframes have the same Transform.
      Parameters:
      boneIndex - which bone (≥0)
      frameTimes - (not null, unaffected)
      transform - the desired Transform (not null, unaffected)
      Returns:
      a new BoneTrack