D
D
dendead2021-05-04 09:13:49
Android
dendead, 2021-05-04 09:13:49

How to properly play animation in sceneform (ArCore)?

I am creating an AR application using https://github.com/ThomasGorisse/sceneform-android-sdk and using this code I add a model to the scene:

ModelRenderable.builder()
        .setSource(this, R.raw.olaf)
        .setIsFilamentGltf(true)
        .build()
        .thenAccept(modelRenderable ->
        {
        mainAnchorNode = new AnchorNode(startAnchor);
        arFragment.getArSceneView().getScene().addChild(mainAnchorNode);

        TransformableNode transformableNode = new TransformableNode(arFragment.getTransformationSystem());
        transformableNode.setLocalRotation(Quaternion.axisAngle(new Vector3(0, 1f, 0), 180f));

        transformableNode.setParent(mainAnchorNode);
        transformableNode.setRenderable(modelRenderable);
}


There are 5 animations in the blender model:

yzw4t.png

I'm trying to reproduce the animation like this (where animationType is the name of the animation from blender: "olaf_walk", "olaf_hello"):

private ObjectAnimator animator;

animator = ModelAnimator.ofAnimation(transformableNode.getRenderableInstance(), animationType);
animator.start();


But when I switch the animation (using the button) to the next one in turn, the previous one continues to play, and the new one does not start.
I've tried canceling (animator.cancel()), stopping (animator.stop()) and creating a new animator for each animation, to no avail.

How to switch between different animations of the same model in sceneform correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question