简体   繁体   English

意外的 transformationMatrix 和 offset Matrix with Skeletal Animation

[英]Unexpected transformationMatrix and offset Matrix with Skeletal Animation

What I use:我用什么:

  • Assimp to import.fbx files from blender Assimp 从搅拌机导入.fbx 文件
  • OpenGL for rendering OpenGL 用于渲染
  • glm lib for handling matrices and vectors用于处理矩阵和向量的 glm 库

I am trying to make skeletal animation work.我正在尝试使骨架 animation 工作。 I dont read the.fbx file directly into the Program but I convert it to a binary at first.我没有将 .fbx 文件直接读入程序,但我首先将其转换为二进制文件。 I tried to understand how transformationMatrix and offsetMatrix is supposed to work.我试图了解 transformationMatrix 和 offsetMatrix 应该如何工作。 This is what I understood: In order to later be able to run an animation, we need to find a way to make a moving Bone affect its vertices but also the bones connected to it.这就是我的理解:为了稍后能够运行 animation,我们需要找到一种方法让移动的骨骼影响其顶点以及与其相连的骨骼。 So the idea is to use transformation matrices, which describe the coordinate system of a bone or a node and we multiply along these paths to a bone and then multiply by is offsetMatrix to be back in objectSpace.所以我们的想法是使用变换矩阵,它描述了骨骼或节点的坐标系,我们沿着这些路径与骨骼相乘,然后乘以 offsetMatrix 返回到 objectSpace。 I think by now I tried every possible combination of multiplying these but I always get something wrong.我想现在我已经尝试了所有可能的乘法组合,但我总是出错。 Then I looked at the values a couple of times and to me it is not obvious at all how this should work.然后我看了几次这些值,对我来说这应该如何工作一点都不明显。 Correct me if I am wrong but my expectation is that when in BindPose and using the offsetMatrices and transformationMatrices from the Assimp import I must result with an identity Matrix, because I want my model in bind pose just as without those Matrices.如果我错了,请纠正我,但我的期望是,当在 BindPose 中并使用来自 Assimp 导入的 offsetMatrices 和 transformationMatrices 时,我必须得到一个恒等矩阵,因为我希望我的 model 处于绑定姿势,就像没有这些矩阵一样。 These are the transformation Matrices from all nodes up to the first bone:这些是从所有节点到第一个骨骼的变换矩阵:

The Root Node is identity根节点是身份

Armature mTransformationMatrix:电枢 mTransformationMatrix:

100 0 0 0 
0 -1.6e-05 100 0
0 -100 -1.629e-05 0
0 0 0 1

Bone mTransformationMatrix:骨骼 mTransformationMatrix:

1 0 0 0
0 1.6e-07 -1 0
0 1 -1.6e-07 0
0 0 0 1  

I expect those two to result with something like an identity*100 when multiplied.我希望这两个结果相乘时会产生类似 identity*100 的结果。

mOffsetMatrix of the corresponding Bone:对应Bone的mOffsetMatrix:

0.38 0 0 0 
0 0 -1 0 
0 0.28 0 0
0 0 1.67 1

In my opinion this doesnt help me at all.在我看来,这对我没有任何帮助。 So either my expectaiton to result with an identity matrix are wrong or the offsetMatrix is.因此,要么我对单位矩阵的期望是错误的,要么是 offsetMatrix。

In case you consider it important what my model looks like:如果您认为我的 model 长什么样很重要:

来自 Blender 中的 bindPose

Edit: I forgot to mention: to read in the aiMatrix4x4 I use编辑:我忘了提及:阅读我使用的 aiMatrix4x4

static inline glm::mat4 mat4_cast(const aiMatrix4x4& m) { return glm::transpose(glm::make_mat4(&m.a1)); }

But the transformationMatrices I wrote in this report are directly from the Scene so only the offsetMatrix is transposed.但是我在这份报告中写的 transformationMatrices 是直接来自场景的,所以只有 offsetMatrix 被转置了。 But this doesn't change a thing.但这并没有改变一件事。

I found the problem.我发现了问题。 The problem is that I also have to transform from meshSpace back to object space.问题是我还必须从 meshSpace 转换回 object 空间。 The offset Matrix is the inverse of the tranformation Matrices multiplied and also multiplied with the inverse of the transformation Matrix to the Mesh which is on a different node.偏移矩阵是变换矩阵的逆相乘,并且还乘以变换矩阵的逆矩阵到不同节点上的网格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM