基本使用
对于类型为 FBModel 的对象,有 GetMatrix() SetMatrix() 方法来获取及设置其变换矩阵
GetMatrix(pMatrix: FBMatrix, pWhat = kModelTransformation, pGlobalInfo = True, pEvaluateInfo = None)
pMatrix:
Matrix to fill with requested information.
pWhat
Type of information requested (default=transformation).
pGlobalInfo
true if it is GlobalInfo, false if Local (default=true).
pEvaluateInfo
EvaluateInfo, Take Display if none specified.
矩阵变换顺序(Matrix Transformation Order)
在Motionbuilder中,模型的全局平移、旋转和旋转矩阵都是单独计算的。这些矩阵计算遵循特定的顺序,如下所示,使用
M
M
M 后缀表示矩阵,使用
V
V
V 后缀表示向量。
全局旋转矩阵
计算局部旋转矩阵和全局旋转矩阵如下所示,矩阵是从右向左应用的。
R
o
t
a
t
i
o
n
D
o
F
M
=
K
R
o
t
a
t
i
o
n
M
⋅
J
R
o
t
a
t
i
o
n
M
⋅
I
R
o
t
a
t
i
o
n
M
RotationDoFM=KRotationM\cdot JRotationM \cdot IRotationM
RotationDoFM=KRotationM⋅JRotationM⋅IRotationM
见上式,其中
I
R
o
t
a
t
i
o
n
M
IRotationM
IRotationM,
J
R
o
t
a
t
i
o
n
M
JRotationM
JRotationM,
K
R
o
t
a
t
i
o
n
KRotation
KRotation 描述的是围绕每个局部旋转轴的旋转量。例如如果模型的旋转循序为
Z
Y
X
ZYX
ZYX
那么
I
R
o
t
a
t
i
o
n
M
IRotationM
IRotationM 表示
Z
Z
Z 轴的旋转量,
J
R
o
t
a
t
i
o
n
M
JRotationM
JRotationM 描述的是
Y
Y
Y 轴的旋转量,
K
R
o
t
a
t
i
o
n
KRotation
KRotation 描述的是
Z
Z
Z 轴的旋转量。
L
o
c
a
l
R
o
t
a
t
i
o
n
M
=
P
r
e
R
o
t
a
t
i
o
n
M
⋅
R
o
t
a
t
i
o
n
D
o
F
M
⋅
P
o
s
t
R
o
t
a
t
i
o
n
M
−
1
LocalRotationM=PreRotationM \cdot RotationDoFM \cdot PostRotationM^{-1}
LocalRotationM=PreRotationM⋅RotationDoFM⋅PostRotationM−1
见上式,
P
o
s
t
R
o
t
a
t
i
o
n
M
−
1
PostRotationM^{-1}
PostRotationM−1 描述的是
P
o
s
t
R
o
t
a
t
i
o
n
M
PostRotationM
PostRotationM 的逆矩阵。
当你想要创建一个T-pose(每个局部旋转轴的值为0的骨骼)骨架时,Post Rotation是有用的。如果你改变了前后旋转,这将影响模型的子模型。要只影响模型的几何形状,可以更改FBModel.GeometricTranslation, FBModel.GeometricRotation 与 FBModel.GeometricScaling。
G
l
o
b
a
l
R
o
t
a
t
i
o
n
M
=
P
a
r
e
n
t
G
l
o
b
a
l
R
o
t
a
t
i
o
n
M
⋅
L
o
c
a
l
R
o
t
a
t
i
o
n
M
GlobalRotationM = ParentGlobalRotationM \cdot LocalRotationM
GlobalRotationM=ParentGlobalRotationM⋅LocalRotationM
见上式,当
P
a
r
e
n
t
G
l
o
b
a
l
R
o
t
a
t
i
o
n
M
ParentGlobalRotationM
ParentGlobalRotationM 矩阵是当前对象的父节点的
G
l
o
b
a
l
R
o
t
a
t
i
o
n
M
GlobalRotationM
GlobalRotationM。所得到的局部旋转矩阵(
L
o
c
a
l
R
o
t
a
t
i
o
n
M
LocalRotationM
LocalRotationM)稍后将用于全局缩放和位移矩阵的计算。
全局缩放矩阵
G
l
o
b
a
l
S
c
a
l
e
V
=
P
a
r
e
n
t
G
l
o
b
a
l
S
c
a
l
e
V
⋅
L
o
c
a
l
S
c
a
l
e
V
(1.1)
\tag{1.1}GlobalScaleV = ParentGlobalScaleV \cdot LocalScaleV
GlobalScaleV=ParentGlobalScaleV⋅LocalScaleV(1.1)
全局缩放矩阵表示为
G
l
o
b
a
l
S
c
a
l
e
M
GlobalScaleM
GlobalScaleM ,其计算根据自身父级的比例继承类型而不同。
Local (
R
r
S
s
RrSs
RrSs) 见式(1.1)表示局部缩放模式,在X、Y、Z轴上缩放父对象时,子对象也转换为与父对象保持成比例的距离。可以在不影响父对象的情况下缩放子对象。
G
l
o
b
a
l
S
c
a
l
e
M
=
L
o
c
a
l
R
o
t
a
t
i
o
n
M
−
1
⋅
P
a
r
e
n
t
G
l
o
b
a
l
S
c
a
l
e
M
⋅
L
o
c
a
l
R
o
t
a
t
i
o
n
M
⋅
L
o
c
a
l
S
c
a
l
e
M
(1.2)
\tag{1.2}GlobalScaleM=LocalRotationM^{-1}\cdot ParentGlobalScaleM \cdot LocalRotationM \cdot LocalScaleM
GlobalScaleM=LocalRotationM−1⋅ParentGlobalScaleM⋅LocalRotationM⋅LocalScaleM(1.2)
Parent (
R
S
r
s
RSrs
RSrs) 激活父缩放模式,见式(1.2),其计算依赖于上文定义的局部旋转矩阵
L
o
c
a
l
R
o
t
a
t
i
o
n
M
LocalRotationM
LocalRotationM 如果在一个轴上缩放父对象,子对象会变形以保持它们的体积,同事拉伸到同一轴上的缩放。
G
l
o
b
a
l
S
c
a
l
e
M
=
L
o
c
a
l
R
o
t
a
t
i
o
n
M
−
1
⋅
P
a
r
e
n
t
G
l
o
b
a
l
S
c
a
l
e
M
⋅
P
a
r
e
n
t
L
o
c
a
l
S
c
a
l
e
M
−
1
⋅
L
o
c
a
l
R
o
t
a
t
i
o
n
M
⋅
L
o
c
a
l
S
c
a
l
e
M
(1.3)
\tag{1.3}GlobalScaleM = LocalRotationM^{-1}\cdot ParentGlobalScaleM \cdot ParentLocalScaleM^{-1} \cdot LocalRotationM \cdot LocalScaleM
GlobalScaleM=LocalRotationM−1⋅ParentGlobalScaleM⋅ParentLocalScaleM−1⋅LocalRotationM⋅LocalScaleM(1.3)
Scale Compensate (比例补偿)。见式(1.3)在这个模式下,子对象不从父对象继承缩放。当父对象被缩放时,子对象不会缩放,而是转换以保持模型之间的比例距离。
全局位移矩阵
S
c
a
l
e
P
i
v
o
t
T
r
a
n
s
l
a
t
i
o
n
V
=
(
I
−
L
o
c
a
l
S
c
a
l
e
M
)
⋅
S
c
a
l
e
P
i
v
o
t
V
+
S
c
a
l
e
P
i
v
o
t
O
f
f
s
e
t
V
ScalePivotTranslationV = (I - LocalScaleM) \cdot ScalePivotV + ScalePivotOffsetV
ScalePivotTranslationV=(I−LocalScaleM)⋅ScalePivotV+ScalePivotOffsetV
其中
I
I
I为单位矩阵
S
c
a
l
e
A
n
d
R
o
t
a
t
e
P
i
v
o
t
T
r
a
n
s
l
a
t
i
o
n
V
=
(
L
o
c
a
l
R
o
t
a
t
i
o
n
M
⋅
(
S
c
a
l
e
P
i
v
o
t
T
r
a
n
s
l
a
t
i
o
n
V
−
R
o
t
a
t
i
o
n
P
i
v
o
t
V
)
)
+
R
o
t
a
t
i
o
n
P
i
v
o
t
V
+
R
o
t
a
t
i
o
n
P
i
v
o
t
O
f
f
s
e
t
V
ScaleAndRotatePivotTranslationV=(LocalRotationM \cdot (ScalePivotTranslationV - RotationPivotV))+RotationPivotV + RotationPivotOffset V
ScaleAndRotatePivotTranslationV=(LocalRotationM⋅(ScalePivotTranslationV−RotationPivotV))+RotationPivotV+RotationPivotOffsetV
L
o
c
a
l
T
r
a
n
s
l
a
t
i
o
n
V
=
T
r
a
n
s
l
a
t
i
o
n
D
o
F
V
+
R
o
t
a
t
i
o
n
P
i
v
o
t
T
r
a
n
s
l
a
t
i
o
n
V
LocalTranslationV = TranslationDoFV + RotationPivotTranslationV
LocalTranslationV=TranslationDoFV+RotationPivotTranslationV
G
l
o
b
a
l
T
r
a
n
s
l
a
t
i
o
n
V
=
P
a
r
e
n
t
G
l
o
b
a
l
T
r
a
n
s
f
o
r
m
a
t
i
o
n
M
⋅
L
o
c
a
l
T
r
a
n
s
l
a
t
i
o
n
V
GlobalTranslationV = ParentGlobalTransformationM \cdot LocalTranslationV
GlobalTranslationV=ParentGlobalTransformationM⋅LocalTranslationV
全局变换矩阵
全局变换矩阵是全局位移、旋转及缩放矩阵的组合
G
l
o
b
a
l
T
r
a
n
s
f
o
r
m
a
t
i
o
n
M
a
t
r
i
x
=
G
l
o
b
a
l
T
r
a
n
s
l
a
t
i
o
n
M
⋅
G
l
o
b
a
l
R
o
t
a
t
i
o
n
M
⋅
G
l
o
b
a
l
S
c
a
l
e
M
GlobalTransformationMatrix = GlobalTranslationM \cdot GlobalRotationM \cdot GlobalScaleM
GlobalTransformationMatrix=GlobalTranslationM⋅GlobalRotationM⋅GlobalScaleM
官方文档
FBModel 文档