当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.row[3]方法代码示例

本文整理汇总了Python中mathutils.Matrix.row[3]方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.row[3]方法的具体用法?Python Matrix.row[3]怎么用?Python Matrix.row[3]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mathutils.Matrix的用法示例。


在下文中一共展示了Matrix.row[3]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_bone_matrix

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import row[3] [as 别名]
def get_bone_matrix(armature, bone, relative=True):
    pose_bone = armature.pose.bones[bone.name]

    m = Matrix()  ### inverted posebone origin matrix
    m.row[0] = [0, 0, 1, 0]
    m.row[1] = [1, 0, 0, 0]
    m.row[2] = [0, 1, 0, 0]
    m.row[3] = [0, 0, 0, 1]

    if bone.parent == None:
        mat_bone_space = m * pose_bone.matrix.copy()
    else:
        if relative:
            mat_bone_space = pose_bone.parent.matrix.inverted() * pose_bone.matrix
        else:
            mat_bone_space = m * pose_bone.matrix

    #### remap matrix
    loc, rot, scale = mat_bone_space.decompose()

    if not bone.use_inherit_scale:
        scale = (m * pose_bone.matrix).decompose()[2]

    loc_mat = Matrix.Translation(loc)

    rot_mat = rot.inverted().to_matrix().to_4x4()

    scale_mat = Matrix()
    scale_mat[0][0] = scale[1]
    scale_mat[1][1] = scale[0]

    mat_bone_space = loc_mat * rot_mat * scale_mat

    return mat_bone_space
开发者ID:,项目名称:,代码行数:36,代码来源:

示例2: get_animation_data

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import row[3] [as 别名]
def get_animation_data(context, sprite_object, armature, bake_anim, bake_interval):
    m = Matrix()  ### inverted posebone origin matrix
    m.row[0] = [0, 0, 1, 0]
    m.row[1] = [1, 0, 0, 0]
    m.row[2] = [0, 1, 0, 0]
    m.row[3] = [0, 0, 0, 1]

    data = []
    scale = 1 / get_addon_prefs(context).sprite_import_export_scale
    anims = sprite_object.coa_anim_collections
    for anim in anims:
        anim_data = animation.copy()
        anim_data["name"] = anim.name
        anim_data["duration"] = anim.frame_end
        anim_data["playTimes"] = 1
        anim_data["bone"] = []
        anim_data["slot"] = []
        anim_data["ffd"] = []
        if anim.name not in ["NO ACTION"]:
            set_action(context, item=anims[1])
            context.scene.update()

            set_action(context, item=anim)
            context.scene.update()
            objs = get_children(context, sprite_object, ob_list=[])
            for obj in objs:
                if obj.animation_data != None:  # and obj.animation_data.action != None:
                    action = None
                    if obj.animation_data.action != None:
                        action = obj.animation_data.action
                    ### get keyframes for Bones (Position, Rotation, Scale)
                    if obj.type == "ARMATURE":
                        ### loop over all bones and get data
                        for bone in obj.data.bones:

                            pose_bone = armature.pose.bones[bone.name]
                            if bone.name not in ignore_bones:
                                bone_data = {}
                                bone_data["name"] = bone.name
                                bone_data["frame"] = []
                                ### loop over action framerange
                                for f in range(0, anim.frame_end + 1):
                                    bpy.context.scene.frame_set(f)
                                    ### if bone has a keyframe on frame -> store data
                                    if (
                                        action != None
                                        and (bone_key_on_frame(bone, f, action))
                                        or (bake_anim and f % bake_interval == 0)
                                        or f == 0
                                    ):

                                        frame_data = {}
                                        frame_data["duration"] = f
                                        if len(bone_data["frame"]) > 0:
                                            idx = len(bone_data["frame"]) - 1
                                            bone_data["frame"][idx]["duration"] = (
                                                f - bone_data["frame"][idx]["duration"]
                                            )  ### set duration of last keyframe
                                        frame_data["tweenEasing"] = 0
                                        # frame_data["curve"] = [0.25, 0.0, 0.75, 1.0]
                                        frame_data["transform"] = {}
                                        ### get bone position

                                        pos = get_bone_pos(armature, bone, scale)
                                        pos -= bone_default_pos[bone.name]
                                        if pos != Vector((0, 0)):
                                            frame_data["transform"]["x"] = pos[0]
                                            frame_data["transform"]["y"] = pos[1]

                                        ### get bone angle
                                        angle = get_bone_angle(armature, bone)
                                        angle -= bone_default_rot[bone.name]
                                        if angle != 0:
                                            frame_data["transform"]["skY"] = angle
                                            frame_data["transform"]["skX"] = angle

                                        ### get bone scale
                                        sca = get_bone_scale(armature, bone)
                                        if sca != Vector((1.0, 1.0, 1.0)):
                                            frame_data["transform"]["scX"] = sca[0]
                                            frame_data["transform"]["scY"] = sca[1]

                                        bone_data["frame"].append(frame_data)
                                anim_data["bone"].append(bone_data)

                    ### get keyframes for slots (Color, Alpha, SlotIndex)
                    elif obj.type == "MESH":
                        slot_data = {}
                        slot_data["name"] = obj.name
                        slot_data["frame"] = []

                        ### get sprite property driver bones
                        arm, bones = get_sprite_driver(obj)
                        arm_action = None
                        if arm != None and arm.animation_data != None:
                            arm_action = arm.animation_data.action

                        ### loop over action framerange
                        for f in range(0, anim.frame_end + 1):
                            bpy.context.scene.frame_set(f)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的mathutils.Matrix.row[3]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。