本文整理汇总了Python中mathutils.Matrix.to_scale方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.to_scale方法的具体用法?Python Matrix.to_scale怎么用?Python Matrix.to_scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Matrix
的用法示例。
在下文中一共展示了Matrix.to_scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transformToLocal
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_scale [as 别名]
def transformToLocal(vec:Vector, mat:Matrix, junk_bme:bmesh=None):
""" transfrom vector to local space of 'mat' matrix """
# decompose matrix
loc = mat.to_translation()
rot = mat.to_euler()
scale = mat.to_scale()[0]
# apply scale
vec = vec / scale
# apply rotation
if rot != Euler((0, 0, 0), "XYZ"):
junk_bme = bmesh.new() if junk_bme is None else junk_bme
v1 = junk_bme.verts.new(vec)
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.z, 3, 'Z'))
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.y, 3, 'Y'))
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.x, 3, 'X'))
vec = v1.co
return vec
示例2: parse_scale_channel
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_scale [as 别名]
def parse_scale_channel(gltf, node, obj, bone, channel, animation):
"""Manage scaling animation."""
blender_path = "pose.bones[" + json.dumps(bone.name) + "].scale"
group_name = bone.name
keys = BinaryData.get_data_from_accessor(gltf, animation.samplers[channel.sampler].input)
values = BinaryData.get_data_from_accessor(gltf, animation.samplers[channel.sampler].output)
bind_scale = scale_to_matrix(node.blender_bone_matrix.to_scale())
if animation.samplers[channel.sampler].interpolation == "CUBICSPLINE":
# TODO manage tangent?
scale_mats = (
scale_to_matrix(loc_gltf_to_blender(values[idx * 3 + 1]))
for idx in range(0, len(keys))
)
else:
scale_mats = (scale_to_matrix(loc_gltf_to_blender(vals)) for vals in values)
if node.parent is None:
final_scales = [
(bind_scale.inverted() @ scale_mat).to_scale()
for scale_mat in scale_mats
]
else:
if not gltf.data.nodes[node.parent].is_joint:
parent_mat = Matrix()
else:
parent_mat = gltf.data.nodes[node.parent].blender_bone_matrix
final_scales = [
(bind_scale.inverted() @ scale_to_matrix(parent_mat.to_scale()) @ scale_mat).to_scale()
for scale_mat in scale_mats
]
BlenderBoneAnim.fill_fcurves(
obj.animation_data.action,
keys,
final_scales,
group_name,
blender_path,
animation.samplers[channel.sampler].interpolation
)