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);
}
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).
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.
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):
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.