|
|
@ -41,16 +41,14 @@ import com.jme3.scene.Spatial; |
|
|
|
import com.jme3.util.TempVars; |
|
|
|
import com.jme3.util.TempVars; |
|
|
|
import com.jme3.util.clone.Cloner; |
|
|
|
import com.jme3.util.clone.Cloner; |
|
|
|
import com.jme3.util.clone.JmeCloneable; |
|
|
|
import com.jme3.util.clone.JmeCloneable; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This class represents the track for spatial animation. |
|
|
|
* This class represents the track for spatial animation. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Marcin Roguski (Kaelthas) |
|
|
|
* @author Marcin Roguski (Kaelthas) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SpatialTrack implements Track, JmeCloneable { |
|
|
|
public class SpatialTrack implements JmeCloneable, Track { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Translations of the track. |
|
|
|
* Translations of the track. |
|
|
@ -250,11 +248,16 @@ public class SpatialTrack implements Track, JmeCloneable { |
|
|
|
return times == null ? 0 : times[times.length - 1] - times[0]; |
|
|
|
return times == null ? 0 : times[times.length - 1] - times[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create a clone with the same track spatial. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return a new track |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Track clone() { |
|
|
|
public SpatialTrack clone() { |
|
|
|
SpatialTrack copy = (SpatialTrack) jmeClone(); |
|
|
|
Cloner cloner = new Cloner(); |
|
|
|
copy.setTrackSpatial(trackSpatial); |
|
|
|
cloner.setClonedValue(trackSpatial, trackSpatial); |
|
|
|
return (Track) copy; |
|
|
|
return cloner.clone(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -270,24 +273,38 @@ public class SpatialTrack implements Track, JmeCloneable { |
|
|
|
return trackSpatial; |
|
|
|
return trackSpatial; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create a shallow clone for the JME cloner. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return a new track |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object jmeClone() { |
|
|
|
public SpatialTrack jmeClone() { |
|
|
|
int tablesLength = times.length; |
|
|
|
try { |
|
|
|
|
|
|
|
return (SpatialTrack) super.clone(); |
|
|
|
float[] timesCopy = this.times.clone(); |
|
|
|
} catch (CloneNotSupportedException exception) { |
|
|
|
Vector3f[] translationsCopy = this.getTranslations() == null ? null : Arrays.copyOf(this.getTranslations(), tablesLength); |
|
|
|
throw new RuntimeException("Can't clone track", exception); |
|
|
|
Quaternion[] rotationsCopy = this.getRotations() == null ? null : Arrays.copyOf(this.getRotations(), tablesLength); |
|
|
|
} |
|
|
|
Vector3f[] scalesCopy = this.getScales() == null ? null : Arrays.copyOf(this.getScales(), tablesLength); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//need to use the constructor here because of the final fields used in this class
|
|
|
|
|
|
|
|
return new SpatialTrack(timesCopy, translationsCopy, rotationsCopy, scalesCopy); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Callback from {@link com.jme3.util.clone.Cloner} to convert this |
|
|
|
|
|
|
|
* shallow-cloned track into a deep-cloned one, using the specified cloner |
|
|
|
|
|
|
|
* to resolve copied fields. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param cloner the cloner currently cloning this control (not null) |
|
|
|
|
|
|
|
* @param original the track from which this track was shallow-cloned |
|
|
|
|
|
|
|
* (unused) |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void cloneFields(Cloner cloner, Object original) { |
|
|
|
public void cloneFields(Cloner cloner, Object original) { |
|
|
|
this.trackSpatial = cloner.clone(((SpatialTrack) original).trackSpatial); |
|
|
|
translations = cloner.clone(translations); |
|
|
|
|
|
|
|
rotations = cloner.clone(rotations); |
|
|
|
|
|
|
|
scales = cloner.clone(scales); |
|
|
|
|
|
|
|
trackSpatial = cloner.clone(trackSpatial); |
|
|
|
|
|
|
|
times = cloner.clone(times); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void write(JmeExporter ex) throws IOException { |
|
|
|
public void write(JmeExporter ex) throws IOException { |
|
|
|
OutputCapsule oc = ex.getCapsule(this); |
|
|
|
OutputCapsule oc = ex.getCapsule(this); |
|
|
|