A Terrain Material file has no header and contains an array of zone material blocks. The zone map controls the layout of these blocks in world space but Battlezone uses row-major order starting at the southwest corner of the map.
Each zone material block is a 64 by 64 array of material entries in row-major order starting at the southwest corner of the zone. Successive entries in a row are at increasing X positions (west to east). Successive rows are at increasing Z positions (south to north).
Each material entry is a 16-bit bitfield and determines the texture and texture coordinates applied to the corresponding 2 by 2 terrain tile. The file data uses little-endian byte ordering so the byte containing Cap, Flip, Rotation, Mix, and Variant comes first and the byte containing Base and Next comes second.
1512 | 118 | 7 | 6 | 54 | 32 | 10 |
---|---|---|---|---|---|---|
Base | Next | Cap | Flip | Rotation | (Unused) | Variant |
Mix |
If Base and Next are the same, the tile will be solid. Otherwise, the tile will be a cap or diagonal depending on the Cap bit. Each solid tile for a given material and cap or diagonal tile for a given pair of materials can have up to four distinct textures selected by Variant.
Cap, Flip, and Rotation combine to form the Mix index. The terrain system uses the Mix index to look up texture coordinates for vertices within a terrain tile. Note that cap (0 through 7) and diagonal (8 through 15) yield different texture coordinates when applying flip (4 through 7 and 12 through 15).
Mix | Img | +X | +Z | Description |
---|---|---|---|---|
0 | +U | +V | Normal | |
1 | -V | +U | Rotate +90 | |
2 | -U | -V | Rotate 180 | |
3 | +V | -U | Rotate -90 | |
4 | -U | +V | Flip across z | |
5 | -V | -U | Flip across -x,+z diagonal | |
6 | +U | -V | Flip across x | |
7 | +V | +U | Flip across +x,+z diagonal | |
8 | +U | +V | Normal | |
9 | -V | +U | Rotate +90 | |
10 | -U | -V | Rotate 180 | |
11 | +V | -U | Rotate -90 | |
12 | -V | -U | Flip across -x,+z diagonal | |
13 | +U | -V | Flip across x | |
14 | +V | +U | Flip across +x,+z diagonal | |
15 | -U | +V | Flip across z |