ws-3d3-b: model/iqm (Inter-Quake Model v2 read + write: meshes, every vertex array format, joints -> skin, poses / frames / anims -> channels, bounds; writer merges skins, samples and quantizes animations); new codecs/model/Sampler (channel evaluation STEP / LINEAR + slerp / CUBICSPLINE, animation poses at a time) with tests
mrfixit.iqm matches assimp and an independent Python IQM reader (its skinning reproduces the bounds the IQM tool stored; ours matches it to 1e-4); round trips and glTF skinned models written by us are skinned identically by the Python reader.
This commit is contained in:
1 parent
4f05c89f01
commit
51daa00a67
11 files changed
+1953
No files matched your search
@@ -0,0 +1,57 @@
|
||||
# Inter-Quake Model fixtures (tools/fixtures.py): assimp's IQM test model (mrfixit.iqm, from the nixpkgs assimp
|
||||
# source, never committed) with assimp's view of it (`assimp info -r`, PreTransformVertices bounds) and an independent
|
||||
# Python reading (tools/fixtures/_iqm_reference.py: counts, and the bounds of the skinned vertices per frame computed
|
||||
# from joints / poses / frames, next to the bounds block the IQM tool stored); glTF sample models (tests/fixtures/gltf)
|
||||
# for the writer; then our encoder's output (tools/fixtures/_iqm_encode.luau) read back by assimp and the Python reader.
|
||||
# tests/gen/iqm_cases.luau { name, data, assimp, ref }
|
||||
# tests/gen/iqm_gltf.luau { name, data, files }
|
||||
# tests/gen/iqm_xcheck.luau { name, assimp, ref }
|
||||
import importlib.util, os
|
||||
|
||||
INPUTS = ["src/Formats/model/iqm", "src/Formats/codecs/model", "tools/fixtures/_model_ref.py", "tools/fixtures/fbx.py",
|
||||
"tools/fixtures/_iqm_reference.py", "tools/fixtures/_iqm_encode.luau", "tests/fixtures/gltf"]
|
||||
|
||||
|
||||
def module(ctx, name):
|
||||
spec = importlib.util.spec_from_file_location(name, os.path.join(ctx.root, "tools", "fixtures", name + ".py"))
|
||||
m = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(m)
|
||||
return m
|
||||
|
||||
|
||||
def info(ctx, M, fbx, path, tmp):
|
||||
a = M.assimp_info(ctx, [path], raw=True)[0]
|
||||
for k in ("min", "max", "perMesh"):
|
||||
a.pop(k, None)
|
||||
if not a.get("failed"):
|
||||
a.update(fbx.ptv_bounds(ctx, path, tmp))
|
||||
return a
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
M = module(ctx, "_model_ref")
|
||||
fbx = module(ctx, "fbx")
|
||||
R = module(ctx, "_iqm_reference")
|
||||
tmp = M.tempdir()
|
||||
p = os.path.join(fbx.assimp_src(ctx), "test", "models", "IQM", "mrfixit.iqm")
|
||||
data = open(p, "rb").read()
|
||||
ctx.emit("iqm_cases", [{"name": "mrfixit.iqm", "data": data, "assimp": info(ctx, M, fbx, p, tmp), "ref": R.read(data)}])
|
||||
gl = os.path.join(ctx.root, "tests", "fixtures", "gltf")
|
||||
picks = []
|
||||
for model in ("RiggedSimple", "SimpleSkin", "Box", "BoxTextured", "BoxVertexColors", "MeshPrimitiveModes", "SimpleMeshes"):
|
||||
d0 = os.path.join(gl, model)
|
||||
for variant in sorted(os.listdir(d0)) if os.path.isdir(d0) else []:
|
||||
d = os.path.join(d0, variant)
|
||||
mains = [f for f in sorted(os.listdir(d)) if f.endswith((".gltf", ".glb"))] if os.path.isdir(d) else []
|
||||
if mains:
|
||||
picks.append({"name": model, "data": open(os.path.join(d, mains[0]), "rb").read(),
|
||||
"files": {f: open(os.path.join(d, f), "rb").read() for f in sorted(os.listdir(d)) if f != mains[0]}})
|
||||
break
|
||||
ctx.emit("iqm_gltf", picks)
|
||||
ours = M.luau_encode(ctx, "tools/fixtures/_iqm_encode.luau")
|
||||
out = []
|
||||
for name in sorted(ours):
|
||||
q = os.path.join(tmp, name)
|
||||
open(q, "wb").write(ours[name])
|
||||
out.append({"name": name, "assimp": info(ctx, M, fbx, q, tmp), "ref": R.read(ours[name])})
|
||||
ctx.emit("iqm_xcheck", out)
|
||||
Reference in new issue
Block a user