It seems you must initialize the animation HashMap manually or you get a null pointer exception at runtime. This appears to be a bug. Can someone confirm… Example code below…
[java]
private AnimControl generateGemAnimation(Geometry target) {
AnimationHelper animationHelper = new AnimationHelper(1, "selectAnim");
animationHelper.addTimeScale(0, target.getLocalScale());
animationHelper.addTimeTranslation(0, target.getLocalTranslation());
animationHelper.addTimeRotation(0, Quaternion.IDENTITY);
animationHelper.addTimeRotation(0.5f, new Quaternion()
.fromAngleNormalAxis(FastMath.PI, Vector3f.UNIT_Y));
animationHelper.addTimeRotation(1f, new Quaternion()
.fromAngleNormalAxis(FastMath.TWO_PI, Vector3f.UNIT_Y));
Animation anim = animationHelper.buildAnimation();
AnimControl control = new AnimControl();
control.setAnimations(new HashMap<String, Animation>()); // remove this line and throws exception on next line…
control.addAnim(anim);
AnimChannel channel = control.createChannel();
channel.setLoopMode(LoopMode.Loop);
channel.setAnim("selectAnim");
return control;
}
[/java]
Please refrain from double posting!
Conversation is in this thread: http://hub.jmonkeyengine.org/groups/development-discussion-jme3/forum/topic/bug-in-animcontrol-1/