Skeletal animation


I have created an animated (walking) droid using blender. Animation is done using armature and for each bone there is a vertex group in droid mesh. Animation consists of poses (location and rotation keys).

The animation works fine in blender. I am trying to get the animation to work in JME2. I have exported the model and animation using OGRE MESHES exporter. The mesh and animation seems to deform when it is displayed in JME2. See attached pictures.

I have used as a reference how to load the model into JME2, but I am using only one animation channel. See attached code.

How can I get the animation (and model) displayed correctly in JME2?


public class TestDroidAnimation extends SimpleGame {

    private static final Logger logger = Logger.getLogger(

    private Node model;

    public static void main(String[] args){
       TestDroidAnimation app = new TestDroidAnimation();

    protected void loadMeshModel(){
        OgreLoader loader = new OgreLoader();
        MaterialLoader matLoader = new MaterialLoader();
        String matUrlString = "/jmetest/data/model/ogrexml/Scene.material";
        String ninjaMeshUrlString =

        try {
            URL matURL = ResourceLocatorTool.locateResource(
                    ResourceLocatorTool.TYPE_TEXTURE, matUrlString);
            URL meshURL = ResourceLocatorTool.locateResource(
                    ResourceLocatorTool.TYPE_MODEL, ninjaMeshUrlString);

            if (meshURL == null)
                throw new IllegalStateException(
                        "Required runtime resource missing: "
                        + ninjaMeshUrlString);
            if (matURL == null)
                throw new IllegalStateException(
                        "Required runtime resource missing: " + matUrlString);
            try {
                        new RelativeResourceLocator(matURL));
                  // This causes relative references in the .material file to
                  // resolve to the same dir as the material file.
                  // Don't have to set up a relative locator for TYPE_MODEL
                  // here, because OgreLoader.loadModel() takes care of that.
            } catch (URISyntaxException use) {
                // Since we're generating the URI from a URL we know to be
                // good, we won't get here.  This is just to satisfy the
                // compiler.
                throw new RuntimeException(use);
            if (matLoader.getMaterials().size() > 0)

            model = (Node) loader.loadModel(meshURL);
        } catch (IOException ex) {
            logger.log(Level.SEVERE, null, ex);
        } catch (ModelFormatException mfe) {
            logger.log(Level.SEVERE, null, mfe);

    protected void simpleInitGame() {


        if (model.getControllerCount() < 1)
            throw new IllegalStateException(
                    "Ninja's animations are missing");

        MeshAnimationController animControl =
                (MeshAnimationController) model.getController(0);
        AnimationChannel lower = animControl.getAnimationChannel();
        animControl.setAnimation(lower, "walk");
        cam.setLocation(new Vector3f(139.05014f, 206.22263f, 225.55989f));
        cam.lookAt(model.getWorldBound().getCenter(), Vector3f.UNIT_Y);

        rootNode.updateGeometricState(0, true);



Thanks! After ctrl-a the animation and mesh seems to be ok. :slight_smile:

btw, is there somewhere an explanation about this ctrl-a (apply rotation and scale)? I still don't fully understand what it actually does and when I need to use it.

Hmm,…did you apply scale and rotation to your mesh? (ctrl-a in blender)

Are the bones (especially the arms) connected? If you want to upload the

blend-file I can have a look.

Thanks for a good explanation. :slight_smile: