Parsing SkinClipSequence

Started by AGP, May 04, 2018, 10:51:28 PM

Previous topic - Next topic

raft

SkinClip is the analogue of sub sequence in jPCT's Animation class. It's for whole skeleton, JointChannel is only for a joint in skeleton.

I can expose the internal data in JointChannel, but may not be trivial to split a channel's animation into shorter ones.

It's a bit weird EasyOgreExporter doesnt support multiple animations, it's written 'multiple Skeleton Animations' in their web page. Anyway, if that is the case, I would suggest, export each animation into a different file, and merge them with Bones, so you will end up with separate animations. merging can be done either with scripts (multiple input files) or programatically with AnimatedGroup.mergeAnimations(..) method.

AGP

They just implemented multiple animations and I just learned a trick to split them. But I still have a problem with the last (occasionally first) frame, which breaks an otherwise perfect loop. Control over the SkinClips would serve all kinds of purpose, and the ability to fix this would be one of them.

raft

okay, exposed a copy of internal data structures in JointChannel. please re-download.

hope this helps

AGP


AGP

I feel like this could be a sticky. It's working, and it will prove very helpful. The ArrayList is there because I was originally testing for nulls before adding to it, but it may as well be removed for performance (although this is the kind of performance that doesn't really matter because you only run this code once before creating your .bones file.


     private void firstFrameToLast() {
SkinClipSequence sequence = animatedGroup.getSkinClipSequence();
for (int i = 0; i < sequence.getSize(); i++) {
     SkinClip clip = sequence.getClip(i);
     java.util.Iterator<JointChannel> jCs = clip.iterator();
     ArrayList<JointChannel> jointChannels = new ArrayList<JointChannel>();
     while (jCs.hasNext()) {
JointChannel jC = jCs.next();
     jointChannels.add(jC);
JointChannel channel = jC;
int index = channel.getJointIndex();
float[] times = channel.getTimes();
SimpleVector[] translations = channel.getTranslations();
Quaternion[] rotations = channel.getRotations();
SimpleVector[] scales = channel.getScales();
translations[translations.length-1] = translations[0];
rotations[rotations.length-1] = rotations[0];
scales[scales.length-1] = scales[0];
channel = new JointChannel(index, times, translations, rotations, scales);
clip.removeChannel(jC);
clip.addChannel(channel);
     }
}
saveToBones(objectFileName.substring(0, objectFileName.lastIndexOf("."))+".bones");
System.out.println("Last Frame Replaced With First");
Toolkit.getDefaultToolkit().beep();
     }