Files
rosetta/tools/fixtures/_usda_encode.luau
T
4DBug 3e658042e3 ws-3d2/usda: model/usda - USD ASCII read / write (+ USDZ read), checked against OpenUSD (pxr), assimp's USD models and Blender exports
Reads stage metadata, xform op stacks (every rotate order, orient, transform, pivots / !invert!, resetXformStack),
time samples -> TRS animation, Mesh (all primvar interpolations + indices, GeomSubsets, holes, leftHanded),
UsdPreviewSurface / UsdUVTexture / UsdTransform2d materials with inherited bindings, cameras, UsdLux lights,
selected variants. USDC returns UNSUPPORTED. Writes Xform / Mesh / GeomSubset / Material / Camera / lights.
2026-10-31 09:41:47 -05:00

35 lines
1.2 KiB
Luau

-- tools/fixtures/_usda_encode: run by tools/fixtures/usda.py (luau CLI, repo root): decodes every USDA case with our
-- reader and writes it back with our writer, printing "<file>\t<hex>" lines (case_<n>.usda + the texture files it
-- references) for OpenUSD (pxr) to read back.
local Usda = require("@formats/model/usda")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/usda_cases")
local HEX = {}
for i = 0, 255 do
HEX[i] = string.format("%02x", i)
end
local function hex(s: string): string
local out = table.create(#s)
for i = 1, #s do
out[i] = HEX[string.byte(s, i)]
end
return table.concat(out)
end
for i, c in Cases do
if not c.expect then
local scene = Usda.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files })
if scene then
local files = {}
local out = assert(Usda.encode(scene, { files = files, name = "case_" .. i .. ".usda" }))
print(string.format("case_%d.usda\t%s", i, hex(buffer.tostring(out))))
for name, data in files do
if not string.find(name, "%.%.") and string.sub(name, 1, 1) ~= "/" then
print(name .. "\t" .. hex(if type(data) == "string" then data else buffer.tostring(data)))
end
end
end
end
end