Documentation
¶
Overview ¶
Package sct implements reading of Total Annihilation SCT (Section) map files.
SCT files contain tile-based terrain sections used by the TA map editor. Each section has a grid of 32×32 pixel tiles, height data, and a 128×128 minimap.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Header ¶
type Header struct {
Version uint32 // Always 3
PtrMinimap uint32 // Offset to 128×128 minimap
NumTiles uint32 // Number of 32×32 tiles
PtrTiles uint32 // Offset to tile pixel data
Width uint32 // Section width in tiles
Height uint32 // Section height in tiles
PtrData uint32 // Offset to section data (tile indices + height)
}
Header is the 28-byte SCT file header.
type HeightData ¶
type HeightData struct {
Height uint8
}
HeightData is one height sample (4 per tile). In V3 files this is 4 bytes; in V2 files it is 8 bytes.
type Section ¶
type Section struct {
Header Header
Tiles [][]byte // NumTiles entries, each 1024 bytes (32×32 palette indices)
TileMap []int16 // Width×Height tile indices into Tiles
HeightMap []HeightData // (Width*2)×(Height*2) height samples at 16px resolution
AttrW int // Width * 2 (attribute grid width)
AttrH int // Height * 2 (attribute grid height)
Minimap []byte // 128×128 palette indices
}
Section is a parsed SCT file.
func LoadFromReader ¶
func LoadFromReader(r io.ReadSeeker) (*Section, error)
LoadFromReader parses an SCT file from the given reader.
func (*Section) RenderHeightMap ¶
RenderHeightMap renders the height data as a normalized greyscale image. The attribute grid is AttrW × AttrH (2× the tile grid, at 16px resolution).
func (*Section) RenderMinimap ¶
RenderMinimap renders the minimap as an RGBA image using the given palette.