Author Topic: Parsing SkinClipSequence  (Read 32221 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Parsing SkinClipSequence
« on: May 04, 2018, 10:51:28 pm »
Since EasyOgreExporter exports all clips into a single animation, I'm forced to write a parser. How, then, might I split a SkinClipSequence of one SkinClip into a SkinClipSequence of two or more?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #1 on: May 04, 2018, 11:01:04 pm »
get clips from sequence, create new sequences, add clips into new sequences

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #2 on: May 04, 2018, 11:21:14 pm »
No, because I need to say that a single clip is actually two or three. It's not about adding, it's about parsing or splitting.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #3 on: May 04, 2018, 11:27:03 pm »
ah okay. well, still the same method in other scale, get JointChannel's from SkinClip, create new clips, add channels into new clips

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #4 on: May 05, 2018, 09:55:14 pm »
OK, I got this far:

Code: [Select]
     private void addSequence() {
java.util.List<JointChannel> jointChannels = (java.util.List)sequence.getClip(0).iterator();
SkinClip clip = new SkinClip(sequence.getSkeleton(), jointChannels);
clip.setName("1");
java.util.ArrayList<SkinClip> clipList = new java.util.ArrayList<SkinClip>();
clipList.add(clip);
clip = new SkinClip(sequence.getSkeleton(), jointChannels);
clip.setName("2");
clipList.add(clip);
newSequence = new SkinClipSequence(clipList);
newSequence.addClip(clip);
     }

But I still haven't given the clips proper information. Is it as simple as passing each half of the JointChannels?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #5 on: May 05, 2018, 10:36:06 pm »
I tried this:
Code: [Select]
     private void addSequence() {
java.util.Iterator<JointChannel> jCs = sequence.getClip(0).iterator();
ArrayList<JointChannel> jointChannels = new ArrayList<JointChannel>();
while (jCs.hasNext())
     jointChannels.add(jCs.next());
System.out.println("jointChannels Length: "+jointChannels.size() +" Is jointChannels[0] null? "+(jointChannels.get(0)==null));
ArrayList<JointChannel> half1 = new ArrayList<JointChannel>(jointChannels.size()/2);
for (int i = 0; i < jointChannels.size()/2; i++)
     half1.add(jointChannels.get(i));
ArrayList<JointChannel> half2 = new ArrayList<JointChannel>(jointChannels.size()/2);
for (int i = jointChannels.size()/2; i < jointChannels.size(); i++)
     half2.add(jointChannels.get(i));
SkinClip clip = new SkinClip(sequence.getSkeleton(), half1);
clip.setName("1");
java.util.ArrayList<SkinClip> clipList = new java.util.ArrayList<SkinClip>();
clipList.add(clip);
clip = new SkinClip(sequence.getSkeleton(), half2);
clip.setName("2");
clipList.add(clip);
newSequence = new SkinClipSequence(clipList);
newSequence.addClip(clip);
     }

But the printout tells me that jointChannnels.get(0) is null. So what am I doing wrong?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #6 on: May 07, 2018, 01:48:39 pm »
Code: [Select]
/** <p>Returns an iterator of channels. Note some channels may be null.</p> */
public Iterator<JointChannel> iterator() {
return Arrays.asList(channels).iterator();
}

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #7 on: May 07, 2018, 08:11:00 pm »
Raft, do you mind being a little more helpful? Is this even the way to go? Because currently I'm only getting NullPointerExceptions.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #8 on: May 07, 2018, 08:14:01 pm »
well, as the Javadoc says, SkinClip.iterator() may return null values, just skip null ones in your code

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #9 on: May 07, 2018, 08:18:23 pm »
OK, so filling two sets of JointChannels with non-null entries will definitely produce two sets of animations?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Parsing SkinClipSequence
« Reply #10 on: May 07, 2018, 08:19:33 pm »
yup, supposed to be

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #11 on: May 07, 2018, 08:22:13 pm »
Thanks.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #12 on: May 07, 2018, 08:35:07 pm »
It worked, but it did not parse the animations: it parsed the movements instead. Now I have an animation that only moves my character's fingers.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #13 on: May 08, 2018, 01:36:21 am »
Isn't SkinClipSequence supposed to be analog to Animation? Because Animation gives us access to KeyFrames, so why can't I find something similar in SkinClipSequence?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Parsing SkinClipSequence
« Reply #14 on: May 08, 2018, 07:32:15 am »
From what I gather, it's the JointChannels themselves, rather than their number, that I need to split here. But Bones doesn't give me access to that. Would you be willing to change that?