Skip to main content

Module bwm

Module bwm 

Source
Expand description

BWM/WOK binary walkmesh support. BWM/WOK binary reader and writer.

BWM is KotOR’s binary walkmesh container format. The same binary layout is used by .wok (area walkmesh), .pwk (placeable walkmesh), and .dwk (door walkmesh) resources.

This module provides lossless table-level parsing and deterministic serialization for the binary BWM V1.0 layout.

§Shape of the container

A 136-byte header and nine data blocks, each located by its own offset out of that header rather than by following on from the block before it.

One face_count sizes four of the nine: indices, materials, normals and planar distances are parallel arrays over the same faces, not independent tables. Vertices, AABB nodes, adjacency, edges and perimeters each carry their own count.

§What is and is not verified here

The counts and offsets from 0x48 onward are confirmed against a real file: the block chain closes exactly, each block starting where the last ends and the final one reaching the file’s exact length.

The header before 0x48 is confirmed too, though not by the fixtures, which zero the whole region and are unrepresentative: across 1,554 vanilla walkmeshes the hook fields are populated in 81% of them, and 0x08 turns out to be a kind discriminator rather than any kind of count. The format page’s engine audit reads these bytes differently and is refuted by that measurement; see docs/src/formats/models/walkmesh.md.

What remains open is the tail: every file is contiguous, but a fifth of .wok and a third of .pwk carry bytes past the last populated block, and nobody has established whether that is padding or content. Preserve it.

Re-exports§

pub use ascii_reader::read_bwm_ascii;
pub use ascii_reader::BwmAsciiError;
pub use ascii_writer::write_bwm_ascii;

Modules§

ascii_reader
ASCII reader. BWM ASCII reader implementation.
ascii_writer
ASCII writer. BWM ASCII writer implementation.

Structs§

Bwm
In-memory binary BWM container.
BwmAabbNode
One AABB-node row.
BwmAdjacency
One adjacency row.
BwmEdge
One edge-transition row.
BwmFace
One face row assembled from index/material/normal/distance tables.
BwmTypeCode
Lossless walkmesh-type wrapper.
BwmVec3
Three-dimensional vector value.

Enums§

BwmBinaryError
Errors produced while parsing or serializing BWM binary data.
BwmType
Known walkmesh type values.
SurfaceMaterial
Surface material IDs used in walkmeshes.

Functions§

read_bwm
Reads BWM data from a reader.
read_bwm_from_bytes
Reads BWM data from bytes.
write_bwm
Writes BWM data to a writer.
write_bwm_to_vec
Serializes BWM data to a byte vector.