Skip to content
Home » Panda3D Part 13 – Exporting the Blender Model to glTF Format

Panda3D Part 13 – Exporting the Blender Model to glTF Format

Spread the love

In the previous couple parts of the series we were modeling and texturing a building model. Now it would be great to see it in Panda3D. In this part we’re going to export it to the glTF format and in the next part we’re going to load it in Panda3D.

But first, let’s open the building.blend file in Blender. Here you can see it in Material Preview shading (A) in the Layout workspace (B):

building model

Before we export the model, let’s check one more time whether it’s ready to export. As for static models, like the building, so models without animations, we have to make sure the origin point is where we want it and the scale is applied. We already took care of it, but let’s check again.

So, go to front view (Num1) and hit N to open the sidebar. As you can see, the origin point is at the bottom (A), which is good, and the scale is 1 on each axis (B), which is also good:

scale

But don’t worry. Even if something is wrong with the model, you can always correct it in Blender and export again.

Exporting to glTF

So, let’s export the model to the glTF format. Blender handles this format out of the box, so we don’t need any add-ons, which used to be the case with the egg format, where you had to install the yabee add-on.

Anyway, go to the File menu and under Export select the glTF format:

export to glTF

A dialog window will open with a few options for you to choose:

export to glTF

Now, let’s have a look at the settings. Let’s start with the Format. There are three options available:

export to glTF

The first one is glTF Binary. It’s a very concise format, where all the information about meshes, textures and so on is packed into a single binary file. We could use this option, but the downside of this format is that it’s not human-readable.

Then we have the glTF Embedded option. What we get using this option is a JSON text-based file. In the Blender documentation you will find the following warning:

This is the least efficient of the available forms, and should only be used when required.

Then there’s the third option, glTF Separate. Here’s the description from the Blender documentation:

This produces a JSON text-based .gltf file describing the overall structure, along with a .bin file containing mesh and vector data, and optionally a number of .png or .jpg files containing image textures referenced by the .gltf file.

We can also see a tip:

Having an assortment of separate files makes it much easier for a user to go back and edit any JSON or images after the export has completed.

Your Panda3D Magazine

Make Awesome Games and Other 3D Apps

with Panda3D and Blender using Python.

Cool stuff, easy to follow articles.

Get the magazine here (PDF).

Anyway, the binary format seems pretty simple to handle as there is just one file with all the information packed in it. However, we’re going to use the glTF Separate option in this series so that we can see how our models are represented in it. So, select it in the drop-down menu (A). Then you will see another field, Textures, where you can type the name of the folder in which the texture images should be put. The folder will be in the same location as the glTF file. Let’s name the folder ‘tex’ (B). You can also fill in Copyright information, but I’m going to skip it. Let’s also check the Remember Export Settings checkbox (C) so that the same settings will be used when we open the blend file again:

export to glTF

Then we have the Include section. Click on the arrow to expand it. Here we’re only going to check Limit to Selected Objects. This is to ensure that only the selected object is exported, in our case the building model. We don’t want to export other objects like the camera or the light:

export to glTF

In the Tranform section let’s leave +Y Up checked. This is the glTF convention of exporting models:

export to glTF

Python Jumpstart Course

Learn the basics of Python, including OOP.

with lots of exercises, easy to follow

The course is available on Udemy.

In the Geometry section you don’t need to change anything either. We don’t have any modifiers, so there is nothing to apply. We are going to use some modifiers with the other models in this series, but we’ll be applying them directly in Blender. We want to export the UVs and normals, so leave these options on. Naturally, we also want to export materials:

export to glTF

The last section is Animation. Our building model is not animated, so we’re not going to tweak the settings in there.

With all the settings in place you can press the Export glTF 2.0 button:

export to glTF

This will export your model to the glTF format. In your project folder you should now see two new files, the building.gltf text file and the binary building.bin file, as well as the tex folder with textures.

So, the model is now exported and we can use it in Panda3D. In the next part we’ll install the glTF utilities for Panda3d and then we’ll load our model.

Blender Jumpstart Course

Learn the basics of 3D modeling in Blender.

step-by-step, easy to follow, visually rich

The course is available on Udemy and on Skillshare.


Spread the love

Leave a Reply