Chapter 27. Terrain Generation with Terragen

This chapter continues the landscape creation theme from Chapter 26 but takes a different approach. A significant drawback of that chapter’s FractalLand3D example is the programmer’s lack of control over the generated terrain. Most games require mountains, fields, lakes, and so on, to be in fixed, specific places, rather than randomly located in a new landscape each time the program starts. Another weakness of the approach is the lack of scenery (e.g., bushes, trees, buildings).

This chapter explains how to create a detailed, fixed landscape that’s the same every time the program uses it and includes scenic dressing. The major topics covered are:

Use of a landscaping tool

There are numerous tools for terrain building, which are better at creating a realistic looking landscape than a do-it-yourself (DIY) approach coded in Java. I’ll be using Terragen, a popular scenery generation package. The landscape is designed with Terragen and then saved as a mesh and texture, which are loaded by my program (Terra3D ) at start time. Utilizing specialized modeling software is better than implementing something from scratch.

3D and 2D ground cover

The landscape can be decorated with two types of scenery: 3D models loaded with the PropManager class (from Chapter 16) and 2D ground cover images (e.g., trees, sagebrush), which stay oriented towards the viewer. The separation into two types is for efficiency: multiple copies of a 2D shape are one instance ...

Get Killer Game Programming in Java now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.