I am trying to get the piece of code (see below) that demonstrates the use of AnimationFactory class in TestCinematic.java (teapot example) to work with an Ogre model that I made and imported from Maya. Unfortunately, I get an IllegalArgumentException exception (see below). Note that the very same code works fine when I use the teapot model rather than the my own, which is just a sphere made in Maya, converted to Ogre format using OgreMax and OgreCommandLineTools_1.7.2, and imported to JME using assetManager.loadModel().
Any ideas?
The code:
AnimationFactory factory = new AnimationFactory (duration, “Anim1”);
factory.addTimeTranslation(0, new Vector3f(0, 10, 10));
factory.addTimeTranslation(4, new Vector3f(10, 0, 40));
AnimControl control = new AnimControl();
control.addAnim(factory.buildAnimation());
obj.addControl(control);
AnimationTrack antr = new AnimationTrack(obj, “Anim1”);
cinematic.addCinematicEvent(timeInstant, antr);
The exception:
java.lang.IllegalArgumentException: The animation Anim1 does not exist in this AnimControl
at com.jme3.animation.AnimControl.getAnimationLength(AnimControl.java:312)
at com.jme3.cinematic.events.AnimationTrack.(AnimationTrack.java:66)
at BallScript.simpleInitApp(BallScript.java:33)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:722)
Maybe your obj spatial already has an AnimControl that gets created when loaded?
So you have 2 controls but then the anim is fetched on the wrong control
in that case instead of creating a new AnimControl do
[java]
AnimControl control = obj.getControl(AnimControl.class);
control.addAnim(factory.buildAnimation());
[/java]
Yes, it was exactly that!!
Thanks nehon!