Importing models with animations from Blender

Hi guys. I have trouble importing some animated 3d models (.blend) to JME.

I have no experience in Blender or in 3d models in general.



The models I’m trying to use can be found here:

http://opengameart.org/users/botanic

They are the ‘Animated Priest, Mage, Knight’, etc. models.





First of all, I have installed the OgreXML plugin for Blender but there are too many export options and I am not sure which ones to enable.



I have managed to export the models to .mesh.xml and .skeleton.xml files, by unchecking “Separate materials”, “Export scene”, “Export selected only”, “Force camera” and “Force lamps” and renaming the exported files accordingly.

However, I cannot find the animatons. I open the .skeleton.xml file in a text editor and I only see one animation called “my_animation”, unlike the Ninja model of JME where there are many different animations.

Also, in some of the models (Animated Knight, Animated Berzerker, Animated Cerberus), Blender strangely does not export a .skeleton.xml file at all.



Furthermore, when I try to load a model from my program, it crashes. This occurs even when I have converted it to .j3o using the jMonkey SDK.

The line that causes the crashing is the last line of this code:



[java] /** Load a model that contains animation /

Node mage = (Node) assetManager.loadModel(“Models/Mage/mage.j3o”);

mage.setLocalTranslation(0, 5, -30);

rootNode.attachChild(mage);



/
* Create a controller and channels. */

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

control.addListener(this);[/java]



and the output is the following:



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

java.lang.NullPointerException

at mygame.Main.testAnimation(Main.java:334)

at mygame.Main.simpleInitApp(Main.java:99)

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:619)[/java]





The Blender version I’m using is 2.62.



I apologize for the long post and I’m sorry if the answer is too obvious.

Can someone please show me exactly the correct way to get these animated models to JME?

Thanks in advance.

You have to select the animations you want to export, also only bone animations are supported. Check the ogre exporter manual (button in the exporter UI).

Thanks for the response.



I don’t know how to select the animations (Blender feels absolutely chaotic to me) and the manual does not seem helpful at all. Can you please offer some advice?

Any help, please? I really need to do this…

Check https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset (also the export tips at the bottom) and also check this video:

blender to jme3 though ogre XML - YouTube


… If you “really need to do this” I bet you don’t mind learning about the topic at hand. You have to understand that you can’t just expect any model to work just like this, you have to understand what data you actually import to what function in the engine, what data you need etc. Also, are you sure the models animations are bone animations? I already told you the animations have to be bone animations to work properly in the engine.

Agreed with Normen, You can do this, but you cannot do it fast… Whether or not you plan on modeling/animating yourself, which it looks like you aren’t, you still need to understand how it works… do yourself a favor and work through these video tutorials… Then if you still have problems, you can come asking questions that people understand how to answer, without doing your work for you.

Thanks for the responses. I went through the tutorials and managed to import some of the models.



However, I still have trouble with a few of them. In the NLA Editor window there should be an object where I can add a track with the animations, like in the video tutorial (at 02:38). However in these models, the NLA Editor window is empty.



I read the Blender manual on the NLA editor and did a lot of searching as well, but I still can’t figure out the solution. Can you help me, please?

DopeSheet → Action Editor → new, will add an armature action (basically, an animation) to the nla window. Inserting a key in the timeline works too (from pose mode with all bones selected, “i” and choose “LocRotScale”).

I finally managed to import all models to JME, however one last problem remains.

In three of the models the animations appear distorted in JME, although they look fine in Blender.



I tried changing the swap axis to -xzy in the Export menu (this had fixed the problem in the other models), however in these ones the distortion remains.



If anyone has any time to spare, here are the models:

http://dl.dropbox.com/u/69517768/Models.zip



The version of Blender I’m using is 2.62.



Thanks a lot for your time.

i had problems with my model too, but i dont remember actually what i done.



make sure you apply data to object, ctrl - a → apply scale and rotation. to both: model and skeleton. Maybe this could help.

And make sure all vertices are assigned to skeleton.

1 Like

apply all the transforms to the model and to the armature in blender before exporting

1 Like

You were right, guys! Applying all the transformations to the model and to the armature fixed the problem!

Thanks a lot!