[Solved] Does the Blender importer work with Animations?

The title is basically the entirety of the question.

Here’s the entire process I’ve been using.

  1. Made my model, rigged it, animated it.

  1. Using the import button at the top of the jME IDE I selected import and selected my model file. I also tried putting the blend file into the same folder path as where the j3o file ended up and converted there with a right click. I assumed it’d work with Blender due to these article on the wiki: https://wiki.jmonkeyengine.org/sdk/3ds_to_blender_to_jmp.html and https://wiki.jmonkeyengine.org/jme3/external/blender.html

  1. This is from the importer just to show that it’s alive.

  1. In the scene composer I see this though which doesn’t appear the same as the import screen or at least it doesn’t show the animation line in step 2 above.

  1. From the wiki I copied the below code. Importing the model alone and attaching it to root works fine enough. But the moment I try to use “channel = control.createChannel();” it throws a null pointer.
        Spatial model = (Spatial) assetManager.loadModel("Models/Cubie/Cubie.j3o");
        
        control = model.getControl(AnimControl.class);
                
        System.out.println("Is this null? " + model.getControl(AnimControl.class));
        
        channel = control.createChannel();
        
        rootNode.attachChild(model);

I assume I’m doing something boneheaded along the lines of I need to do something different for the blender import to work properly but I’ve poured over the wiki a number of times and forum but coming up with nothing super helpful (or… as I said… I’m being dumb). Any ideas?

https://wiki.jmonkeyengine.org/jme3/advanced/mixamo.html#action-baking

I did see this one but the line “Baking is a destructive process so it is recommended that after completion of Creating Blender Animations, test the animation in-game.” was kinda where I went “I don’t think this is for me”.

New weirdness. In the bottom left panel of the scene explorer it does show my animations and I can play them in the Scene Composer. But the code still throws a null pointer.

You do it in a copy of the original because you will need to clear your action from the buffer afterwards or the blender importer will duplicate the animation. The blender importer does not bake actions.

I recommend using the ogre script that comes with the 3.2 sdk. You have to create an NLA strip to use it but that is fully explained in step 8 onward here.

https://wiki.jmonkeyengine.org/jme3/advanced/mixamo.html#appending-blender-animations

Your anim control is not under the root node.

https://wiki.jmonkeyengine.org/jme3/advanced/traverse_scenegraph.html

Huh. So since my AnimControl isn’t under the root node do I just need to alter how I reference it to make it work or is that a fools errand?

Just seems odd that through the Scene Explorer it can play the animation fine but trying to call it with code keeps killing itself.

Blender importer will bury the anim control using the node layout of blender.

Each import/export method is different. Some exporters are easier to use than others.

Ogre will place the anim control under the models root node, others don’t.

Some exporters apply modifiers for you, some don’t.

Some bake actions for you, some don’t.

Some use NLA strips, some don’t.

Using getChild would require ether setting up all your animations to use same node names or knowing in advance the childs name.

Much easier to just traverse and grab the control.

Gotcha. I’ll give that a shot and let you know. Thanks a bunch!

You can also use adapters.
https://javadoc.jmonkeyengine.org/index.html?com/jme3/scene/SceneGraphVisitorAdapter.html

Heh. That 127.0.0.1 address won’t work from over here :yum:

I’ll try out your other suggestions tonight.

Sorry bout that, fixed it.

1 Like

I haven’t read the whole post but the BlenderImporter hasn’t been updated for a while and animations were a problem as of 3.1 already. Even worse: As much as Blender progresses, the importer will break more and more, so I can recommend using xbuf for that

1 Like

most of us are using gltf it’s works great with animations just export from blender to gltf and use it in jme.
soon blender 2.8 will be released and we won’t be able to use blender importer at all.

1 Like

Just to save you some search work…

1 Like

Yep, as things stand gltf is the only solution with any chance of working in the future to get models from blender.

1 Like

Thanks guys! I’ll be giving this a shot a bit later today. If I manage to get this working from beginning to end would it be of any use to write a how-to for this? Like… not cover how to do the modelling since that’s not jME’s job naturally but at least how to get this portion working right.

In theory there should be plenty of posts for that workflow.
For both xbuf and gltf: Use the Exporter in Blender (for xbuf you need the render set to Xbuf (instead Cycles/Normal)) and (for xbuf: Set the Asset Path in Renderer Options, it’s where textures get placed) and then just right click the xbuf/gltf file and select “create j3o” in the SDK and you are done

Huh. Right clicking and saying convert to j3o throws me a wobbly:

An Exception has occured when trying to load asset Cubie
com.jme3.asset.AssetLoadException: An error occurred loading Models/Cubie/Cubie.gltf
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:150)
	at com.jme3.scene.plugins.gltf.GltfLoader.load(GltfLoader.java:78)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:259)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:373)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:416)
	at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:94)
	at com.jme3.gde.core.assets.actions.ConvertModel$1.run(ConvertModel.java:65)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.jme3.asset.AssetNotFoundException: Models/Cubie/Cubie.bin
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:370)
	at com.jme3.scene.plugins.gltf.GltfLoader.getBytes(GltfLoader.java:535)
	at com.jme3.scene.plugins.gltf.GltfLoader.readData(GltfLoader.java:513)
	at com.jme3.scene.plugins.gltf.GltfLoader.readBuffer(GltfLoader.java:484)
	at com.jme3.scene.plugins.gltf.GltfLoader$Matrix4fArrayPopulator.populate(GltfLoader.java:1436)
	at com.jme3.scene.plugins.gltf.GltfLoader$Matrix4fArrayPopulator.populate(GltfLoader.java:1423)
	at com.jme3.scene.plugins.gltf.GltfLoader.readAccessorData(GltfLoader.java:465)
	at com.jme3.scene.plugins.gltf.GltfLoader.readSkins(GltfLoader.java:952)
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:122)
	... 7 more