Landscape object is created by
WrapTerra3D, and is passed a reference to the world's scene (
sceneBG) and the filename supplied on the command line (e.g., test1).
Landscape's primary purpose is to display a terrain composed from a mesh and a texture.
Landscape looks in the models/ subdirectory for a OBJ file containing the mesh (e.g., test1.obj) and for a JPG (e.g., test1.jpg) to act as the texture. The OBJ file is loaded, becoming the
landBG BranchGroup linked to
sceneBG. The texture is laid over the geometry stored within
Landscape can add two kinds of scenery to the terrain:
PropManager. This type of scenery includes irregular objects that the user can move around and perhaps enter (e.g., the castle shown in Figure 27-1).
Represented by 2D images that rotate to face the user. This kind of scenery is for simple, symmetrical objects that decorate the ground, such as trees and bushes (see Figures 27-1 and 27-2). Ground cover shapes are managed by a
The terrain is surrounded by walls covered in a mountain range image.
Landscape() constructor loads the mesh, checks that the resulting Java 3D subgraph has the right characteristics, and extracts various mesh dimensions. At the end of the constructor, the land is added to the world and the texture laid over it:
// globals private BranchGroup sceneBG; private BranchGroup landBG = null; private Shape3D landShape3D = null; // various ...