Manish Paul
Manish Paul

Reputation: 183

Sceneform 1.15 Unable to play fbx animations in ARCore- Android

I'm new to Sceneform (1.15.0) and related 3D file formats like fbx and glTF. I saw the sample animation project (Andy Dance) on how to run animations and the sceneform documentation.

What am I trying?

Run animations that are present in the sceneform fbx assets. I have 2 assets- a ka27 helicopter and a 3d model

Both these fbx assets have some animation. When I try to import these assets into Android Studio, it currently throws an error which I've overcome by adding the sceneform asset into my sampledata directory and adding the information in the app/gradle file. The .sfa and .sfb files are generated correctly.

sceneform.asset('sampledata/models/ka27.FBX',
        'default',
        'sampledata/models/ka27.sfa',
        'src/main/res/raw/ka27')

The generated .sfb file

But now if I try running the animation, I can see the helicopter in the scene, but without animation-

arFragment.getArSceneView().getScene().addChild(helicopterNode);
AnimationData animationData = helicopterRenderable.getAnimationData("ka27");
ModelAnimator helicopterAnimator = new ModelAnimator(animationData, helicopterRenderable);
helicopterAnimator.start();

My Questions-

  1. Are these assets correct and compatible with sceneform animations?
  2. In getAnimationData, what is the parameter that needs to be passed? Can i find this information by opening this asset? (I tried importing these assets, including sceneform's sample andy_dance into Blender and Unity and while I can see the animation playing, I really can't see animation data name property anywhere.)
  3. Do .fbx to .glTF converted assets retain their animation?
  4. Can sceneform run .glTF animations?
  5. Do animations have to be exported separately for sceneform? If yes, then how?

Sample illustration of the app in which the .fbx animation does not work-

enter image description here

Upvotes: 0

Views: 1537

Answers (1)

espilon
espilon

Reputation: 29

If you open your .sfa, you will find a key animations if your .fbx file contains any animation. It should look like this:

{
  animations: [
    {
      clips: [
        {
          name: 'Animation 001',
          runtime_name: 'animation_1',
        },
      ],
      path: 'sampledata/models/ka27.fbx',
    },
  ],
  ...
}

getAnimationData expects the value of runtime_name so you need to modifiy the following line:

AnimationData animationData = helicopterRenderable.getAnimationData("ka27");

With my .sfa file this line becomes:

AnimationData animationData = helicopterRenderable.getAnimationData("animation_1");

You can notice that getAnimationData can also take as parameter the index of the animation in the array animations of the .sfa file. So you can write:

AnimationData animationData = helicopterRenderable.getAnimationData(0);

The documentation of the ModelRenderable is available here.

Upvotes: 1

Related Questions