问题:
我的目标是编写一个代码,该代码使bvh的根连接旋转,度为全局y轴3.,并将值保持在-180到180的范围内(就像MotionBuilder所做的那样)。我试着用euler,四元数,矩阵来旋转一个关节(考虑bvh的旋转顺序),但是我还没有想出如何得到正确的值。MotionBuilder计算x,y,z值,因此它们对于bvh文件是有效的。我想写一个代码来计算一个关节的旋转x,y,z,就像在MotionBuilder中一样。
示例:
初始:根旋转:[x= -169.56, y=15.97, z=39.57]

手动旋转约45度后:根旋转:[x=-117.81, y=49.37, z=70.15]

全局y轴:

发布于 2019-10-15 00:08:03
若要使节点围绕世界Y轴旋转任意次数,请执行以下工作(矩阵):
import math
from pyfbsdk import *
angle = 45.0
radians = math.radians(angle)
root_matrix = FBMatrix()
root.GetMatrix(root_matrix, FBModelTransformationType.kModelRotation, True)
transformation_matrix = FBMatrix([
math.cos(radians), 0.0, math.sin(radians), 0.0,
0.0, 1.0, 0.0, 0.0,
-math.sin(radians), 0.0, math.cos(radians), 0.0,
0.0, 0.0, 0.0, 1.0
])
result_matrix = root_matrix * transformation_matrix
root.SetMatrix(result_matrix , FBModelTransformationType.kModelRotation, True)如果根节点上有任何预旋转,则过程更复杂,您可以尝试使用SetVector和LRMToDof方法设置旋转。
result_vector = FBVector3d()
root.LRMToDof(result_vector, result_matrix)
root.SetVector(result_vector, FBModelTransformationType.kModelRotation, True)https://stackoverflow.com/questions/55636412
复制相似问题