Browse Source

sceneconverter: test also behavior with ignored contents.

pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
fee4de16fe
  1. 1
      src/Magnum/SceneTools/Test/CMakeLists.txt
  2. 27
      src/Magnum/SceneTools/Test/SceneConverterTest.cpp
  3. 77
      src/Magnum/SceneTools/Test/SceneConverterTestFiles/ignoring-unsupported.gltf
  4. 2
      src/Magnum/SceneTools/sceneconverter.cpp

1
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

27
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 {

77
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
}
}
}
]
}

2
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};

Loading…
Cancel
Save