From 6f8ad66a907ae11a8a1774a86d129226be08c8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 11 May 2021 13:37:06 +0200 Subject: [PATCH] sceneconverter: list also animations in --info. --- doc/changelog.dox | 4 +- src/Magnum/MeshTools/sceneconverter.cpp | 57 ++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 5f35b0a00..0ce99357e 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -266,8 +266,8 @@ See also: - Added a `--bounds` option to @ref magnum-sceneconverter "magnum-sceneconverter", showing data ranges of known attributes -- @ref magnum-sceneconverter "magnum-sceneconverter" now lists also lights, - materials and textures in `--info` +- @ref magnum-sceneconverter "magnum-sceneconverter" now lists also + animations, lights, materials and textures in `--info` @subsubsection changelog-latest-changes-platform Platform libraries diff --git a/src/Magnum/MeshTools/sceneconverter.cpp b/src/Magnum/MeshTools/sceneconverter.cpp index fcb3f58c6..be9639758 100644 --- a/src/Magnum/MeshTools/sceneconverter.cpp +++ b/src/Magnum/MeshTools/sceneconverter.cpp @@ -40,6 +40,7 @@ #include "Magnum/Math/FunctionsBatch.h" #include "Magnum/MeshTools/RemoveDuplicates.h" #include "Magnum/Trade/AbstractImporter.h" +#include "Magnum/Trade/AnimationData.h" #include "Magnum/Trade/LightData.h" #include "Magnum/Trade/MaterialData.h" #include "Magnum/Trade/MeshData.h" @@ -282,6 +283,12 @@ used.)") return 0; } + struct AnimationInfo { + UnsignedInt animation; + Trade::AnimationData data{{}, {}}; + std::string name; + }; + struct LightInfo { UnsignedInt light; UnsignedInt references; @@ -346,8 +353,28 @@ used.)") } } - /* Light properties */ + /* Animation properties */ bool error = false; + Containers::Array animationInfos; + for(UnsignedInt i = 0; i != importer->animationCount(); ++i) { + Containers::Optional animation; + { + Duration d{importTime}; + if(!(animation = importer->animation(i))) { + error = true; + continue; + } + } + + AnimationInfo info{}; + info.animation = i; + info.name = importer->animationName(i); + info.data = *std::move(animation); + + arrayAppend(animationInfos, std::move(info)); + } + + /* Light properties */ Containers::Array lightInfos; for(UnsignedInt i = 0; i != importer->lightCount(); ++i) { Containers::Optional light; @@ -514,6 +541,34 @@ used.)") Containers::Array imageInfos = Trade::Implementation::imageInfo(*importer, error, compactImages); + for(const AnimationInfo& info: animationInfos) { + Debug d; + d << "Animation" << info.animation << Debug::nospace << ":"; + if(!info.name.empty()) d << info.name; + + d << Debug::newline << " Duration:" << info.data.duration(); + + for(UnsignedInt i = 0; i != info.data.trackCount(); ++i) { + d << Debug::newline << " Track" << i << Debug::nospace << ":" + << info.data.trackType(i); + if(info.data.trackType(i) != info.data.trackResultType(i)) + d << "->" << info.data.trackResultType(i); + d << Debug::nospace << "," << info.data.track(i).size() + << "keyframes"; + if(info.data.track(i).duration() != info.data.duration()) + d << Debug::nospace << "," << info.data.track(i).duration(); + d << Debug::newline << " " + << info.data.track(i).interpolation(); + d << Debug::newline << " " + << info.data.track(i).before() << Debug::nospace << "," + << info.data.track(i).after(); + d << Debug::newline << " Target: object" + << info.data.trackTarget(i) << Debug::nospace << "," + << info.data.trackTargetType(i); + /** @todo might be useful to show bounds here as well, though + not so much for things like complex numbers or quats */ + } + } for(const LightInfo& info: lightInfos) { Debug d; d << "Light" << info.light;