merge ws/engines

This commit is contained in:
4DBug committed 2026-11-01 20:14:34 -06:00
commit 8bd15840d8
66 files changed
+31751 -1331

No files matched your search

+93
View File
@@ -991,6 +991,96 @@ local bones = arm:list("bonebase")
assert(bones[1]:str("name") == "lower" and bones[1]:list("childbase")[1]:str("name") == "upper")
```
## 3ds Max ASCII export (ASE)
`.ase` files (`*3DSMAX_ASCIIEXPORT`) load as a Z-up scene: one node per geometry, helper, camera and light object,
parented by `*NODE_PARENT`. ASE stores mesh vertices in world space; the reader moves them into the node's frame (the
inverse `*NODE_TM`), so `Scene.flatten` puts them back where 3ds Max had them. Faces split into one primitive per
sub-material of a Multi/Sub-Object material (`*MESH_MTLID`); each corner is its own vertex (texture channels,
vertex colours and `*MESH_VERTEXNORMAL`s are per corner). Materials are Phong (the raw values in `extras`), bitmaps
become textures with a `uri` (data through `opts.resolve`), UVW tiling / offset a texture transform. Camera FOVs
stay the stored horizontal angle. `*TM_ANIMATION` tracks are not read (`meta.source.animated` says they exist).
The writer puts every scene material in one Multi/Sub-Object material and writes world-space vertices.
```luau
local scene = assert(F.load(aseText))
assert(scene.meta.source.format == "ase" and scene.meta.up == "z")
assert(#scene.materials == 2 and scene.materials[1].name == "Brick")
local quad = scene.nodes[2]
assert(quad.name == "Quad" and #scene.meshes[quad.mesh].primitives == 2)
local tex = scene.textures[scene.materials[1].baseColorTexture.texture]
assert(tex.uri == "textures\\brick.png")
local again = assert(F.load(F.save(scene, nil, { format = "ase" })))
assert(#again.meshes[again.nodes[2].mesh].primitives == 2)
```
## Godot scenes (TSCN / ESCN)
Godot text scenes load as a Y-up Scene (one node per `[node]`, the scene root first), checked against Godot 4's own
loader. Node3D transforms come from `transform = Transform3D(...)` (or `position` / `rotation` / `scale`); a
MeshInstance3D gets its ArrayMesh sub-resource (Godot 4.2+ surfaces, and the `"arrays"` surfaces of Godot 3 / Blender
`.escn` files) or its primitive mesh (Box, Plane, Quad, Sphere and Cylinder are built as Godot builds them), with
`surface_material_override/N` applied. StandardMaterial3D / SpatialMaterial become PBR materials (Godot's sRGB
albedo and emission converted to linear; the raw values in `material.extras.godot`); textures are `ExtResource`
paths (`res://` dropped) with their bytes through `opts.resolve`. Camera3D (`fov` is vertical) and Omni / Spot /
Directional lights map to cameras and lights (`intensity` = `light_energy`). Instanced scenes
(`instance=ExtResource(...)`) are read through `opts.resolve` and grafted under their node. Godot's front faces are
clockwise: indices are reversed into glTF's counter-clockwise winding (and back on save). Every node keeps its Godot
type and raw properties in `node.extras.godot`, so 2D trees (Node2D, Sprite2D, Control) are kept there too.
```luau
local scene = assert(F.load(tscnText, { resolve = function(path) return nil end }))
assert(scene.meta.source.format == "godot" and scene.meta.up == "y")
local box = scene.nodes[2]
assert(box.name == "Box" and box.extras.godot.type == "MeshInstance3D")
assert(box.matrix[13] == 2) -- Transform3D origin x
local mat = scene.materials[scene.meshes[box.mesh].primitives[1].material]
assert(mat.extras.godot.albedo[1] == 1 and mat.metallic == 0.5)
assert(scene.cameras[1].type == "perspective" and math.abs(math.deg(scene.cameras[1].yfov) - 60) < 1e-9)
local hud = scene.nodes[4]
assert(hud.extras.godot.type == "Node2D" and hud.extras.godot.properties.position.args[1] == 10)
local tscn = assert(F.saveString(scene, { format = "godot" })) -- Godot 4 text, format 3
assert(string.find(tscn, '[node name="Box" type="MeshInstance3D" parent="."]', 1, true))
```
The writer makes Node3D / MeshInstance3D / Camera3D / light nodes, ArrayMesh sub-resources (uncompressed format 2
surfaces with positions, normals, tangents, colours, two UV sets) and StandardMaterial3D, plus a `Texture2D`
`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 |
@@ -1031,6 +1121,9 @@ assert(bones[1]:str("name") == "lower" and bones[1]:list("childbase")[1]:str("na
| 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 |
| Blender `.blend` | yes | | 2.4x - 5.x, compressed; meshes of every generation, materials, skins, shape keys, actions; see "Blender" above |
| 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) |
| Roblox `.rbxm` / `.rbxl`, `.rbxmx` / `.rbxlx` | as an `RbxTree` | yes | instance trees with typed properties: see [roblox.md](roblox.md) |