Animation plays in SDK but not in Code?

Hello dear community,

for my game I exported an animated model from blender to my assets folder through ogre. In the SDK I can open the model and view the animations. The animations are played properly in the SDK.

Now, in code if I set an animation nothing happens. The model remains in its t-pose position. This never happened to me and this is not the first animated model I work with, so that’s really strange! I mean, if it works perfectly in the SDK, why shouldn’t it work in code as well?

I use the latest blender (2.79) and ogre (0.60) version. The model does not have a normal map.

Here a small test case. Nothing special as you can see.

@Override
public void simpleInitApp() {

    // demon model does not work
    Spatial demon = assetManager.loadModel("Models/Monster/Demon.j3o");
    AnimControl control = demon.getControl(AnimControl.class);
    AnimChannel channel = control.createChannel();
    channel.setAnim("Idle");

    // player works perfectly
    Spatial player = assetManager.loadModel(ModelType.Player);
    player.setLocalTranslation(2,0,0);
    AnimControl control1 = player.getControl(AnimControl.class);
    AnimChannel channel1 =control1.createChannel();
    channel1.setAnim("walk");


    rootNode.attachChild(demon);
    rootNode.attachChild(player);

    AmbientLight light = new AmbientLight();
    light.setColor(ColorRGBA.White);
    rootNode.addLight(light);

}

Hopefully, somebody can help me.

Best regards
Domenic

So, I finally figured it out. In my case I need to disable hardware skinning like this.

SkeletonControl skeletonControl = spatial.getControl(SkeletonControl.class);
skeletonControl.setHardwareSkinningPreferred(false);

Then the animations work. But I was told that disables HwSkinning has a negative effect regarding performance. So why does this model not work like any other? Are there some special settings in Blender I need to consider? (By the way, the model is not created by me).

3 Likes

Hmmm I just checked and my game has multiple models that uses hardware skinning and works fine. I’m not sure if this is of any help, but while I was working on that model it gave me this notification and I thought it could possibly be relevent to help you find the cause:

Material instances cannot be shared when hardware skinning is used. Ensure all models use unique material instances.

1 Like

Hey Dominic,upload your model so that we can have a look at it :slight_smile:

1 Like

Thanks for your answer. I had a look at the model again and it actually had several geometries using the same material. I have batched them into one geometry, but unfortunately I still need to disable hardware skinning to make it run the animation.

Alright, here is the model file (without texture):

https://drive.google.com/drive/folders/0B2chyb26ralKWTVUSUNGdmItR1E?usp=sharing

FYI, this issue is fixed in jME 3.2

So I imported your model in the SDK 3.1 and no animation plays in the SDK.
None plays in code either,using the code you provided.
But it plays normally when I disable the hardware skinning.

Hi, okay, I think I know why I get this behavior. I use one of the latest builds of the SDK, which is newer than the version I use in my main project. (I work in another IDE). So it seems I don’t have the fix @Momoko_Fan talked about. I will try to use a newer build then.

The shared instances were only a warning that jme will now clone the marerial to use hwskinning, I think?

However this new Animation Feature is unsupported in 3.1, so j3os arent backwards compatible

That cannot be right, the Jaime J3O is a jME 3.1 model, but it still works in jME 3.2

I took it the other way… a 3.2 j3o won’t run in a 3.1 SDK.