Package com.jme3.anim

Class MorphTrack

java.lang.Object
com.jme3.anim.MorphTrack
All Implemented Interfaces:
AnimTrack<float[]>, Savable, JmeCloneable, Cloneable

public class MorphTrack extends Object implements AnimTrack<float[]>
Contains a list of weights and times for each keyframe.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Serialization-only.
     
    MorphTrack(Geometry target, float[] times, float[] weights, int nbMorphTargets)
    Creates a morph track with the given Geometry as a target
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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, float[] store)
    Determine the track value for the specified time.
    double
    Determine the duration of the track.
    int
     
    Access the target geometry.
    float[]
    returns the arrays of time for this track
    float[]
    return the array of weights of this track
    Performs a regular shallow clone of the object.
    void
    De-serialize this track from the specified importer, for example when loading from a J3O file.
    void
    Replace the FrameInterpolator.
    void
    setKeyframes(float[] times, float[] weights)
    Sets the times and weights for this morph track.
    void
    setKeyframesWeight(float[] weights)
    Set the weights for this morph track.
    void
    setNbMorphTargets(float[] weights, int nbMorphTargets)
    Sets the number of morph targets and the corresponding weights.
    void
    Replace the target geometry.
    void
    setTimes(float[] times)
    Sets the keyframes times for this Joint track
    void
    Serialize this track to the specified exporter, for example when saving to a J3O file.

    Methods inherited from class java.lang.Object

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

    • MorphTrack

      protected MorphTrack()
      Serialization-only. Do not use.
    • MorphTrack

      public MorphTrack(Geometry target, float[] times, float[] weights, int nbMorphTargets)
      Creates a morph track with the given Geometry as a target
      Parameters:
      target - the desired target (alias created)
      times - a float array with the time of each frame (alias created -- do not modify after passing it to this constructor)
      weights - the morphs for each frames (alias created -- do not modify after passing it to this constructor)
      nbMorphTargets - the desired number of morph targets
  • Method Details

    • getWeights

      public float[] getWeights()
      return the array of weights of this track
      Returns:
      the pre-existing array -- do not modify
    • setKeyframesWeight

      public void setKeyframesWeight(float[] weights)
      Set the weights for this morph track. Note that the number of weights must equal the number of frames times the number of morph targets.
      Parameters:
      weights - the weights of the morphs for each frame (alias created -- do not modify after passing it to this setter)
      Throws:
      IllegalStateException - if this track does not have times set
      IllegalArgumentException - if weights is an empty array or if the number of weights violates the frame count constraint
    • getTimes

      public float[] getTimes()
      returns the arrays of time for this track
      Returns:
      the pre-existing array -- do not modify
    • setTimes

      public void setTimes(float[] times)
      Sets the keyframes times for this Joint track
      Parameters:
      times - the keyframes times (alias created -- do not modify after passing it to this setter)
      Throws:
      IllegalArgumentException - if times is empty
    • setKeyframes

      public void setKeyframes(float[] times, float[] weights)
      Sets the times and weights for this morph track. Note that the number of weights must equal the number of frames times the number of morph targets.
      Parameters:
      times - a float array with the time of each frame (alias created -- do not modify after passing it to this setter)
      weights - the weights of the morphs for each frame (alias created -- do not modify after passing it to this setter)
    • getNbMorphTargets

      public int getNbMorphTargets()
      Returns:
      the number of morph targets
    • setNbMorphTargets

      public void setNbMorphTargets(float[] weights, int nbMorphTargets)
      Sets the number of morph targets and the corresponding weights. Note that the number of weights must equal the number of frames times the number of morph targets.
      Parameters:
      weights - the weights for each frame (alias created -- do not modify after passing it to this setter)
      nbMorphTargets - the desired number of morph targets
      Throws:
      IllegalArgumentException - if the number of weights and the new number of morph targets violate the frame count constraint
    • getLength

      public double getLength()
      Description copied from interface: AnimTrack
      Determine the duration of the track.
      Specified by:
      getLength in interface AnimTrack<float[]>
      Returns:
      the duration (in seconds, ≥0)
    • getDataAtTime

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

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

      public Geometry getTarget()
      Access the target geometry.
      Returns:
      the pre-existing instance
    • setTarget

      public void setTarget(Geometry target)
      Replace the target geometry.
      Parameters:
      target - the Geometry to use as the target (alias created)
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize 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-serialize 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 use (not null)
      Throws:
      IOException - from the importer
    • jmeClone

      public Object 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.