Model amin controll return null

Hello i have model with animation



the screenshot shows that the model has anim composer
in object 1

my code:

        Node player= (Node)assetManager.loadModel("Models/char.j3o");
        Node object = (Node)player.getChild(0);

        System.out.println(object);

        AnimControl baseAnimControl = object.getControl(AnimControl.class);
        System.out.println(baseAnimControl);

return
1 (Node)
null

how to get AnimControl form model?

1 Like

When this happens it’s usually because the control is attached to some spatial other than object. Either analyze the model in advance or else search the scene-graph subtree at runtime.

1 Like

try search objects

        Node player= (Node)assetManager.loadModel("Models/char.j3o");
        ArrayList<Spatial> nodes = new ArrayList(player.getChildren());
 
        for(Spatial item:nodes){ 
            
             Node rootScene= (Node) item; 
             
             ArrayList<Spatial> nodesChild = new ArrayList(rootScene.getChildren());
              for(Spatial itemChild:nodesChild){
                  System.out.println(itemChild.getName());
              }

         }

returns
Cube.001

  Node player= (Node)assetManager.loadModel("Models/char.j3o");
        Geometry node = (Geometry)player.getChild("Cube.001");
        AnimControl baseAnimControl = node.getControl(AnimControl.class);
        System.out.println(baseAnimControl);

null

Why do you add so much extra unnecessary code?

    Node player= (Node)assetManager.loadModel("Models/char.j3o"); 
    for(Spatial item:player.getChildren()){             
         Node rootScene= (Node)item;              
         for(Spatial itemChild:rootScene.getChildren()){
              System.out.println(itemChild.getName());
         }
    }

Yes, and it’s very clearly on the root object and not one of the children:

…completely unnecessary.

AnimComposer anim = player.getControl(AnimComposer.class);

…would work in your object.

Edit: and actually, that may be wrong based on the printlns but I’m not convinced that you have presented the output that goes with the posted code.

1 Like

        Node player= (Node)assetManager.loadModel("Models/char.j3o");
        AnimControl baseAnimControl = player.getControl(AnimControl.class);
        System.out.println(baseAnimControl);

null

AnimComposer not AnimControl!

1 Like

thank you already understood

Yeah, I completely missed that.

1 Like

anim composer i getting
now how to get skeleton?

SkeletonControl skeleton;
        Node player= (Node)assetManager.loadModel("Models/test.glb");
        Node armature = (Node)player.getChild("Armature");
        Geometry cube = (Geometry)player.getChild("Cube");

        for(Spatial item:player.getChildren()){             
             Node rootScene= (Node)item;              
             for(Spatial itemChild:rootScene.getChildren()){
                  System.out.println("childs:" + itemChild.getName());
             }
        }
        
        
        AnimComposer anim = armature.getControl(AnimComposer.class); 
        System.out.println("anim composer " + anim);//true
        
        skeleton = player.getControl(SkeletonControl.class);
        System.out.println("skeleton of player " + skeleton);

        skeleton = armature.getControl(SkeletonControl.class);
        System.out.println("skeleton of armature " + skeleton);
        
        skeleton = cube.getControl(SkeletonControl.class);
        System.out.println("skeleton of cube " + skeleton);

childs:Cube
anim composer com.jme3.anim.AnimComposer@76bfd9f6
skeleton of player null
skeleton of armature null
skeleton of cube null

It should be SkinningControl I guess.

AnimControl and SkeletonControl are from the old animation system.

I have done some tests myself and found that the FBXImported still make use of the AnimControl and not the AnimComposer.
I just want to confirm that this is correct?

1 Like

confirm that this is correct?

Yes, that’s correct. Since it’s so easy to convert from old system to the new system, I don’t see this as a major issue.