Exporting a 3D Animation

If you have not read how to Export a 3D Model with the DAE, please do so before continuing. Make sure to read the following sections:

  • Using the DAE
  • Open the DAE Script

The process to export a 3D Animation is very similar to how you export a 3D model. The only difference is the Export Option selected in the DAE.

To begin, download the following 3D Animation provided in the Untold Engine Marketplace. In it, you will find a Blender file called astronautWalkAnim.blend. Download the animation and open the DAE script as specified in the article Export a 3D Model with the DAE.

Export the Animation

If the left-side gutter is not visible, click on the key “T” on your keyboard. You should see a tab with the name “Untold Engine.”

Make sure the 3D Model, not the Armature, is selected. Else the tab with the name “Untold Engine” will not be visible.

image

Click on Export. The following window should show up.

image

For the Export Type options, select Animation Data Only.

Give a name to the animation file such as “myFirstAnimation.u4d” and store the file inside the Resources folder in the Untold Engine, as shown below:

image

Using the Animation

Drag the file (.u4d) from the Resource folder into the Resource folder of the Xcode project navigation.

image

When prompted, make sure that the files are copied to the iOS and Mac targets.

image

Finally, make sure that the Xcode’s project navigation contains the file:

image

Getting the Animation Name

To run an animation, the engine needs to know the name of the “.u4d” file and the name of the animation you want to run.

The name of the animation can be found in the Properties view of Blender. The name will be nested under the Armature & Animation tree as shown below:

In this case, the name of the animation is “walking”.

image

Once you have the names of the file and animation, you can animate the animation.

For example, to animate the character, you would provide the name of the file and animation in line 4, as shown below:

void Earth::init(){

    /*----DO NOT REMOVE. THIS IS REQUIRED-----*/
    //Configures the perspective view, shadows, lights and camera.
    setupConfiguration();

    //Renders the background models: skybox and island models. Remove if you want to.
    setupBackgroundModels();

    ////////////CREATE ASTRONAUT HERE/////////////

    //Line 1. Create an instance of U4DGameObject type
    myAstronaut=new U4DGameObject();

    //Line 2. Load attribute (rendering information) into the game entity
    if (myAstronaut->loadModel("astronaut","myFirstModelAttributes.u4d")) {

        //Line 3. Create an Animation object and link it to the 3D model
        walkAnimation=new U4DAnimation(myAstronaut);

        //Line 4. Load animation data into the animation object
        if(myAstronaut->loadAnimationToModel(walkAnimation, "walking", "myFirstAnimation.u4d")){

            //If animation data was successfully loaded, you can set other parameters here. For now, we won't do this.

        }

        //Line 5. Load rendering information into the GPU
        myAstronaut->loadRenderingInformation();

        //Line 6. Add astronaut to the scenegraph
        addChild(myAstronaut);

    }

    //Line 7. Check if the animation object exist and play the animation
    if (walkAnimation!=nullptr) {

        walkAnimation->play();

    }

}