The Mesh Generator

In many instances, BGL generates scenery elements on a regular grid; some examples are the scenery elements in the following list.

The mesh generator is used to create all of the scenery elements in the preceding list. The PROCESS_MESH procedure in the file Bglseed.asm is used to generate meshes using variables defined as shown in the following graphic.

When the mesh generator is called, the x_grid, z_grid size (in number of grid lines) is submitted. This defines an equally spaced grid of x_grid-1 by z_grid-1. The x_patch and z_patch is specified in design units of the scale that you're working in. The grid is assumed to begin at 0,0 design units in the southwest corner of the mesh.

Important: You must submit an action vector to the mesh generator. For every patch in the mesh, the action vector is called.

When the PROCESS_MESH is called, eye position relative to the mesh is computed, and for every patch, the action vector is called. The grid coordinates are passed to the called routine in bx=x and cx=z. Then, the action vector generates items for the patch.

The patches are passed to the action vector in an order based on where you're working with relation to the grid. The farthest patches are passed first for a depth-sorting effect. For example, the following graphic shows the processing order of a 5x5 mesh.