use of com.jme3.animation.Animation in project jmonkeyengine by jMonkeyEngine.
the class SkeletonLoader method endElement.
public void endElement(String uri, String name, String qName) {
if (qName.equals("translate") || qName.equals("position") || qName.equals("scale")) {
} else if (qName.equals("axis")) {
} else if (qName.equals("rotate") || qName.equals("rotation")) {
rotation = new Quaternion();
axis.normalizeLocal();
rotation.fromAngleNormalAxis(angle, axis);
angle = 0;
axis = null;
} else if (qName.equals("bone")) {
bone.setBindTransforms(position, rotation, scale);
bone = null;
position = null;
rotation = null;
scale = null;
} else if (qName.equals("bonehierarchy")) {
Bone[] bones = new Bone[indexToBone.size()];
// also assign the bones to the bonelist
for (Map.Entry<Integer, Bone> entry : indexToBone.entrySet()) {
Bone bone = entry.getValue();
bones[entry.getKey()] = bone;
}
indexToBone.clear();
skeleton = new Skeleton(bones);
} else if (qName.equals("animation")) {
animations.add(animation);
animation = null;
} else if (qName.equals("track")) {
if (track != null) {
// if track has keyframes
tracks.add(track);
track = null;
}
} else if (qName.equals("tracks")) {
BoneTrack[] trackList = tracks.toArray(new BoneTrack[tracks.size()]);
animation.setTracks(trackList);
tracks.clear();
} else if (qName.equals("keyframe")) {
assert time >= 0;
assert position != null;
assert rotation != null;
times.add(time);
translations.add(position);
rotations.add(rotation);
if (scale != null) {
scales.add(scale);
} else {
scales.add(new Vector3f(1, 1, 1));
}
time = -1;
position = null;
rotation = null;
scale = null;
} else if (qName.equals("keyframes")) {
if (times.size() > 0) {
float[] timesArray = new float[times.size()];
for (int i = 0; i < timesArray.length; i++) {
timesArray[i] = times.get(i);
}
Vector3f[] transArray = translations.toArray(new Vector3f[translations.size()]);
Quaternion[] rotArray = rotations.toArray(new Quaternion[rotations.size()]);
Vector3f[] scalesArray = scales.toArray(new Vector3f[scales.size()]);
track.setKeyframes(timesArray, transArray, rotArray, scalesArray);
//track.setKeyframes(timesArray, transArray, rotArray);
} else {
track = null;
}
times.clear();
translations.clear();
rotations.clear();
scales.clear();
} else if (qName.equals("skeleton")) {
nameToBone.clear();
}
assert elementStack.peek().equals(qName);
elementStack.pop();
}
Aggregations