I’ve a gltf (.glb) mannequin which I loaded with assimp.
I used to be attempting to implement animations however it seems that this mannequin has no bones, the animation is barely based mostly on full mesh transformation. Right here is the mannequin.
This 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<:node>& allModelNodes) {
Eigen::Matrix4f nodeLocalTransform = node->localTransform;
std::string nodeName = node->identify;
if (anim.tracks.incorporates(nodeName)) {
const BoneAnimation& monitor = anim.tracks.at(nodeName);
Eigen::Matrix4f posMatrix = interpolatePosition(time, monitor);
Eigen::Matrix4f rotMatrix = interpolateRotation(time, monitor);
Eigen::Matrix4f scaleMatrix = interpolateScale(time, monitor);
nodeLocalTransform = posMatrix * rotMatrix * scaleMatrix;
}
Eigen::Matrix4f globalTransform = parentTransform * node->localTransform;
node->animatedTransform = nodeLocalTransform;
if (skeleton.boneMapping.incorporates(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);
}
}
After I strive it I get this:
The slider transfer appropriately, the gun strikes appropriately however the set off is approach too huge.
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 monitor, however the animation monitor’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 monitor incorporates deltas fairly than absolutes) but when I do that nodeLocalTransform = node->localTransform*posMatrix * rotMatrix * scaleMatrix;
I get this

Which I assume fixes the scaling situation however messes up every thing else.
Anyhow I’ve tried many alternative issues however I simply cannot discover easy methods to make it work.
I do know that the mannequin is not the difficulty as a result of each 3d viewer I attempted present the animation simply positive.
