Files
rosetta/tools/fixtures/docs_sourcemdl.py
T

30 lines
1.4 KiB
Python

# Docs inputs for the Source models section of docs/guide/scene.md (tools/fixtures.py; tools/docs_check.py explains
# the inputs): a v49 model with its .vvd / .dx90.vtx / .phy and a .vmt, from tools/fixtures/sourcemdl.py's writer.
# tests/gen/docs_sourcemdl.luau { files = { [name] = bytes }, vars = { sourceMdlBytes = "model.mdl", ... } }
import importlib.util, os
INPUTS = ["tools/docs_check.py", "tools/fixtures/sourcemdl.py"]
def load(ctx, rel, name):
spec = importlib.util.spec_from_file_location(name, os.path.join(ctx.root, rel))
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
def generate(ctx):
check = load(ctx, "tools/docs_check.py", "docs_check")
smdl = load(ctx, "tools/fixtures/sourcemdl.py", "fx_sourcemdl")
rng = ctx.rng(49)
m = smdl.make(rng, 49)
checksum = rng.randrange(1 << 31)
mdl, _, _, _ = smdl.write_mdl(m, rng, checksum)
vvd, _ = smdl.write_vvd(m, rng, checksum)
vtx, _ = smdl.write_vtx(m, rng, checksum, True)
phy, _, _ = smdl.write_phy(rng, checksum)
vmt = "materials/models/test/skin_a.vmt"
files = {"model.mdl": mdl, "model.vvd": vvd, "model.dx90.vtx": vtx, "model.phy": phy, vmt: smdl.VMTS[vmt].encode()}
check.emit_inputs(ctx, files, {"sourceMdlBytes": "model.mdl", "sourceVvdBytes": "model.vvd", "sourceVtxBytes": "model.dx90.vtx",
"sourcePhyBytes": "model.phy", "skinVmtText": vmt})