1
votes

I have created a Blender model that uses an armature with bone constraints to animate the model. After exporting the model as a .fbx file and passing it through fbx-conv, my animation is split up into several animations.

Each animation ends up with an ID similar to "MyObject|MyAnimation".

In other words, I need to run all of these sub-animations at once to run my full animation.

I tried several AnimationController methods. First I tried calling AnimationController.setAnimation() for each of the animations, which doesn't work because it cancels the current animation each time it is called.

The AnimationController.animate() method sounds like it is supposed to do what I want, but I just get the same result as with .setAnimation().

Here is the code I tried:

instance = new ModelInstance( myModel );
controller = new AnimationController( instance );

for( Animation animation : instance.animations ) {
    controller.animate( animation.id, 0 );
}

Is this not how .animate() is intended to work?

Also, I am not entirely certain of how to correctly use the second argument, transitionTime. Could that be the problem?

1
"If you want to apply multiple animations to the same ModelInstance, you can use multiple AnimationControllers, as long as they don't interfere with each other (don't affect the same nodes)." github.com/libgdx/libgdx/wiki/3D-animations-and-skinningXoppa
Thanks, that works. I'm not sure how I missed reading that in the wiki.twiz

1 Answers

1
votes

As Xoppa pointed out, the LibGDX docs on 3D Animations and Skinning says the following:

"If you want to apply multiple animations to the same ModelInstance, you can use multiple AnimationControllers, as long as they don't interfere with each other (don't affect the same nodes)."


Example:

ModelInstance myInstance = new ModelInstance( myModel );

AnimationController controllerOne = new AnimationController( myInstance );
AnimationController controllerTwo = new AnimationController( myInstance );

controllerOne.setAnimation( "FirstAnimationId", -1 );
controllerTwo.setAnimation( "SecondAnimationId", -1 );

Then in your render loop, you will also need to call .update(delta) on all of your AnimationControllers:

controllerOne.update( Gdx.graphics.getDeltaTime() );
controllerTwo.update( Gdx.graphics.getDeltaTime() );