def buildRoot(self, ctrlSize, cleanup): # controls self.root_01_ctrl = controls.circleBumpCtrl(name='root_01_CTRL', axis='y', radius=ctrlSize) self.root_01_ctrl.setParent(self.ctrls_grp) self.ctrls.append(self.root_01_ctrl) self.root_02_ctrl = controls.circleBumpCtrl(name='root_02_CTRL', axis='y', radius=ctrlSize * .85) self.root_02_ctrl.setParent(self.root_01_ctrl) self.ctrls.append(self.root_02_ctrl) self.root_03_ctrl = controls.circleBumpCtrl(name='root_03_CTRL', axis='y', radius=ctrlSize * .7) self.root_03_ctrl.setParent(self.root_02_ctrl) self.ctrls.append(self.root_03_ctrl) coreUtils.colorize('green', self.ctrls) # connections self.exposeSockets({'03': self.root_03_ctrl}) if cleanup: self.cleanup()
def buildHand(self, settingsNode, fingerDict, colour, cleanup): ctrlSize=None for finger in fingerDict.keys(): for i in range(len(fingerDict[finger])): if not ctrlSize: ctrlSize = coreUtils.getDistance(fingerDict[finger][0], fingerDict[finger][1]) * .25 if i > 0: j2 = coreUtils.createAlignedNode(fingerDict[finger][i], 'joint', '%s_%s_%s_translate_JNT' % (self.name, finger, str(i+1).zfill(2))) j2.setParent(self.joints[-1]) j2.jointOrient.set(fingerDict[finger][i].jointOrient.get()) j2.r.set((0, 0, 0)) coreUtils.addParent(j2, 'group', '%s_%s_%s_translateJnt_ZERO' % (self.name, finger, str(i+1).zfill(2))) self.joints.append(j2) j = coreUtils.createAlignedNode(fingerDict[finger][i], 'joint', '%s_%s_%s_JNT' % (self.name, finger, str(i+1).zfill(2))) c = controls.squareCtrl(axis='x', name='%s_%s_%s_CTRL' % (self.name, finger, str(i+1).zfill(2)), size=ctrlSize) coreUtils.align(c, j) pmc.select('%s.cv[*]' % c.name()) pmc.scale(5.0, scaleY=1) if i == 0: j.setParent(self.rig_grp) jGrp = coreUtils.addParent(j, 'group', '%s_%s_joints_GRP' % (self.name, finger)) j.jointOrient.set((0, 0, 0)) j.r.set((0, 0, 0)) c.setParent(self.ctrls_grp) cGrp = coreUtils.addParent(c, 'group', '%s_%s_ctrls_GRP' % (self.name, finger)) c.t.connect(j.t) c.r.connect(j.r) pmc.parentConstraint(cGrp, jGrp) else: j.setParent(self.joints[-1]) j.jointOrient.set((0, 0, 0)) j.r.set((0, 0, 0)) c.setParent(self.ctrls[-1]) coreUtils.addParent(c, 'group', '%s_%s_%s_ZERO' % (self.name, finger, str(i+1).zfill(2))) c.t.connect(j2.t) c.r.connect(j.r) self.joints.append(j) self.ctrls.append(c) coreUtils.colorize(colour, self.ctrls) if settingsNode: pmc.addAttr(settingsNode, longName='finger_ctrls_vis', at='bool', k=0, h=0) pmc.setAttr(settingsNode.finger_ctrls_vis, channelBox=1) settingsNode.finger_ctrls_vis.connect(self.ctrls_grp.visibility) if cleanup: self.cleanup()
def _makeCtrl(prefix='', colour='red', pos=(0, 0, 0), grpParent=None): c = controls.squareCtrl(size=ctrlSize, name='%s_CTRL' % prefix, axis='z') c.t.set(pos) zero = coreUtils.addParent(c, 'group', '%sCtrl_ZERO' % prefix) zero.setParent(self.ctrls_grp) pmc.select('%s.cv[ * ]' % coreUtils.getShape(c)) pmc.scale(.33, scaleY=1) coreUtils.colorize(colour, [c]) self.ctrls.append(c) g = coreUtils.addChild(grpParent, 'group', '%s_DRV' % prefix) _addControl(g, c) return c, g
def _makeSubCtrls(parent, prefix='', colour='red', grpParent=None): for i in range(len(subs.keys())): c = controls.squareCtrl(size=ctrlSize * .15, name='%s_%s_CTRL' % (prefix, subs[i][0]), axis='z') coreUtils.align(c, parent, parent=1) c.tx.set(ctrlSize * subs[i][1]) coreUtils.addParent(c, 'group', c.name().replace('_CTRL', 'Ctrl_ZERO')) coreUtils.colorize(colour, [c]) self.ctrls.append(c) g = coreUtils.addChild(grpParent, 'group', '%s_%s_DRV' % (prefix, subs[i][0])) j = coreUtils.addChild(g, 'joint', '%s_%s_JNT' % (prefix, subs[i][0])) j.t.set((ctrlSize * subs[i][1], 0, 0)) self.joints.append(j) c.t.connect(g.t)
def buildHead(self, startPos, cleanup): # controls ctrlSize = startPos[1] * .1 self.head_ctrl = controls.circleBumpCtrl(name='head_CTRL', axis='y', radius=ctrlSize) self.head_ctrl.setParent(self.ctrls_grp) self.head_ctrl.t.set(startPos) self.headZero_grp = coreUtils.addParent(self.head_ctrl, 'group', name='head_ZERO') self.ctrls.append(self.head_ctrl) self.head_ctrl.rotateOrder.set(4) j = coreUtils.addChild(self.rig_grp, 'joint', 'head_JNT') self.joints.append(j) pmc.parentConstraint(self.head_ctrl, j, mo=0) # Extract twist twist = coreUtils.extractAxis(self.head_ctrl, axis='y', name='head_twist', exposeNode=self.main_grp, exposeAttr='twist') twist['main_grp'].setParent(self.rig_grp) pmc.parentConstraint(self.headZero_grp, twist['main_grp']) # colours coreUtils.colorize('green', [self.head_ctrl]) # connections self.exposeSockets({'ctrl': self.head_ctrl}) if cleanup: self.cleanup()
def buildMouth(self, crv, numCtrls, numLipJoints, cleanup): if not crv: return 'DrMouth: Please provide a curve for the mouth to ride along' self.topLip = drRail.DrRail(name='topLip', crv=crv, numCtrls=numCtrls, numSubCtrls=numLipJoints) self.topLip.main_grp.end_uValue.set(1.0) self.topLip.main_grp.setParent(self.main_grp) self.btmLip = drRail.DrRail(name='btmLip', crv=crv, numCtrls=numCtrls, numSubCtrls=numLipJoints) self.btmLip.main_grp.end_uValue.set(1.0) self.btmLip.main_grp.setParent(self.main_grp) ctrlSize = coreUtils.getDistance(crv.getCV(0), crv.getCV(1)) * .5 self.rtCtrl = controls.circleBumpCtrl(radius=ctrlSize, name='%s_rt_corner_CTRL' % self.name) coreUtils.align(self.rtCtrl, self.topLip.ctrls[0]) self.rtCtrl.setParent(self.ctrls_grp) zero = coreUtils.addParent(self.rtCtrl, 'group', '%s_rt_cornerCtrl_ZERO' % self.name) coreUtils.colorize('red', [self.rtCtrl]) self.lfCtrl = controls.circleBumpCtrl(radius=ctrlSize, name='%s_lf_corner_CTRL' % self.name) coreUtils.align(self.lfCtrl, self.topLip.ctrls[-1]) self.lfCtrl.setParent(self.ctrls_grp) zero = coreUtils.addParent(self.lfCtrl, 'group', '%s_lf_cornerCtrl_ZERO' % self.name) coreUtils.colorize('blue', [self.lfCtrl]) zero.sx.set(-1) #split into left and right for i in range(numCtrls): topCtrl = self.topLip.ctrls[i] topLoc = self.topLip.locs[i] btmCtrl = self.btmLip.ctrls[i] btmLoc = self.btmLip.locs[i] if i < numCtrls / 2: coreUtils.colorize('red', [topCtrl, btmCtrl]) elif i > numCtrls / 2: coreUtils.colorize('blue', [topCtrl, btmCtrl]) topCtrl.getParent().sx.set(-1) topLoc.getParent().sx.set(-1) btmCtrl.getParent().sx.set(-1) btmLoc.getParent().sx.set(-1) else: coreUtils.colorize('green', [topCtrl, btmCtrl]) if i == 0: pmc.delete([topCtrl.getParent(), btmCtrl.getParent()]) if i == (numCtrls - 1): pmc.delete([topCtrl.getParent(), btmCtrl.getParent()]) self.topLip.ctrls = self.topLip.ctrls[1:-1] self.btmLip.ctrls = self.btmLip.ctrls[1:-1] #split subCtrls into left and right for i in range(numLipJoints): topCtrl = self.topLip.subCtrls[i] topDrv = self.topLip.drivenGrps[i] btmCtrl = self.btmLip.subCtrls[i] btmDrv = self.btmLip.drivenGrps[i] if i < numLipJoints / 2: coreUtils.colorize('red', [topCtrl, btmCtrl]) elif i > numLipJoints / 2: coreUtils.colorize('blue', [topCtrl, btmCtrl]) topCtrl.getParent().sx.set(-1) topDrv.sx.set(-1) btmCtrl.getParent().sx.set(-1) btmDrv.sx.set(-1) else: coreUtils.colorize('green', [topCtrl, btmCtrl]) rt_loc = coreUtils.addChild(self.rig_grp, 'locator', '%s_rt_corner_LOC' % self.name) coreUtils.align(rt_loc, self.rtCtrl) rt_zero = coreUtils.addParent(rt_loc, 'group', '%s_rt_cornerLoc_ZERO' % self.name) self.rtCtrl.t.connect(rt_loc.t) self.rtCtrl.getParent().t.connect(rt_zero.t) rtCornerClosestPoint = pmc.createNode( 'nearestPointOnCurve', name='closestCrvPoint_%s_rt_corner_UTL' % self.name) locShape = pmc.listRelatives(rt_loc, s=1, c=1)[0] locShape.worldPosition[0].connect(rtCornerClosestPoint.inPosition) crvShape = coreUtils.getShape(crv) crvShape.worldSpace[0].connect(rtCornerClosestPoint.inputCurve) rtCornerClosestPoint.parameter.connect( self.topLip.main_grp.start_uValue) rtCornerClosestPoint.parameter.connect( self.btmLip.main_grp.start_uValue) self.rtCtrl.ty.connect(self.topLip.locs[0].ty) self.rtCtrl.tz.connect(self.topLip.locs[0].tz) self.rtCtrl.ty.connect(self.btmLip.locs[0].ty) self.rtCtrl.tz.connect(self.btmLip.locs[0].tz) lf_loc = coreUtils.addChild(self.rig_grp, 'locator', '%s_lf_corner_LOC' % self.name) coreUtils.align(lf_loc, self.lfCtrl) lf_zero = coreUtils.addParent(lf_loc, 'group', '%s_lf_cornerLoc_ZERO' % self.name) self.lfCtrl.t.connect(lf_loc.t) self.lfCtrl.getParent().t.connect(lf_zero.t) lfCornerClosestPoint = pmc.createNode( 'nearestPointOnCurve', name='closestCrvPoint_%s_lf_corner_UTL' % self.name) locShape = pmc.listRelatives(lf_loc, s=1, c=1)[0] locShape.worldPosition[0].connect(lfCornerClosestPoint.inPosition) crvShape.worldSpace[0].connect(lfCornerClosestPoint.inputCurve) lfCornerClosestPoint.parameter.connect(self.topLip.main_grp.end_uValue) lfCornerClosestPoint.parameter.connect(self.btmLip.main_grp.end_uValue) self.lfCtrl.ty.connect(self.topLip.locs[-1].ty) self.lfCtrl.tz.connect(self.topLip.locs[-1].tz) self.lfCtrl.ty.connect(self.btmLip.locs[-1].ty) self.lfCtrl.tz.connect(self.btmLip.locs[-1].tz) # Constrain systems pmc.parentConstraint(self.ctrls_grp, self.topLip.const_grp) pmc.scaleConstraint(self.ctrls_grp, self.topLip.const_grp) pmc.parentConstraint(self.ctrls_grp, self.btmLip.const_grp) pmc.scaleConstraint(self.ctrls_grp, self.btmLip.const_grp) if cleanup: self.cleanup()
def buildEyes(self, rtPos, lfPos): if not rtPos or not lfPos: return 'DrEyes: Please supply and right and left location for your eye rig' # Make Ctrls ctrlSize = coreUtils.getDistance(rtPos, lfPos) self.mainCtrl = controls.squareCtrl(axis='z', name='%s_CTRL' % self.name, size=ctrlSize) pmc.select('%s.cv[ * ]' % coreUtils.getShape(self.mainCtrl)) pmc.scale(2.5, scaleX=1) pmc.scale(1.25, scaleY=1) self.ctrls.append(self.mainCtrl) ctrlZero = coreUtils.addParent(self.mainCtrl, 'group', '%s_ctrl_ZERO' % self.name) ctrlZero.setParent(self.ctrls_grp) midPos = coreUtils.pointsAlongVector(lfPos, rtPos)[1] ctrlZero.t.set((midPos[0], midPos[1], midPos[2] + (ctrlSize * 10))) self.rtCtrl = controls.circleCtrl(radius=ctrlSize * .25, name='rt_eye_CTRL') self.ctrls.append(self.rtCtrl) coreUtils.align(self.rtCtrl, self.mainCtrl, parent=1) rtCtrlZero = coreUtils.addParent(self.rtCtrl, 'group', 'rt_eyeCtrl_ZERO') rtCtrlZero.tx.set(rtPos[0]) self.lfCtrl = controls.circleCtrl(radius=ctrlSize * .25, name='lf_eye_CTRL') self.ctrls.append(self.lfCtrl) coreUtils.align(self.lfCtrl, self.mainCtrl, parent=1) lfCtrlZero = coreUtils.addParent(self.lfCtrl, 'group', 'lf_eyeCtrl_ZERO') lfCtrlZero.tx.set(lfPos[0]) lfCtrlZero.sx.set(-1) coreUtils.colorize('green', [self.mainCtrl]) coreUtils.colorize('red', [self.rtCtrl]) coreUtils.colorize('blue', [self.lfCtrl]) # Set up aims rtGrp = coreUtils.addChild(self.rig_grp, 'group', 'rt_eye_GRP') rtGrp.t.set(rtPos) pmc.parentConstraint(self.ctrls_grp, rtGrp, mo=1) pmc.scaleConstraint(self.ctrls_grp, rtGrp, mo=1) rtAimGrp = coreUtils.addChild(rtGrp, 'group', 'rt_eyeAim_GRP') pmc.aimConstraint(self.rtCtrl, rtAimGrp, aim=(0, 0, 1), wut='objectrotation', wuo=rtGrp) rtJnt = coreUtils.addChild(rtAimGrp, 'joint', 'rt_eyeAim_JNT') self.joints.append(rtJnt) lfGrp = coreUtils.addChild(self.rig_grp, 'group', 'lf_eye_GRP') lfGrp.t.set(lfPos) pmc.parentConstraint(self.ctrls_grp, lfGrp, mo=1) pmc.scaleConstraint(self.ctrls_grp, lfGrp, mo=1) lfAimGrp = coreUtils.addChild(lfGrp, 'group', 'lf_eyeAim_GRP') pmc.aimConstraint(self.lfCtrl, lfAimGrp, aim=(0, 0, 1), wut='objectrotation', wuo=lfGrp) lfJnt = coreUtils.addChild(lfAimGrp, 'joint', 'lf_eyeAim_JNT') self.joints.append(lfJnt) # softness pmc.addAttr(self.main_grp, longName='eye_pull', minValue=0.0, maxValue=1.0, at='double', k=1, h=0) eyePullRev = coreUtils.reverse(self.main_grp.eye_pull, name='rev_eyePull_UTL') rtSoftGrp = coreUtils.addChild(rtGrp, 'group', 'rt_eyeSoft_GRP') rtSoftJnt = coreUtils.addChild(rtSoftGrp, 'joint', 'rt_soft_JNT') self.joints.append(rtSoftJnt) con = pmc.orientConstraint(rtGrp, rtAimGrp, rtSoftGrp) con.interpType.set(2) w0 = pmc.Attribute('%s.%sW0' % (con.name(), rtGrp.name())) w1 = pmc.Attribute('%s.%sW1' % (con.name(), rtAimGrp.name())) self.main_grp.eye_pull.connect(w1) eyePullRev.outputX.connect(w0) lfSoftGrp = coreUtils.addChild(lfGrp, 'group', 'lf_eyeSoft_GRP') lfSoftJnt = coreUtils.addChild(lfSoftGrp, 'joint', 'lf_soft_JNT') self.joints.append(lfSoftJnt) con = pmc.orientConstraint(lfGrp, lfAimGrp, lfSoftGrp) con.interpType.set(2) w0 = pmc.Attribute('%s.%sW0' % (con.name(), lfGrp.name())) w1 = pmc.Attribute('%s.%sW1' % (con.name(), lfAimGrp.name())) self.main_grp.eye_pull.connect(w1) eyePullRev.outputX.connect(w0) ############################################################################################################# # Lids pmc.addAttr(self.main_grp, ln='lids_rotate_factor', at='double', k=0, h=0) pmc.setAttr(self.main_grp.lids_rotate_factor, channelBox=1) self.main_grp.lids_rotate_factor.set(-10) pmc.addAttr(self.main_grp, ln='lids_auto', at='double', k=0, h=0, minValue=0.0, maxValue=1.0) self.main_grp.lids_auto.set(1.0) rtLidGrp = coreUtils.addChild(self.rig_grp, 'group', 'rt_lids_GRP') coreUtils.align(rtLidGrp, rtGrp) # rt_top rtTopLidZero = coreUtils.addChild(rtLidGrp, 'group', 'rt_topLid_ZERO') rtTopLidAutoGrp = coreUtils.addChild(rtTopLidZero, 'group', 'rt_topLidAuto_GRP') md = coreUtils.multiply(rtAimGrp.rx, self.main_grp.lids_auto, name='md_rtLidsAuto_UTL') md.outputX.connect(rtTopLidAutoGrp.rx) # rt_btm rtBtmLidZero = coreUtils.addChild(rtLidGrp, 'group', 'rt_btmLid_ZERO') rtBtmLidAutoGrp = coreUtils.addChild(rtBtmLidZero, 'group', 'rt_btmLidAuto_GRP') md.outputX.connect(rtBtmLidAutoGrp.rx) # lf_top lfLidGrp = coreUtils.addChild(self.rig_grp, 'group', 'lf_lids_GRP') coreUtils.align(lfLidGrp, lfGrp) lfTopLidZero = coreUtils.addChild(lfLidGrp, 'group', 'lf_topLid_ZERO') lfTopLidAutoGrp = coreUtils.addChild(lfTopLidZero, 'group', 'lf_topLidAuto_GRP') md = coreUtils.multiply(lfAimGrp.rx, self.main_grp.lids_auto, name='md_lfLidsAuto_UTL') md.outputX.connect(lfTopLidAutoGrp.rx) # lf_btm lfBtmLidZero = coreUtils.addChild(lfLidGrp, 'group', 'lf_btmLid_ZERO') lfBtmLidAutoGrp = coreUtils.addChild(lfBtmLidZero, 'group', 'lf_btmLidAuto_GRP') md.outputX.connect(lfBtmLidAutoGrp.rx) def _addControl(slave, driver): md = coreUtils.multiply(driver.ty, self.main_grp.lids_rotate_factor, name='md_%s_UTL' % driver.name().replace('_CTRL', '')) md.outputX.connect(slave.rx) # CTRLS def _makeCtrl(prefix='', colour='red', pos=(0, 0, 0), grpParent=None): c = controls.squareCtrl(size=ctrlSize, name='%s_CTRL' % prefix, axis='z') c.t.set(pos) zero = coreUtils.addParent(c, 'group', '%sCtrl_ZERO' % prefix) zero.setParent(self.ctrls_grp) pmc.select('%s.cv[ * ]' % coreUtils.getShape(c)) pmc.scale(.33, scaleY=1) coreUtils.colorize(colour, [c]) self.ctrls.append(c) g = coreUtils.addChild(grpParent, 'group', '%s_DRV' % prefix) _addControl(g, c) return c, g def _makeSubCtrls(parent, prefix='', colour='red', grpParent=None): for i in range(len(subs.keys())): c = controls.squareCtrl(size=ctrlSize * .15, name='%s_%s_CTRL' % (prefix, subs[i][0]), axis='z') coreUtils.align(c, parent, parent=1) c.tx.set(ctrlSize * subs[i][1]) coreUtils.addParent(c, 'group', c.name().replace('_CTRL', 'Ctrl_ZERO')) coreUtils.colorize(colour, [c]) self.ctrls.append(c) g = coreUtils.addChild(grpParent, 'group', '%s_%s_DRV' % (prefix, subs[i][0])) j = coreUtils.addChild(g, 'joint', '%s_%s_JNT' % (prefix, subs[i][0])) jEnd = coreUtils.addChild( j, 'joint', '%s_%sEnd_JNT' % (prefix, subs[i][0])) jEnd.t.set((ctrlSize * subs[i][1], 0, ctrlSize * .33)) self.joints.append(jEnd) _addControl(g, c) subs = {0: ['in', .33], 1: ['mid', 0], 2: ['out', -.33]} # rt top lid c, g = _makeCtrl('rt_topLid', 'red', (rtPos[0], rtPos[1] + (ctrlSize * .33), rtPos[2] + ctrlSize), rtTopLidAutoGrp) _makeSubCtrls(c, 'rt_topLid', 'red', g) # rt btm lid c, g = _makeCtrl('rt_btmLid', 'red', (rtPos[0], rtPos[1] + (ctrlSize * -.33), rtPos[2] + ctrlSize), rtBtmLidAutoGrp) _makeSubCtrls(c, 'rt_btmLid', 'red', g) subs = {0: ['in', -.33], 1: ['mid', 0], 2: ['out', .33]} # lf top lid c, g = _makeCtrl('lf_topLid', 'blue', (lfPos[0], lfPos[1] + (ctrlSize * .33), lfPos[2] + ctrlSize), lfTopLidAutoGrp) _makeSubCtrls(c, 'lf_topLid', 'blue', g) #lf btm lid c, g = _makeCtrl('lf_btmLid', 'blue', (lfPos[0], lfPos[1] + (ctrlSize * -.33), lfPos[2] + ctrlSize), lfBtmLidAutoGrp) _makeSubCtrls(c, 'lf_btmLid', 'blue', g)
def buildArm(self, colour, numTwistSegs, flipTwist, upAxis): self.bendyCtrls_grp = coreUtils.addChild(self.main_grp, 'group', name='%s_bendyCtrls_GRP' % self.name) pmc.addAttr(self.settingsCtrl, longName='bendy_ctrls_vis', at='bool', k=1, h=0) pmc.setAttr(self.settingsCtrl.bendy_ctrls_vis, k=0, channelBox=1) self.settingsCtrl.bendy_ctrls_vis.connect( self.bendyCtrls_grp.visibility) # Elbow ctr aimVec = (1, 0, 0) if flipTwist: aimVec = (-1, 0, 0) elbowAim = coreUtils.addChild(self.const_grp, 'locator', '%s_elbowOrient_LOC' % self.name) pmc.aimConstraint(self.tripleChain['resultChain'][2], elbowAim, mo=0, wut='objectRotation', wuo=self.topTwist['nonRoll'], aimVector=aimVec) ctrlSize = coreUtils.getDistance( self.tripleChain['resultChain'][0], self.tripleChain['resultChain'][1]) * .25 self.elbowCtrl = controls.squareCtrl(axis='x', size=ctrlSize, name='%s_elbow_CTRL' % self.name) self.elbowCtrl.setParent(self.bendyCtrls_grp) elbowZero = coreUtils.addParent(self.elbowCtrl, 'group', '%s_elbowCtrl_ZERO' % self.name) pmc.pointConstraint(self.tripleChain['resultChain'][1], elbowZero, mo=0) pmc.orientConstraint(elbowAim, elbowZero, mo=0) self.ctrls.append(self.elbowCtrl) # Twisty Segments # Upper twist twistAxis = 'x' if flipTwist: twistAxis = '-x' self.upperTwist = drTwistySegment.DrTwistySegmentCurve( name='%s_upperTwist' % self.name, start=self.tripleChain['resultChain'][0], end=self.tripleChain['resultChain'][1], numSegs=numTwistSegs, numCtrls=2, axis=twistAxis, upAxis=upAxis, worldUpAxis=upAxis, colour=colour, flipTwist=flipTwist, upNode=self.tripleChain['resultChain'][0], cleanup=1) self.upperTwist.main_grp.setParent(self.bendyCtrls_grp) self.upperTwist.main_grp.inheritsTransform.set(0) pmc.parentConstraint(self.topTwist['nonRoll'], self.upperTwist.start_grp, mo=0) pmc.pointConstraint(self.elbowCtrl, self.upperTwist.end_grp, mo=0) self.main_grp.mid_twist.connect(self.upperTwist.twist_pma.input1D[0]) elbowTwist_inv = coreUtils.convert(self.elbowCtrl.rx, -57.2958, name='uc_%s_elbowTwistInvert_UTL' % self.name) elbowTwist_inv.output.connect(self.upperTwist.twist_pma.input1D[1]) ''' if flipTwist: self.elbowCtrl.rx.connect(self.upperTwist.twist_pma.input1D[1]) else: elbowTwist_inv.output.connect(self.upperTwist.twist_pma.input1D[1]) ''' pmc.parentConstraint(self.elbowCtrl, self.upperTwist.bendyTargs[-1], mo=1) self.main_grp.globalScale.connect(self.upperTwist.main_grp.globalScale) # Lower twist self.lowerTwist = drTwistySegment.DrTwistySegmentCurve( name='%s_lowerTwist' % self.name, start=self.tripleChain['resultChain'][1], end=self.tripleChain['resultChain'][2], numSegs=numTwistSegs, numCtrls=2, axis=twistAxis, upAxis=upAxis, worldUpAxis=upAxis, colour=colour, flipTwist=flipTwist, upNode=self.tripleChain['resultChain'][1], cleanup=1) self.lowerTwist.main_grp.setParent(self.bendyCtrls_grp) self.lowerTwist.main_grp.inheritsTransform.set(0) p = pmc.parentConstraint(self.elbowCtrl, self.lowerTwist.start_grp, mo=0) self.main_grp.mid_twist.connect( p.target[0].targetOffsetRotate.targetOffsetRotateX) self.elbowCtrl.rx.connect(self.lowerTwist.twist_pma.input1D[1]) ''' if flipTwist: uc = coreUtils.convert(self.main_grp.mid_twist, -.017, name='uc_%s_midTwistInvert_UTL' % self.name) uc.output.connect(p.target[0].targetOffsetRotate.targetOffsetRotateX) elbowTwist_inv.output.connect(self.lowerTwist.twist_pma.input1D[1]) else: self.main_grp.mid_twist.connect(p.target[0].targetOffsetRotate.targetOffsetRotateX) self.elbowCtrl.rx.connect(self.lowerTwist.twist_pma.input1D[1]) ''' pmc.parentConstraint(self.tripleChain['resultChain'][2], self.lowerTwist.end_grp, mo=0) self.main_grp.btm_twist.connect(self.lowerTwist.twist_pma.input1D[0]) self.main_grp.globalScale.connect(self.lowerTwist.main_grp.globalScale) pmc.parentConstraint(self.elbowCtrl, self.lowerTwist.bendyTargs[0], mo=1) # Average joints startAvgJnt = coreUtils.addChild(self.rig_grp, 'joint', '%s_startAvg_JNT' % self.name) pmc.parentConstraint(self.const_grp, self.topTwist['nonRoll'], startAvgJnt, mo=0).interpType.set(2) elbowAvgJnt = coreUtils.addChild(self.rig_grp, 'joint', '%s_midAvg_JNT' % self.name) pmc.parentConstraint(self.upperTwist.joints[-1], self.lowerTwist.joints[0], elbowAvgJnt, mo=0).interpType.set(2) wristAvgJnt = coreUtils.addChild(self.rig_grp, 'joint', '%s_endAvg_JNT' % self.name) pmc.parentConstraint(self.lowerTwist.joints[-1], self.tripleChain['resultChain'][2], wristAvgJnt, mo=0).interpType.set(2) # add joints for publishing self.joints.append(startAvgJnt) for joint in self.upperTwist.joints: self.joints.append(joint) self.joints.append(elbowAvgJnt) for joint in self.lowerTwist.joints: self.joints.append(joint) self.joints.append(wristAvgJnt) coreUtils.colorize(colour, self.ctrls)
def buildFoot(self, ankle, foot, ball, toe, inner, outer, heel, settingsNode, blendAttr, colour, cleanup): # Make duplicate joint chains self.tripleChain = systemUtils.tripleChain( joints=[ankle, foot, ball, toe], name=self.name, flip=0) ikConst_grp = coreUtils.addParent(self.tripleChain['ikChain'][0], 'group', '%s_ikConst_GRP' % self.name) fkConst_grp = coreUtils.addParent(self.tripleChain['fkChain'][0], 'group', '%s_fkConst_GRP' % self.name) resultConst_grp = coreUtils.addParent( self.tripleChain['resultChain'][0], 'group', '%s_resultConst_GRP' % self.name) self.tripleChain['main_grp'].setParent(self.rig_grp) if blendAttr: par = pmc.parentConstraint(ikConst_grp, fkConst_grp, resultConst_grp, mo=0) attr = pmc.Attribute('%s.%sW1' % (par.name(), fkConst_grp.name())) blendAttr.connect(attr) attr = pmc.Attribute('%s.%sW0' % (par.name(), ikConst_grp.name())) blend_rev = coreUtils.reverse(blendAttr, 'reverse_%s_blend, UTL' % self.name) blend_rev.outputX.connect(attr) for bc in self.tripleChain['blendColors']: blendAttr.connect(bc.blender) # Orientation for controls axis = 'x' if self.tripleChain['resultChain'][1].tx.get() < 0.0: axis = '-x' ctrlSize = coreUtils.getDistance( self.tripleChain['resultChain'][0], self.tripleChain['resultChain'][1]) * .5 # ikHandles footIkHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_foot_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][0], endEffector=self.tripleChain['ikChain'][1], setupForRPsolver=1)[0] footIkHandle.setParent(self.rig_grp) footIkHandleConst = coreUtils.addParent( footIkHandle, 'group', '%s_footIkHandle_CONST' % self.name) ballIkHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_ball_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][1], endEffector=self.tripleChain['ikChain'][2], setupForRPsolver=1)[0] ballIkHandle.setParent(self.rig_grp) ballIkHandleConst = coreUtils.addParent( ballIkHandle, 'group', '%s_ballIkHandle_CONST' % self.name) toeIkHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_toe_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][2], endEffector=self.tripleChain['ikChain'][3], setupForRPsolver=1)[0] toeIkHandle.setParent(self.rig_grp) toeIkHandleConst = coreUtils.addParent( toeIkHandle, 'group', '%s_toeIkHandle_CONST' % self.name) # ikCtrls self.heelIkCtrl = controls.squareCtrl(name='%s_heel_ik_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.heelIkCtrl, heel) self.heelIkCtrl.setParent(self.ctrls_grp) self.ikCtrls_grp = coreUtils.addParent(self.heelIkCtrl, 'group', '%s_ikCtrls_GRP' % self.name) coreUtils.addParent(self.heelIkCtrl, 'group', '%s_heelIkCtrl_ZERO' % self.name) self.ctrls.append(self.heelIkCtrl) self.toeIkCtrl = controls.squareCtrl(name='%s_toe_ik_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.toeIkCtrl, self.tripleChain['ikChain'][3]) self.toeIkCtrl.setParent(self.heelIkCtrl) coreUtils.addParent(self.toeIkCtrl, 'group', '%s_toeIkCtrl_ZERO' % self.name) self.ctrls.append(self.toeIkCtrl) self.innerLoc = coreUtils.createAlignedNode(inner, 'group', '%s_inner_GRP' % self.name) self.innerLoc.setParent(self.toeIkCtrl) innerZero = coreUtils.addParent(self.innerLoc, 'group', '%s_inner_ZERO' % self.name) self.outerLoc = coreUtils.createAlignedNode(outer, 'group', '%s_outer_GRP' % self.name) self.outerLoc.setParent(self.innerLoc) outerZero = coreUtils.addParent(self.outerLoc, 'group', '%s_outer_ZERO' % self.name) self.ballPivotIkCtrl = controls.squareCtrl( name='%s_ballPivot_ik_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.ballPivotIkCtrl, self.tripleChain['ikChain'][2]) self.ballPivotIkCtrl.setParent(self.outerLoc) coreUtils.addParent(self.ballPivotIkCtrl, 'group', '%s_ballPivotIkCtrl_ZERO' % self.name) inv_grp = coreUtils.addParent(self.ballPivotIkCtrl, 'group', '%s_ballPivotIkCtrlRotX_INV' % self.name) inv_uc = coreUtils.convert(self.ballPivotIkCtrl.rx, -1.0, name='uc_%s_ballPivotIkCtrlRotX_UTL' % self.name) inv_uc.output.connect(inv_grp.rx) pmc.parentConstraint(self.ballPivotIkCtrl, toeIkHandleConst, mo=1) self.ctrls.append(self.ballPivotIkCtrl) self.ballPivotIkCtrl.rx.connect(self.outerLoc.rx) pmc.transformLimits(self.innerLoc, rx=(-45, 0), erx=(0, 1)) self.ballPivotIkCtrl.rx.connect(self.innerLoc.rx) pmc.transformLimits(self.outerLoc, rx=(0, 45), erx=(1, 0)) self.ballIkCtrl = controls.squareCtrl(name='%s_ball_ik_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.ballIkCtrl, self.tripleChain['ikChain'][2]) self.ballIkCtrl.setParent(self.ballPivotIkCtrl) coreUtils.addParent(self.ballIkCtrl, 'group', '%s_ballIkCtrl_ZERO' % self.name) pmc.parentConstraint(self.ballIkCtrl, ballIkHandleConst, mo=1) self.ctrls.append(self.ballIkCtrl) self.footIkCtrl = controls.squareCtrl(name='%s_foot_ik_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.footIkCtrl, self.tripleChain['ikChain'][1]) self.footIkCtrl.setParent(self.ballIkCtrl) coreUtils.addParent(self.footIkCtrl, 'group', '%s_footIkCtrl_ZERO' % self.name) pmc.parentConstraint(self.footIkCtrl, footIkHandleConst, mo=1) pmc.parentConstraint(self.footIkCtrl, ikConst_grp, mo=1) self.ctrls.append(self.footIkCtrl) # fkCtrls self.footFkCtrl = controls.squareCtrl(name='%s_foot_fk_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.footFkCtrl, self.tripleChain['fkChain'][1]) self.footFkCtrl.setParent(self.ctrls_grp) self.fkCtrls_grp = coreUtils.addParent(self.footFkCtrl, 'group', '%s_fkCtrls_GRP' % self.name) coreUtils.addParent(self.footFkCtrl, 'group', '%s_footFkCtrl_ZERO' % self.name) pmc.parentConstraint(self.footFkCtrl, self.tripleChain['fkChain'][1]) self.ctrls.append(self.footFkCtrl) self.ballFkCtrl = controls.squareCtrl(name='%s_ball_fk_CTRL' % self.name, axis=axis, size=ctrlSize) coreUtils.align(self.ballFkCtrl, self.tripleChain['fkChain'][2]) self.ballFkCtrl.setParent(self.footFkCtrl) coreUtils.addParent(self.ballFkCtrl, 'group', '%s_ballFkCtrl_ZERO' % self.name) pmc.parentConstraint(self.ballFkCtrl, self.tripleChain['fkChain'][2]) self.ctrls.append(self.ballFkCtrl) coreUtils.colorize(colour, self.ctrls) for ctrl in self.ctrls: pmc.select('%s.cv[*]' % ctrl.name()) if ctrl != self.ballPivotIkCtrl: pmc.scale(3.0, scaleZ=1) else: pmc.scale(3.0, scaleY=1) pmc.parentConstraint(self.fkCtrls_grp, fkConst_grp, mo=1) for joint in self.tripleChain['resultChain']: self.joints.append(joint) # connections self.exposeSockets({'ikFoot': self.tripleChain['ikChain'][0]}) if cleanup: self.cleanup()
def buildFoot(self, ankle, foot, ball, toe, inner, outer, heel, settingsNode, blendAttr, colour, cleanup): # Make duplicate joint chains self.tripleChain = systemUtils.tripleChain(joints=[ankle, foot, toe], name=self.name, flip=0) ikConst_grp = coreUtils.addParent(self.tripleChain['ikChain'][0], 'group', '%s_ikConst_GRP' % self.name) fkConst_grp = coreUtils.addParent(self.tripleChain['fkChain'][0], 'group', '%s_fkConst_GRP' % self.name) resultConst_grp = coreUtils.addParent( self.tripleChain['resultChain'][0], 'group', '%s_resultConst_GRP' % self.name) self.tripleChain['main_grp'].setParent(self.rig_grp) if blendAttr: par = pmc.parentConstraint(ikConst_grp, fkConst_grp, resultConst_grp, mo=0) attr = pmc.Attribute('%s.%sW1' % (par.name(), fkConst_grp.name())) blendAttr.connect(attr) attr = pmc.Attribute('%s.%sW0' % (par.name(), ikConst_grp.name())) blend_rev = coreUtils.reverse(blendAttr, 'reverse_%s_blend, UTL' % self.name) blend_rev.outputX.connect(attr) for bc in self.tripleChain['blendColors']: blendAttr.connect(bc.blender) # Orientation for controls axis = 'x' if self.tripleChain['resultChain'][1].tx.get() < 0.0: axis = '-x' ctrlSize = coreUtils.getDistance( self.tripleChain['resultChain'][0], self.tripleChain['resultChain'][1]) * .5 # ikHandles ballIkHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_ball_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][0], endEffector=self.tripleChain['ikChain'][1], setupForRPsolver=1)[0] ballIkHandle.setParent(self.rig_grp) ballIkHandleConst = coreUtils.addParent( ballIkHandle, 'group', '%s_ballIkHandle_CONST' % self.name) toeIkHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_toe_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][1], endEffector=self.tripleChain['ikChain'][2], setupForRPsolver=1)[0] toeIkHandle.setParent(self.rig_grp) toeIkHandleConst = coreUtils.addParent( toeIkHandle, 'group', '%s_toeIkHandle_CONST' % self.name) # ikCtrls self.heelLoc = coreUtils.createAlignedNode(heel, 'group', '%s_heel_GRP' % self.name) self.heelLoc.setParent(self.rig_grp) self.ikRig_grp = coreUtils.addParent(self.heelLoc, 'group', '%s_heel_ZERO' % self.name) self.toeLoc = coreUtils.createAlignedNode(toe, 'group', '%s_toe_GRP' % self.name) self.toeLoc.setParent(self.heelLoc) self.innerLoc = coreUtils.createAlignedNode(inner, 'group', '%s_inner_GRP' % self.name) self.innerLoc.setParent(self.toeLoc) innerZero = coreUtils.addParent(self.innerLoc, 'group', '%s_inner_ZERO' % self.name) self.outerLoc = coreUtils.createAlignedNode(outer, 'group', '%s_outer_GRP' % self.name) self.outerLoc.setParent(self.innerLoc) outerZero = coreUtils.addParent(self.outerLoc, 'group', '%s_outer_ZERO' % self.name) self.ballPivotLoc = coreUtils.createAlignedNode( ball, 'group', '%s_ballPivot_GRP' % self.name) self.ballPivotLoc.setParent(self.outerLoc) coreUtils.addParent(self.ballPivotLoc, 'group', '%s_ballPivot_ZERO' % self.name) pmc.transformLimits(self.innerLoc, rx=(-45, 0), erx=(0, 1)) pmc.transformLimits(self.outerLoc, rx=(0, 45), erx=(1, 0)) self.ballLoc = coreUtils.createAlignedNode(foot, 'group', '%s_ball_GRP' % self.name) self.ballLoc.setParent(self.ballPivotLoc) self.ballZero = coreUtils.addParent(self.ballLoc, 'group', '%s_ball_ZERO' % self.name) self.toeWiggleLoc = coreUtils.addChild(self.ballZero, 'group', '%s_toeWiggle_GRP' % self.name) pmc.parentConstraint(self.ballLoc, ballIkHandleConst, mo=1) pmc.parentConstraint(self.toeWiggleLoc, toeIkHandleConst, mo=1) # driver attributes for attrName in [ 'roll_heel', 'roll_ball', 'roll_toe', 'pivot_heel', 'pivot_ball', 'pivot_toe', 'tilt_side', 'lean_ankle', 'wiggle_toe', 'lean_toe' ]: pmc.addAttr(settingsNode, ln=attrName, at='double', k=1, h=0) attr = pmc.Attribute('%s.roll_heel' % settingsNode.name()) attr.connect(self.heelLoc.ry) attr = pmc.Attribute('%s.roll_ball' % settingsNode.name()) attr.connect(self.ballLoc.ry) attr = pmc.Attribute('%s.roll_toe' % settingsNode.name()) attr.connect(self.toeLoc.ry) attr = pmc.Attribute('%s.pivot_heel' % settingsNode.name()) attr.connect(self.heelLoc.rz) attr = pmc.Attribute('%s.pivot_ball' % settingsNode.name()) attr.connect(self.ballPivotLoc.rz) attr = pmc.Attribute('%s.pivot_toe' % settingsNode.name()) attr.connect(self.toeLoc.rz) attr = pmc.Attribute('%s.tilt_side' % settingsNode.name()) attr.connect(self.innerLoc.rx) attr.connect(self.outerLoc.rx) attr = pmc.Attribute('%s.lean_ankle' % settingsNode.name()) attr.connect(self.ballLoc.rx) attr = pmc.Attribute('%s.wiggle_toe' % settingsNode.name()) attr.connect(self.toeWiggleLoc.ry) attr = pmc.Attribute('%s.lean_toe' % settingsNode.name()) attr.connect(self.toeWiggleLoc.rx) # fkCtrl self.ballFkCtrl = controls.pinCtrl(name='%s_ball_fk_CTRL' % self.name, axis=axis, radius=ctrlSize) coreUtils.align(self.ballFkCtrl, self.tripleChain['fkChain'][1]) self.ballFkCtrl.setParent(self.ctrls_grp) self.ballFkCtrlZero = coreUtils.addParent( self.ballFkCtrl, 'group', '%s_ballFkCtrl_ZERO' % self.name) pmc.parentConstraint(self.ballFkCtrl, self.tripleChain['fkChain'][1]) coreUtils.colorize(colour, [self.ballFkCtrl]) pmc.parentConstraint(self.ballFkCtrlZero, fkConst_grp, mo=1) for joint in self.tripleChain['resultChain']: self.joints.append(joint) # connections self.exposeSockets({'ikFoot': self.tripleChain['ikChain'][0]}) if cleanup: self.cleanup()