Skip to content

Animation

Animated models contain clips that describe changes over time, such as a character standing or walking. jMonkeyEngine's AnimComposer control plays and combines actions. For a complete example, see Hello Animation.

Import an animated model

Export an animated glTF model, put it and any referenced resources under your project resource root, and include the glTF loader from jme3-plugins. Load it through the asset manager. The path below is illustrative: use an actual model and the names of its clips.

Spatial model = assetManager.loadModel("Models/Character/character.glb");
rootNode.attachChild(model);

Find and play clips

Find the AnimComposer on the spatial that owns it. The control can be on a child of the loaded scene; inspect the scene graph if getControl() returns null.

AnimComposer composer = model.getControl(AnimComposer.class);
if (composer != null) {
    for (String clipName : composer.getAnimClipsNames()) {
        System.out.println(clipName);
    }
    composer.setCurrentAction("Walk"); // replace with a clip in your model
}

A composer can play named actions on layers. Create additional layers and masks when you need to combine animation on different parts of a model. The default action loops; an overload of setCurrentAction lets you select a layer and whether to loop. Actions and tweens can also be composed into sequences, for example to run a callback after a walk. See Hello Animation for a full example.

Skinning and debugging

A skinned model uses a SkinningControl and an armature. Locate the control on the spatial that owns it; ArmatureDebugAppState can visualize its armature during development. For glTF export and model setup, see Blender and glTF.

Note

The older AnimControl and channel API belongs to the legacy animation system. Existing applications can consult the earlier reference, while new examples should use the current API and test the clips exported by their models.