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:
Getting ready
You will need to place the Map.png
file in the pi3d/textures
directory of the Pi3D library. Alternatively, you can use one of the elevation maps already present—replace the reference to Map.png
for another one of the elevation maps, such as testislands.jpg
.
How to do it…
Create the following 3dWorld.py
script:
#!/usr/bin/python3 from __future__ import absolute_import, division from __future__ import print_function, unicode_literals """ An example of generating...