Error using a blender2ogre animation

I am getting an error when I try to use an animation that I created in blender and exported using blender2ogre. If I read correctly, JME was made to use ogre files so that’s why I went this route.

I export my model and I get the mesh and material files as always. I also get a two skeleton files, one being an xml. I open the file and I see this.

 <animation name = "my_animation" blah blah>

So I am assuming that the animation was exported correctly. I am getting an error though when I try to load the animation.

channel.setAnim("my_animation", 0.5f);

The error being: Cannot find animation “my_animation”. All of my files are in a folder and the model and texture load correctly. I am wondering if I am using the animation class wrong or loading it wrong?

Spatial mushroom = assetManager.loadModel("Models/MushroomAnim2/mushroom.mesh.xml");

Then I use this spatial within my PlayerNode class.

    control = new AnimControl();
    channel = control.createChannel();

The player node class extends Node and implements AnimEventListener. The above code is in the Initialize method. Am I loading the animation listener wrong? Or is it an error in my exported files somewhere?

Edit: I’ve noticed in the tutorials when creating an AnimControl, they use player = this.getClass(AnimControl.class); I don’t know if creating a new AnimControl has anything to do with it, but its just a thought.

Yeah I think you’re kinda on it…

It get’s the skeleton stuff when you load the model.mesh.xml
So you should be doing

control = mushroom.getControl(AnimControl.class);
channel = control.createChannel();

And you have to make sure that the AnimControl is actually a direct child of the mushroom. You might want to convert the model to a .j3o and play all the animations to see if they work before you try to use it in code.

I converted to j3o and the AnimControl is a child of the model. The animation was exported wrong but it still moves If not the right way.

control = this.getControl(AnimControl.class);
    channel = control.createChannel();

The second line now gives me a null pointer error.

So the AnimControl is most likely not a direct child of your model. If you have a model structure like this:


you have to call model.getChild(Node1).getControl(AnimControl)