I think I found an issue with MotionPath / MotionEvent classes.
It’s happening the following error:
com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.jme3.math.Spline.interpolate(Spline.java:288)
at com.jme3.cinematic.MotionPath.interpolatePath(MotionPath.java:94)
at com.jme3.cinematic.events.MotionEvent.onUpdate(MotionEvent.java:199)
at com.jme3.cinematic.events.MotionEvent.internalUpdate(MotionEvent.java:181)
at com.jme3.cinematic.events.MotionEvent.update(MotionEvent.java:164)
at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:570)
at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:688)
at com.jme3.scene.Node.updateLogicalState(Node.java:145)
at com.jme3.scene.Node.updateLogicalState(Node.java:152)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:244)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:722)
Here is what I’m doing:
[java]
final MotionPath path = new MotionPath();
path.addWayPoint(target.getNode().getLocalTranslation());
path.addWayPoint(new Vector3f(3, -2, 7));
path.setPathSplineType(Spline.SplineType.CatmullRom);
MotionEvent motionControl = new MotionEvent(target.getNode(),path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setSpeed(12f);
motionControl.play();
path.addListener(new MotionPathListener() {
public void onWayPointReach(MotionEvent control, int wayPointIndex) {
if (path.getNbWayPoints() == wayPointIndex + 1) {
System.out.println("finish");
}
}
});
[/java]
I have several targets in my scene. This error is intermitent. If we had more object/target in scene moving around, the problem occurs more frequently.
This problem is occurring in Jmonkey layer. I can’t protect or treat this error in game layer. It’s outside of my code.
Did someone see this problem? Could anyone help me?
netsky08 you are right. It solved the problem. We spent 3 minutes to solved the problem with your tip. Thanks a lot.
But Jmonkey should be prepared to treat this problem. It’s not friendly/elegant break the application. At least should use a try/catch to treat this exception.
Awww man!!.. I had the same exception thrown and was pulling my hair out for hours until I found this thread! I was beginning to think I was crazy or something haha
Thx for fixing it. Now it doesn’t crash at all anymore, it’s so relieving
+1’ed the hero.
EDIT: Quick note, it still happens if you add two identical wayPoints (e.g.: when dynamically animating stuff on the scene, it may still happen that they are the same and throw that same out of bounds exception)
So here’s what I do now to make absolutely sure it never crashes (of course, it would be better to AVOID that entire animation if you can like using a IF branch or something):