O'Reilly logo

Killer Game Programming in Java by Andrew Davison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making 3D Scenery

3D scenes are models which the user may enter, move around, and view from different angles. An example is the castle in the test2.obj landscape, as seen in Figures 27-1 and 27-14.

The castle in the test2.obj terrain

Figure 27-14. The castle in the test2.obj terrain

Tip

The user can enter a model and can walk right through its walls. Terra3D doesn't enforce any constraints on the user's movements around models.

The placement of models and the user's initial position in the terrain are specified in a text file with the same name as the landscape's OBJ file; for this example, the text file is test2.txt in the directory models/:

    start 3960 1800 255.64
    Castle.cob   4100  4230  220  70

    bldg4.3ds    6780  3840  780  90
    hand1.obj    1830  570  781.98   120

The file format is:

    start x y z
    <model file>  x y z scale
    <model file>  x y z scale
    // more model file lines

A start line must be included in the file because specifies where the user is initially placed in the landscape, but the scenery objects are optional. The (x, y, z) values are in landscape coordinates, and the scale value is used to adjust the model's size in the terrain.

Each scenery object is loaded with a PropManager object (introduced back in Chapter 16); the code assumes the existence of coords datafiles for the models.

A difficult task is deciding on suitable (x, y, z) and scale values. One approach is to jot down likely coordinates while running Terragen. Another technique ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required