public static void padJointTracks(List<TransformTrack> tracks, Joint staticJoint) { Joint j = staticJoint; if (j != null) { // joint has no track , we create one with the default pose float[] times = new float[]{0}; Vector3f[] translations = new Vector3f[]{j.getLocalTranslation()}; Quaternion[] rotations = new Quaternion[]{j.getLocalRotation()}; Vector3f[] scales = new Vector3f[]{j.getLocalScale()}; TransformTrack track = new TransformTrack(j, times, translations, rotations, scales); tracks.add(track); } }
/** * Creates a transform track for the given bone index * * @param times a float array with the time of each frame * @param translations the translation of the bone for each frame * @param rotations the rotation of the bone for each frame * @param scales the scale of the bone for each frame */ public TransformTrack(HasLocalTransform target, float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) { this.target = target; this.setKeyframes(times, translations, rotations, scales); }
@Override public Collection<HasLocalTransform> getTargets() { List<HasLocalTransform> targets = new ArrayList<>(clip.getTracks().length); for (AnimTrack track : clip.getTracks()) { if (track instanceof TransformTrack) { targets.add(((TransformTrack) track).getTarget()); } } return targets; }
/** * Set the translations, rotations and scales for this bone track * * @param times a float array with the time of each frame * @param translations the translation of the bone for each frame * @param rotations the rotation of the bone for each frame * @param scales the scale of the bone for each frame */ public void setKeyframes(float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) { setTimes(times); if (translations != null) { setKeyframesTranslation(translations); } if (rotations != null) { setKeyframesRotation(rotations); } if (scales != null) { setKeyframesScale(scales); } }
String jointName = SAXUtil.parseString(attribs.getValue("bone")); joint = nameToJoint.get(jointName); track = new TransformTrack(); track.setTarget(joint); } else if (qName.equals("boneparent")) { assert elementStack.peek().equals("bonehierarchy");
private void interpolateTransformTrack(double t, TransformTrack track) { HasLocalTransform target = track.getTarget(); transform.set(target.getLocalTransform()); track.getDataAtTime(t, transform); if (collectTransformDelegate != null) { collectTransformDelegate.collectTransform(target, transform, getWeight(), this); } else { this.collectTransform(target, transform, getTransitionWeight(), this); } } private void interpolateMorphTrack(double t, MorphTrack track) {
@Override public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); translations = (CompactVector3Array) ic.readSavable("translations", null); rotations = (CompactQuaternionArray) ic.readSavable("rotations", null); times = ic.readFloatArray("times", null); scales = (CompactVector3Array) ic.readSavable("scales", null); target = (HasLocalTransform) ic.readSavable("target", null); setTimes(times); }
spatials.add(s); if (trackData.rotations != null || trackData.translations != null || trackData.scales != null) { TransformTrack track = new TransformTrack(s, trackData.times, trackData.translations, trackData.rotations, trackData.scales); aTracks.add(track); TransformTrack track = new TransformTrack(jw.joint, trackData.times, trackData.translations, trackData.rotations, trackData.scales); aTracks.add(track); Quaternion[] rotations = new Quaternion[]{joint.getLocalRotation()}; Vector3f[] scales = new Vector3f[]{joint.getLocalScale()}; TransformTrack track = new TransformTrack(joint, times, translations, rotations, scales); aTracks.add(track);
Vector3f[] scalesArray = scales.toArray(new Vector3f[scales.size()]); track.setKeyframes(timesArray, transArray, rotArray, scalesArray); } else { track = null;
@Override public void doInterpolate(double t) { AnimTrack[] tracks = clip.getTracks(); for (AnimTrack track : tracks) { if (track instanceof TransformTrack) { TransformTrack tt = (TransformTrack) track; if(getMask() != null && !getMask().contains(tt.getTarget())){ continue; } interpolateTransformTrack(t, tt); } else if (track instanceof MorphTrack) { interpolateMorphTrack(t, (MorphTrack) track); } } }
TransformTrack t = new TransformTrack(joint, times, translations, rotations, scales); return t;
}; TransformTrack track1 = new TransformTrack(j1, times, null, rotations, scales); TransformTrack track2 = new TransformTrack(j2, times, null, rotations, null);
}; TransformTrack track1 = new TransformTrack(j1, times, null, rotations, scales); TransformTrack track2 = new TransformTrack(j2, times, null, rotations, null);