tests/model: comments: specs only
This commit is contained in:
1 parent
5f7f6005f6
commit
fe7566cbba
37 files changed
+72
-440
No files matched your search
+2
-20
@@ -1,10 +1,5 @@
|
||||
-- model/fbx tests: assimp's FBX test models (binary 7.4 / 7.5, ASCII 7.4 - 7.7, embedded textures, skeletons,
|
||||
-- animation), Blender's exporter (materials, textures, colours, skin, shape keys, animation, camera, lights) and
|
||||
-- assimp's exporters (binary and ASCII), against assimp (meshes, polygons, vertices, world bounds, materials,
|
||||
-- animations, cameras, lights) and Blender's importer (meshes, polygons, materials, bones, shape keys, cameras,
|
||||
-- lights, images); round trips through our writer (binary and ASCII) and glTF sample models through FBX (world
|
||||
-- triangles, materials, textures, skins, morph targets, sampled animation, cameras, lights); assimp and Blender
|
||||
-- reading our files like the originals (fbx_xcheck); errors; the fuzz no-throw pass. Fixtures: tools/fixtures/fbx.py.
|
||||
-- model/fbx tests: assimp's FBX models, Blender and assimp exports, against assimp and Blender's importer.
|
||||
-- Fixtures: tools/fixtures/fbx.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Fbx = require("@rosetta/model/fbx")
|
||||
@@ -51,7 +46,6 @@ local function triArea(prim: any): number
|
||||
return area
|
||||
end
|
||||
|
||||
-- assimp-like counts: placed primitives, polygons, corners
|
||||
local function counts(scene: any): (number, number, number)
|
||||
local prims, faces, verts = 0, 0, 0
|
||||
local seen = {}
|
||||
@@ -109,7 +103,6 @@ local function boundsMatch(lo: { number }, hi: { number }, want: any, eps: numbe
|
||||
return eq({ lo[1], lo[3], -hi[2] }, { hi[1], hi[3], -lo[2] }, want.min, want.max)
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local checked = { assimp = 0, blender = 0, roundTrips = 0, failed = 0 }
|
||||
local scenes = {}
|
||||
for i, c in Cases do
|
||||
@@ -152,8 +145,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against assimp, %d against Blender, %d rejected by both", #Cases, checked.assimp, checked.blender, checked.failed)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
-- world triangles (area, count, bounds), materials, textures, skins, morph targets, animation samples, cameras, lights
|
||||
local function compare(a: any, b: any, label: string, eps: number)
|
||||
local ma, mb = MeshOps.merge(a), MeshOps.merge(b)
|
||||
local na = if ma and ma.indices then ma.indices.count // 3 else 0
|
||||
@@ -281,7 +272,6 @@ local function compare(a: any, b: any, label: string, eps: number)
|
||||
for ai, an in a.animations do
|
||||
local bn = b.animations[ai]
|
||||
if bn then
|
||||
-- channels by node name + path
|
||||
local byKey = {}
|
||||
for _, ch in an.channels do
|
||||
byKey[(a.nodes[ch.node].name or "") .. "/" .. ch.path] = ch
|
||||
@@ -336,7 +326,6 @@ for i, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- glTF sample models through FBX
|
||||
local ng = 0
|
||||
for _, g in GltfCases do
|
||||
local scene, gerr = Gltf.decode(Bytes.reader(buffer.fromstring(g.data)), { files = g.files })
|
||||
@@ -365,8 +354,6 @@ for _, g in GltfCases do
|
||||
end
|
||||
t:note("%d round trips of the reference files (binary + ASCII), %d glTF models through FBX", checked.roundTrips, ng)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cross-check
|
||||
-- assimp and Blender read our files like the originals
|
||||
local nx = 0
|
||||
for _, x in Xcheck do
|
||||
local c = Cases[x.case]
|
||||
@@ -403,7 +390,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by assimp / Blender like the originals", nx)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local byName = {}
|
||||
for i, c in Cases do
|
||||
@@ -463,10 +449,8 @@ do
|
||||
t:check(emb.textures[1] and emb.textures[1].data and emb.meta.source.binary == false, "ASCII: base64 embedded texture")
|
||||
t:eq(emb.meta.up, "z", "3ds Max: Z up")
|
||||
end
|
||||
-- polygons kept / triangulated
|
||||
local box = decode(Cases[2].data)
|
||||
t:check(box.meshes[1].primitives[1].mode == "triangles", "triangulated by default")
|
||||
-- through the api
|
||||
local s = F.load(Cases[2].data)
|
||||
t:check(s and s.kind == "scene" and s.meta.source.format == "fbx", "F.load detects binary FBX")
|
||||
local viaApi = F.save(s, nil, { format = "fbx" })
|
||||
@@ -493,7 +477,6 @@ do
|
||||
t:check(qb and qb.meshes[1].primitives[1].faces.count == 1 and qb.meshes[1].primitives[1].indices.count == 4, "a quad stays one polygon")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("; FBX 6.1.0 project file\nFBXHeaderExtension: {\n\tFBXVersion: 6100\n}\n")
|
||||
t:check(e1 and e1.code == Err.UNSUPPORTED, "FBX 6: " .. tostring(e1))
|
||||
@@ -514,7 +497,6 @@ do
|
||||
t:check(e8 and e8.code == Err.ARG, "encode version 6100")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Cases do
|
||||
|
||||
Reference in new issue
Block a user