From fee4de16fe7bff816ffab38e7da2e32cd261a3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 18 Jan 2023 17:47:02 +0100 Subject: [PATCH] sceneconverter: test also behavior with ignored contents. --- src/Magnum/SceneTools/Test/CMakeLists.txt | 1 + .../SceneTools/Test/SceneConverterTest.cpp | 27 +++++++ .../ignoring-unsupported.gltf | 77 +++++++++++++++++++ src/Magnum/SceneTools/sceneconverter.cpp | 2 + 4 files changed, 107 insertions(+) create mode 100644 src/Magnum/SceneTools/Test/SceneConverterTestFiles/ignoring-unsupported.gltf diff --git a/src/Magnum/SceneTools/Test/CMakeLists.txt b/src/Magnum/SceneTools/Test/CMakeLists.txt index e74989316..9bbcf6441 100644 --- a/src/Magnum/SceneTools/Test/CMakeLists.txt +++ b/src/Magnum/SceneTools/Test/CMakeLists.txt @@ -107,6 +107,7 @@ if(CORRADE_TARGET_UNIX AND NOT CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT) SceneConverterTestFiles/images-3d.gltf SceneConverterTestFiles/images-3d-1x1x1.bin SceneConverterTestFiles/images-3d-1x1x1.gltf + SceneConverterTestFiles/ignoring-unsupported.gltf SceneConverterTestFiles/info-data.txt SceneConverterTestFiles/info-data-ignored-output.txt SceneConverterTestFiles/info-converter.txt diff --git a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp index ba1eef78d..ea68f4c4f 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp @@ -664,6 +664,33 @@ const struct { "Processing 3D image 1 with StbResizeImageConverter...\n" "Trade::AbstractSceneConverter::addImporterContents(): adding texture 0 out of 2\n" "Trade::AbstractSceneConverter::addImporterContents(): adding texture 1 out of 2\n"}, + {"data unsupported by the converter", {InPlaceInit, { + "-I", "GltfImporter", "-i", "experimentalKhrTextureKtx", + "-C", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/ignoring-unsupported.gltf"), + Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply") + }}, + "GltfImporter", "KtxImporter", "StanfordSceneConverter", + {"StbResizeImageConverter", nullptr}, nullptr, + "quad.ply", nullptr, + "Trade::AbstractSceneConverter::addSupportedImporterContents(): ignoring 1 2D images not supported by the converter\n" + "Trade::AbstractSceneConverter::addSupportedImporterContents(): ignoring 1 3D images not supported by the converter\n" + "Trade::AbstractSceneConverter::addSupportedImporterContents(): ignoring 2 textures not supported by the converter\n"}, + {"per-image processed images unsupported by the converter", {InPlaceInit, { + "-I", "GltfImporter", "-i", "experimentalKhrTextureKtx", + "-P", "StbResizeImageConverter", "-p", "size=\"1 1\"", + "-C", "StanfordSceneConverter", + Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/ignoring-unsupported.gltf"), + Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad.ply") + }}, + "GltfImporter", "KtxImporter", "StanfordSceneConverter", + {"StbResizeImageConverter", nullptr}, nullptr, + "quad.ply", nullptr, + /* Compared to "data unsupported by the converter" these messages are + printed by sceneconverter itself, not the converter interface */ + "Ignoring 1 2D images not supported by the converter\n" + "Ignoring 1 3D images not supported by the converter\n" + "Trade::AbstractSceneConverter::addSupportedImporterContents(): ignoring 2 textures not supported by the converter\n"}, }; const struct { diff --git a/src/Magnum/SceneTools/Test/SceneConverterTestFiles/ignoring-unsupported.gltf b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/ignoring-unsupported.gltf new file mode 100644 index 000000000..1cb4f720c --- /dev/null +++ b/src/Magnum/SceneTools/Test/SceneConverterTestFiles/ignoring-unsupported.gltf @@ -0,0 +1,77 @@ +{ + "asset": { + "version": "2.0", + "note": "Contains one mesh equivalent to quad.ply and images etc that will cause warnings during conversion" + }, + "extensionsUsed": [ + "KHR_texture_ktx" + ], + "extensionsRequired": [ + "KHR_texture_ktx" + ], + "buffers": [ + { + "uri": "quad.bin", + "byteLength": 72 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteOffset": 0, + "byteLength": 24 + }, + { + "buffer": 0, + "byteOffset": 24, + "byteLength": 48 + } + ], + "accessors": [ + { + "bufferView": 0, + "componentType": 5125, + "count": 6, + "type": "SCALAR" + }, + { + "bufferView": 1, + "componentType": 5126, + "count": 4, + "type": "VEC3" + } + ], + "meshes": [ + { + "primitives": [ + { + "indices": 0, + "attributes": { + "POSITION": 1 + } + } + ] + } + ], + "images": [ + { + "uri": "red2x2.png" + }, + { + "uri": "blue4x4x1.ktx2" + } + ], + "textures": [ + { + "source": 0 + }, + { + "extensions": { + "KHR_texture_ktx": { + "source": 1, + "layer": 0 + } + } + } + ] +} diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index 86e512e3b..a0c31e88f 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -1067,6 +1067,8 @@ well, the IDs reference attributes of the first mesh.)") takes them from the importer instead */ if(meshes) { if(!(Trade::sceneContentsFor(*converter) & Trade::SceneContent::Meshes)) { + /** @todo test this branch once there's a plugin that doesn't + support meshes (URDF exporter, for example? glXF?) */ Warning{} << "Ignoring" << meshes.size() << "meshes not supported by the converter"; } else for(UnsignedInt j = 0; j != meshes.size(); ++j) { Trade::Implementation::Duration d{conversionTime};