Bug in AnimControl

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]

1 Like

I think this is intentional, as the Javadoc at one point mentioned that you had to call setAnimations in order for the class to be useful but it seems that bit of documentation is gone… @Momoko_Fan?



Oh, and welcome to the forum… thanks for the quality first post! :slight_smile:

1 Like

that’s strange i committed a fix to that when I committed the AnimationHelper…

Are you using nightly? are you using source code from svn? if it’s the latter make sure you updated the whole project.



Also AnimationHelper is a bit fresh, so there might be some issues yet.

1 Like

Ahh… I pulled the beta release and then noticed AnimationHelper later on and “kyped” the code by itself… Thanks for the greetings and GOOD WORK! btw… Very cool stuff.

Works quite well so far. Definitely a big help to me.

Cool thanks for your feed back.

BTW it has been renamed to AnimationFactory in the last SVN