Browse Source

sceneconverter: adapt tests to GltfImporter and SceneConverter changes.

pull/595/head
Vladimír Vondruš 4 years ago
parent
commit
e808d10c85
  1. 1
      src/Magnum/SceneTools/Test/CMakeLists.txt
  2. 6
      src/Magnum/SceneTools/Test/SceneConverterTest.cpp
  3. 10
      src/Magnum/SceneTools/Test/SceneConverterTestFiles/images-3d-1x1x1.gltf
  4. 75
      src/Magnum/SceneTools/Test/SceneConverterTestFiles/two-triangles-transformed-no-default-scene.gltf
  5. 3
      src/Magnum/SceneTools/Test/SceneConverterTestFiles/two-triangles-transformed.gltf
  6. 11
      src/Magnum/SceneTools/sceneconverter.cpp

1
src/Magnum/SceneTools/Test/CMakeLists.txt

@ -138,6 +138,7 @@ if(CORRADE_TARGET_UNIX AND NOT CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT)
SceneConverterTestFiles/two-quads.gltf
SceneConverterTestFiles/two-triangles-transformed.bin
SceneConverterTestFiles/two-triangles-transformed.gltf
SceneConverterTestFiles/two-triangles-transformed-no-default-scene.gltf
SceneConverterTestFiles/two-triangles.obj)
target_include_directories(SceneToolsSceneConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
if(MAGNUM_WITH_SCENECONVERTER)

6
src/Magnum/SceneTools/Test/SceneConverterTest.cpp

@ -176,6 +176,12 @@ const struct {
"GltfImporter", nullptr, "StanfordSceneConverter", {}, nullptr,
"quad-duplicates.ply", nullptr,
{}},
{"concatenate meshes with a scene but no default scene", Containers::array<Containers::String>({
"--concatenate-meshes",
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterTestFiles/two-triangles-transformed-no-default-scene.gltf"), Utility::Path::join(SCENETOOLS_TEST_OUTPUT_DIR, "SceneConverterTestFiles/quad-duplicates.ply")}),
"GltfImporter", nullptr, "StanfordSceneConverter", {}, nullptr,
"quad-duplicates.ply", nullptr,
{}},
/** @todo drop --mesh once it's not needed anymore again, then add a
multi-mesh variant */
{"one mesh, filter mesh attributes", Containers::array<Containers::String>({

10
src/Magnum/SceneTools/Test/SceneConverterTestFiles/images-3d-1x1x1.gltf

@ -26,8 +26,17 @@
"byteLength": 255
}
],
"samplers": [
{
"wrapS": 10497,
"wrapT": 10497,
"minFilter": 9987,
"magFilter": 9729
}
],
"textures": [
{
"sampler": 0,
"extensions": {
"KHR_texture_ktx": {
"source": 0,
@ -36,6 +45,7 @@
}
},
{
"sampler": 0,
"extensions": {
"KHR_texture_ktx": {
"source": 1,

75
src/Magnum/SceneTools/Test/SceneConverterTestFiles/two-triangles-transformed-no-default-scene.gltf

@ -0,0 +1,75 @@
{
"asset": {
"version": "2.0"
},
"buffers": [
{
"uri": "two-triangles-transformed.bin",
"byteLength": 72
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 36
},
{
"buffer": 0,
"byteOffset": 36,
"byteLength": 36
}
],
"accessors": [
{
"bufferView": 0,
"componentType": 5126,
"count": 3,
"type": "VEC3"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 3,
"type": "VEC3"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"POSITION": 0
}
}
]
},
{
"primitives": [
{
"attributes": {
"POSITION": 1
}
}
]
}
],
"nodes": [
{
"mesh": 0
},
{
"name": "Explicit intermediate node to test proper traversal",
"translation": [0, -5, 0],
"children": [2]
},
{
"mesh": 1,
"translation": [0, -5, 0]
}
],
"scenes": [
{
"nodes": [0, 1]
}
]
}

3
src/Magnum/SceneTools/Test/SceneConverterTestFiles/two-triangles-transformed.gltf

@ -71,5 +71,6 @@
{
"nodes": [0, 1]
}
]
],
"scene": 0
}

11
src/Magnum/SceneTools/sceneconverter.cpp

@ -621,13 +621,16 @@ well, the IDs reference attributes of the first mesh.)")
/* If there's a scene, use it to flatten mesh hierarchy. If not,
assume all meshes are in the root. */
/** @todo make it possible to choose the scene */
if(importer->defaultScene() != -1) {
if(importer->defaultScene() != -1 || importer->sceneCount()) {
Containers::Optional<Trade::SceneData> scene;
{
/** @todo make it possible to choose the scene, or possibly
fail if there are multiple scenes but no default one
and require the user to pick? */
const UnsignedInt defaultScene = importer->defaultScene() == -1 ? 0 : importer->defaultScene();
Trade::Implementation::Duration d{importConversionTime};
if(!(scene = importer->scene(importer->defaultScene()))) {
Error{} << "Cannot import scene" << importer->defaultScene() << "for mesh concatenation";
if(!(scene = importer->scene(defaultScene))) {
Error{} << "Cannot import scene" << defaultScene << "for mesh concatenation";
return 1;
}
}

Loading…
Cancel
Save