[SOLVED] Jaime.j3o getControl(AnimComposer.class) is null

I switched AnimControl to AnimComposer not available.

I used the model in testdata 'Models/Jaime/Jaime.j3o"

why is this?

Thanks a lot.

    public void getJaimeAnim() {
        Spatial spatial = assetManager.loadModel("Models/Jaime/Jaime.j3o");
        List<AnimComposer> animComposers = new ArrayList<>();
        loadAnimComposer(spatial, animComposers);
        System.out.println(animComposers);
        // return []
    }
    

    // Traverse all nodes to obtain AnimComposer
    public void loadAnimComposer(Spatial spatial, List<AnimComposer> animComposers) {
        if (spatial instanceof Node) {
            Node node = (Node) spatial;
            AnimComposer anim = node.getControl(AnimComposer.class);
            if (anim != null) {
                animComposers.add(anim);
            }
            for (Spatial spatialChild : node.getChildren()) {
                loadAnimComposer(spatialChild, animComposers);
            }
        }
    }

Just look at example code in JME Tests. You are using old test model with old control.

There you have:

AnimMigrationUtils.migrate(jaime);

Basically as i know test models have AnimControl to maintain backward versions compatibility.

New JME versons are using AnimComposer

You can see example code yourself:

Normally you dont need to use this line of code, but when model is in .j3o format with older animation control, then you need reconvert it or use this line of code.

1 Like

Thanks for your help, it’s OK now. :smiley:

3 Likes