diff --git a/doc/changelog.dox b/doc/changelog.dox index b40b2014e..15ab0f554 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -539,6 +539,7 @@ See also: [mosra/magnum#529](https://github.com/mosra/magnum/pull/529)) - Recognizing KTX2 for (compressed) 1D/2D/3D and multi-level 1D/2D/3D images in @relativeref{Trade,AnyImageConverter} +- Recognizing glTF files in @relativeref{Trade,AnySceneConverter} - Recognizing 3MF files in @relativeref{Trade,AnySceneImporter} - Recognizing OpenVBD files in @relativeref{Trade,AnyImageImporter} and @relativeref{Trade,AnyImageConverter} diff --git a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp index 747350b79..84c5d126e 100644 --- a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp +++ b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp @@ -83,7 +83,10 @@ bool AnySceneConverter::doConvertToFile(const MeshData& mesh, const Containers:: /* Detect the plugin from extension */ Containers::StringView plugin; - if(normalizedExtension == ".ply"_s) + if(normalizedExtension == ".gltf"_s || + normalizedExtension == ".glb"_s) + plugin = "GltfSceneConverter"_s; + else if(normalizedExtension == ".ply"_s) plugin = "StanfordSceneConverter"_s; else { Error{} << "Trade::AnySceneConverter::convertToFile(): cannot determine the format of" << filename; @@ -132,7 +135,10 @@ bool AnySceneConverter::doBeginFile(const Containers::StringView filename) { /* Detect the plugin from extension */ Containers::StringView plugin; - if(normalizedExtension == ".ply"_s) + if(normalizedExtension == ".gltf"_s || + normalizedExtension == ".glb"_s) + plugin = "GltfSceneConverter"_s; + else if(normalizedExtension == ".ply"_s) plugin = "StanfordSceneConverter"_s; else { Error{} << "Trade::AnySceneConverter::beginFile(): cannot determine the format of" << filename; diff --git a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h index d11296579..8fa18d800 100644 --- a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h +++ b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h @@ -60,6 +60,8 @@ namespace Magnum { namespace Trade { Detects file type based on file extension, loads corresponding plugin and then tries to convert the file with it. Supported formats: +- glTF (`*.gltf`, `*.glb`), converted with @ref GltfSceneConverter or any + other plugin that provides it - Stanford (`*.ply`), converted with @ref StanfordSceneConverter or any other plugin that provides it diff --git a/src/MagnumPlugins/AnySceneConverter/Test/AnySceneConverterTest.cpp b/src/MagnumPlugins/AnySceneConverter/Test/AnySceneConverterTest.cpp index 1b65dda77..7f2526e30 100644 --- a/src/MagnumPlugins/AnySceneConverter/Test/AnySceneConverterTest.cpp +++ b/src/MagnumPlugins/AnySceneConverter/Test/AnySceneConverterTest.cpp @@ -73,6 +73,8 @@ constexpr struct { const char* filename; const char* plugin; } DetectConvertData[]{ + {"glTF", "khronos.gltf", "GltfSceneConverter"}, + {"glTF binary", "khronos.glb", "GltfSceneConverter"}, {"Stanford PLY", "bunny.ply", "StanfordSceneConverter"}, /* Have at least one test case with uppercase */ {"Stanford PLY uppercase", "ARMADI~1.PLY", "StanfordSceneConverter"} @@ -83,6 +85,8 @@ constexpr struct { const char* filename; const char* plugin; } DetectBeginEndData[]{ + {"glTF", "khronos.gltf", "GltfSceneConverter"}, + {"glTF binary", "khronos.glb", "GltfSceneConverter"}, {"Stanford PLY", "bunny.ply", "StanfordSceneConverter"}, /* Have at least one test case with uppercase */ {"Stanford PLY uppercase", "ARMADI~1.PLY", "StanfordSceneConverter"}