I’ve a gltf (.glb) mannequin which I loaded with assimp.
I used to be making an attempt to implement animations however it seems that this mannequin has no bones, the animation is simply based mostly on full mesh transformation. Right here is the mannequin.
Here is the code of the animator which is meant to supply the animatedTransform of the node:
void AnimationSystem::applyTransforms(Mannequin::Node* node, const Eigen::Matrix4f& parentTransform, Mannequin::Skeleton& skeleton, double time,
const Animation& anim, std::vector<Mannequin::Node>& allModelNodes) {
Eigen::Matrix4f nodeLocalTransform = node->localTransform;
std::string nodeName = node->title;
if (anim.tracks.comprises(nodeName)) {
const BoneAnimation& observe = anim.tracks.at(nodeName);
Eigen::Matrix4f posMatrix = interpolatePosition(time, observe);
Eigen::Matrix4f rotMatrix = interpolateRotation(time, observe);
Eigen::Matrix4f scaleMatrix = interpolateScale(time, observe);
nodeLocalTransform = posMatrix * rotMatrix * scaleMatrix;
}
Eigen::Matrix4f globalTransform = parentTransform * node->localTransform;
node->animatedTransform = nodeLocalTransform;
if (skeleton.boneMapping.comprises(nodeName)) {
int boneID = skeleton.boneMapping.at(nodeName);
Eigen::Matrix4f finalMatrix = skeleton.globalInverseTransform * globalTransform * skeleton.bones[boneID].offsetMatrix;
skeleton.bones[boneID].finalTransformation = finalMatrix;
}
for (int childIndex : node->youngsters) {
applyTransforms(&allModelNodes[childIndex], globalTransform, skeleton, time, anim, allModelNodes);
}
}
Once I strive it I get this:
The slider transfer accurately, the gun strikes accurately however the set off is means too massive.
After some debugging I discovered that the set off node of the mannequin has a scaling issue != 1.
However after all this code nodeLocalTransform = posMatrix * rotMatrix * scaleMatrix; replaces the localtransform with no matter is the animation observe, however the animation observe’s scaling is 1 in order that explains the discrepancy.
My conclusion could be that we nonetheless have to multiply with the localtransform (I.E the animation observe comprises deltas moderately than absolutes) but when I do that nodeLocalTransform = node->localTransform*posMatrix * rotMatrix * scaleMatrix;
I get this

Which I suppose fixes the scaling problem however messes up all the things else.
In any case I’ve tried many various issues however I simply cannot discover the way to make it work.
I do know that the mannequin is not the problem as a result of each 3d viewer I attempted present the animation simply superb.



