def addLeftSmileLipsPivots(mirror=False): bnds = [ nt.Joint(u'LT_sneer_bnd'), nt.Joint(u'LT_mid_crease_bnd'), nt.Joint(u'LT_up_crease_bnd'), nt.Joint(u'LT_up_cheek_bnd'), nt.Joint(u'LT_cheek_bnd') ] if mirror: bnds = [pm.PyNode(bnd.name().replace('LT_', 'RT_')) for bnd in bnds] for eachBnd in bnds: addPivotToBnd(eachBnd, 'smilePivot')
def addLeftBrowHoriPivots(mirror=False): bnds = [ nt.Joint(u'LT_in_brow_bnd'), nt.Joint(u'LT_mid_brow_bnd'), nt.Joint(u'LT_out_brow_bnd'), nt.Joint(u'CT_brow_bnd') ] pivotName = 'browHoriLT' if mirror: bnds = rsym.mirror_PyNodes(bnds) pivotName = 'browHoriRT' for eachBnd in bnds: addPivotToBnd(eachBnd, pivotName)
def assignEyelidBndNames(prefix): upperBnds = [nt.Joint(prefix+'_inner_eyelid_bnd'), nt.Joint(prefix+'_upperInner_eyelid_bnd'), nt.Joint(prefix+'_upper_eyelid_bnd'), nt.Joint(prefix+'_upperOuter_eyelid_bnd'), nt.Joint(prefix+'_outer_eyelid_bnd')] lowerBnds = [nt.Joint(prefix+'_inner_eyelid_bnd'), nt.Joint(prefix+'_lowerInner_eyelid_bnd'), nt.Joint(prefix+'_lower_eyelid_bnd'), nt.Joint(prefix+'_lowerOuter_eyelid_bnd'), nt.Joint(prefix+'_outer_eyelid_bnd')] return upperBnds, lowerBnds
def modulateLeftSmilePivotWeights(mirror=False): ctlAttr = pm.PyNode('LT_corner_lip_pri_ctrl.tx') bnds = [ nt.Joint(u'LT_up_crease_bnd'), nt.Joint(u'LT_up_cheek_bnd'), nt.Joint(u'LT_mid_crease_bnd'), nt.Joint(u'LT_cheek_bnd'), nt.Joint(u'LT_sneer_bnd') ] keys = {0: 0.2, 1: 1} if mirror: ctlAttr, bnds = sym.mirror_PyNodes(ctlAttr, bnds) keys = {0: 0.2, -1: 1} modulatePivotWeightOnBnd(ctlAttr, bnds, 'smilePivot', keys)
def layer_nose(mll): ''' ''' meshName, skn = mll.getTargetInfo() mesh = pm.PyNode(meshName) jntInfs = [u'CT__noseBridge_bnd', u'CT__noseTip_bnd', u'LT__nostril_bnd'] # helper bnds to get better influence weights inbtInfTargets = [[nt.Joint(u'CT__noseBridge_bnd'), nt.Joint(u'CT__noseTip_bnd')], [nt.Joint(u'CT__noseBridge_bnd'), nt.Joint(u'LT__nostril_bnd')]] inbtInfGrp = layer_weighting.addInbetweenBndSystem(inbtInfTargets, mesh) inbtInfNames = [bnd.name() for bnd in inbtInfGrp.getChildren(type='joint')] jntInfs = jntInfs + inbtInfNames # helper bnds to get better mask weighting inbtBndTargetsMask = [[nt.Joint(u'CT__noseBridge_bnd'), nt.Joint(u'LT_up_crease_bnd')], [nt.Joint(u'CT__noseTip_bnd'), nt.Joint(u'CT__philtrum_bnd')], [nt.Joint(u'LT__nostril_bnd'), nt.Joint(u'LT__philtrum_bnd')]] inbtBndMaskGrp = layer_weighting.addInbetweenBndSystem(inbtBndTargetsMask, mesh) inbtBndsMaskNames = [bnd.name() for bnd in inbtBndMaskGrp.getChildren(type='joint')] maskInInfs = jntInfs + inbtBndsMaskNames maskOutInfs = [u'CT__brow_bnd', u'LT_in_brow_bnd', u'LT_inner_eyelid_bnd', u'LT_in_cheek_bnd', u'LT_up_crease_bnd', u'LT__philtrum_bnd', u'CT__philtrum_bnd', u'LT_mid_crease_bnd'] layerInfo = 'Nose', jntInfs, maskInInfs, maskOutInfs layerId = layer_weighting.buildLayer(mll, layerInfo) pm.delete(inbtBndMaskGrp) layer_weighting.mergeBlockWeights(mll, layerId, inbtInfNames, 'CT__noseBridge_bnd') pm.delete(inbtInfGrp) layer_weighting.mirrorLayer(mll, layerId) layer_weighting.smoothLayerMask(mll, layerId, [2.0, 1.5, 1.0]) layer_weighting.relaxLayerInfluences(mll, layerId, [41,41,23], [0.2333,0.2333,0.0941])
def addRollLipsPivots(): bnds = [ nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'LT_upper_sneer_lip_bnd'), nt.Joint(u'LT_upper_pinch_lip_bnd'), nt.Joint(u'LT_lower_pinch_lip_bnd'), nt.Joint(u'LT_lower_sneer_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'), nt.Joint(u'RT_lower_sneer_lip_bnd'), nt.Joint(u'RT_lower_pinch_lip_bnd'), nt.Joint(u'RT_upper_pinch_lip_bnd'), nt.Joint(u'RT_upper_sneer_lip_bnd') ] for eachBnd in bnds: addPivotToBnd(eachBnd, 'rollPivot')
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 addLocToVertCrv(cth, vertCrv, driverJnt): ''' get closest pt to ctl on vertCrv get param, get length, get percentage along length (for motionPath) multiply percentage by vertCrv.lengthRatio return loc ''' cthId = int(cth.name().split('_')[1][-1]) pt = driverJnt.getTranslation(space='world') param = vertCrv.getParamAtPoint(pt) ptLength = findLengthFromParam(vertCrv, param) totalLength = vertCrv.length() lengthPercent = ptLength / totalLength # multiply lengthPercent mdl = pm.createNode('multDoubleLinear', n=vertCrv + '_md_' + str(cthId)) mdl.input1.set(lengthPercent) vertCrv.lengthRatio >> mdl.input2 # percentage used for motionPath uVal mp = pm.createNode('motionPath', n=vertCrv + '_mp_' + str(cthId)) vertCrv.worldSpace[0] >> mp.gp mdl.output >> mp.uValue mp.fractionMode.set(True) # aim settings for motionPath aimObjects = { 0: nt.Joint(u'Mathilda_spine_end_jnt'), 2: nt.Joint(u'Mathilda_spine_hi_jnt'), 4: nt.Joint(u'Mathilda_spine_mid_jnt'), 6: nt.Joint(u'Mathilda_hip_jnt') } aimObj = aimObjects[cthId] mp.wut.set(1) # object up aimObj.worldMatrix >> mp.worldUpMatrix mp.frontAxis.set(0) # X mp.upAxis.set(2) # Z mp.inverseUp.set(True) # create locator to substitute for joint loc = pm.spaceLocator(n=vertCrv + '_loc_' + str(cthId)) mp.ac >> loc.t mp.r >> loc.r return loc
def addLeftSneerPivots(mirror=False): bnds = [ nt.Joint(u'LT_in_philtrum_bnd'), nt.Joint(u'LT_philtrum_bnd'), nt.Joint(u'LT_nostril_bnd'), nt.Joint(u'LT_sneer_bnd'), nt.Joint(u'LT_upper_pinch_lip_bnd'), nt.Joint(u'LT_lower_pinch_lip_bnd'), nt.Joint(u'LT_lower_sneer_lip_bnd'), nt.Joint(u'LT_upper_sneer_lip_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd') ] pivotName = 'sneerLT' if mirror: bnds = [pm.PyNode(bnd.name().replace('LT_', 'RT_')) for bnd in bnds] pivotName = 'sneerRT' for eachBnd in bnds: addPivotToBnd(eachBnd, pivotName)
def showRotateOrderAttrs(): ctls = [ nt.Transform(u'Ori_neck_ctrl'), nt.Joint(u'Ori_midNeck_ctrl'), nt.Transform(u'Ori_head_ctrl'), nt.Transform(u'Ori_spineHigh_ctrl'), nt.Transform(u'Ori_spineMid_2_ctrl'), nt.Transform(u'Ori_spineMid_1_ctrl'), nt.Transform(u'Ori_spineLow_ctrl'), nt.Transform(u'Ori_cog_ctrl') ] for ctl in ctls: ctl.rotateOrder.set(cb=True)
def moveClaviclePivot(): ''' ''' # move clavicle pivot newPos = pm.dt.Vector([-1.06312130585, 91.7071256576, -1.76231053414]) moveNode = nt.Transform(u'Mathilda_rt_clavicleTrans_ctrl_zeroFrzGrp') jnt = nt.Joint(u'Mathilda_rt_clavicle_jnt') newPivot = pm.spaceLocator(n='rt_newpivot') newPivot.t.set(newPos) incomingCons = set(jnt.inputs(type='constraint')) outgoingCons = set(jnt.outputs(type='constraint')) outgoingCons = [con for con in outgoingCons if con not in incomingCons] wMatDict = {} # store world matrices for constrainees for con in outgoingCons: dag = con.ctx.outputs()[0] wMat = dag.getMatrix(worldSpace=True) wMatDict[con] = wMat mel.moveJointsMode(True) # assume move node is currently an identity matrix # so we can just use translate for offset newPos = newPivot.getTranslation(space='world') moveNode.setTranslation(newPos, space='world') # restore world matrices for constainees for con in outgoingCons: dag = con.ctx.outputs()[0] wMat = wMatDict[con] dag.setMatrix(wMat, worldSpace=True) pm.parentConstraint(jnt, dag, mo=True, e=True) mel.moveJointsMode(False)
# constrain the control cons = pm.parentConstraint(mover, ctgFrz, mo=True, w=1) if 'eyelid_' in bnd.name(): scaleCons = pm.scaleConstraint(mover, ctgFrz, mo=True, w=1) else: # no scale for socket bnds pass # connect bnd by direct trs (to keep it local) ctgFrz.t >> bndFrz.t ctgFrz.r >> bndFrz.r ctgFrz.s >> bndFrz.s bnds = [ nt.Joint(u'LT_inner_eyelid_bnd'), nt.Joint(u'LT_lowerOuter_eyeSocket_bnd'), nt.Joint(u'LT_lowerInner_eyeSocket_bnd'), nt.Joint(u'LT_lower_eyeSocket_bnd'), nt.Joint(u'LT_lower_eyelid_bnd'), nt.Joint(u'LT_lowerOuter_eyelid_bnd'), nt.Joint(u'LT_upper_eyelid_bnd'), nt.Joint(u'LT_upperOuter_eyelid_bnd'), nt.Joint(u'LT_outer_eyelid_bnd'), nt.Joint(u'LT_upperInner_eyelid_bnd'), nt.Joint(u'LT_lowerInner_eyelid_bnd'), nt.Joint(u'LT_upper_eyeSocket_bnd'), nt.Joint(u'LT_upperInner_eyeSocket_bnd'), nt.Joint(u'LT_upperOuter_eyeSocket_bnd'), nt.Joint(u'LT_outer_eyeSocket_bnd'), nt.Joint(u'LT_inner_eyeSocket_bnd')
def addInOutEyelidCorners(): # add primarys for eyelids in/out bnd = nt.Joint(u'LT_inner_eyelid_bnd') pCtl = priCtl.addPrimaryCtlToBnd(bnd) bndsToConnect = [nt.Joint(u'LT_innerUpper_eyelid_bnd'), nt.Joint(u'LT_inner_eyelid_bnd'), nt.Joint(u'LT_innerLower_eyelid_bnd'), nt.Joint(u'LT_inCorner_eyeSocket_bnd')] priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) bnd = nt.Joint(u'LT_outer_eyelid_bnd') pCtl = priCtl.addPrimaryCtlToBnd(bnd) bndsToConnect = [nt.Joint(u'LT_outerUpper_eyelid_bnd'), nt.Joint(u'LT_outer_eyelid_bnd'), nt.Joint(u'LT_outerLower_eyelid_bnd'), nt.Joint(u'LT_outCorner_eyeSocket_bnd')] priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) bnd = nt.Joint(u'RT_inner_eyelid_bnd') pCtl = priCtl.addPrimaryCtlToBnd(bnd) bndsToConnect = [nt.Joint(u'RT_innerUpper_eyelid_bnd'), nt.Joint(u'RT_inner_eyelid_bnd'), nt.Joint(u'RT_innerLower_eyelid_bnd'), nt.Joint(u'RT_inCorner_eyeSocket_bnd')] priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) bnd = nt.Joint(u'RT_outer_eyelid_bnd') pCtl = priCtl.addPrimaryCtlToBnd(bnd) bndsToConnect = [nt.Joint(u'RT_outerUpper_eyelid_bnd'), nt.Joint(u'RT_outer_eyelid_bnd'), nt.Joint(u'RT_outerLower_eyelid_bnd'), nt.Joint(u'RT_outCorner_eyeSocket_bnd')] priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) '''
def test_classCreation(self): self.newobjs.append(nt.Joint()) self.newobjs.append(nt.Transform())
for srcPlug, destPlug in all_output_cons: if jnt.name() in destPlug.nodeName(): srcPlug // destPlug attr = destPlug.attrName() try: newDestPlug = cth.attr(attr) print newDestPlug srcPlug >> newDestPlug except: pass ctl | jnt ctl.v.set(l=True, k=False, ch=False) pm.select(ctl) jnt = nt.Joint(u'Ori_lf_wrist_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_lf_elbow_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_rt_wrist_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_rt_elbow_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_lf_ankle_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_lf_knee_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_rt_ankle_jnt') addTranslateControlToJoint(jnt) jnt = nt.Joint(u'Ori_rt_knee_jnt') addTranslateControlToJoint(jnt)
Created on Sep 29, 2014 @author: Leon ''' import pymel.core as pm from pymel.core.language import Mel mel = Mel() import pymel.core.nodetypes as nt #=============================================================================== # Add bnds for local rig #=============================================================================== bnds = [ nt.Joint(u'LT_lowerPinch_lip_bnd'), nt.Joint(u'LT_upperSide_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'), nt.Joint(u'LT_lowerSneer_lip_bnd'), nt.Joint(u'LT_corner_lip_bnd'), nt.Joint(u'LT_lowerSide_lip_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'LT_upperPinch_lip_bnd'), nt.Joint(u'LT_upperSneer_lip_bnd'), nt.Joint(u'RT_lowerPinch_lip_bnd'), nt.Joint(u'RT_upperSide_lip_bnd'), nt.Joint(u'RT_lowerSneer_lip_bnd'), nt.Joint(u'RT_corner_lip_bnd'), nt.Joint(u'RT_lowerSide_lip_bnd'), nt.Joint(u'RT_upperPinch_lip_bnd'), nt.Joint(u'RT_upperSneer_lip_bnd')
attrName = 'CT__jaw_pri_ctrl_weight_' bndAttr = bnd.attr(attrName+channels[0]) cornerAttr = cornerBnd.attr(attrName+channels[0]) ratio = bndAttr.get() / cornerAttr.get() md = pm.createNode('multDoubleLinear', n=bnd+'_jawInfluence_md') cornerAttr >>md.input1 md.input2.set(ratio) bta = pm.createNode('blendTwoAttr', n=bnd+'_jawInfluence_bta') bta.input[0].set(bndAttr.get()) md.output >> bta.input[1] bta.ab.set(weight) for channel in channels: bta.output >> bnd.attr(attrName+channel) # left side bnds = {nt.Joint(u'LT__sneer_bnd'):1, nt.Joint(u'LT_mid_crease_bnd'):1, nt.Joint(u'LT_high_cheek_bnd'):0.8, nt.Joint(u'LT_low_crease_bnd'):0.8, nt.Joint(u'LT_mid_cheek_bnd'):0.7} cornerBnd = nt.Joint(u'LT_corner_lip_bnd') for bnd, weight in bnds.items(): connectToCornerWeights(bnd, cornerBnd, weight) # right side bnds = {nt.Joint(u'RT__sneer_bnd'):1, nt.Joint(u'RT_mid_crease_bnd'):1, nt.Joint(u'RT_high_cheek_bnd'):0.8, nt.Joint(u'RT_low_crease_bnd'):0.8, nt.Joint(u'RT_mid_cheek_bnd'):0.7} cornerBnd = nt.Joint(u'RT_corner_lip_bnd') for bnd, weight in bnds.items():
def addJawUpSquash(): ''' add CT__jawB_pLoc first - just duplicate CT__jaw_pLoc ''' import rigger.modules.face as face reload(face) # add bnds pLoc = nt.Transform(u'CT__jawB_pLoc') bndGrp = nt.Transform(u'CT_bnd_grp') bnd = face.createBndFromPlacementLoc(pLoc, bndGrp) # sec system face.addSecondaryControlSystemToBnd(bnd) # connect to pri system import rigger.modules.priCtl as priCtl reload(priCtl) # add pri ctl priBnd = bnd newCtl = priCtl.addPrimaryCtlToBnd(priBnd) # drive other bnds bndsToDrive = [ nt.Joint(u'LT_lowerSide_lip_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'LT_lowerPinch_lip_bnd'), nt.Joint(u'LT_upperPinch_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'), nt.Joint(u'LT_upperSide_lip_bnd'), nt.Joint(u'LT_corner_lip_bnd'), nt.Joint(u'LT_upperSneer_lip_bnd'), nt.Joint(u'LT_lowerSneer_lip_bnd'), nt.Joint(u'RT_lowerSide_lip_bnd'), nt.Joint(u'RT_lowerPinch_lip_bnd'), nt.Joint(u'RT_upperPinch_lip_bnd'), nt.Joint(u'RT_upperSide_lip_bnd'), nt.Joint(u'RT_corner_lip_bnd'), nt.Joint(u'RT_upperSneer_lip_bnd'), nt.Joint(u'RT_lowerSneer_lip_bnd'), nt.Joint(u'LT_low_crease_bnd'), nt.Joint(u'RT_low_crease_bnd'), nt.Joint(u'CT__jawB_bnd'), nt.Joint(u'LT__philtrum_bnd'), nt.Joint(u'LT_in_philtrum_bnd'), nt.Joint(u'LT__sneer_bnd'), nt.Joint(u'RT__philtrum_bnd'), nt.Joint(u'RT_in_philtrum_bnd'), nt.Joint(u'RT__sneer_bnd') ] for bnd in bndsToDrive: priCtl.connectBndToPriCtl(bnd, newCtl, False) # newCtl to drive other priCtls affectedPriCtlBnds = [ nt.Joint(u'LT_lowerSneer_lip_bnd'), nt.Joint(u'LT_corner_lip_bnd'), nt.Joint(u'LT_upperSneer_lip_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'RT_upperSneer_lip_bnd'), nt.Joint(u'RT_corner_lip_bnd'), nt.Joint(u'RT_lowerSneer_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd') ] for bnd in affectedPriCtlBnds: priCtl.driveAttachedPriCtl(bnd, newCtl)
def mapFeaturePtsToBnds(): # TRANSFER FEATURE PT POSITIONS relative to bnds bndGrp = pm.PyNode('CT_bnd_grp') allBnds = bndGrp.getChildren() # home level allBnds = [hm.getChildren()[0] for hm in allBnds] # priDrv level allBnds = [pri.getChildren()[0] for pri in allBnds] # secDrv level allBnds = [sec.getChildren()[0] for sec in allBnds] # bnd level markerGrp = pm.PyNode('Marker') allMarkerGrps = markerGrp.getChildren() markerToBndTable = {} for eachMarker in allMarkerGrps: markerPos = eachMarker.getRotatePivot(space='world') closestBnd = min(allBnds, key=lambda bnd: (bnd.getTranslation(space='world') - markerPos).length()) markerToBndTable[eachMarker] = closestBnd markerToBndTable = {nt.Transform(u'MarkerGroup_CHIN'): nt.Joint(u'CT_mid_chin_bnd'), nt.Transform(u'MarkerGroup_LBCH'): nt.Joint(u'LT_low_crease_bnd'), nt.Transform(u'MarkerGroup_LBLP'): nt.Joint(u'LT_lower_pinch_lip_bnd'), nt.Transform(u'MarkerGroup_LCHIN'): nt.Joint(u'LT_mid_chin_bnd'), nt.Transform(u'MarkerGroup_LCHN'): nt.Joint(u'LT_chin_bnd'), nt.Transform(u'MarkerGroup_LIBR'): nt.Joint(u'LT_in_brow_bnd'), nt.Transform(u'MarkerGroup_LICH'): nt.Joint(u'LT_low_cheek_bnd'), nt.Transform(u'MarkerGroup_LIEY'): nt.Joint(u'LT_squint_bnd'), nt.Transform(u'MarkerGroup_LLACH'): nt.Joint(u'LT_eyelid_lower_bnd'), nt.Transform(u'MarkerGroup_LLID'): nt.Joint(u'LT_eyelid_upper_bnd'), nt.Transform(u'MarkerGroup_LLLP'): nt.Joint(u'LT_lower_sneer_lip_bnd'), nt.Transform(u'MarkerGroup_LMBR'): nt.Joint(u'LT_mid_brow_bnd'), nt.Transform(u'MarkerGroup_LMCH'): nt.Joint(u'LT_low_jaw_bnd'), nt.Transform(u'MarkerGroup_LMEY'): nt.Joint(u'LT_up_cheek_bnd'), nt.Transform(u'MarkerGroup_LMLP'): nt.Joint(u'LT_upper_sneer_lip_bnd'), nt.Transform(u'MarkerGroup_LMOU'): nt.Joint(u'LT_philtrum_bnd'), nt.Transform(u'MarkerGroup_LNOSE'): nt.Joint(u'LT_mid_crease_bnd'), nt.Transform(u'MarkerGroup_LOBR'): nt.Joint(u'LT_temple_bnd'), nt.Transform(u'MarkerGroup_LOCH'): nt.Joint(u'LT_out_cheek_bnd'), nt.Transform(u'MarkerGroup_LOEY'): nt.Joint(u'LT_in_cheek_bnd'), nt.Transform(u'MarkerGroup_LOLP'): nt.Joint(u'LT_corner_lip_bnd'), nt.Transform(u'MarkerGroup_LTCH'): nt.Joint(u'LT_cheek_bnd'), nt.Transform(u'MarkerGroup_LTEMP'): nt.Joint(u'LT_low_temple_bnd'), nt.Transform(u'MarkerGroup_LTFH'): nt.Joint(u'LT_out_low_forehead_bnd'), nt.Transform(u'MarkerGroup_LTFH1'): nt.Joint(u'LT_in_low_forehead_bnd'), nt.Transform(u'MarkerGroup_LTJA'): nt.Joint(u'LT_up_jaw_bnd'), nt.Transform(u'MarkerGroup_LTLP'): nt.Joint(u'LT_upper_pinch_lip_bnd'), nt.Transform(u'MarkerGroup_LUBR'): nt.Joint(u'LT_out_brow_bnd'), nt.Transform(u'MarkerGroup_LUFH'): nt.Joint(u'LT_out_forehead_bnd'), nt.Transform(u'MarkerGroup_LUFH1'): nt.Joint(u'LT_in_forehead_bnd'), nt.Transform(u'MarkerGroup_MNOS'): nt.Joint(u'CT_noseTip_bnd'), nt.Transform(u'MarkerGroup_RBCH'): nt.Joint(u'RT_low_crease_bnd'), nt.Transform(u'MarkerGroup_RBLP'): nt.Joint(u'RT_lower_pinch_lip_bnd'), nt.Transform(u'MarkerGroup_RCHIN'): nt.Joint(u'RT_mid_chin_bnd'), nt.Transform(u'MarkerGroup_RCHN'): nt.Joint(u'RT_chin_bnd'), nt.Transform(u'MarkerGroup_RIBR'): nt.Joint(u'RT_in_brow_bnd'), nt.Transform(u'MarkerGroup_RICH'): nt.Joint(u'RT_low_cheek_bnd'), nt.Transform(u'MarkerGroup_RIEY'): nt.Joint(u'RT_squint_bnd'), nt.Transform(u'MarkerGroup_RLACH'): nt.Joint(u'RT_eyelid_lower_bnd'), nt.Transform(u'MarkerGroup_RLID'): nt.Joint(u'RT_eyelid_upper_bnd'), nt.Transform(u'MarkerGroup_RLLP'): nt.Joint(u'RT_lower_sneer_lip_bnd'), nt.Transform(u'MarkerGroup_RMBR'): nt.Joint(u'RT_mid_brow_bnd'), nt.Transform(u'MarkerGroup_RMCH'): nt.Joint(u'RT_low_jaw_bnd'), nt.Transform(u'MarkerGroup_RMEY'): nt.Joint(u'RT_up_cheek_bnd'), nt.Transform(u'MarkerGroup_RMLP'): nt.Joint(u'RT_upper_sneer_lip_bnd'), nt.Transform(u'MarkerGroup_RMOU'): nt.Joint(u'RT_philtrum_bnd'), nt.Transform(u'MarkerGroup_RNOSE'): nt.Joint(u'RT_mid_crease_bnd'), nt.Transform(u'MarkerGroup_ROBR'): nt.Joint(u'RT_temple_bnd'), nt.Transform(u'MarkerGroup_ROCH'): nt.Joint(u'RT_out_cheek_bnd'), nt.Transform(u'MarkerGroup_ROEY'): nt.Joint(u'RT_in_cheek_bnd'), nt.Transform(u'MarkerGroup_ROLP'): nt.Joint(u'RT_corner_lip_bnd'), nt.Transform(u'MarkerGroup_RTCH'): nt.Joint(u'RT_cheek_bnd'), nt.Transform(u'MarkerGroup_RTEMP'): nt.Joint(u'RT_low_temple_bnd'), nt.Transform(u'MarkerGroup_RTFH'): nt.Joint(u'RT_out_low_forehead_bnd'), nt.Transform(u'MarkerGroup_RTFH1'): nt.Joint(u'RT_in_low_forehead_bnd'), nt.Transform(u'MarkerGroup_RTJA'): nt.Joint(u'RT_up_jaw_bnd'), nt.Transform(u'MarkerGroup_RTLP'): nt.Joint(u'RT_upper_pinch_lip_bnd'), nt.Transform(u'MarkerGroup_RUBR'): nt.Joint(u'RT_out_brow_bnd'), nt.Transform(u'MarkerGroup_RUFH'): nt.Joint(u'RT_out_forehead_bnd'), nt.Transform(u'MarkerGroup_RUFH1'): nt.Joint(u'RT_in_forehead_bnd'), nt.Transform(u'MarkerGroup_TNOS'): nt.Joint(u'CT_brow_bnd'), nt.Transform(u'MarkerGroup_ULLIP'): nt.Joint(u'LT_sneer_bnd'), nt.Transform(u'MarkerGroup_ULLIP1'): nt.Joint(u'LT_in_philtrum_bnd'), nt.Transform(u'MarkerGroup_URLIP'): nt.Joint(u'RT_sneer_bnd'), nt.Transform(u'MarkerGroup_URLIP1'): nt.Joint(u'RT_in_philtrum_bnd')} # set global positioning first (for scale) # place markers at respective bnds for eachMarker, eachBnd in markerToBndTable.items(): bndPosition = eachBnd.getTranslation(space='world') newPosition = bndPosition - eachMarker.getRotatePivot(space='world') eachMarker.setTranslation(newPosition, space='world') pm.makeIdentity(eachMarker, t=True, a=True)
def addInnerLipsPivots(): bnds = [ nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'LT_upper_sneer_lip_bnd'), nt.Joint(u'LT_upper_pinch_lip_bnd'), nt.Joint(u'LT_corner_lip_bnd'), nt.Joint(u'LT_lower_pinch_lip_bnd'), nt.Joint(u'LT_lower_sneer_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'), nt.Joint(u'RT_lower_sneer_lip_bnd'), nt.Joint(u'RT_lower_pinch_lip_bnd'), nt.Joint(u'RT_corner_lip_bnd'), nt.Joint(u'RT_upper_pinch_lip_bnd'), nt.Joint(u'RT_upper_sneer_lip_bnd') ] for eachBnd in bnds: addPivotToBnd(eachBnd, 'innerPivot')
outHm.setParent(jntPar) inHm.setParent(outGrp) jnt.setParent(inGrp) # connect sideAttr to grp.rz rt.connectSDK(sideAttr, inGrp.rz, {0: 0, 90: 90}) rt.connectSDK(sideAttr, outGrp.rz, {-90: -90, 0: 0}) # left foot ctl = nt.Transform(u'Ori_lf_heel_ik_ctrl') outPivot = nt.Transform(u'locator2') inPivot = nt.Transform(u'locator1') ctl.addAttr('revHeelSide', k=True) sideAttr = ctl.revHeelSide jnt = nt.Joint(u'Ori_lf_ball_rev_rig_jnt') addSidePivotsToFoot(sideAttr, jnt, inPivot, outPivot) jnt = nt.Joint(u'Ori_lf_ball_ik_jnt') addSidePivotsToFoot(sideAttr, jnt, inPivot, outPivot) # right foot ctl = nt.Transform(u'Ori_rt_heel_ik_ctrl') outPivot = nt.Transform(u'locator4') inPivot = nt.Transform(u'locator3') ctl.addAttr('revHeelSide', k=True) sideAttr = ctl.revHeelSide jnt = nt.Joint(u'Ori_rt_ball_rev_rig_jnt') addSidePivotsToFoot(sideAttr, jnt, inPivot, outPivot) jnt = nt.Joint(u'Ori_rt_ball_ik_jnt') addSidePivotsToFoot(sideAttr, jnt, inPivot, outPivot)
normal=(1, 0, 0), ch=False, sweep=359)[0] ctg = pm.group(ctl, n=ctl + '_grp') cth = pm.group(ctg, n=ctl + '_cth') mat = jnt.getMatrix(ws=True) cth.setMatrix(mat, ws=True) par = jnt.getParent() par | cth pm.copyAttr(jnt, ctg, inConnections=True) ctl | jnt spreadJnts = [ nt.Joint(u'Ori_lf_pinkyCup_jnt'), nt.Joint(u'Ori_lf_ringCup_jnt'), nt.Joint(u'Ori_lf_middleCup_jnt'), nt.Joint(u'Ori_lf_indexCup_jnt'), nt.Joint(u'Ori_rt_pinkyCup_jnt'), nt.Joint(u'Ori_rt_ringCup_jnt'), nt.Joint(u'Ori_rt_middleCup_jnt'), nt.Joint(u'Ori_rt_indexCup_jnt') ] # add ctl for each spread jnt for jnt in spreadJnts: addCtrlToSpreadJnt(jnt)
pos = targetNode.getTranslation(space='world') grp = pm.group(em=True, n=targetNode + '_worldOrient_grp') hm = pm.group(grp, n=targetNode + '_worldOrient_hm') hm.setTranslation(pos) targetParent = targetNode.getParent() targetParent | hm grp | targetNode pm.select(grp, r=True) return grp targetNodes = [ nt.Joint(u'Ori_lf_heel_rev_rig_jnt'), nt.Joint(u'Ori_lf_toe_rev_rig_jnt'), nt.Joint(u'Ori_lf_ball_ik_jnt'), nt.Joint(u'Ori_lf_ball_rev_rig_jnt'), nt.Joint(u'Ori_rt_heel_rev_rig_jnt'), nt.Joint(u'Ori_rt_toe_rev_rig_jnt'), nt.Joint(u'Ori_rt_ball_ik_jnt'), nt.Joint(u'Ori_rt_ball_rev_rig_jnt') ] # Fix rotateYs for each joint for jnt in targetNodes: newNode = addWorldOrientParent(jnt) inPlug = jnt.ry.inputs(p=True)[0] inPlug >> newNode.ry inPlug // jnt.ry
''' Created on Sep 17, 2014 @author: Leon ''' import pymel.core as pm from pymel.core.language import Mel mel = Mel() import pymel.core.nodetypes as nt bndsToDrive = [ nt.Joint(u'LT_mid_crease_bnd'), nt.Joint(u'LT_up_cheek_bnd'), nt.Joint(u'LT_out_cheek_bnd'), nt.Joint(u'LT__squint_bnd'), nt.Joint(u'LT_up_jaw_bnd'), nt.Joint(u'LT_low_cheek_bnd') ] pCtl = nt.Transform(u'LT_mid_cheek_pri_ctrl') import rigger.modules.priCtl as priCtl reload(priCtl) for bnd in bndsToDrive: priCtl.connectBndToPriCtl(bnd, pCtl, False) priBndsToDrive = [nt.Joint(u'LT__squint_bnd')] for bnd in priBndsToDrive: priCtl.driveAttachedPriCtl(bnd, pCtl)
def setEyelidLoopWeights(prefix, upperBnds=None, lowerBnds=None): # define data drvCrv = pm.PyNode(prefix + '_eye_aimAt_crv_0') if not upperBnds: upperBnds = [ nt.Joint(prefix + '_inner_eyelid_bnd'), nt.Joint(prefix + '_innerUpper_eyelid_bnd'), nt.Joint(prefix + '_upper_eyelid_bnd'), nt.Joint(prefix + '_outerUpper_eyelid_bnd'), nt.Joint(prefix + '_outer_eyelid_bnd') ] if not lowerBnds: lowerBnds = [ nt.Joint(prefix + '_inner_eyelid_bnd'), nt.Joint(prefix + '_innerLower_eyelid_bnd'), nt.Joint(prefix + '_lower_eyelid_bnd'), nt.Joint(prefix + '_outerLower_eyelid_bnd'), nt.Joint(prefix + '_outer_eyelid_bnd') ] cornerBnds = upperBnds[0], upperBnds[2], upperBnds[4], lowerBnds[2] ''' cornerPLocs = [pm.PyNode(bnd.replace('_bnd','_pLoc')) for bnd in cornerBnds] cornerCvIds = [pLoc.cv_id.get() for pLoc in cornerPLocs] print cornerCvIds ''' cornerCvIds = [ lcrv.getClosestCVtoXfo(eachBnd, drvCrv).index() for eachBnd in cornerBnds ] print cornerCvIds targetCrvs = getUpperLowerEyeCurves(drvCrv, cornerCvIds) setEyelidControlsWeights(prefix, upperBnds, lowerBnds, targetCrvs) # map bnds to CV index upperBndTable = {} for eachBnd in upperBnds: # get CV index closest to eachBnd cv = lcrv.getClosestCVtoXfo(eachBnd, drvCrv) upperBndTable[eachBnd] = cv.index() lowerBndTable = {} for eachBnd in lowerBnds: # get CV index closest to eachBnd cv = lcrv.getClosestCVtoXfo(eachBnd, drvCrv) lowerBndTable[eachBnd] = cv.index() # initial bind skn = pm.skinCluster(upperBnds + lowerBnds, drvCrv) # make sure each bnd has 100% weight to its closest cv for eachBnd in upperBnds: bindCV = upperBndTable[eachBnd] pm.skinPercent(skn, drvCrv.cv[bindCV], tv=(eachBnd, 1.0)) for eachBnd in lowerBnds: bindCV = lowerBndTable[eachBnd] pm.skinPercent(skn, drvCrv.cv[bindCV], tv=(eachBnd, 1.0)) # bind splices between each bind jnt # get vector from upper control heightVec = pm.dt.Vector(0, -1, 0) * upperBnds[2].getMatrix(ws=True) intVec = pm.dt.Vector(0, 0, -1) * upperBnds[2].getMatrix(ws=True) bindSpliceBetweenJoints(upperBnds[0], upperBnds[1], drvCrv, upperBndTable[upperBnds[0]], upperBndTable[upperBnds[1]], targetCrvs['lower'], skn, heightVec, intVec) bindSpliceBetweenJoints(upperBnds[1], upperBnds[2], drvCrv, upperBndTable[upperBnds[1]], upperBndTable[upperBnds[2]], targetCrvs['lower'], skn, heightVec, intVec) bindSpliceBetweenJoints(upperBnds[2], upperBnds[3], drvCrv, upperBndTable[upperBnds[2]], upperBndTable[upperBnds[3]], targetCrvs['lower'], skn, heightVec, intVec) bindSpliceBetweenJoints(upperBnds[3], upperBnds[4], drvCrv, upperBndTable[upperBnds[3]], upperBndTable[upperBnds[4]], targetCrvs['lower'], skn, heightVec, intVec) # get vector from lower control heightVec = pm.dt.Vector(0, -1, 0) * lowerBnds[2].getMatrix(ws=True) intVec = pm.dt.Vector(0, 0, -1) * lowerBnds[2].getMatrix(ws=True) bindSpliceBetweenJoints(lowerBnds[0], lowerBnds[1], drvCrv, lowerBndTable[lowerBnds[0]], lowerBndTable[lowerBnds[1]], targetCrvs['upper'], skn, heightVec, intVec) bindSpliceBetweenJoints(lowerBnds[1], lowerBnds[2], drvCrv, lowerBndTable[lowerBnds[1]], lowerBndTable[lowerBnds[2]], targetCrvs['upper'], skn, heightVec, intVec) bindSpliceBetweenJoints(lowerBnds[2], lowerBnds[3], drvCrv, lowerBndTable[lowerBnds[2]], lowerBndTable[lowerBnds[3]], targetCrvs['upper'], skn, heightVec, intVec) bindSpliceBetweenJoints(lowerBnds[3], lowerBnds[4], drvCrv, lowerBndTable[lowerBnds[3]], lowerBndTable[lowerBnds[4]], targetCrvs['upper'], skn, heightVec, intVec) pm.delete(targetCrvs.values())
def addHighCheekControls(): ''' ''' import rigger.modules.face as face reload(face) # add bnds pLoc = nt.Transform(u'LT_high_cheek_pLoc') bndGrp = nt.Transform(u'CT_bnd_grp') face.createBndFromPlacementLoc(pLoc, bndGrp) pLoc = nt.Transform(u'RT_high_cheek_pLoc') bndGrp = nt.Transform(u'CT_bnd_grp') face.createBndFromPlacementLoc(pLoc, bndGrp) # sec system bnd = nt.Joint(u'LT_high_cheek_bnd') face.addSecondaryControlSystemToBnd(bnd) bnd = nt.Joint(u'RT_high_cheek_bnd') face.addSecondaryControlSystemToBnd(bnd) # connect to pri system import rigger.modules.priCtl as priCtl reload(priCtl) # left bndsToConnect = [nt.Joint(u'LT_high_cheek_bnd')] pCtl = nt.Transform(u'LT__squint_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'CT__mouthMover_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'CT__jaw_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'LT_mid_cheek_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'LT_corner_lip_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) # right bndsToConnect = [nt.Joint(u'RT_high_cheek_bnd')] pCtl = nt.Transform(u'RT__squint_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'CT__mouthMover_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'CT__jaw_pri_ctrl') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'RT_mid_cheek_pri_ctrl_real') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) pCtl = nt.Transform(u'RT_corner_lip_pri_ctrl_real') priCtl.connectBndsToPriCtl(bndsToConnect, pCtl) # add pri ctl to high_cheek_bnd priBnd = nt.Joint(u'LT_high_cheek_bnd') newCtl = priCtl.addPrimaryCtlToBnd(priBnd) priCtl.addPriCtlDrivers(priBnd) priBnd = nt.Joint(u'RT_high_cheek_bnd') newCtl = priCtl.addPrimaryCtlToBnd(priBnd) priCtl.addPriCtlDrivers(priBnd) # drive other bnds newCtl = nt.Transform(u'LT_high_cheek_pri_ctrl') bndsToDrive = [ nt.Joint(u'LT_up_crease_bnd'), nt.Joint(u'LT_in_cheek_bnd'), nt.Joint(u'LT_up_cheek_bnd'), nt.Joint(u'LT_out_cheek_bnd'), nt.Joint(u'LT__squint_bnd'), nt.Joint(u'LT_high_cheek_bnd'), nt.Joint(u'LT_mid_crease_bnd'), nt.Joint(u'LT_low_crease_bnd'), nt.Joint(u'LT_mid_cheek_bnd'), nt.Joint(u'LT_low_cheek_bnd') ] for bnd in bndsToDrive: priCtl.connectBndToPriCtl(bnd, newCtl, False) # drive other bnds newCtl = nt.Transform(u'RT_high_cheek_pri_ctrl') bndsToDrive = [ nt.Joint(u'RT_up_crease_bnd'), nt.Joint(u'RT_in_cheek_bnd'), nt.Joint(u'RT_up_cheek_bnd'), nt.Joint(u'RT_out_cheek_bnd'), nt.Joint(u'RT__squint_bnd'), nt.Joint(u'RT_high_cheek_bnd'), nt.Joint(u'RT_mid_crease_bnd'), nt.Joint(u'RT_low_crease_bnd'), nt.Joint(u'RT_mid_cheek_bnd'), nt.Joint(u'RT_low_cheek_bnd') ] for bnd in bndsToDrive: priCtl.connectBndToPriCtl(bnd, newCtl, False) # newCtl to drive other priCtls newCtl = nt.Transform(u'LT_high_cheek_pri_ctrl') priCtl.driveAttachedPriCtl(nt.Joint(u'LT__squint_bnd'), newCtl) priCtl.driveAttachedPriCtl(nt.Joint(u'LT_mid_cheek_bnd'), newCtl) newCtl = nt.Transform(u'RT_high_cheek_pri_ctrl') priCtl.driveAttachedPriCtl(nt.Joint(u'RT__squint_bnd'), newCtl) priCtl.driveAttachedPriCtl(nt.Joint(u'RT_mid_cheek_bnd'), newCtl)
def setEyelidControlsWeights(prefix, upperBnds, lowerBnds, targetCrvs): # define all data - hard coded if not upperBnds: upperBnds = [ nt.Joint(prefix + '_inner_eyelid_bnd'), nt.Joint(prefix + '_innerUpper_eyelid_bnd'), nt.Joint(prefix + '_upper_eyelid_bnd'), nt.Joint(prefix + '_outerUpper_eyelid_bnd'), nt.Joint(prefix + '_outer_eyelid_bnd') ] if not lowerBnds: lowerBnds = [ nt.Joint(prefix + '_inner_eyelid_bnd'), nt.Joint(prefix + '_innerLower_eyelid_bnd'), nt.Joint(prefix + '_lower_eyelid_bnd'), nt.Joint(prefix + '_outerLower_eyelid_bnd'), nt.Joint(prefix + '_outer_eyelid_bnd') ] upperCtls = [ pm.PyNode(node.name().replace('_bnd', '_ctrl')) for node in upperBnds ] lowerCtls = [ pm.PyNode(node.name().replace('_bnd', '_ctrl')) for node in lowerBnds ] # weight ctls # UPPER controls # get vector from upper control heightVec = pm.dt.Vector(0, -1, 0) * upperBnds[2].getMatrix(ws=True) intVec = pm.dt.Vector(0, 0, -1) * upperBnds[2].getMatrix(ws=True) # get Y-height from lower curve upperHeight = lcrv.calcHeightFromCurve(upperBnds[2], targetCrvs['lower'], heightVec=heightVec, intVec=intVec) upperInnerHeight = lcrv.calcHeightFromCurve(upperBnds[1], targetCrvs['lower'], heightVec=heightVec, intVec=intVec) upperOuterHeight = lcrv.calcHeightFromCurve(upperBnds[3], targetCrvs['lower'], heightVec=heightVec, intVec=intVec) upperInnerWeight = upperInnerHeight / upperHeight upperOuterWeight = upperOuterHeight / upperHeight channels = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'] upperPriCtl = upperCtls[2].name().replace('_ctrl', '_pri_ctrl') [ upperBnds[1].attr(upperPriCtl + '_weight_' + channel).set(upperInnerWeight) for channel in channels ] [ upperBnds[3].attr(upperPriCtl + '_weight_' + channel).set(upperOuterWeight) for channel in channels ] # LOWER controls # get vector from lower control heightVec = pm.dt.Vector(0, 1, 0) * lowerBnds[2].getMatrix(ws=True) intVec = pm.dt.Vector(0, 0, -1) * lowerBnds[2].getMatrix(ws=True) # get y-height from upper crv lowerHeight = lcrv.calcHeightFromCurve(lowerBnds[2], targetCrvs['upper'], heightVec=heightVec, intVec=intVec) lowerInnerHeight = lcrv.calcHeightFromCurve(lowerBnds[1], targetCrvs['upper'], heightVec=heightVec, intVec=intVec) lowerOuterHeight = lcrv.calcHeightFromCurve(lowerBnds[3], targetCrvs['upper'], heightVec=heightVec, intVec=intVec) lowerInnerWeight = lowerInnerHeight / lowerHeight lowerOuterWeight = lowerOuterHeight / lowerHeight channels = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'] lowerPriCtl = lowerCtls[2].name().replace('_ctrl', '_pri_ctrl') [ lowerBnds[1].attr(lowerPriCtl + '_weight_' + channel).set(lowerInnerWeight) for channel in channels ] [ lowerBnds[3].attr(lowerPriCtl + '_weight_' + channel).set(lowerOuterWeight) for channel in channels ]
bnds = [] for pLoc in pLocs: bnds.append(face.createBndFromPlacementLoc(pLoc, bndGrp)) # secondary system for bnd in bnds: face.addSecondaryControlSystemToBnd(bnd) # add pri ctls shaperCtls = [] for bnd in bnds: shaperCtls.append(priCtl.addPrimaryCtlToBnd(bnd)) # drive lowerB bnds bndsToDrive = [ nt.Joint(u'LT__philtrum_bnd'), nt.Joint(u'LT_mid_crease_bnd'), nt.Joint(u'LT_low_crease_bnd'), nt.Joint(u'LT_corner_jaw_bnd'), nt.Joint(u'LT_low_jaw_bnd'), nt.Joint(u'LT__chin_bnd'), nt.Joint(u'CT__chin_bnd'), nt.Joint(u'CT__neck_bnd'), nt.Joint(u'LT__neck_bnd'), nt.Joint(u'CT__jaw_bnd'), nt.Joint(u'CT__mouthMover_bnd'), nt.Joint(u'LT_lowerSide_lip_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'LT_lowerPinch_lip_bnd'), nt.Joint(u'LT_upperPinch_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'),
def addLeftCheekPuffPivots(mirror=False): bnds = [ nt.Joint(u'LT_upper_sneer_lip_bnd'), nt.Joint(u'LT_upper_pinch_lip_bnd'), nt.Joint(u'LT_corner_lip_bnd'), nt.Joint(u'LT_lower_pinch_lip_bnd'), nt.Joint(u'LT_lower_sneer_lip_bnd'), nt.Joint(u'LT_sneer_bnd'), nt.Joint(u'LT_mid_chin_bnd'), nt.Joint(u'CT_upper_lip_bnd'), nt.Joint(u'CT_lower_lip_bnd'), nt.Joint(u'CT_mid_chin_bnd'), nt.Joint(u'LT_low_crease_bnd') ] pivotName = 'cheekPuffLeft' if mirror: bnds = [pm.PyNode(bnd.name().replace('LT_', 'RT_')) for bnd in bnds] pivotName = 'cheekPuffRight' for eachBnd in bnds: addPivotToBnd(eachBnd, pivotName)
''' Created on Sep 24, 2014 @author: Leon ''' import pymel.core as pm from pymel.core.language import Mel mel = Mel() import pymel.core.nodetypes as nt #=============================================================================== # drive temple joints by jaw #=============================================================================== bndsToDrive = [nt.Joint(u'LT_low_temple_bnd'), nt.Joint(u'RT_low_temple_bnd')] pCtl = nt.Transform(u'CT__jawDown_pri_ctrl') import rigger.modules.priCtl as priCtl reload(priCtl) for bnd in bndsToDrive: priCtl.connectBndToPriCtl(bnd, pCtl, False) #=============================================================================== # drive eyelid joints by corners #=============================================================================== import rigger.modules.priCtl as priCtl reload(priCtl) bndsToDrive = [ nt.Joint(u'LT_upper_eyelid_bnd'),