Parsing SkinClipSequence

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

Previous topic - Next topic

AGP

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?

raft

get clips from sequence, create new sequences, add clips into new sequences

AGP

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.

raft

ah okay. well, still the same method in other scale, get JointChannel's from SkinClip, create new clips, add channels into new clips

AGP

OK, I got this far:


     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?

AGP

I tried this:

     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?

raft

/** <p>Returns an iterator of channels. Note some channels may be null.</p> */
public Iterator<JointChannel> iterator() {
return Arrays.asList(channels).iterator();
}

AGP

Raft, do you mind being a little more helpful? Is this even the way to go? Because currently I'm only getting NullPointerExceptions.

raft

well, as the Javadoc says, SkinClip.iterator() may return null values, just skip null ones in your code

AGP

OK, so filling two sets of JointChannels with non-null entries will definitely produce two sets of animations?

raft


AGP


AGP

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.

AGP

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?

AGP

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?