Getting null AnimComposer

Hi All,
Coming to JME after a long vacation about more than 3-4 years. I hope all of you are well in the era of the corona.
I see that the AnimControl class is marked as deprecated and replaced it with AnimComposor.

I was trying to use one but couldn’t find the way how to use it.

Whenever I try to get AnimComposor from model loaded from bland it returns null. but it correctly returns AnimControl.

Should I use AnimControl even though it is deprecated? or I missed something to use AnimComposer?

here is the code snippet.

       Node deer = (Node)scene.getChild("deer");
        Node head = (Node)deer.getChild("Head");
        AnimComposer composer = head.getControl(AnimComposer.class); // Returns null
        AnimControl control = head.getControl(AnimControl.class); // Returns Animation Controll

I used free assets downloaded from somewhere in the internet to test my hand in JME after a long time.
Screenshot

System information
Product Version: jMonkeyEngine SDK 3.3.0-v3.3.0-beta1-sdk1-SNAPSHOT
Updates: jMonkeyEngine SDK is updated to version NetBeans 8.2 Patch 2
Java: 11.0.7; Java HotSpot™ 64-Bit Server VM 11.0.7+8-LTS
Runtime: Java™ SE Runtime Environment 11.0.7+8-LTS
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (jmonkeyplatform)

Hi, welcome back :slightly_smiling_face:

A null result is because the Blender loader does not support the new animation system.

You can use this method to migrate your model from old animation system to new one:

Note, If you convert your model into Gltf (which is recommended format) and then load it with JME it will automatically load your model with the new animation system.

2 Likes

GLTF support nlaStrips in the blender as animation-name in Jme just like using Xbuf?
I add a new animation to a skeleton but when I exported to Xbuf rotation of some bones will be crashed and other transforms were not working at all.
I applied transforms of mesh in object mode, and skeleton at positioning mode.
how can I solve it?

Yes, NLA actions are supported, but you should use Blender 2.8 (I recommend Blender 2.82+) which has better Gltf support now.

1 Like

what is the best way to import blend file made in 2.79 into blender 2.82?
I think I can export mesh as a obj file and then append skeleton from blend file to it…

what about the second part of my question? how to solve wrong transform in playing animation?

I think it should work file to load directly from the blend file. You might need to re-add the materials though.

Do not know, I have not used Xbuf since long ago. It is not maintained anymore.

1 Like

Were you able to use your animated model?

Thanks @Ali_RS, AnimMigrationUtils is migrating controller to the composer and works fine. but it’s taking too much time to load/initialize the application.

So, I tried to export the converted spatial to a new j3o file using the below script.

    deer = (Node) AnimMigrationUtils.migrate(deer);
    BinaryExporter exporter = new BinaryExporter();
    exporter.getCapsule(deer);
    try {
        exporter.save(deer, new File("C:\\Personal\\JME\\Projects\\BasicGame\\assets\\Models\\deer\\new_deer.j3o"));
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

Now the exported j3o looks like the below screen. it seems all noses are dislocated somehow.

And, yes I tried exporting the model to GLTF, there are 2-3 ways to do it in blender I tries all of them. but when I try to import it in JME the model looks black, it may be I am using latest blender version!!

This should fix it

1 - Does it display correctly if you open exported Gltf model in these Gltf viewers:

2- Make sure the model material is setup as explained here

https://docs.blender.org/manual/en/2.83/addons/import_export/scene_gltf2.html

and

https://wiki.jmonkeyengine.org/docs/jme3/external/blender/blender_gltf.html

3- You might need to add a light probe to the scene. (though this is not necessary)

If you do not know how to add it, then follow this topic: