Documentation
¶
Overview ¶
Package terrain implements decoders for the WDT and ADT terrain formats.
Index ¶
- Constants
- Variables
- func CalcBlockCornerPos(m *MapParam, bi BlockIndex) (pos tempest.C2Vector, err error)
- type BlockIndex
- type ChunkAlphaMap
- type ChunkData
- type ChunkHeader
- type ChunkIndex
- type ChunkInfo
- type ChunkLayer
- type ChunkLiquids
- type ChunkOldSoundEmitter
- type Dir
- type DoodadDef
- type HeaderFlags
- type Index
- type MapBlock
- type MapParam
- type MapReader
- type Source
- type TileFlags
- type TileIndex
- type WMODef
Constants ¶
View Source
const ( BlockSize = 533.33333 ChunkSize = BlockSize / 16 )
View Source
const ChunkBufferSize = 9*9 + 8*8
Variables ¶
View Source
var ( MapVersion = chunked.ID("MVER") MainTileIndex = chunked.ID("MAIN") MapIndexHeader = chunked.ID("MPHD") MapObject = chunked.ID("MWMO") MapChunkInfo = chunked.ID("MCIN") MapTextures = chunked.ID("MTEX") BlockHeader = chunked.ID("MHDR") MapModels = chunked.ID("MMDX") MapModelFilenamesOffsets = chunked.ID("MMID") MapObjectFilenameOffsets = chunked.ID("MWID") DoodadDefs = chunked.ID("MDDF") MapObjectDefs = chunked.ID("MODF") Chunk = chunked.ID("MCNK") Normals = chunked.ID("MCNR") Heights = chunked.ID("MCVT") Layer = chunked.ID("MCLY") CollisionObjects = chunked.ID("MCRF") ShadowMap = chunked.ID("MCSH") Alpha = chunked.ID("MCAL") Liquids = chunked.ID("MCLQ") SoundEmitters = chunked.ID("MCSE") )
View Source
var ( DefaultMap = MapParam{ BlockSize: tempest.C2iVector{ X: 64, Y: 64, }, } )
Functions ¶
func CalcBlockCornerPos ¶
func CalcBlockCornerPos(m *MapParam, bi BlockIndex) (pos tempest.C2Vector, err error)
Using a BlockIndex, return the in-world XY position of the corner of this. Note that this does not return the CENTER of the block, only the lowest corner. For instance, 32,32 -> 0,0
Types ¶
type BlockIndex ¶
func CalcBlockIndex ¶
func CalcBlockIndex(m *MapParam, pos tempest.C2Vector) (bi BlockIndex, err error)
Using map parameters, calculate what the block index of a position is. Will error if pos is out of bounds.
type ChunkAlphaMap ¶
type ChunkAlphaMap [64 * 64]byte
type ChunkData ¶
type ChunkData struct {
ChunkHeader
// MCNR
Normals [ChunkBufferSize][3]byte
NormalsPad [13]byte
// MCVT
Heights [ChunkBufferSize]float32
// MCLY
Layer []ChunkLayer
// MCRF
CollisionDoodads []uint32
CollisionWMOs []uint32
// MCSH
ShadowMap [64]uint64
// MCAL
AlphaMaps []ChunkAlphaMap
// MCLQ
Liquids ChunkLiquids
// MCSE
OldSoundEmitters []ChunkOldSoundEmitter
}
type ChunkHeader ¶
type ChunkHeader struct {
Flags uint32
IndexX uint32
IndexY uint32
// Radius float32
NumLayers uint32
NumDoodadRefs uint32
OffsetHeight uint32
OffsetNormal uint32
OffsetLayer uint32
OffsetRefs uint32
OffsetAlpha uint32
SizeAlpha uint32
OffsetShadow uint32
SizeShadow uint32
AreaID uint32
NumMapObjRefs uint32
Holes uint16
Pad0 uint16
PredTex [8]uint16
NumEffectDoodad [8]byte
OffsetSndEmitters uint32
NumSndEmitters uint32
OffsetLiquid uint32
SizeLiquid uint32
Position tempest.C3Vector
OffsetMCCV uint32
Unused1 uint32
Unused2 uint32
}
type ChunkIndex ¶
func CalcChunkIndex ¶
func CalcChunkIndex(m *MapParam, pos tempest.C2Vector) (ci ChunkIndex, err error)
Using 2d position vector, determine what chunk slot this position falls into. Pos must be a valid position before calling. Call CalcBlockIndex to be sure.
type ChunkLayer ¶
type ChunkLiquids ¶
type ChunkOldSoundEmitter ¶
type ChunkOldSoundEmitter struct {
SoundPointID uint32
SoundNameID uint32
Position tempest.C3Vector
MinDistance float32
MaxDistance float32
CutoffDistance float32
StartTime uint16
EndTime uint16
Mode uint16
GroupSilenceMin uint16
GroupSilenceMax uint16
PlayInstancesMin uint16
PlayInstancesMax uint16
LoopCountMin byte
LoopCountMax byte
InterSoundGapMin uint16
InterSoundGapMax uint16
}
type DoodadDef ¶
type DoodadDef struct {
// NameID references an entry in the MMID chunk, specifying the model to use.
NameID uint32 // 0x00
UniqueID uint32 // 0x04
Position tempest.C3Vector // 0x08
Rotation tempest.C3Vector // 0x14
Scale uint16 // 0x20
Flags uint16 // 0x22
}
DoodadDef Placement information for doodads (M2 models). Additional to this, the models to render are referenced in each MCRF chunk.
type HeaderFlags ¶
type HeaderFlags uint32
const ( WDTUsesGlobalWMO HeaderFlags = 1 << iota ADTHasMCCV ADTHasBigAlpha )
type Index ¶
type Index struct {
// MVER
Version uint32
// MPHD
HeaderFlags HeaderFlags
// MAIN
Tiles [64 * 64]TileIndex
}
type MapBlock ¶
type MapBlock struct {
// MVER
Version uint32
// MHDR
Flags uint32
// MCIN
ChunkInfo [16 * 16]ChunkInfo
// MTEX
Textures []string
// MMDX
MapModels []byte // m2 files
// MMID
MapModelFilenameOffsets []uint32
// MWMO
MapObjects []byte // wmo files
// MWID
MapObjectFilenameOffsets []uint32
// MDDF
DoodadDefs []DoodadDef
// MODF
MapObjectDefs []WMODef
// MCNK * 16 * 16
ChunkData [16][16]*ChunkData
}
Click to show internal directories.
Click to hide internal directories.