Link

Exporting a 3D Model

Overview

To render a 3D object on a screen, the Untold Engine requires the attributes of the 3D model.

The Untold Engine provides a Digital Asset Exporter (DAE) plug-in that retrieves the attributes of a character modeled in Blender 3D. The Digital Asset Exporter extracts the following information from a 3D object:

  • Vertices
  • Normal vectors
  • UV coordinates
  • Texture image
  • Armature
  • Animation

The information extracted by the DAE must be stored in a file with the following file extension “.u4d”. The Untold Engine uses the data stored in the .u4d file to recreate the 3D model on your game.

Using the DAE

If you want to model your 3D character and have experience using modeling tools such as Blender 3D, then you will have no problem using the DAE. The DAE is merely a Blender plugin that retrieves your character’s attributes information.

If you haven’t done so, download Blender 3D. And download the following 3D model provided in the Untold Engine Marketplace.

Open the blend file

Once you have downloaded Blender 3D, open it up and open the astronaut.blend file you downloaded from the marketplace.

The astronaut.blend file should contain the Astronaut model and the floating island.

image

Open the DAE script

Once opened, click on the navigation bar and select “Scripting” as shown:

image

The Blender Scripting View will show up. Click on Open and browse to the DAE Python source code that you downloaded.

image

Once opened, then click on Run Script.

image

Next, click on the “Default” as shown below:

image

Export the Attributes

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.”

image

Click on Export. The following window should show up. Under Export Mesh, the Export Type drop-down menu provides the following options:

image

  • Light Data Only: Exports light information
  • Animation Data Only: Exports animation data such as keyframes
  • Mesh and Animation Data: Exports both Mesh and Animation data
  • Mesh Data Only: Exports only attributes such as vertices, Normals, UVs

For now, let’s export only the Mesh Data of the 3D models.

Click on Mesh Data Only.

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

image

Most likely your model will contain textures. So make sure to copy the textures into the Resources folder as well. In this instance, the exported models use the following textures:

  • astronaut.png
  • greyrocks.png

image

Rendering the Models

Drag the files (.u4d and png) 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 files:

image

At this point, the models are ready to be used.

Getting the Names of the Models

To render a character, the engine needs to know the name of the “.u4d” file and the name of the model you want to render. The name of the models can be found in the Properties view of Blender.

If your model contains an armature, the name will be nested inside the “Armature” name. For example, the Astronaut contains an armature. Its name is nested inside the “Armature” name, as shown below:

image

In this case, the name of the Astronaut is simply “astronaut”.

If your model does not contain an armature, then the name is simply listed. For example, the name of the floating island is “island”.

Once you have the names, then you can render the characters. For example, to render the Astronaut, you would provide its name and the “.u4d” file as shown in line 2.

//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. Load rendering information into the GPU
    myAstronaut->loadRenderingInformation();

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

}