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 |

**Variant**(bits 0 through 1) is the texture variant.- Bits 2 through 3 are unused.
**Rotation**(bits 4 through 5) is the rotation of the tile. Each step rotates the tile 90 degrees counterclockwise. This combined with Flip determines texture coordinates for the tile.**Flip**(bit 6) determines whether the tile should be flipped. For a cap tile, it flips the texture left to right before rotation. For a diagonal tile, it flips the texture lower left corner to upper right corner before rotation. This combined with Rotation determines texture coordinates for the tile.**Cap**(bit 7) selects between cap (0) and diagonal (1) tiles. Flipped diagonal tiles uses different texture coordinates from cap tiles.**Next**(bits 8 through 11) is the secondary material index for the tile.**Base**(bits 12 through 15) is the primary material index for the tile.

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 |