2009-05-19 15:38:36 +00:00
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
2009-05-28 23:45:50 +00:00
|
|
|
class BoneButtonsPanel(bpy.types.Panel):
|
2009-08-22 08:48:01 +00:00
|
|
|
__space_type__ = 'PROPERTIES'
|
|
|
|
__region_type__ = 'WINDOW'
|
2009-05-20 02:17:53 +00:00
|
|
|
__context__ = "bone"
|
|
|
|
|
|
|
|
def poll(self, context):
|
2009-06-19 14:56:49 +00:00
|
|
|
return (context.bone or context.edit_bone)
|
2009-05-20 02:17:53 +00:00
|
|
|
|
2009-07-09 09:42:34 +00:00
|
|
|
class BONE_PT_context_bone(BoneButtonsPanel):
|
2009-07-26 03:54:17 +00:00
|
|
|
__show_header__ = False
|
2009-07-09 09:07:25 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-09 09:07:25 +00:00
|
|
|
bone = context.bone
|
|
|
|
if not bone:
|
|
|
|
bone = context.edit_bone
|
|
|
|
|
2009-07-21 00:55:20 +00:00
|
|
|
row = layout.row()
|
2009-08-22 08:48:01 +00:00
|
|
|
row.itemL(text="", icon='ICON_BONE_DATA')
|
2009-07-21 00:55:20 +00:00
|
|
|
row.itemR(bone, "name", text="")
|
2009-07-09 09:07:25 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
class BONE_PT_transform(BoneButtonsPanel):
|
2009-07-14 12:32:19 +00:00
|
|
|
__label__ = "Transform"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
ob = context.object
|
2009-07-14 12:32:19 +00:00
|
|
|
bone = context.bone
|
|
|
|
if not bone:
|
|
|
|
bone = context.edit_bone
|
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
row = layout.row()
|
|
|
|
row.column().itemR(bone, "head")
|
|
|
|
row.column().itemR(bone, "tail")
|
|
|
|
|
|
|
|
col = row.column()
|
|
|
|
sub = col.column(align=True)
|
|
|
|
sub.itemL(text="Roll:")
|
|
|
|
sub.itemR(bone, "roll", text="")
|
|
|
|
sub.itemL()
|
|
|
|
sub.itemR(bone, "locked")
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
else:
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
|
|
|
|
|
|
|
layout.itemR(pchan, "rotation_mode")
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
col = row.column()
|
|
|
|
col.itemR(pchan, "location")
|
|
|
|
col.active = not (bone.parent and bone.connected)
|
2009-07-14 12:32:19 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
col = row.column()
|
|
|
|
if pchan.rotation_mode == 'QUATERNION':
|
2009-09-28 10:19:20 +00:00
|
|
|
col.itemR(pchan, "rotation_quaternion", text="Rotation")
|
2009-09-11 12:05:09 +00:00
|
|
|
elif pchan.rotation_mode == 'AXIS_ANGLE':
|
2009-09-28 10:19:20 +00:00
|
|
|
#col.itemL(text="Rotation")
|
|
|
|
#col.itemR(pchan, "rotation_angle", text="Angle")
|
|
|
|
#col.itemR(pchan, "rotation_axis", text="Axis")
|
|
|
|
col.itemR(pchan, "rotation_axis_angle", text="Rotation")
|
2009-07-14 17:59:26 +00:00
|
|
|
else:
|
2009-09-28 10:19:20 +00:00
|
|
|
col.itemR(pchan, "rotation_euler", text="Rotation")
|
2009-07-14 17:59:26 +00:00
|
|
|
|
|
|
|
row.column().itemR(pchan, "scale")
|
2009-09-12 12:30:23 +00:00
|
|
|
|
|
|
|
class BONE_PT_transform_locks(BoneButtonsPanel):
|
|
|
|
__label__ = "Transform Locks"
|
2009-09-19 19:40:38 +00:00
|
|
|
__default_closed__ = True
|
2009-09-12 12:30:23 +00:00
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
return context.bone
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
bone = context.bone
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
col = row.column()
|
|
|
|
col.itemR(pchan, "lock_location")
|
|
|
|
col.active = not (bone.parent and bone.connected)
|
|
|
|
|
|
|
|
col = row.column()
|
|
|
|
if pchan.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
|
|
|
|
col.itemR(pchan, "lock_rotations_4d", text="Lock Rotation")
|
|
|
|
if pchan.lock_rotations_4d:
|
|
|
|
col.itemR(pchan, "lock_rotation_w", text="W")
|
|
|
|
col.itemR(pchan, "lock_rotation", text="")
|
|
|
|
else:
|
|
|
|
col.itemR(pchan, "lock_rotation", text="Rotation")
|
|
|
|
|
|
|
|
row.column().itemR(pchan, "lock_scale")
|
2009-07-14 12:32:19 +00:00
|
|
|
|
2009-05-28 23:45:50 +00:00
|
|
|
class BONE_PT_bone(BoneButtonsPanel):
|
2009-05-20 02:17:53 +00:00
|
|
|
__label__ = "Bone"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-08-23 12:53:55 +00:00
|
|
|
ob = context.object
|
2009-06-13 21:22:21 +00:00
|
|
|
bone = context.bone
|
2009-07-14 17:59:26 +00:00
|
|
|
arm = context.armature
|
2009-09-01 00:33:39 +00:00
|
|
|
|
2009-06-19 14:56:49 +00:00
|
|
|
if not bone:
|
|
|
|
bone = context.edit_bone
|
2009-09-03 12:20:59 +00:00
|
|
|
pchan = None
|
2009-08-23 12:53:55 +00:00
|
|
|
else:
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
2009-05-20 02:17:53 +00:00
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
2009-07-27 20:39:10 +00:00
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Parent:")
|
2009-07-14 17:59:26 +00:00
|
|
|
if context.bone:
|
2009-07-27 20:39:10 +00:00
|
|
|
col.itemR(bone, "parent", text="")
|
2009-07-14 17:59:26 +00:00
|
|
|
else:
|
2009-07-27 20:39:10 +00:00
|
|
|
col.item_pointerR(bone, "parent", arm, "edit_bones", text="")
|
2009-08-23 12:53:55 +00:00
|
|
|
|
2009-07-27 20:39:10 +00:00
|
|
|
row = col.row()
|
|
|
|
row.active = bone.parent != None
|
|
|
|
row.itemR(bone, "connected")
|
2009-08-23 12:53:55 +00:00
|
|
|
|
2009-07-27 20:39:10 +00:00
|
|
|
col.itemL(text="Layers:")
|
2009-09-09 17:39:19 +00:00
|
|
|
col.itemR(bone, "layer", text="")
|
2009-08-23 12:53:55 +00:00
|
|
|
|
2009-07-27 20:39:10 +00:00
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Inherit:")
|
|
|
|
col.itemR(bone, "hinge", text="Rotation")
|
|
|
|
col.itemR(bone, "inherit_scale", text="Scale")
|
|
|
|
col.itemL(text="Display:")
|
|
|
|
col.itemR(bone, "draw_wire", text="Wireframe")
|
|
|
|
col.itemR(bone, "hidden", text="Hide")
|
2009-08-23 12:53:55 +00:00
|
|
|
|
|
|
|
if ob and pchan:
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Bone Group:")
|
|
|
|
col.item_pointerR(pchan, "bone_group", ob.pose, "bone_groups", text="")
|
|
|
|
|
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Custom Shape:")
|
|
|
|
col.itemR(pchan, "custom_shape", text="")
|
2009-07-09 09:07:25 +00:00
|
|
|
|
2009-07-14 22:11:25 +00:00
|
|
|
class BONE_PT_inverse_kinematics(BoneButtonsPanel):
|
|
|
|
__label__ = "Inverse Kinematics"
|
|
|
|
__default_closed__ = True
|
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
ob = context.object
|
|
|
|
bone = context.bone
|
|
|
|
|
|
|
|
if ob and context.bone:
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
|
|
|
return pchan.has_ik
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-14 22:11:25 +00:00
|
|
|
ob = context.object
|
|
|
|
bone = context.bone
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
row = layout.row()
|
|
|
|
row.itemR(ob.pose, "ik_solver")
|
|
|
|
|
2009-07-14 22:11:25 +00:00
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
split.itemR(pchan, "ik_dof_x", text="X")
|
|
|
|
row = split.row()
|
2009-09-19 21:40:37 +00:00
|
|
|
row.itemR(pchan, "ik_stiffness_x", text="Stiffness", slider=True)
|
2009-07-14 22:11:25 +00:00
|
|
|
row.active = pchan.ik_dof_x
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(pchan, "ik_limit_x", text="Limit")
|
|
|
|
row.active = pchan.ik_dof_x
|
|
|
|
row = split.row(align=True)
|
|
|
|
row.itemR(pchan, "ik_min_x", text="")
|
|
|
|
row.itemR(pchan, "ik_max_x", text="")
|
|
|
|
row.active = pchan.ik_dof_x and pchan.ik_limit_x
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
split.itemR(pchan, "ik_dof_y", text="Y")
|
|
|
|
row = split.row()
|
2009-09-19 21:40:37 +00:00
|
|
|
row.itemR(pchan, "ik_stiffness_y", text="Stiffness", slider=True)
|
2009-07-14 22:11:25 +00:00
|
|
|
row.active = pchan.ik_dof_y
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(pchan, "ik_limit_y", text="Limit")
|
|
|
|
row.active = pchan.ik_dof_y
|
|
|
|
row = split.row(align=True)
|
|
|
|
row.itemR(pchan, "ik_min_y", text="")
|
|
|
|
row.itemR(pchan, "ik_max_y", text="")
|
|
|
|
row.active = pchan.ik_dof_y and pchan.ik_limit_y
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
split.itemR(pchan, "ik_dof_z", text="Z")
|
|
|
|
row = split.row()
|
2009-09-19 21:40:37 +00:00
|
|
|
row.itemR(pchan, "ik_stiffness_z", text="Stiffness", slider=True)
|
2009-07-14 22:11:25 +00:00
|
|
|
row.active = pchan.ik_dof_z
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.25)
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(pchan, "ik_limit_z", text="Limit")
|
|
|
|
row.active = pchan.ik_dof_z
|
|
|
|
row = split.row(align=True)
|
|
|
|
row.itemR(pchan, "ik_min_z", text="")
|
|
|
|
row.itemR(pchan, "ik_max_z", text="")
|
|
|
|
row.active = pchan.ik_dof_z and pchan.ik_limit_z
|
|
|
|
split = layout.split()
|
2009-09-19 21:40:37 +00:00
|
|
|
split.itemR(pchan, "ik_stretch", text="Stretch", slider=True)
|
2009-07-14 22:11:25 +00:00
|
|
|
split.itemL()
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
if ob.pose.ik_solver == "ITASC":
|
|
|
|
layout.itemL(text="Joint constraint:")
|
|
|
|
split = layout.split(percentage=0.3)
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(pchan, "ik_rot_control", text="Rotation")
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(pchan, "ik_rot_weight", text="Weight", slider=True)
|
|
|
|
row.active = pchan.ik_rot_control
|
|
|
|
# not supported yet
|
|
|
|
#split = layout.split(percentage=0.3)
|
|
|
|
#row = split.row()
|
|
|
|
#row.itemR(pchan, "ik_lin_control", text="Size")
|
|
|
|
#row = split.row()
|
|
|
|
#row.itemR(pchan, "ik_lin_weight", text="Weight", slider=True)
|
|
|
|
#row.active = pchan.ik_lin_control
|
|
|
|
|
2009-07-09 09:07:25 +00:00
|
|
|
class BONE_PT_deform(BoneButtonsPanel):
|
|
|
|
__label__ = "Deform"
|
2009-07-14 22:11:25 +00:00
|
|
|
__default_closed__ = True
|
2009-07-09 09:07:25 +00:00
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
bone = context.bone
|
2009-09-01 00:33:39 +00:00
|
|
|
|
2009-07-09 09:07:25 +00:00
|
|
|
if not bone:
|
|
|
|
bone = context.edit_bone
|
|
|
|
|
2009-09-01 00:33:39 +00:00
|
|
|
self.layout.itemR(bone, "deform", text="")
|
2009-07-09 09:07:25 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-09 09:07:25 +00:00
|
|
|
bone = context.bone
|
2009-09-01 00:33:39 +00:00
|
|
|
|
2009-07-09 09:07:25 +00:00
|
|
|
if not bone:
|
|
|
|
bone = context.edit_bone
|
|
|
|
|
|
|
|
layout.active = bone.deform
|
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Envelope:")
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
sub = col.column(align=True)
|
2009-05-19 15:38:36 +00:00
|
|
|
sub.itemR(bone, "envelope_distance", text="Distance")
|
|
|
|
sub.itemR(bone, "envelope_weight", text="Weight")
|
2009-07-14 17:59:26 +00:00
|
|
|
col.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
|
|
|
|
|
|
|
|
sub = col.column(align=True)
|
|
|
|
sub.itemL(text="Radius:")
|
|
|
|
sub.itemR(bone, "head_radius", text="Head")
|
|
|
|
sub.itemR(bone, "tail_radius", text="Tail")
|
|
|
|
|
|
|
|
col = split.column()
|
|
|
|
col.itemL(text="Curved Bones:")
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
sub = col.column(align=True)
|
2009-05-19 15:38:36 +00:00
|
|
|
sub.itemR(bone, "bbone_segments", text="Segments")
|
|
|
|
sub.itemR(bone, "bbone_in", text="Ease In")
|
|
|
|
sub.itemR(bone, "bbone_out", text="Ease Out")
|
|
|
|
|
2009-07-14 17:59:26 +00:00
|
|
|
col.itemL(text="Offset:")
|
|
|
|
col.itemR(bone, "cyclic_offset")
|
2009-07-09 09:07:25 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
class BONE_PT_iksolver_itasc(BoneButtonsPanel):
|
|
|
|
__idname__ = "BONE_PT_iksolver_itasc"
|
|
|
|
__label__ = "iTaSC parameters"
|
|
|
|
__default_closed__ = True
|
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
ob = context.object
|
|
|
|
bone = context.bone
|
|
|
|
|
|
|
|
if ob and context.bone:
|
|
|
|
pchan = ob.pose.pose_channels[context.bone.name]
|
|
|
|
return pchan.has_ik and ob.pose.ik_solver == "ITASC" and ob.pose.ik_param
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-09-27 11:00:35 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
ob = context.object
|
|
|
|
itasc = ob.pose.ik_param
|
|
|
|
|
|
|
|
layout.row().itemR(itasc, "simulation")
|
|
|
|
if itasc.simulation:
|
|
|
|
split = layout.split()
|
|
|
|
row = split.row()
|
|
|
|
row.itemR(itasc, "reiteration")
|
|
|
|
row = split.row()
|
|
|
|
if itasc.reiteration:
|
|
|
|
itasc.initial_reiteration = True
|
|
|
|
row.itemR(itasc, "initial_reiteration")
|
|
|
|
row.active = not itasc.reiteration
|
|
|
|
|
|
|
|
flow = layout.column_flow()
|
|
|
|
flow.itemR(itasc, "precision")
|
|
|
|
flow.itemR(itasc, "num_iter")
|
|
|
|
flow.active = not itasc.simulation or itasc.initial_reiteration or itasc.reiteration
|
|
|
|
|
|
|
|
if itasc.simulation:
|
|
|
|
layout.itemR(itasc, "auto_step")
|
|
|
|
row = layout.row()
|
|
|
|
if itasc.auto_step:
|
|
|
|
row.itemR(itasc, "min_step")
|
|
|
|
row.itemR(itasc, "max_step")
|
|
|
|
else:
|
|
|
|
row.itemR(itasc, "num_step")
|
|
|
|
|
|
|
|
layout.itemR(itasc, "solver")
|
|
|
|
if itasc.simulation:
|
|
|
|
layout.itemR(itasc, "feedback")
|
|
|
|
layout.itemR(itasc, "max_velocity")
|
|
|
|
if itasc.solver == "DLS":
|
|
|
|
row = layout.row()
|
|
|
|
row.itemR(itasc, "dampmax")
|
|
|
|
row.itemR(itasc, "dampeps")
|
2009-05-19 15:38:36 +00:00
|
|
|
|
2009-07-09 09:42:34 +00:00
|
|
|
bpy.types.register(BONE_PT_context_bone)
|
2009-07-14 17:59:26 +00:00
|
|
|
bpy.types.register(BONE_PT_transform)
|
2009-09-12 12:30:23 +00:00
|
|
|
bpy.types.register(BONE_PT_transform_locks)
|
2009-06-19 14:56:49 +00:00
|
|
|
bpy.types.register(BONE_PT_bone)
|
2009-07-09 09:07:25 +00:00
|
|
|
bpy.types.register(BONE_PT_deform)
|
2009-07-14 22:11:25 +00:00
|
|
|
bpy.types.register(BONE_PT_inverse_kinematics)
|
2009-09-24 21:22:24 +00:00
|
|
|
bpy.types.register(BONE_PT_iksolver_itasc)
|