Exporting a model for the new glTF Pipeline using Blender - Terasology/TutorialAssetSystem GitHub Wiki

This is a quick tutorial on how to export assets for the new glTF Pipeline.

Getting started

You'll need to download Blender if you don't have it already, preferably a newer version (2.8 or higher) as those have the glTF exporter installed by default.

Using Blender

After installing Blender, open the .blend file of the model you want to export, or otherwise, if the model is in another format such as FBX, OBJ, DAE, etc you should import it into Blender by clicking File -> Import -> Your model's format

After you have your model inside Blender, remember to keep in mind that it can only one texture, be one mesh, and if it's rigged only have one root bone. You can join everything into one mesh by selecting all of the different meshes (Shift + Right click on each one, or A to select all) and then use Control + J to join.

Exporting

Once we have everything set up, to export we just need to click on File -> Export -> glTF 2.0

And then after choosing the folder you want to export the model to, you need to change the format from .glb to .gltf on the bottom left menu

You might want to validate the exported file using https://gltf-viewer.donmccurdy.com - that should help in case there are later issues with the model inside Terasology. If the viewer has a problem with it probably something needs fixing in Blender.

Remember that glTF as well as .blend don't store texture files, so those need to be included separate. The glTF file should go into the skeletalMesh folder and the texture into the textures folder

Using glTF with prefabs

Changing the prefabs to work with glTF is quite simple. Differently from the md5 format, we don't need multiple files for the skeletal mesh and the animations. Instead, both are embedded within the new glTF format. Let us use the deer from WildAnimals as an example. We will export the original blender model to a new file named newDeer.gltf following the steps above, and place it under the assets/skeletalMesh folder:

In this case, newDeer.gltf contains not only the original skeletal mesh (deer.md5mesh) but also all the animations in the assets/animations folder. Each animation will probably have the same name as its respective md5anim file (you can check this easily by opening the glTF file with a text editor). Since all animations are now be embedded in the glTF file, the prefab now must use the format <glTF_file_name>#<animation_name> to reference each animation. Here's how the deer.prefab file looks with the new format (compared side-by-side with its original version):

Observe that the material property remains the same - the changes are on mesh (pointing to the new file) and on the animation references (lines 6, 21,...,26), pointing to anchors within newDeer. Everything else remains the same.

The heightoffset is a vertical offset of the mesh. with a collider if the origin is at the bottom of the mesh the offset is half the negative height of the collider.

Note: GLTF is a work in progress so there are some conditional limitations.

Conditions:

  • You can only use one material since each additional material adds another primitive.
  • For rigged entities, a root bone at the top of the hierarchy is required.
  • Single mesh for each gltf file else the first mesh is loaded.