Changes to animations loading in blender importer (IMPORTANT for importer users)

@sgold

OK I will add proper checks to such situation.
I think I will commit the fix as well. If you say you did not have problems with hanging maybe I did something wrong.
If there are problems - they will be reported quite fast I belive :wink:

1 Like

Thanks for the reply.

Perhaps you believed that the test application was hanging because it did not open a viewport. But thatā€™s normal behavior for a headless app.

@sgold said: Perhaps you believed that the test application was hanging because it did not open a viewport. But that's normal behavior for a headless app.

Yes that was it :slight_smile:
@nehon no need to check anything now.
Sorry, my mistake.

But I added non-existing animation to the blender key as you suggested and I did not have an exception.
Instead I got a warning logged by AnimationHelper:

Mar 04, 2014 3:09:08 PM com.jme3.scene.plugins.blender.animations.AnimationHelper applyAnimations
WARNING: Cannot find animation named: aaa.

Could you update to the latest version and try again ? Or maybe post your code again and Iā€™'ll try it out.

2 Likes

Sorry I didnā€™t have time to look into that, Iā€™m glad you fixed it.

@Kaelthas said: But I added non-existing animation to the blender key as you suggested and I did not have an exception. Instead I got a warning logged by AnimationHelper:

Mar 04, 2014 3:09:08 PM com.jme3.scene.plugins.blender.animations.AnimationHelper applyAnimations
WARNING: Cannot find animation named: aaa.

Could you update to the latest version and try again ? Or maybe post your code again and Iā€™'ll try it out.

Thank you, @Kaelthas, for looking into this.

I updated to rev 11068, and now I see the warning you described. So thatā€™s taken care of.

However, I notice that if the nodeName passed to addSkeletonAnimation() is invalid, the bone animation seems to get silently ignored. Perhaps a diagnostic message is needed for that case.

@sgold
Animations are applied after the object is loaded. If you add animation of an object that does not exist it will never be taken care of - so no warning will appear.

I could of course add some checks at the end of the loading process, but I think it is unnecessary. Not seeing an animation in your node is a good warning by itself :wink:

After updating to the latest nightly build (140319) I am getting this stacktrace when trying to load a blender model that worked before.

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.animation.SkeletonControl.cloneForSpatial(SkeletonControl.java:375)
at com.jme3.scene.Spatial.clone(Spatial.java:1185)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1172)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1172)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1214)
at com.jme3.scene.Spatial.clone(Spatial.java:66)
at com.jme3.asset.CloneableAssetProcessor.createClone(CloneableAssetProcessor.java:48)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:327)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:378)
at spaceworld.UFOSpaceWorld.simpleInitApp(UFOSpaceWorld.java:228)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Unknown Source)[/java]

What I tried to run was

[java] BlenderKey blenderKey = new BlenderKey(
ā€œobjects/creatures/alien/alien.mesh.xmlā€);
Spatial alien = (Spatial) assetManager
.loadModel(ā€œobjects/creatures/alien/alienmodel.blendā€);[/java]

Do you think anything can be done about it?

What are you doing with blenderKey, if anything? I thought the idea was to pass the BlenderKey to loadModel() in place of a path string.

1 Like
@sgold said: What are you doing with blenderKey, if anything? I thought the idea was to pass the BlenderKey to loadModel() in place of a path string.

I used to blenderKey to load the model but then the texture did not appear, so I loaded it with the .blend file instead. But even if I comment out the blenderkey the stracktrace will be the same. I think that Iā€™m using a model with no animation. Iā€™m not very skilled with blender and I wonder if itā€™s possible to load the model somehow, since I could load other models with the updated jme3.

I could run code to load another model:

[java] Spatial spaceStationSpatial = assetManager
.loadModel(ā€œSpaceStation.blendā€);[/java]

So maybe I could try and convert the models with the jme IDE? Iā€™m currently using Eclipse.

I do remember something about models with a skeleton will need at least one animation. I thought maybe it was fixed but I superstitiously add animations to anything with a skeleton now so I wouldnā€™t know for sure personally.

1 Like

I believe the NPE youā€™re seeing means thereā€™s a skeleton (what Blender calls an ā€œarmatureā€) in your alien model. Get rid of the armature and it should import just like your other models. To find the armature, I recommend using the Outliner editor in Blender.

Or if your alien is intended to have an armature, then provide it with some animations (what Blender calls ā€œactionsā€) and import like so:
[java]
BlenderKey key = new BlenderKey(ā€œobjects/creatures/alien/alienmodel.blendā€);
key.addSkeletonAnimation(ā€œalienā€, ā€œcollapseā€);
Spatial model = assetManager.loadModel(key);
[/java]

You could of course write an app in Eclipse to do the import for you, but it would invoke the same importer code and youā€™d get the same NPE.

1 Like

I donā€™t know how to do an animation and after I removed the armature in Blender then I still get NPE. When I try and open the model in the jme IDE then it prints warnings and crashes. Is there no simple way? This is what happened:

[java] BlenderKey blenderKey = new BlenderKey(
ā€œobjects/creatures/alien/alienmodel.blendā€);
Spatial alien = (Spatial) assetManager
.loadModel(blenderKey);[/java]

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.animation.SkeletonControl.cloneForSpatial(SkeletonControl.java:375)
at com.jme3.scene.Spatial.clone(Spatial.java:1185)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1172)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1172)
at com.jme3.scene.Node.clone(Node.java:565)
at com.jme3.scene.Node.clone(Node.java:60)
at com.jme3.scene.Spatial.clone(Spatial.java:1214)
at com.jme3.scene.Spatial.clone(Spatial.java:66)
at com.jme3.asset.CloneableAssetProcessor.createClone(CloneableAssetProcessor.java:48)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:327)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)[/java]

Did I forget something in blender when I removed the armature?

The stack track suggests that JME is trying to load a model asset with a skeleton/armature. Maybe itā€™s loading some other model than the one you removed the armature from.

At some point, weā€™ll need to see the .blend file in order to understand whatā€™s happening.

1 Like

Thanks for the replies. The alienmodel.blend if you could have a look at it.

Not sure where I should put this, so putting it here:

Tools/OgreXml/install Ogre Blender xml in the sdk asks the user to point to the blender scripts directory. Only worked for me when I moved the created python file to the addons directory. So I guess the window should ask to be pointed towards the scripts/addons directory instead.

@loopies:

Please create a new thread at

http://hub.jmonkeyengine.org/forum/board/troubleshooting/jmonkeyplatform/

regarding your SDK issue.

1 Like
@niklasro said: Thanks for the replies. The alienmodel.blend if you could have a look at it.

The alien.blend file you pointed me to includes an armature named ā€˜rigā€™. Loading the model with a ā€˜trunkā€™ build of JME3 (checked out from Google Code Archive - Long-term storage for Google Code Project Hosting.) gave an NPE in SkeletonControl.java:375.

After I deleted the armature in Blender, I was able to load the model and view it with no difficulty.

I thought you said you had removed the armature?

Ok, now it works. I first deleted the armature node but I didnā€™t realize that I also had to delete another node in Blender. Now the model appears in the scene! Thanks a lot for all the help. 8)

1 Like