我有一组数据,其中我有模型的局部旋转,全局旋转和全局位置。我需要计算每个骨骼的局部位置。
我首先尝试使用bone.globalpos - bone_parent.globalpos然后意识到这些不依赖于旋转,所以这是父骨骼和子骨骼之间的差异。我需要一些关于如何考虑旋转以及骨骼的建议。本地和全局旋转都存储为四元数。
我按照骨骼存储数据
bone.globalpos (Vector3)
bone.globalrot (Quaternion)
bone.localpos (Unknown, but should be a Vector3)
bone.localrot (Quaternion)
由于局部姿势也应该基于旋转,而不仅仅是与父母的距离,我对如何计算它感到迷茫。
示例数据:
bone_parent.globalpos = (-1.252995 8.46457E-05 37.22802)
bone_parent.globalrot = (-0.5405273 -0.4560547 -0.4560547 0.5405273)
bone_parent.localpos = (0 0 0) (I provided)
bone_parent.localrot = (1.0 0.0 0.0 0.0)
bone_child.globalpos = (-1.252995 5.001462 37.22802)
bone_child.globalrot = (0.4948359 0.505096 -0.505096 0.4948359)
bone_child.localpos = (0 0 5.001377) This is what I need to calculate, but here is the answer to what I'm trying to get
bone_child.localrot = (0.07421875 0.9970703 0 0)
答案 0 :(得分:1)
据我所知,你想在父母坐标系中表达方向向量。这可以通过用父反向全局旋转变换方向向量来完成。
child.localPos = transform(conjugate(parent.globalRot), child.globalPos - parent.globalPos)