diff --git a/src/Magnum/SceneTools/Test/CMakeLists.txt b/src/Magnum/SceneTools/Test/CMakeLists.txt index 3c5821a3c..c896d66b6 100644 --- a/src/Magnum/SceneTools/Test/CMakeLists.txt +++ b/src/Magnum/SceneTools/Test/CMakeLists.txt @@ -80,6 +80,8 @@ corrade_add_test(SceneToolsSceneConverterTest SceneConverterTest.cpp SceneConverterTestFiles/quad-duplicates.obj SceneConverterTestFiles/quad-duplicates.ply SceneConverterTestFiles/quad-normals-texcoords.obj + SceneConverterTestFiles/quad-strip.bin + SceneConverterTestFiles/quad-strip.gltf SceneConverterTestFiles/quad.bin SceneConverterTestFiles/quad.gltf SceneConverterTestFiles/quad.obj diff --git a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp index bc10d1a29..2dad7f2f9 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp @@ -212,24 +212,26 @@ const struct { "Fuzzy duplicate removal: 6 -> 4 vertices\n"}, {"one mesh, two converters", Containers::array({ "-C", "MeshOptimizerSceneConverter", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", - "quad.ply", nullptr, + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", + "quad.gltf", "quad.bin", {}}, {"one mesh, two converters, explicit last", Containers::array({ - "-C", "MeshOptimizerSceneConverter", "-C", "StanfordSceneConverter", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", - "quad.ply", nullptr, + "-C", "MeshOptimizerSceneConverter", "-C", "GltfSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", + "quad.gltf", "quad.bin", {}}, {"one mesh, two converters, verbose", Containers::array({ "-C", "MeshOptimizerSceneConverter", "-v", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", - "quad.ply", nullptr, - /** @todo this is a no-op, use some other converter that tests also - that the resulting mesh is actually passed further */ - "Trade::AnySceneImporter::openFile(): using ObjImporter\n" + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", + "quad.gltf", "quad.bin", + /* While this looks like a no-op in the output, it converts a + triangle strip to indexed triangles, which verifies that the output + of MeshOptimizerSceneConverter got actually passed further and not + discarded */ + "Trade::AnySceneImporter::openFile(): using GltfImporter\n" "Trade::MeshOptimizerSceneConverter::convert(): processing stats:\n" " vertex cache:\n" " 4 -> 4 transformed vertices\n" @@ -243,16 +245,16 @@ const struct { " 65536 -> 65536 shaded pixels\n" " 65536 -> 65536 covered pixels\n" " overdraw 1 -> 1\n" - "Trade::AnySceneConverter::convertToFile(): using StanfordSceneConverter\n"}, + "Trade::AnySceneConverter::convertToFile(): using GltfSceneConverter\n"}, {"one mesh, two converters, explicit last, verbose", Containers::array({ - "-C", "MeshOptimizerSceneConverter", "-C", "StanfordSceneConverter", "-v", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", - "quad.ply", nullptr, + "-C", "MeshOptimizerSceneConverter", "-C", "GltfSceneConverter", "-v", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", + "quad.gltf", "quad.bin", /* As the importers and converters are specified explicitly, there's no messages from AnySceneConverter, OTOH as we have more than one -C option the verbose output includes a progress info */ - "Trade::AnySceneImporter::openFile(): using ObjImporter\n" + "Trade::AnySceneImporter::openFile(): using GltfImporter\n" "Processing (1/2) with MeshOptimizerSceneConverter...\n" "Trade::MeshOptimizerSceneConverter::convert(): processing stats:\n" " vertex cache:\n" @@ -267,38 +269,38 @@ const struct { " 65536 -> 65536 shaded pixels\n" " 65536 -> 65536 covered pixels\n" " overdraw 1 -> 1\n" - "Saving output (2/2) with StanfordSceneConverter...\n"}, + "Saving output (2/2) with GltfSceneConverter...\n"}, {"one mesh, two converters, options for the first only", Containers::array({ "-C", "MeshOptimizerSceneConverter", "-c", "nonexistentMeshOptimizerOption=yes", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), + "GltfImporter", "GltfSceneConverter", "quad.ply", nullptr, "Option nonexistentMeshOptimizerOption not recognized by MeshOptimizerSceneConverter\n"}, {"one mesh, two converters, explicit last, options for the first only", Containers::array({ "-C", "MeshOptimizerSceneConverter", "-c", "nonexistentMeshOptimizerOption=yes", "-C", "StanfordSceneConverter", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), + "GltfImporter", "GltfSceneConverter", "quad.ply", nullptr, "Option nonexistentMeshOptimizerOption not recognized by MeshOptimizerSceneConverter\n"}, {"one mesh, two converters, options for both", Containers::array({ "-C", "MeshOptimizerSceneConverter", "-c", "nonexistentMeshOptimizerOption=yes", "-c", "nonexistentAnyConverterOption=no", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", "quad.ply", nullptr, "Option nonexistentMeshOptimizerOption not recognized by MeshOptimizerSceneConverter\n" - "Trade::AnySceneConverter::convertToFile(): option nonexistentAnyConverterOption not recognized by StanfordSceneConverter\n"}, + "Trade::AnySceneConverter::convertToFile(): option nonexistentAnyConverterOption not recognized by GltfSceneConverter\n"}, {"one mesh, two converters, explicit last, options for both", Containers::array({ "-C", "MeshOptimizerSceneConverter", "-c", "nonexistentMeshOptimizerOption=yes", "-C", "StanfordSceneConverter", "-c", "nonexistentStanfordConverterOption=no", - Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad.obj"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply")}), - "ObjImporter", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/quad-strip.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.gltf")}), + "GltfImporter", "GltfSceneConverter", "quad.ply", nullptr, "Option nonexistentMeshOptimizerOption not recognized by MeshOptimizerSceneConverter\n" "Option nonexistentStanfordConverterOption not recognized by StanfordSceneConverter\n"}, diff --git a/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin new file mode 100644 index 000000000..bc7b194eb Binary files /dev/null and b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin differ diff --git a/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin.in b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin.in new file mode 100644 index 000000000..8792d7ef4 --- /dev/null +++ b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.bin.in @@ -0,0 +1,13 @@ +type = "3f3f3f3f" +input = [ + # 2--3 2 2--3 + # |\ | -> |\ \ | + # | \| | \ \| + # 0--1 0--1 1 + -1, -1, 0, + 1, -1, 0, + -1, 1, 0, + 1, 1, 0, +] + +# kate: hl python diff --git a/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.gltf b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.gltf new file mode 100644 index 000000000..ec94c181d --- /dev/null +++ b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/quad-strip.gltf @@ -0,0 +1,38 @@ +{ + "asset": { + "version": "2.0" + }, + "buffers": [ + { + "uri": "quad-strip.bin", + "byteLength": 48 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteOffset": 0, + "byteLength": 48 + } + ], + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "mode": 5 + } + ] + } + ] +}