Battlezone HGT (Terrain Height)
A Terrain Height file has no header and contains an array of zone height 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.
Zone Height Block
Each zone height block is a 128 by 128 array of height 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).
Height Entry
Each height entry is a 16-bit bitfield. The file data uses little-endian byte order so the byte containing the low 8 bits of the height comes first and the byte containing the high 4 bits of the height and the coplanar flags comes second.
15 |
14 |
1312 |
110 |
Coplanar Triangles |
Coplanar Squares |
(Unused) |
Height |
- Height (bits 0 through 11) is the height of the southwest corner of the grid square in units of height granularity (0.1 meter).
- Bits 12 through 13 are unused.
- Coplanar Squares (bit 14) indicates whether the two triangles in the grid square are exactly coplanar with the two triangles in the next grid square in the X direction (to the east) within the same texture tile. If this bit is set, terrain rendering can combine the two squares into a single polygon. This condition mostly applies on flat, level ground.
- Coplanar Triangles (bit 15) indicates whether the two triangles in the grid square are approximately coplanar (specifically, the dot product of the plane normals is greater than 0.995). If this bit is set, terrain rendering can combine the triangles into a single square. If not, it must draw them separately.