Creating a 3D world to roam in

Now that we are able to create models and objects within our 3D space, as well as generate backgrounds, we may want to create a more interesting environment within which to place them.

3D terrain maps provide an elegant way to define very complex landscapes. The terrain is defined using a grayscale image to set the elevation of the land. The following example shows how we can define our own landscape and simulate flying over it, or even walk on its surface:

Creating a 3D world to roam in

A 3D landscape generated from a terrain map

Getting ready

You will need to place the Map.png file (available in the book resource files) in the pi3d/textures directory ...

Get Raspberry Pi for Python Programmers Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.