JointController IndexOutOfBoundsException for ms3d

Hi guys,

I've been lurking for a while but this is my first post, so I apologize in advance if I'm duplicating messages. I promise I did try search first!

When loading an ms3d file which has a skeleton and either zero or one keyframe(s) (using the same code as in TestMilkJmeWrite), I was getting the following exception:

SEVERE: Exception in game loop

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.RangeCheck(Unknown Source)

at java.util.ArrayList.get(Unknown Source)

at com.jmex.model.animation.JointController.processController(


at com.jme.util.export.binary.BinaryImporter.readObject(

at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(

at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(

… etc

I had a look, and made a slight change to code which appears to have fixed it. The change was in JointController.processController(), as follows:


        if (movementInfo.size() == 1) { // IE no times were added or only time 0

            // was added

            movementInfo.add(0, new PointInTime(0));



        if (movementInfo.size() <= 1) { // IE no times were added or only time 0

            // was added

            movementInfo.add(0, new PointInTime(numJoints));


I can provide some sample ms3d files which suffer the problem if that is of assistance to you.

Thanks for a great engine btw, I expect I'll be back with a lot of questions once I get past my first few experimental steps!

I'm surprised that would work…  I'd expect you'd have to test for 0 size and do an add with no index param.

Well the out of bounds was happening because it was trying to load the positions for each joint in turn from the first PointInTime, but there was no records for it to read from. Giving it numJoints just meant that it had the right number of joints, and each of them was defaulting to 0 (or null, I forget, but it was able to handle it then). Changing the == to <= just meant that it caught the zero-keyframe case as well.

I'm not sure if this is the right answer, just that it is an answer which might have been of use in the debugging process. :slight_smile: