Author Topic: Parsing SkinClipSequence  (Read 709 times)

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1984
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #15 on: May 08, 2018, 05:44:50 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1611
    • View Profile
Re: Parsing SkinClipSequence
« Reply #16 on: May 08, 2018, 06:26:02 pm »
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1984
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #17 on: May 08, 2018, 07:51:07 pm »
okay, exposed a copy of internal data structures in JointChannel. please re-download.

hope this helps

Offline AGP

  • quad
  • ******
  • Posts: 1611
    • View Profile
Re: Parsing SkinClipSequence
« Reply #18 on: May 08, 2018, 08:38:19 pm »
Thanks a lot.

Offline AGP

  • quad
  • ******
  • Posts: 1611
    • View Profile
Re: Parsing SkinClipSequence
« Reply #19 on: May 08, 2018, 10:18:15 pm »
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.

Code: [Select]
     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();
     }