merge ws/idtech: UDMF (codecs/model/DoomMap), Doom 3 / Quake 4 .map + .proc, Wolf3D VSWAP + GAMEMAPS, codecs/text/Lexer

This commit is contained in:
4DBug committed 2026-11-01 19:48:30 -06:00
commit 0e0b213a80
38 files changed
+11791 -2566

No files matched your search

+53
View File
@@ -625,6 +625,56 @@ local built = assert(F.model.load(assert(F.saveString(doc, { format = "vmf" })),
assert(#built.meshes[1].primitives == 1 and built.meta.entities[2].classname == "info_player_start")
```
## Doom maps (UDMF)
Doom-engine maps load as Scenes (z up, map units): floors and ceilings triangulated from the sector outlines, walls
with vanilla texture alignment, things as child nodes standing on their floor. Maps inside a WAD (binary lumps or a
UDMF `TEXTMAP`) load through `F.format("wad").map(wad, name)` (see the archive page); a standalone UDMF text
(`.udmf`, or a `TEXTMAP` lump saved alone) loads directly, with texture sizes from `textureSize` (else 64 x 128 walls
and 64 x 64 flats) and the textures as URIs. `F.format("udmf").data` gives the tables: every UDMF block keeps its
fields as written (`fields`, lower-case keys: namespace and `user_` keys too), flags are rebuilt in the binary layout
(Doom bits for the Doom / Heretic / Strife namespaces, Hexen bits otherwise), and unknown blocks stay in `blocks`.
```luau
local room = assert(F.model.load(udmfText))
assert(room.meta.source.format == "udmf" and room.meta.source.namespace == "ZDoom")
assert(room.nodes[3].translation[3] == 40) -- a thing 8 units above the 32-unit pillar
local Udmf = F.format("udmf")
local data = assert(Udmf.data(F.Bytes.reader(buffer.fromstring(udmfText))))
assert(data.sectors[1].fields.user_gravity == 0.5)
assert(data.linedefs[4].tag == 7 and data.blocks[1].type == "vavoombox")
```
## Doom 3 / Quake 4 levels
A compiled `.proc` file (dmap's render geometry: `mapProcFile003`, Quake 4's `PROC "4"`) loads as a Scene: each model
(the areas `_area0`, `_area1`, ... and the inline models of entities) is a mesh with a primitive per surface
(positions, normals, texture coordinates, Quake 4 vertex colours as `COLOR_0`) and a child node of the root; the
materials are URIs. id Tech 4 triangles are clockwise-front, so they are turned counter-clockwise. The portals between
areas, the BSP nodes and the shadow models load as data in `meta.proc`.
The editor's `.map` (`Version 2` for Doom 3, `Version 3` for Quake 4; told apart from Quake's `.map` by that line)
loads as a Scene too: `brushDef3` brushes (plane equations) become polygons through the same brush clipper as the
Quake maps, with Doom 3's texture matrices, and `patchDef2` / `patchDef3` surfaces become triangle grids (patchDef3 at
its stored subdivisions, patchDef2 at `patchLevel` segments per sub-patch). Each entity is a node with its keys in
`extras.keys`; entities with geometry get a mesh (in world coordinates), point entities their `origin`, `rotation`
or `angle`. `skip` leaves materials out (`"textures/common/caulk"`), `hull` drops faces hidden inside other brushes.
```luau
local level = assert(F.model.load(procText))
assert(level.meshes[1].name == "_area0" and level.meta.up == "z")
local proc = level.meta.proc
assert(proc.areas == 2 and proc.portals[1].positive == 1 and #proc.portals[1].points == 12)
assert(proc.nodes[1].negative == -1) -- < 0: area -1 - n; > 0: a node (1-based); 0: solid
assert(level.materials[1].name == "textures/base_wall/lfwall1")
local room = assert(F.model.load(d3mapText, { name = "room.map", skip = { "textures/common/caulk" } }))
assert(room.meta.source.format == "d3map" and room.meta.source.variant == "doom3")
assert(#room.meshes[1].primitives == 1) -- the floor material; caulk skipped
local start = room.nodes[3]
assert(start.extras.classname == "info_player_start" and start.translation[3] == 1)
```
## Blitz3D (B3D)
`.b3d` files (Blitz3D, also written by many old game tools) load read-only. The node tree keeps its names and TRS;
@@ -868,6 +918,9 @@ assert(back.meshes[1].primitives[1].indices.count == 3)
| MD2, MD3, MDL, MD5, BSP, VBSP | yes | - | game models and maps: see "Game models" above |
| VMF | yes | yes (round trip, builders) | Hammer maps: see "Hammer maps (VMF)" above |
| SMD | yes | yes | Valve studiomdl data |
| Doom 3 / Quake 4 `.proc` | yes | | render geometry per area, portals and BSP nodes as data |
| Doom 3 / Quake 4 `.map` (d3map) | yes | | brushDef3, patchDef2 / 3, entities as nodes |
| UDMF (`.udmf`, `TEXTMAP`) | yes | | Doom maps as text: see "Doom maps (UDMF)" above |
| Roblox `.mesh` (robloxmesh) | yes | yes | see [roblox.md](roblox.md) |
| Roblox `.rbxm` / `.rbxl`, `.rbxmx` / `.rbxlx` | as an `RbxTree` | yes | instance trees with typed properties: see [roblox.md](roblox.md) |