model/t3d: Unreal T3D (UE1-4) brushes through codecs/model/Brush and actors as nodes

This commit is contained in:
4DBug committed 2026-11-01 19:33:35 -06:00
1 parent 37aa29d03e
commit 8d305bb942
10 files changed
+1084 -4

No files matched your search

+1
View File
@@ -94,6 +94,7 @@ is tested under both runtimes (luau `--codegen -O2` and LuaJIT through the build
| model | schematic | .schem .schematic .litematic | yes | yes | voxels: true, blocks: true, variants: "schem", "schematic", "litematic" | `tests/model/schematic.luau` |
| model | smd | .smd | yes | yes | skins: true, animation: true | `tests/model/smd.luau` |
| model | stl | .stl | yes | yes | ascii: true, binary: true, colors: true, indexed: false | `tests/model/stl.luau` |
| model | t3d | .t3d | yes | - | text: true, brushes: true, actors: true | `tests/model/t3d.luau` |
| model | usda | .usda .usd .usdz | yes | yes | materials: true, animation: true, cameras: true, lights: true, polygons: true, vertexColors: true, usdz: "read", usdc: false | `tests/model/usda.luau` |
| model | vox | .vox | yes | yes | voxels: true, sceneGraph: true, materials: true | `tests/model/vox.luau` |
| model | vrml | .wrl .wrz .vrml | yes | yes | materials: true, polygons: true, animation: true, cameras: true, lights: true, lines: true, points: true | `tests/model/vrml.luau` |
+34
View File
@@ -831,6 +831,39 @@ surfaces with positions, normals, tangents, colours, two UV sets) and StandardMa
`ext_resource` per texture with a `uri`. Skins, animations and morph targets are not written. Godot resources
(`.tres`) are data: see [data.md](data.md).
## Unreal T3D
UnrealEd's text export (`.t3d`: `Begin Map` / `Begin Actor` / `Begin Brush` / `Begin PolyList` / `Begin Polygon`,
UE1 to UE4) loads as a Scene in Unreal's own Z-up, left-handed coordinates (`meta.handedness = "left"`; nothing is
mirrored). Every actor is a root node with its class, properties, CSG operation and components in
`node.extras.t3d`; its matrix is the brush transform (PrePivot, MainScale, Rotation, PostScale, Location; rotations
in 65536ths of a turn, or degrees in UE4 text) or the actor's Location / Rotation / DrawScale (UE4: the root
component's `Relative*`). Brush polygons become one primitive per texture through `codecs/model/Brush`, with UVs from
`TextureU` / `TextureV` / `Origin` / `Pan` divided by the texture size (`opts.textureSize`: a function or a
`{ [name] = { w, h } }` table, default 256). Triangles wind counter-clockwise about each polygon's stored normal;
subtractive brushes are turned inside out (a room is seen from within), the red builder brush is skipped unless
`builder = true`. No BSP CSG is done: overlapping brushes stay separate meshes. Lights (UE1 hue / saturation /
brightness, UE3-4 light components) and cameras map across; static mesh actors keep their mesh path in
`extras.t3d.staticMesh`.
```luau
local level = assert(F.load(t3dText, { textureSize = { Bricks = { 128, 64 }, Floor = { 256, 256 } } }))
assert(level.meta.source.format == "t3d" and level.meta.up == "z")
local room
for _, n in level.nodes do
if n.name == "Brush0" then
room = n
end
end
assert(room.extras.t3d.csg == "CSG_Subtract" and room.mesh)
assert(room.matrix[13] == 64) -- Location X
local names = {}
for _, p in level.meshes[room.mesh].primitives do
names[level.materials[p.material].name] = true
end
assert(names.Bricks and names.Floor)
```
## Formats
| Format | Read | Write | Notes |
@@ -862,6 +895,7 @@ surfaces with positions, normals, tangents, colours, two UV sets) and StandardMa
| MD2, MD3, MDL, MD5, BSP | yes | - | game models and maps: see "Game models" above; BSP lightmaps, hulls, PVS: "Quake maps" |
| Quake / Half-Life / Quake II / Quake III `.map` | yes | yes | entities as nodes, brushes CSG'd, patches: see "Quake maps" |
| SMD | yes | yes | Valve studiomdl data |
| Unreal T3D (`.t3d`) | yes | - | brushes as polygons per texture (no CSG), actors with properties, lights, cameras; Z up, left-handed |
| Godot `.tscn` / `.escn` | yes | yes (`.tscn`) | Node3D trees, ArrayMesh and primitive meshes, StandardMaterial3D, cameras, lights, instances; 2D nodes in extras |
| ASE (3ds Max ASCII) | yes | yes | Multi/Sub-Object materials, texture channels, vertex colours, normals, helpers, cameras, lights; no animation; Z up |
| Roblox `.mesh` (robloxmesh) | yes | yes | see [roblox.md](roblox.md) |