forked from bartvdbraak/blender
UI makeover for mocap constraints panel. Now has the look and feel of regular Blender constraints
This commit is contained in:
parent
75029e1119
commit
d959f77e79
@ -77,6 +77,9 @@ class MocapConstraint(bpy.types.PropertyGroup):
|
|||||||
default=True,
|
default=True,
|
||||||
description="Constraint is active",
|
description="Constraint is active",
|
||||||
update=setConstraint)
|
update=setConstraint)
|
||||||
|
show_expanded = bpy.props.BoolProperty(name="Show Expanded",
|
||||||
|
default=True,
|
||||||
|
description="Constraint is fully shown")
|
||||||
targetPoint = bpy.props.FloatVectorProperty(name="Point", size=3,
|
targetPoint = bpy.props.FloatVectorProperty(name="Point", size=3,
|
||||||
subtype="XYZ", default=(0.0, 0.0, 0.0),
|
subtype="XYZ", default=(0.0, 0.0, 0.0),
|
||||||
description="Target of Constraint - Point",
|
description="Target of Constraint - Point",
|
||||||
@ -250,41 +253,45 @@ class MocapConstraintsPanel(bpy.types.Panel):
|
|||||||
if context.active_object.data.name in bpy.data.armatures:
|
if context.active_object.data.name in bpy.data.armatures:
|
||||||
enduser_obj = context.active_object
|
enduser_obj = context.active_object
|
||||||
enduser_arm = enduser_obj.data
|
enduser_arm = enduser_obj.data
|
||||||
layout.operator("mocap.addconstraint")
|
layout.operator_menu_enum("mocap.addmocapfix", "type")
|
||||||
layout.operator("mocap.bakeconstraints")
|
bakeRow = layout.row()
|
||||||
layout.operator("mocap.unbakeconstraints")
|
bakeRow.operator("mocap.bakeconstraints")
|
||||||
|
bakeRow.operator("mocap.unbakeconstraints")
|
||||||
layout.separator()
|
layout.separator()
|
||||||
for i, m_constraint in enumerate(enduser_arm.mocap_constraints):
|
for i, m_constraint in enumerate(enduser_arm.mocap_constraints):
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.prop(m_constraint, 'name')
|
headerRow = box.row()
|
||||||
box.prop(m_constraint, 'type')
|
headerRow.prop(m_constraint, 'show_expanded', text='', icon='TRIA_DOWN' if m_constraint.show_expanded else 'TRIA_RIGHT', emboss=False)
|
||||||
box.prop_search(m_constraint, 'constrained_bone', enduser_obj.pose, "bones")
|
headerRow.prop(m_constraint, 'type', text='')
|
||||||
if m_constraint.type == "distance" or m_constraint.type == "point":
|
headerRow.prop(m_constraint, 'name', text='')
|
||||||
box.prop_search(m_constraint, 'constrained_boneB', enduser_obj.pose, "bones")
|
headerRow.prop(m_constraint, 'active', icon='MUTE_IPO_ON' if m_constraint.active else'MUTE_IPO_OFF', text='', emboss=False)
|
||||||
frameRow = box.row()
|
headerRow.operator("mocap.removeconstraint", text="", icon='X', emboss=False).constraint = i
|
||||||
frameRow.label("Frame Range:")
|
if m_constraint.show_expanded:
|
||||||
frameRow.prop(m_constraint, 's_frame')
|
box.separator()
|
||||||
frameRow.prop(m_constraint, 'e_frame')
|
box.prop_search(m_constraint, 'constrained_bone', enduser_obj.pose, "bones", icon='BONE_DATA')
|
||||||
smoothRow = box.row()
|
if m_constraint.type == "distance" or m_constraint.type == "point":
|
||||||
smoothRow.label("Smoothing:")
|
box.prop_search(m_constraint, 'constrained_boneB', enduser_obj.pose, "bones", icon='CONSTRAINT_BONE')
|
||||||
smoothRow.prop(m_constraint, 'smooth_in')
|
frameRow = box.row()
|
||||||
smoothRow.prop(m_constraint, 'smooth_out')
|
frameRow.label("Frame Range:")
|
||||||
targetRow = box.row()
|
frameRow.prop(m_constraint, 's_frame')
|
||||||
targetLabelCol = targetRow.column()
|
frameRow.prop(m_constraint, 'e_frame')
|
||||||
targetLabelCol.label("Target settings:")
|
smoothRow = box.row()
|
||||||
targetPropCol = targetRow.column()
|
smoothRow.label("Smoothing:")
|
||||||
if m_constraint.type == "floor":
|
smoothRow.prop(m_constraint, 'smooth_in')
|
||||||
targetPropCol.prop_search(m_constraint, 'targetMesh', bpy.data, "objects")
|
smoothRow.prop(m_constraint, 'smooth_out')
|
||||||
if m_constraint.type == "point" or m_constraint.type == "freeze":
|
targetRow = box.row()
|
||||||
box.prop(m_constraint, 'targetSpace')
|
targetLabelCol = targetRow.column()
|
||||||
if m_constraint.type == "point":
|
targetLabelCol.label("Target settings:")
|
||||||
targetPropCol.prop(m_constraint, 'targetPoint')
|
targetPropCol = targetRow.column()
|
||||||
if m_constraint.type == "distance" or m_constraint.type == "floor":
|
if m_constraint.type == "floor":
|
||||||
targetPropCol.prop(m_constraint, 'targetDist')
|
targetPropCol.prop_search(m_constraint, 'targetMesh', bpy.data, "objects")
|
||||||
checkRow = box.row()
|
if m_constraint.type == "point" or m_constraint.type == "freeze":
|
||||||
checkRow.prop(m_constraint, 'active')
|
box.prop(m_constraint, 'targetSpace')
|
||||||
layout.operator("mocap.removeconstraint", text="Remove constraint").constraint = i
|
if m_constraint.type == "point":
|
||||||
layout.separator()
|
targetPropCol.prop(m_constraint, 'targetPoint')
|
||||||
|
if m_constraint.type == "distance" or m_constraint.type == "floor":
|
||||||
|
targetPropCol.prop(m_constraint, 'targetDist')
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
|
|
||||||
class OBJECT_OT_RetargetButton(bpy.types.Operator):
|
class OBJECT_OT_RetargetButton(bpy.types.Operator):
|
||||||
@ -462,15 +469,22 @@ class OBJECT_OT_ScaleFixArmature(bpy.types.Operator):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class OBJECT_OT_AddMocapConstraint(bpy.types.Operator):
|
class MOCAP_OT_AddMocapFix(bpy.types.Operator):
|
||||||
'''Add a post-retarget fix - useful for fixing certain artifacts following the retarget'''
|
'''Add a post-retarget fix - useful for fixing certain artifacts following the retarget'''
|
||||||
bl_idname = "mocap.addconstraint"
|
bl_idname = "mocap.addmocapfix"
|
||||||
bl_label = "Add constraint to target armature"
|
bl_label = "Add constraint to target armature"
|
||||||
|
type = bpy.props.EnumProperty(name="Type of constraint",
|
||||||
|
items=[("point", "Maintain Position", "Bone is at a specific point"),
|
||||||
|
("freeze", "Maintain Position at frame", "Bone does not move from location specified in target frame"),
|
||||||
|
("floor", "Stay above", "Bone does not cross specified mesh object eg floor"),
|
||||||
|
("distance", "Maintain distance", "Target bones maintained specified distance")],
|
||||||
|
description="Type of constraint")
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
enduser_obj = bpy.context.active_object
|
enduser_obj = bpy.context.active_object
|
||||||
enduser_arm = enduser_obj.data
|
enduser_arm = enduser_obj.data
|
||||||
new_mcon = enduser_arm.mocap_constraints.add()
|
new_mcon = enduser_arm.mocap_constraints.add()
|
||||||
|
new_mcon.type = self.type
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user