本文整理匯總了Python中mathutils.Quaternion.to_4x4方法的典型用法代碼示例。如果您正苦於以下問題:Python Quaternion.to_4x4方法的具體用法?Python Quaternion.to_4x4怎麽用?Python Quaternion.to_4x4使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mathutils.Quaternion
的用法示例。
在下文中一共展示了Quaternion.to_4x4方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_bones
# 需要導入模塊: from mathutils import Quaternion [as 別名]
# 或者: from mathutils.Quaternion import to_4x4 [as 別名]
def _create_bones(self, bone, parent):
abone = self._armature.edit_bones.new(bone.name)
abone.tail = Vector([0, 1, 0])
if parent:
abone.parent = parent
rot_part = Quaternion(bone.rotation).inverted().to_matrix()
pos_part = Vector(bone.position)
transform = Matrix.Translation(bone.position) * rot_part.to_4x4()
if parent:
transform = parent.matrix * transform
rot_part = transform.to_3x3()
pos_part = transform.to_translation()
# abone.transform(transform)
abone.transform(rot_part)
abone.translate(pos_part)
nrm_mtx = transform.to_3x3()
nrm_mtx.invert()
nrm_mtx.transpose()
for vi in range(0, bone.vertex_count):
vt_ind = vi + bone.vertex_index
self._file.vertices[vt_ind] = list(transform * Vector(self._file.vertices[vt_ind]))
self._file.normals[vt_ind] = list(nrm_mtx * Vector(self._file.normals[vt_ind]))
for child in bone.children:
self._create_bones(child, abone)