Compare commits
7 Commits
cb3999de33
...
develop
Author | SHA1 | Date | |
---|---|---|---|
522fbc3383 | |||
2abd74bdc8 | |||
be06439bc0 | |||
486b23b378 | |||
0c4ecffc18 | |||
5ffe61e81d | |||
95955d2dfd |
50
common.py
50
common.py
@ -37,6 +37,17 @@ def searchPoseMarker(context, posename, type):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def selectBonesinPose(context, posename, active_marker):
|
||||||
|
try:
|
||||||
|
arm_object, pose_library = getArmatureData(context)
|
||||||
|
for bone in arm_object.pose.bones:
|
||||||
|
bone.bone.select = False
|
||||||
|
if findKeyframe(context, bone, active_marker.frame):
|
||||||
|
bone.bone.select = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def findFcurve(context, bone_name, transform, index_int):
|
def findFcurve(context, bone_name, transform, index_int):
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
pose_markers = pose_library.pose_markers
|
pose_markers = pose_library.pose_markers
|
||||||
@ -62,6 +73,16 @@ def createFcurve(context, bone_name, transform, index_int):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def findKeyframe(context, bone, active_frame):
|
||||||
|
arm_object, pose_library = getArmatureData(context)
|
||||||
|
|
||||||
|
for fcu in pose_library.fcurves:
|
||||||
|
if fcu.data_path.startswith('pose.bones["'+bone.name+'"]'):
|
||||||
|
for kp in fcu.keyframe_points:
|
||||||
|
if kp.co.x == active_frame:
|
||||||
|
return fcu.data_path
|
||||||
|
|
||||||
|
|
||||||
def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
|
def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
pose_markers = pose_library.pose_markers
|
pose_markers = pose_library.pose_markers
|
||||||
@ -84,11 +105,7 @@ def setKeyframesFromBones(context, arm_object, new_marker):
|
|||||||
if bone.bone.select or none_selected == True:
|
if bone.bone.select or none_selected == True:
|
||||||
bone_name = bone.name
|
bone_name = bone.name
|
||||||
|
|
||||||
if bone.rotation_mode == "XYZ":
|
if bone.rotation_mode in ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"):
|
||||||
rot_mode = "rotation_euler"
|
|
||||||
elif bone.rotation_mode == "YZX":
|
|
||||||
rot_mode = "rotation_euler"
|
|
||||||
elif bone.rotation_mode == "ZXY":
|
|
||||||
rot_mode = "rotation_euler"
|
rot_mode = "rotation_euler"
|
||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
@ -149,11 +166,10 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
|
|||||||
if bone.bone.select or none_selected == True:
|
if bone.bone.select or none_selected == True:
|
||||||
bone_name = bone.name
|
bone_name = bone.name
|
||||||
|
|
||||||
if bone.rotation_mode == "XYZ":
|
if findKeyframe(context, bone, active_marker.frame) is None:
|
||||||
rot_mode = "rotation_euler"
|
continue
|
||||||
elif bone.rotation_mode == "YZX":
|
|
||||||
rot_mode = "rotation_euler"
|
if bone.rotation_mode in ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"):
|
||||||
elif bone.rotation_mode == "ZXY":
|
|
||||||
rot_mode = "rotation_euler"
|
rot_mode = "rotation_euler"
|
||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
@ -178,21 +194,9 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
|
|||||||
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
|
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
|
||||||
|
|
||||||
bone.location = mathutils.Vector((loc_x, loc_y, loc_z))
|
bone.location = mathutils.Vector((loc_x, loc_y, loc_z))
|
||||||
if bone.rotation_mode == "XYZ":
|
if rot_mode == "rotation_euler":
|
||||||
bone.rotation_euler = mathutils.Euler(
|
bone.rotation_euler = mathutils.Euler(
|
||||||
(rot_x, rot_y, rot_z))
|
(rot_x, rot_y, rot_z))
|
||||||
elif bone.rotation_mode == "YZX":
|
|
||||||
bone.rotation_euler = mathutils.Euler(
|
|
||||||
(rot_x, rot_y, rot_z))
|
|
||||||
elif bone.rotation_mode == "ZXY":
|
|
||||||
bone.rotation_euler = mathutils.Euler(
|
|
||||||
(rot_z, rot_x, rot_y))
|
|
||||||
elif bone.rotation_mode == "YXZ":
|
|
||||||
bone.rotation_euler = mathutils.Euler(
|
|
||||||
(rot_y, rot_x, rot_z))
|
|
||||||
elif bone.rotation_mode == "XZY":
|
|
||||||
bone.rotation_euler = mathutils.Euler(
|
|
||||||
(rot_x, rot_z, rot_y))
|
|
||||||
elif rot_mode == "rotation_quaternion":
|
elif rot_mode == "rotation_quaternion":
|
||||||
bone.rotation_quaternion = mathutils.Quaternion(
|
bone.rotation_quaternion = mathutils.Quaternion(
|
||||||
(rot_w, rot_x, rot_y, rot_z))
|
(rot_w, rot_x, rot_y, rot_z))
|
||||||
|
13
operators.py
13
operators.py
@ -254,7 +254,7 @@ class DSPL_OT_MovePose(bpy.types.Operator):
|
|||||||
class DSPL_OT_ApplyPose(bpy.types.Operator):
|
class DSPL_OT_ApplyPose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.apply_pose"
|
bl_idname = "dspl.apply_pose"
|
||||||
bl_label = "Apply Pose"
|
bl_label = "Apply Pose"
|
||||||
bl_description = "Apply Pose (Ctrl+Click to select, Shift+Click to rename, Alt+Click to remove)"
|
bl_description = "Apply Pose (Ctrl+Click to select bones, Shift+Click to rename, Alt+Click to remove)"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
posename: bpy.props.StringProperty()
|
posename: bpy.props.StringProperty()
|
||||||
@ -283,9 +283,16 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
if event.ctrl:
|
if event.ctrl:
|
||||||
# Select
|
# Select bones
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
pose_library.pose_markers.active_index = searchPoseMarker(context, posename=self.posename, type="index")
|
active_marker = searchPoseMarker(context, posename=self.posename, type="marker")
|
||||||
|
|
||||||
|
arm_object.select = True
|
||||||
|
bpy.context.view_layer.objects.active = arm_object
|
||||||
|
bpy.ops.object.mode_set(mode='POSE')
|
||||||
|
selectBonesinPose(context, self.posename, active_marker)
|
||||||
|
|
||||||
|
self.execute(context)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
elif event.alt:
|
elif event.alt:
|
||||||
# Remove
|
# Remove
|
||||||
|
Reference in New Issue
Block a user