Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation tutorial refers to the deprecated code that no longer works #1833

Closed
stevenbright opened this issue Jul 3, 2022 · 5 comments
Closed

Comments

@stevenbright
Copy link

stevenbright commented Jul 3, 2022

I'm using latest stable release of jmonkeyengine, specifically 3.5.2-stable. While reading latest documentation - https://wiki.jmonkeyengine.org/docs/3.4/tutorials/beginner/hello_animation.html I tried to run relevant sample code, but it turns out:

  1. All animation-related entities referred on that documentation page are deprecated.
  2. Moreover, relevant code no longer works. In particular related sample code referred on that page fails with NullPointerException after attempting to obtain AnimControl instance via control = player.getControl(AnimControl.class);.

Minimalistic example:

    @Override
    public void simpleInitApp() {
        viewPort.setBackgroundColor(ColorRGBA.LightGray);
        initKeys();
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
        rootNode.addLight(dl);
        player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
        player.setLocalScale(0.5f);
        rootNode.attachChild(player);
        control = player.getControl(AnimControl.class);
        control.addListener(new TestAnimation());
        channel = control.createChannel();
        channel.setAnim("stand");
    }

Also I believe I referred all required libraries: jme3-core, jme3-desktop, jme3-lwjgl, jme3-testdata, jme3-plugins

All libraries imported from maven central, all of 3.5.2-stable version.

I'd like to suggest to (1) update documentation, (2) change engine code so that deprecated entities are handled in a distinct manner, e.g. by throwing UnsupportedOperationException or the like in the relevant places.

@stephengold
Copy link
Member

stephengold commented Jul 3, 2022

Thanks for getting in touch.

We're aware that the Wiki is out-of-date and the code listed in the animation tutorial doesn't work with recent versions of JMonkeyEngine.

The deprecated classes and methods still work in general. However, the structure of the 3-D model used in HelloAnimation changed as of JME version 3.3. That's what causes the NullPointerException you encountered.

There's an updated version of HelloAnimation.java available from GitHub, which should work for you: https://github.com/jMonkeyEngine/jmonkeyengine/blob/v3.5/jme3-examples/src/main/java/jme3test/helloworld/HelloAnimation.java

For JMonkeyEngine support, the place to go is our Discord forum: https://hub.jmonkeyengine.org/

@stephengold
Copy link
Member

Note this issue is effectively a duplicate of #1402 and jMonkeyEngine/wiki#96

@stevenbright
Copy link
Author

Thanks, will look that up.

I still think that it'd be an improvement if deprecated code is treated as such: as long as old entities are in place AND behavior gets changed and this is exactly what's happening, e.g. if old approach is not meant to be working anymore but old entities are still kept intact - I guess to ease the migration without compilation errors, I'd still suggest changing the behavior of getControl method to start temporarily throwing UnsupportedOperationException upon seeing AnimControl.class as long as deprecated animation entities are not removed.

@pspeed42
Copy link
Contributor

pspeed42 commented Jul 3, 2022

There can be a hundred different unexpected reasons that getControl() might return null.

Perhaps the real issue is that the tutorial is not defensive about the fact that getControl() may return null... and in cases where it has nothing to do with AnimControl versus AnimComposer.

@stevenbright
Copy link
Author

Makes sense, thank you for responding so quickly. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants