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

Hey everyone,

today I made a commit that fixed the animations issue in blender importer.
It turned out that loading the poses of the skeleton, plus several minor bugs in ipo curves loading, caused the wrong behaviour.
I removed pose loading for now so it should be working at the moment.
The problem with different poses and animation I described here:

http://hub.jmonkeyengine.org/forum/topic/blender-importer-and-multiple-bone-animations/
But it looks like nobody is interested in it or I am completely wrong about it :wink:

There is one very important change I made.
In blender key you will need to map explicitly what actions should be used in what models in either skeleton or spatial animations.
Similar functionality had been there before with the difference that it did not recognise skeleton from spatial animations.
I removed it because I thought that each node has its own actions array, marked by a pointer to the first one, that are assigned only to the model.
It turned out that I was wrong about it and blender does not store such link. In blender every defined action can be used by several different models and that
is why we need explicit mapping here.
I would be very much like to be wrong about it so if anyone knows something about the explicit link in blender btween action and the model - please let me know :slight_smile:

In blender key I added several methods. Two of them are most important for you:
[java]
/**
* Adds spatial animation name for specified node.
* @param nodeName
* the name of the node
* @param animationName
* the spatial animation name
*/
public void addNodeAnimation(String nodeName, String animationName);

/**
* Adds bone animation name for specified node.
* @param nodeName
* the name of the node
* @param animationName
* the bone animation name
*/
public void addSkeletonAnimation(String nodeName, String animationName);
[/java]

I know that it is not very much convenient to add such mapping usind the SDK so I have an idea.
We could use some prefix system in animations naming that would allow importer to apply animations automatically.

For example:
jmesa-{node-name}-{action-name}
and
jmeba-{node-name}-{action-name}

jmesa = JME Spatial Animation
jmeba = JME Bone Animation

In such case the importer would load animations named: {action-name} - without the prefixes and it would link them to the proper node automatically.

Tell me what do you think about this idea. And if you like it suggest the syntax for the prefixes so that they are short and easy recognizable :slight_smile:

6 Likes

Updating my engine to rev 10985 and importing my ā€œbob.blendā€ model results in an NPE (which did not occur at rev 10984).

Here is a traceback:

Jan 13, 2014 12:50:16 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[Headless Application 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 bats.AssetProcessor.processModel(AssetProcessor.java:234)
at bats.AssetProcessor.processUnitModels(AssetProcessor.java:324)
at bats.AssetProcessor.simpleInitApp(AssetProcessor.java:144)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.NullContext.initInThread(NullContext.java:84)
at com.jme3.system.NullContext.run(NullContext.java:127)
at java.lang.Thread.run(Thread.java:722)

@sgold
I guess it happens when you try to run your animation.
Remember to add your animation. For example:
[java]
blenderKey.addSkeletonAnimation(ā€œbobā€, ā€œtrail.Rā€);
[/java]

I did not get NPE and loaded the animations correctly.

Note that the back trace goes through AssetManager.loadModel(). I was still loading models. I hadnā€™t started any animations yet.

@sgold said: Note that the back trace goes through AssetManager.loadModel(). I was still loading models. I hadn't started any animations yet.
You have to add the animation to the BlenderKey before loading the model.

@Kaelthas sorry about that other post I didnā€™t see it, gonna read it and answer.
About the animation there have to be some kind of link, because the animation animates a skeleton or an object etcā€¦ Iā€™m not completely fond of the idea of the naming scheme to properly import animationsā€¦But if there is no other way i guess thatā€™s okā€¦

EDIT : I wonder how the ogre exporter does it. Because bone animation and pose animation are exported, but you have to turn them in NLA tracksā€¦

Btw, you should move your development to the gradle-restructure branch until that becomes trunk

@nehon
There is a link only between armature/object and a single action. But this can change depending on what action you worked with when you saved the blend file.
The rest of the actions are not linked so I do not know anything where to put them.
But I will take a look at NLA editor, maybe I will find something useful there.

@normen
OK, I will check this out and work on that one. Maybe that would be safer for current users, especially when I do a lot of changes in the code.

@Kaelthas said: OK, I will check this out and work on that one. Maybe that would be safer for current users, especially when I do a lot of changes in the code.
Two misunderstandings in this sentence ^^ 1) Trunk *is* for live changes and where the development happens, its okay when it breaks. Stable is the one that should be handled with care. 2) gradle-restructure basically is our trunk at the moment, it will be moved to trunk and replace it in a few days, thats why you *have to* commit your code there, else it will be lost.

ā€¦and for now, itā€™s good to commit to both ā€œtrunksā€ just in case something bad happens.

After the last update Iā€™m seeing the imported animations (from Blender) worse than before. :frowning:

Before I was able to import a walking animation without some joint animations, but the rest of it seemed fine. After the last update the import from Blender is just all messed up:

Animation from Blender:

Animation imported in jMonkey 3.0 (without updates, directly from the downloads section):


Notice the legs, for example.

Animation imported after the latest update including nightly:

Hey @gonzalofarias1
could you upload your model ?
I will check this out.

But on the other hand if you change a texture of the model in your last pic to Mr. Fantastic from ā€˜Fantastic 4ā€™ everything will look OK :mrgreen:

@Kaelthas said: Hey @gonzalofarias1 could you upload your model ? I will check this out.

But on the other hand if you change a texture of the model in your last pic to Mr. Fantastic from ā€˜Fantastic 4ā€™ everything will look OK :mrgreen:

LOL! Iā€™ll upload the model as soon as I get home.
Iā€™m using the latest Blender (2.69). Does it change a lot from previous versions?

Hereā€™s the model:

Model

@gonzalofarias1 said: Here's the model:

Model

No update on this either? :frowning:

Hey @gonzalofarias1

sorry for my late response.

I was able to run the animation in your model and there are problems indeed with it. Probably wrong ipo computation - I will try to find out what is wrong and why as soon as possiblem.

But the model you uploaded has several issues - which has delayed me a bit.
First is the material - the model is invisible. I will investigate it later. For now I just removed the troublesome materials.

The second problem is that you use single armature to several different meshes.
That is not supported by the importer for now.
The problem is that the skeleton in JME only exists in its node space and that defines the transformations of the skeletonā€™s bones.

I will try to add support for it by simply loading the same skeleton for different meshes and removing bones that does not modify the particular mesh in any way.

The other problem is with constraints applying and AnimControl of the node. The importer has issues with finding proper AnimControl in the node so I guess I will take a look at it first.

And once again - really sorry I takes me so long. My job had consumed a lot of my time recently :frowning:

@gonzalofarias1

OK, I think I solved the issue. The problem was with starting location, rotation and scale for bones when animationā€™s interpolation curves were computed.

Your model has one difference from those I use for testing - the bones only have rotation changed.
So when I used their local positions to properly fill the track with data, it became a total mess.

I will make a commit today after I get home and test the solution on other models. :slight_smile:

And btw. in your blender model I am unable to play animations in 3D view. Probably there is some setting that disables it - do you know which one ?

1 Like

@gonzalofarias1
check out to the lates version and let me know if it works now.

@Kaelthas said: @gonzalofarias1 check out to the lates version and let me know if it works now.

Thanks! You rock!

Iā€™ll take a look as soon as I can and let you know if it works well, but thaks a lot in advance. :slight_smile:

@gonzalofarias1 said: Thanks! You rock!

Iā€™ll take a look as soon as I can and let you know if it works well, but thaks a lot in advance. :slight_smile:

I donā€™t find any update on the nightly builds of the engine. Is it working?

Also I tried to build it from the sources but I get this error: No dependent module org.netbeans.modules.editor.codetemplates

And the only link I find to solve this:
http://hub.jmonkeyengine.org/forum/topic/jme3-with-netbeans-6-9-1-build-error/

Says:

Seems like you try to build not only jme3 but also jMP :) If you want to build jMP, theres a detailed guide: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:jmonkeyplatform#development Cheers, Normen

And that link is down. :-[

@gonzalofarias1
I commited the fix to both the trunk and gradle-restructure branch.
I do not know which one is currently used by nightly builds.
Maybe youā€™re right they are down at the moment untill the sources use gradle for building.

I am afraid I cannot help you with that because I do not use JMP :wink: I only use the engine sources in eclipse - so I do not even use netbeans for development.

Meybe try asking developers about it.

But anyway let me know if the nighly builds are back and if the fix worked for you :slight_smile: