Skip to content

Play With Animation


Now that you've learnt how to load 3D model, we are going to learn how to play with animation in VR

Create Project

Create an SXR project by copying the template project

Perform the following steps to make sure your project runs correctly

  1. (if developing for Gear VR) Copy your Oculus signature file to app/src/main/assets folder.
  2. Change the applicationId in build.gradle to a unique name to avoid naming conflict when you test the app later
  3. Change the app_name in res/values/strings.xml to avoid confusion when you debug the app.


Before we start, we have to obtain a 3D model file with animation.

The SXR SDK supports following formats

  • FBX
  • Collada(.dae)

And here is one animated 3D model that we are going to use for this tutorial

How to play animations

Make sure to copy both files into app/src/main/assets folder

You can load the animated model with following code

    SXRModelNode character = sxrContext.getAssetLoader().loadModel("astro_boy.dae");
    character.getTransform().setRotationByAxis(45.0f, 0.0f, 1.0f, 0.0f);
    character.getTransform().setScale(6, 6, 6);
    character.getTransform().setPosition(0.0f, -0.5f, -1f);

And play the animation with SXRAnimator, here we make sure the animation in looping forever with the setRepeatCount set to -1

    SXRAnimator animator = (SXRAnimator)character.getComponent(SXRAnimator.getComponentType());

Work with 3D modeling tools

Fbx is the recommended format for the SXR SDK. Currently, all major 3D modeling tools support exporting to FBX format.

Source Code

Complete Source Code for this sample