From 6ed99e02a70e7f511a7020c5450a721b20b3ae06 Mon Sep 17 00:00:00 2001 From: dimi309 Date: Sat, 30 Sep 2023 04:53:01 +0200 Subject: [PATCH] Warning about non-support for non-skeletal glTF animation. --- README.md | 6 ++++-- src/GlbFile.cpp | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be391dce..b6faad0a 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,13 @@ and the use of cutting edge methods and technologies. - Font rendering - Sound (ogg and native files) - Collision detection -- Frame-based animation -- Skeletal animation (only based on rigs read from glb files; animation linked directly to models without bones/joints is ignored) +- Frame-based animation (Wavefront) +- Skeletal animation (glTF) # Partly humorous list of things NOT supported +- Animation read from glTF and linked directly to models without bones/joints +- Non-PNG images - Scenes - no Scene data structure; just SceneObjects rendered in an infinite space - Ray tracing - ECS diff --git a/src/GlbFile.cpp b/src/GlbFile.cpp index 441c346f..0691442c 100644 --- a/src/GlbFile.cpp +++ b/src/GlbFile.cpp @@ -991,6 +991,24 @@ namespace small3d { model.origTransformation = tmpNode.transformation * model.origTransformation; } + + uint32_t animationIdx = 0; + bool warnedNonSkeletal = false; + while (existAnimation(animationIdx)) { + auto animation = getAnimation(animationIdx); + for (auto& channel : animation.channels) { + if (channel.target.node == meshNode.index) { + LOGDEBUG("Non-skeletal animation ignored."); + warnedNonSkeletal = true; + break; + } + } + if (warnedNonSkeletal) { + break; + } + ++animationIdx; + } + if (!meshNode.noSkin && existSkin(meshNode.skin)) { auto skin = getSkin(meshNode.skin); @@ -1024,7 +1042,7 @@ namespace small3d { bool inputStored = false; uint32_t storedInput = 0; - uint32_t animationIdx = 0; + animationIdx = 0; while (existAnimation(animationIdx)) { auto animation = getAnimation(animationIdx); @@ -1046,6 +1064,7 @@ namespace small3d { auto output = getBufferByAccessor(sampler.output); + for (auto& joint : model.joints) { if (joint.animations.size() < animationIdx + 1) { joint.animations.emplace_back(Model::JointAnimation()); @@ -1096,6 +1115,7 @@ namespace small3d { } } } + } ++animationIdx; } // end existAnimation loop