private void interpolateMorphTrack(double t, MorphTrack track) { Geometry target = track.getTarget(); float[] weights = target.getMorphState(); track.getDataAtTime(t, weights); target.setMorphState(weights); // if (collectTransformDelegate != null) { // collectTransformDelegate.collectTransform(target, transform, getWeight(), this); // } else { // this.collectTransform(target, transform, getTransitionWeight(), this); // } }
/** * Creates a morph track with the given Geometry as a target * * @param times a float array with the time of each frame * @param weights the morphs for each frames */ public MorphTrack(Geometry target, float[] times, float[] weights, int nbMorphTargets) { this.target = target; this.nbMorphTargets = nbMorphTargets; this.setKeyframes(times, weights); }
/** * Set the weight for this morph track * * @param times a float array with the time of each frame * @param weights the weights of the morphs for each frame */ public void setKeyframes(float[] times, float[] weights) { setTimes(times); if (weights != null) { if (times == null) { throw new RuntimeException("MorphTrack doesn't have any time for key frames, please call setTimes first"); } this.weights = weights; assert times != null && times.length == weights.length; } }
MorphTrack track = new MorphTrack(g, trackData.times, trackData.weights, nbMorph); aTracks.add(track);
@Override public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); weights = ic.readFloatArray("weights", null); times = ic.readFloatArray("times", null); target = (Geometry) ic.readSavable("target", null); nbMorphTargets = ic.readInt("nbMorphTargets", 0); setTimes(times); }