def addJacketCollarRig(): # jacket collar rig collarjnts = pm.ls(sl=True) # add hm, grp and auto nulls for jnt in collarjnts: ctl = pm.circle(r=0.5, sweep=359, normal=(1,0,0), n=jnt.replace('_jnt', '_ctl')) auto = pm.group(ctl, n=jnt.replace('_jnt', '_auto')) grp = pm.group(auto, n=jnt.replace('_jnt', '_grp')) hm = pm.group(grp, n=jnt.replace('_jnt', '_hm')) wMat = jnt.getMatrix(worldSpace=True) hm.setMatrix(wMat, worldSpace=True) collarparent = jnt.getParent() collarparent | hm auto | jnt # auto import rigger.modules.poseReader as poseReader reload(poseReader) xfo = nt.Joint(u'Mathilda_neck_jnt') poseReader.radial_pose_reader(xfo, (1,0,0), (1,0,0)) # connect auto to sdks import utils.rigging as rt import rigger.utils.modulate as modulate angleMult = pm.PyNode('Mathilda_neck_jnt.vectorAngle') # Left collar A rt.connectSDK('Mathilda_neck_jnt.param', 'LT_collarA_auto.rz', {3.25:0, 4.6:50, 5.5:0}) mod = modulate.multiplyInput(pm.PyNode('LT_collarA_auto.rz'), 0, '_angle') angleMult >> mod # Letf collar B rt.connectSDK('Mathilda_neck_jnt.param', 'LT_collarB_auto.rz', {4:0, 5:180, 6:180, 7:0}) mod = modulate.multiplyInput(pm.PyNode('LT_collarB_auto.rz'), 0, '_angle') angleMult >> mod # Letf collar C rt.connectSDK('Mathilda_neck_jnt.param', 'LT_collarC_auto.rz', {0:200, 1.4:0, 4:0, 5.5:200, 6.6:280, 8:0}) mod = modulate.multiplyInput(pm.PyNode('LT_collarC_auto.rz'), 0, '_angle') angleMult >> mod # center collar rt.connectSDK('Mathilda_neck_jnt.param', 'CT_collar_auto.rz', {0:320, 2.5:0, 5.5:0, 8:320}) mod = modulate.multiplyInput(pm.PyNode('CT_collar_auto.rz'), 0, '_angle') angleMult >> mod # right collar A rt.connectSDK('Mathilda_neck_jnt.param', 'RT_collarA_auto.rz', {4.75:0, 3.4:50, 2.5:0}) mod = modulate.multiplyInput(pm.PyNode('RT_collarA_auto.rz'), 0, '_angle') angleMult >> mod # right collar B rt.connectSDK('Mathilda_neck_jnt.param', 'RT_collarB_auto.rz', {4:0, 3:180, 2:180, 1:0}) mod = modulate.multiplyInput(pm.PyNode('RT_collarB_auto.rz'), 0, '_angle') angleMult >> mod # right collar C rt.connectSDK('Mathilda_neck_jnt.param', 'RT_collarC_auto.rz', {0:200, 6.6:0, 4:0, 2.5:200, 1.4:280, 8:0}) mod = modulate.multiplyInput(pm.PyNode('RT_collarC_auto.rz'), 0, '_angle') angleMult >> mod pm.select(pm.PyNode(u'Mathilda_neck_jnt.param').outputs())
def build(): ''' ''' mesh = nt.Mesh(u'CT_face_geoShape') placementGrp = nt.Transform(u'CT_placement_grp') #---------------------------------------------------------------------- bind if 'bind' in data.build_actions: bindGrp = face.createBndsFromPlacement(placementGrp) pm.refresh() else: bindGrp = nt.Transform(u'CT_bnd_grp') #--------------------------------------------------------- sec motion system if 'sec_motion_system' in data.build_actions: face.buildSecondaryControlSystem(placementGrp, bindGrp, mesh) pm.refresh() #------------------------------------------------------------ pri ctl system first if 'primary_ctl_system_first' in data.build_actions: # run a simple first pass # which can be used to block out mappings bndsForPriCtls = data.all_bnds_for_priCtls priCtl.setupPriCtlFirstPass(bindGrp, bndsForPriCtls) priCtl.driveAttachedPriCtlsRun(bindGrp) #------------------------------------------------------------ pri ctl system second if 'primary_ctl_system_second' in data.build_actions: if data.priCtlMappings: # if priCtlMappings is set up, use the data priCtlMappings = data.priCtlMappings priCtl.setupPriCtlSecondPass(priCtlMappings) priCtl.driveAttachedPriCtlsRun(bindGrp) pm.refresh() else: pm.warning('no data for pri ctl system') #-------------------------------------------------------------- load weights if 'load_weights' in data.build_actions: priCtlWeights = data.priCtlWeights priCtl.setPriCtlSecondPassWeights(priCtlWeights) pm.refresh() #--------------------------------------------------------------------- clean if 'clean' in data.build_actions: print 'clean' face.cleanFaceRig() pm.select(cl=True) pm.refresh() #--------------------------------------------------------------- skin_layers if 'skin_layers' in data.build_actions: mll = skin.setupSkinLayers(None, layers=[ 'base', 'jaw', 'cheeks', 'crease', 'lips', 'mouthbag', 'nose', 'brow' ]) _, skn = mll.getTargetInfo() pm.PyNode(skn).skinningMethod.set(1) pm.PyNode(skn).deformUserNormals.set(0) #---------------------------------------------------------------------- eyes if 'eyes' in data.build_actions: buildEyeRig(placementGrp) #------------------------------------------------------------------ eyeballs if 'eyeballs' in data.build_actions: #------------------------------------------ EYEBALL RIG (SIMPLE AIM CONSTRAINTS) eye.buildEyeballRig() eye.addEyeAim(prefix='LT_', distance=25) # BROKEN if there is already a # node named LT_eyeball_grp!!! eye.addEyeAim(prefix='RT_', distance=25) # BROKEN #--------------------------------------------------------------- fleshy_eyes if 'fleshy_eyes' in data.build_actions: import rigger.modules.poseReader as poseReader reload(poseReader) xfo = pm.PyNode('LT_eyeball_bnd') poseReader.radial_pose_reader(xfo) xfo = pm.PyNode('RT_eyeball_bnd') poseReader.radial_pose_reader(xfo) eye.addFleshyEye() #--------------------------------------------------------------- sticky lips if 'sticky_lips' in data.build_actions: import rigger.modules.sticky as sticky reload(sticky) sticky.Sticky(up_bnd=pm.PyNode('CT_upper_lip_bnd'), low_bnd=pm.PyNode('CT_lower_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSide_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('LT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSide_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('RT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.addStickyToFRS() sticky.patchOldSticky() #----------------------------------------------------------------- auto_sdks if 'auto_sdks' in data.build_actions: import utils.rigging as rt pCtl = pm.PyNode('CT__mouthMover_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', suffix='_autoRotate') rt.connectSDK(pCtl.tx, offsetGrp.ry, {-1.2: -15, 0: 0, 1.2: 15}) rt.connectSDK(pCtl.tx, offsetGrp.rz, {-1.2: -12, 0: 0, 1.2: 12}) rt.connectSDK(pCtl.tx, offsetGrp.tz, {-1.2: 0.4, 0: 0, 1.2: 0.4}) # squint pCtl = pm.PyNode('LT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0: 0, 1: 0.5}) pCtl = pm.PyNode('RT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0: 0, 1: 0.5}) # inbrow import rigger.modules.secCtl as secCtl reload(secCtl) sCtl = pm.PyNode('LT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0: 0, -1: 0.2}) sCtl = pm.PyNode('RT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0: 0, 1: 0.2}) if 'finish_mathilda' in data.build_actions: # a few mathilda specific things to finalize rig # for demo reel purposes # 1. lock all TZs for better volume allCtls = pm.ls('*_ctrl', type='transform') for ctl in allCtls: ctl.tz.set(l=True, k=False) # 2. hide eye aim locators eyeAimLocs = [ nt.Transform(u'LT_eye_aim_loc'), nt.Transform(u'RT_eye_aim_loc') ] for loc in eyeAimLocs: loc.v.set(False) # 3. go to object mode so we can select controls pm.selectMode(object=True) # 4. bind tongue and teeth geos = [ nt.Transform(u'CT_lowerGums_geo'), nt.Transform(u'CT_tongue_geo'), nt.Transform(u'CT_lowerTeeth_geo') ] for geo in geos: pm.parentConstraint(pm.PyNode('CT__jaw_bnd'), geo, mo=True) ''' # 5. reference all geos to make it easier to select controls allGeos = pm.PyNode('CT_geo_grp').getChildren(ad=True, type='mesh') for geo in allGeos: geo.overrideEnabled.set(True) geo.overrideDisplayType.set(True) ''' # 6. smooth face mesh to make it look nicer pm.PyNode('CT_face_geoShape').displaySmoothMesh.set(2)
def build(): ''' ''' mesh = nt.Mesh(u'CT_face_geoShape') placementGrp = nt.Transform(u'CT_placement_grp') #---------------------------------------------------------------------- bind if 'bind' in data.build_actions: bindGrp = face.createBndsFromPlacement(placementGrp) pm.refresh() else: bindGrp = nt.Transform(u'CT_bnd_grp') #--------------------------------------------------------- sec motion system if 'sec_motion_system' in data.build_actions: face.buildSecondaryControlSystem(placementGrp, bindGrp, mesh) pm.refresh() #------------------------------------------------------------ pri ctl system first if 'primary_ctl_system_first' in data.build_actions: # run a simple first pass # which can be used to block out mappings bndsForPriCtls = data.all_bnds_for_priCtls priCtl.setupPriCtlFirstPass(bindGrp, bndsForPriCtls) priCtl.driveAttachedPriCtlsRun(bindGrp) #------------------------------------------------------------ pri ctl system second if 'primary_ctl_system_second' in data.build_actions: if data.priCtlMappings: # if priCtlMappings is set up, use the data priCtlMappings = data.priCtlMappings priCtl.setupPriCtlSecondPass(priCtlMappings) priCtl.driveAttachedPriCtlsRun(bindGrp) pm.refresh() else: pm.warning('no data for pri ctl system') #-------------------------------------------------------------- load weights if 'load_weights' in data.build_actions: priCtlWeights = data.priCtlWeights priCtl.setPriCtlSecondPassWeights(priCtlWeights) pm.refresh() #--------------------------------------------------------------------- clean if 'clean' in data.build_actions: print 'clean' face.cleanFaceRig() pm.select(cl=True) pm.refresh() #--------------------------------------------------------------- skin_layers if 'skin_layers' in data.build_actions: # initial bind mll = skin.setupSkinLayers(None, layers=[['base', None]]) # split masks for up and low lips upVerts, lowVerts = skin.splitLipsVertices(mll) mll = skin.setupSkinLayers(mll, layers=[['neck', None], ('jaw', lowVerts), ('cheeks', upVerts), ('chin', lowVerts), ('crease', upVerts), ('lips', None), ('nose', None), ('brow', None) ]) _, skn = mll.getTargetInfo() pm.PyNode(skn).skinningMethod.set(1) pm.PyNode(skn).deformUserNormals.set(0) #---------------------------------------------------------------------- eyes if 'eyes' in data.build_actions: buildEyeRig(placementGrp) #------------------------------------------------------------------ eyeballs if 'eyeballs' in data.build_actions: #------------------------------------------ EYEBALL RIG (SIMPLE AIM CONSTRAINTS) eye.buildEyeballRig() eye.addEyeAim(prefix='LT_', distance=25) # BROKEN if there is already a # node named LT_eyeball_grp!!! eye.addEyeAim(prefix='RT_', distance=25) # BROKEN #--------------------------------------------------------------- fleshy_eyes if 'fleshy_eyes' in data.build_actions: import rigger.modules.poseReader as poseReader reload(poseReader) xfo = pm.PyNode('LT_eyeball_bnd') poseReader.radial_pose_reader(xfo) xfo = pm.PyNode('RT_eyeball_bnd') poseReader.radial_pose_reader(xfo) eye.addFleshyEye() #--------------------------------------------------------------- sticky lips if 'sticky_lips' in data.build_actions: import rigger.modules.sticky as sticky reload(sticky) sticky.Sticky(up_bnd=pm.PyNode('CT_upper_lip_bnd'), low_bnd=pm.PyNode('CT_lower_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSide_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('LT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSide_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('RT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.addStickyToFRS() sticky.patchOldSticky() #----------------------------------------------------------------- auto_sdks if 'auto_sdks' in data.build_actions: import utils.rigging as rt pCtl = pm.PyNode('CT__mouthMover_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', suffix='_autoRotate') rt.connectSDK(pCtl.tx, offsetGrp.ry, {-1.2:-15, 0:0, 1.2:15}) rt.connectSDK(pCtl.tx, offsetGrp.rz, {-1.2:-12, 0:0, 1.2:12}) rt.connectSDK(pCtl.tx, offsetGrp.tz, {-1.2:0.4, 0:0, 1.2:0.4}) # squint pCtl = pm.PyNode('LT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0:0, 1:0.5}) pCtl = pm.PyNode('RT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0:0, 1:0.5}) # inbrow import rigger.modules.secCtl as secCtl reload(secCtl) sCtl = pm.PyNode('LT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0:0, -1:0.2}) sCtl = pm.PyNode('RT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0:0, 1:0.2}) if 'finish_mathilda' in data.build_actions: # a few mathilda specific things to finalize rig # for demo reel purposes # 1. lock all TZs for better volume allCtls = pm.ls('*_ctrl', type='transform') for ctl in allCtls: ctl.tz.set(l=True, k=False) # 2. hide eye aim locators eyeAimLocs = [nt.Transform(u'LT_eye_aim_loc'), nt.Transform(u'RT_eye_aim_loc')] for loc in eyeAimLocs: loc.v.set(False) # 3. go to object mode so we can select controls pm.selectMode(object=True) # 4. bind tongue and teeth ''' geos = [nt.Transform(u'CT_lowerGums_geo'), nt.Transform(u'CT_tongue_geo'), nt.Transform(u'CT_lowerTeeth_geo')] ''' geos = [nt.Transform(u'CT_tongue_geo'), nt.Transform(u'CT_lowerTeeth_geo')] for geo in geos: pm.parentConstraint(pm.PyNode('CT__jaw_bnd'), geo, mo=True) '''
center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upper_sneer_lip_bnd'), low_bnd=pm.PyNode('RT_lower_sneer_lip_bnd'), center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upper_pinch_lip_bnd'), low_bnd=pm.PyNode('RT_lower_pinch_lip_bnd'), center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.addStickyToFRS() #------------------------------------------------------------------ AUTO EYELIDS # create pose reader on eye joint import rigger.modules.poseReader as poseReader reload(poseReader) xfo = pm.PyNode('LT_eyeball_bnd') poseReader.radial_pose_reader(xfo) xfo = pm.PyNode('RT_eyeball_bnd') poseReader.radial_pose_reader(xfo) eye.addFleshyEye() # adjust sdk tangents #------------------------------------------------------------------- MOUTH MOVER # create offset for mouth pri control import rigger.modules.priCtl as priCtl reload(priCtl) pCtl = pm.PyNode('CT_mouthMover_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', '_autoRotate') rt.connectSDK(pCtl.tx, offsetGrp.ry, {-1:-15, 0:0, 1:15}) rt.connectSDK(pCtl.tx, offsetGrp.rz, {-1:-15, 0:0, 1:15}) rt.connectSDK(pCtl.tx, offsetGrp.tz, {-1:0.25, 0:0, 1:0.25})
center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upper_sneer_lip_bnd'), low_bnd=pm.PyNode('RT_lower_sneer_lip_bnd'), center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upper_pinch_lip_bnd'), low_bnd=pm.PyNode('RT_lower_pinch_lip_bnd'), center=pm.PyNode('CT_jaw_pri_ctrl')) sticky.addStickyToFRS() #------------------------------------------------------------------ AUTO EYELIDS # create pose reader on eye joint import rigger.modules.poseReader as poseReader reload(poseReader) xfo = pm.PyNode('LT_eyeball_bnd') poseReader.radial_pose_reader(xfo) xfo = pm.PyNode('RT_eyeball_bnd') poseReader.radial_pose_reader(xfo) eye.addFleshyEye() # adjust sdk tangents #------------------------------------------------------------------- MOUTH MOVER # create offset for mouth pri control import rigger.modules.priCtl as priCtl reload(priCtl) pCtl = pm.PyNode('CT_mouthMover_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', '_autoRotate') rt.connectSDK(pCtl.tx, offsetGrp.ry, {-1: -15, 0: 0, 1: 15}) rt.connectSDK(pCtl.tx, offsetGrp.rz, {-1: -15, 0: 0, 1: 15}) rt.connectSDK(pCtl.tx, offsetGrp.tz, {-1: 0.25, 0: 0, 1: 0.25})