AnimationControl Blender 2.61 null pointer exception?

Hi there!

Ive fished around a bit but couldn’t find the solution to my problem.

I used Blender 2.61 to model, skin, rig and animate my game character, I converted the .blend file to .j3o from inside the jmp and the model displays just fine in the sceneComposer. AnimControl object is there too and i can play my animation.



But when i try and load the model with its animations in game i always get a Null.Pointer.Exception on this line:

[java]AnimChannel channel = control.createChannel();[/java]



as far as i know im not missing anything



[java]playerModel = Main.app.getAssetManager().loadModel(“Models/untitled9.j3o”);

playerModel.setLocalScale(0.8f);

Main.app.makeToonish(playerModel);

AnimControl control = playerModel.getControl(AnimControl.class);

AnimChannel channel = control.createChannel();

channel.setAnim(“stand”);[/java]



many thanks!

i really been pulling my hair out on this one im going to try and remake my animations in blender 2.49 and see what happens, i would much rather prefer to animate in 2.61 though if anyone has suggestions :frowning:

I’m having a similar problem. I updated my ide and started getting some weirdness. I get null pointers logged all over the place but my code seems to run fine.



I have found that targeting cameras to objects and some IPO curves seems to break things when converting from .blend to .j3o.

Thanks for the reply,

i havent used any IPO curves or cameras in my scene i just cant understand why the animation plays just fine in the sceneComposer but cant load in game. 8O

Here’s my exact error message



SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at mygame.client.Player.buildPlayerModel(Player.java:48)

at mygame.client.Player.(Player.java:29)

at mygame.client.MePlayer.(MePlayer.java:20)

at mygame.client.Main.simpleInitApp(Main.java:107)

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)



and here’s my model maybe someone can test it out see whats wrong? (.blend and the .j3o)

http://www.mediafire.com/?fl8u7nmpqlsb01o

Hey don’t know if I can be of much help but can you post any error messages that you get? Maybe someone can see if there is something you might have missed.

Look at the model in the SceneExplorer, your code would only work if the AnimControl is on the root Node, if its in a sub-node you have to retrieve that and getControl() there.

Yes, I got the same errors. norman is correct. In my scene I had no animation controls, or so I thought. I did try and attach a shape key but removed it. It seems like in blender, the control remained. After removing it in Blender, my scene runs without errors. :slight_smile:



Thanks @norman!

Question: In the file wishmaster shared, how do you move the Animation control to the rootNode?

Thanks Norman i can see exactly what you are saying it does make sense but im not exactly sure how to move the animControl to the rootNode or retrive it from where it is in the sub node the tree in the sceneComposer looks like this

Models/Player/player.blend → Armature → Cylinder → (AnimControl + Cylinder1)

I worked out out to access it, im sure there’s a more economical way but if any is interested this is how i did it



Node playerModel = (Node)Main.app.getAssetManager().loadModel(“Models/Player/player.j3o”);

Node armature = (Node)playerModel.getChild(0);

Node cylinder = (Node)armature.getChild(0);

AnimControl control = cylinder.getControl(AnimControl.class);



Thanks to everyone who helped me work this out :smiley:

you can just go getChild(name) from the root node, it will work for nested geometry too as long as the name is unique.

thanks Norman your the man with all the answers :smiley: