Skip to content
Home » Panda3D Part 15 – The Terrain Model

Panda3D Part 15 – The Terrain Model

Spread the love

In the previous part of the Panda3D series we loaded the building model in Panda3D. But this is not the only model we’ll need for our game. Let’s have a look at the terrain model today.

In Panda3D we differentiate between models, which are static models, and actors, which are animated character models. We’ll have a look at the latter a bit later, and now let’s focus on the static models.

We already have the building model and you could see step by step how it was modeled and textured. We’ll also need a terrain model for the building to stand on, as well as a tent model and a tree model. Then we’re going to join all the models so that we have just one terrain model. Depending on how the game is played, it may be advisable to keep all models separate and load them individually in Panda3D, but for our simple game, let’s just join all the objects into one model.

Now, we’re not going to create the models from scratch. Instead you can grab the whole terrain model from my github repository. In my Panda3D book that I’m working on right now, I’m going to discuss each model in great detail so that you can follow along and create it from scratch. Generally I’m using the same techniques as for the building model and some more.

Create a terrain folder in the models folder and download the terrain model from github there. Here are all the parts of the terrain model discussed one by one.

Terrain Plane

The actual terrain model is going to be very simple, just a plane. This is the world where everything will be placed, including the slugs. Here’s what it looks like:

Terrain Plane

Tent

Then we’ll need four tents, one for each slug. Here’s what a tent model will look like:

Tent

Tree

Then we’ll need some trees. They will be scattered all around the scene. A single tree will look like this:

Tree

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

The Joined Terrain Model

Now we can use all the separate models to create our final terrain model. Here it is:

The Joined Terrain Model

We can now export this model to glTF and then import it in Panda3D. Here’s the code:

 from direct.showbase.ShowBase import ShowBase
 from panda3d.core import WindowProperties
 from panda3d.core import load_prc_file
 import simplepbr
  
 load_prc_file('myConfig.prc')
  
 class Slugrace3D(ShowBase):
     def __init__(self):
         ShowBase.__init__(self)
         simplepbr.init()
  
         self.terrain = loader.loadModel("models/terrain/terrain.gltf")
  
         # Let's position the terrain.
         self.terrain.setPos(0, 0, -1)
  
         self.terrain.reparentTo(render)           
  
 app = Slugrace3D()
 app.run() 

Python Jumpstart Course

Learn the basics of Python, including OOP.

with lots of exercises, easy to follow

The course is available on Udemy.

For this to work, make sure the terrain.gltf file is in the terrain folder, along with the textures:

terrain folder

And now, if you run the code, you will see the following:

terrain in Panda3D

Feel free to navigate the window and view the model from different angles:

terrain in Panda3D

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

3 thoughts on “Panda3D Part 15 – The Terrain Model”

    1. Thanks, I’m now also working on a Panda3D book, but I’ll be posting the following parts of the tutorial as soon as I can.

    2. Thanks, I’m working on the Panda3D series, as well as on a Panda3D book, but also on other stuff like Kivy, Matplotlib and more. I hope you’ll enjoy it.

Leave a Reply