Browse Source

AnySceneConverter: recognize glTF files.

pull/589/head
Vladimír Vondruš 4 years ago
parent
commit
213e80426d
  1. 1
      doc/changelog.dox
  2. 10
      src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp
  3. 2
      src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h
  4. 4
      src/MagnumPlugins/AnySceneConverter/Test/AnySceneConverterTest.cpp

1
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}

10
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;

2
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

4
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"}

Loading…
Cancel
Save