Changeset View
Changeset View
Standalone View
Standalone View
rigify/rigs/limbs/super_limb.py
| import bpy | import bpy | ||||
| from .arm import Rig as armRig | from .arm import Rig as armRig | ||||
| from .leg import Rig as legRig | from .leg import Rig as legRig | ||||
| from .paw import Rig as pawRig | from .paw import Rig as pawRig | ||||
| from ...utils import ControlLayersOption | |||||
| class Rig: | class Rig: | ||||
| def __init__(self, obj, bone_name, params): | def __init__(self, obj, bone_name, params): | ||||
| """ Initialize super_limb rig wrapper class """ | """ Initialize super_limb rig wrapper class """ | ||||
| self.obj = obj | self.obj = obj | ||||
| self.params = params | self.params = params | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | def add_parameters(params): | ||||
| params.bbones = bpy.props.IntProperty( | params.bbones = bpy.props.IntProperty( | ||||
| name = 'bbone segments', | name = 'bbone segments', | ||||
| default = 10, | default = 10, | ||||
| min = 1, | min = 1, | ||||
| description = 'Number of segments' | description = 'Number of segments' | ||||
| ) | ) | ||||
| # Setting up extra layers for the FK and tweak | # Setting up extra layers for the FK and tweak | ||||
| params.tweak_extra_layers = bpy.props.BoolProperty( | ControlLayersOption.FK.add_parameters(params) | ||||
| name = "tweak_extra_layers", | ControlLayersOption.TWEAK.add_parameters(params) | ||||
| default = True, | |||||
| description = "" | |||||
| ) | |||||
| params.tweak_layers = bpy.props.BoolVectorProperty( | |||||
| size = 32, | |||||
| description = "Layers for the tweak controls to be on", | |||||
| default = tuple( [ i == 1 for i in range(0, 32) ] ) | |||||
| ) | |||||
| # Setting up extra layers for the FK and tweak | |||||
| params.fk_extra_layers = bpy.props.BoolProperty( | |||||
| name = "fk_extra_layers", | |||||
| default = True, | |||||
| description = "" | |||||
| ) | |||||
| params.fk_layers = bpy.props.BoolVectorProperty( | |||||
| size = 32, | |||||
| description = "Layers for the FK controls to be on", | |||||
| default = tuple( [ i == 1 for i in range(0, 32) ] ) | |||||
| ) | |||||
| def parameters_ui(layout, params): | def parameters_ui(layout, params): | ||||
| """ Create the ui for the rig parameters.""" | """ Create the ui for the rig parameters.""" | ||||
| r = layout.row() | r = layout.row() | ||||
| r.prop(params, "limb_type") | r.prop(params, "limb_type") | ||||
| r = layout.row() | r = layout.row() | ||||
| r.prop(params, "rotation_axis") | r.prop(params, "rotation_axis") | ||||
| if 'auto' not in params.rotation_axis.lower(): | if 'auto' not in params.rotation_axis.lower(): | ||||
| r = layout.row() | r = layout.row() | ||||
| etremities = {'arm': 'Hand', 'leg': 'Foot', 'paw': 'Claw'} | etremities = {'arm': 'Hand', 'leg': 'Foot', 'paw': 'Claw'} | ||||
| text = "Auto align " + etremities[params.limb_type] | text = "Auto align " + etremities[params.limb_type] | ||||
| r.prop(params, "auto_align_extremity", text=text) | r.prop(params, "auto_align_extremity", text=text) | ||||
| r = layout.row() | r = layout.row() | ||||
| r.prop(params, "segments") | r.prop(params, "segments") | ||||
| r = layout.row() | r = layout.row() | ||||
| r.prop(params, "bbones") | r.prop(params, "bbones") | ||||
| bone_layers = bpy.context.active_pose_bone.bone.layers[:] | ControlLayersOption.FK.parameters_ui(layout, params) | ||||
| ControlLayersOption.TWEAK.parameters_ui(layout, params) | |||||
| for layer in ['fk', 'tweak']: | |||||
| r = layout.row() | |||||
| r.prop(params, layer + "_extra_layers") | |||||
| r.active = params.tweak_extra_layers | |||||
| col = r.column(align=True) | |||||
| row = col.row(align=True) | |||||
| for i in range(8): | |||||
| icon = "NONE" | |||||
| if bone_layers[i]: | |||||
| icon = "LAYER_ACTIVE" | |||||
| row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) | |||||
| row = col.row(align=True) | |||||
| for i in range(16,24): | |||||
| icon = "NONE" | |||||
| if bone_layers[i]: | |||||
| icon = "LAYER_ACTIVE" | |||||
| row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) | |||||
| col = r.column(align=True) | |||||
| row = col.row(align=True) | |||||
| for i in range(8,16): | |||||
| icon = "NONE" | |||||
| if bone_layers[i]: | |||||
| icon = "LAYER_ACTIVE" | |||||
| row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) | |||||
| row = col.row(align=True) | |||||
| for i in range(24,32): | |||||
| icon = "NONE" | |||||
| if bone_layers[i]: | |||||
| icon = "LAYER_ACTIVE" | |||||
| row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) | |||||
| def create_sample(obj): | def create_sample(obj): | ||||
| # generated by rigify.utils.write_metarig | # generated by rigify.utils.write_metarig | ||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| arm = obj.data | arm = obj.data | ||||
| bones = {} | bones = {} | ||||
| ▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines | |||||