def addCtrlsToLattice(lattice, name=''): ''' Creates a control at each lattice point, creates a constrained joint for each ctrl, skins lattice to joints ''' main_grp = pmc.group(empty=1, name='%s_GRP' % name) ctrlsGrp = coreUtils.addChild(main_grp, 'group', name='%s_ctrls_GRP' % name) rigGrp = coreUtils.addChild(main_grp, 'group', name='%s_rig_GRP' % name) divs = lattice.getDivisions() points = [] for x in range(divs[0]): for y in range(divs[1]): for z in range(divs[2]): points.append(lattice.pt[x][y][z]) positions = [pmc.pointPosition(p, w=1) for p in points] ctrlSize = ( (lattice.sx.get() + lattice.sy.get() + lattice.sz.get()) / 3.0) * .25 joints = [] for i in range(len(points)): num = str(i + 1).zfill(2) p = points[i] c = controls.crossCtrl(name='%s_%s_CTRL' % (name, num), size=ctrlSize) c.setParent(ctrlsGrp) c.t.set(positions[i]) coreUtils.addParent(c, 'group', '%s_%sCtrl_ZERO' % (name, num)) j = coreUtils.createAlignedNode(c, 'joint', '%s_%s_BND' % (name, num)) j.setParent(rigGrp) coreUtils.addParent(j, 'group', '%s_%sCtrl_ZERO' % (name, num)) joints.append(j) c.t.connect(j.t) rigGrp.visibility.set(0) pmc.skinCluster(joints, lattice, mi=1)
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 _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 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 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 buildHoof(self, ankle, toe, inner, outer, heel, settingsNode, colour, cleanup, blendAttr): if not ankle: return 'DrReverseFoot: Please supply or select joints for Ankle, Toe, Inner, Outer and Heel positions.' self.innerLoc = coreUtils.createAlignedNode(inner, 'group', '%s_inner_GRP' % self.name) self.innerLoc.setParent(self.rig_grp) 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.toeLoc = coreUtils.createAlignedNode(toe, 'group', '%s_toe_GRP' % self.name) self.toeLoc.setParent(self.outerLoc) toeZero = coreUtils.addParent(self.toeLoc, 'group', '%s_toe_ZERO' % self.name) self.heelLoc = coreUtils.createAlignedNode(heel, 'group', '%s_heel_GRP' % self.name) self.heelLoc.setParent(self.toeLoc) heelZero = coreUtils.addParent(self.heelLoc, 'group', '%s_heel_ZERO' % self.name) self.ankleLoc = coreUtils.createAlignedNode(ankle, 'group', '%s_ankle_GRP' % self.name) self.ankleLoc.setParent(self.heelLoc) ankleZero = coreUtils.addParent(self.ankleLoc, 'group', '%s_ankle_ZERO' % self.name) self.ikConstGrp = coreUtils.createAlignedNode( ankle, 'group', '%s_ik_CONST' % self.name) self.ikConstGrp.setParent(self.rig_grp) innerZero.setParent(self.ikConstGrp) self.fkConstGrp = coreUtils.createAlignedNode( ankle, 'group', '%s_fk_CONST' % self.name) self.fkConstGrp.setParent(self.rig_grp) self.constGrp = coreUtils.createAlignedNode(ankle, 'group', '%s_CONST' % self.name) self.constGrp.setParent(self.rig_grp) j = coreUtils.addChild(self.constGrp, 'joint', '%s_JNT' % self.name) self.joints.append(j) if not blendAttr: blendAttr = pmc.addAttr(self.main_grp, ln='ik_fk_blend', at='double', k=1, h=0) if not settingsNode: settingsNode = self.main_grp pmc.addAttr(settingsNode, longName='heel_toe', at='double', k=1, h=0) pmc.addAttr(settingsNode, longName='side_side', at='double', k=1, h=0) settingsNode.heel_toe.connect(self.heelLoc.rx) settingsNode.heel_toe.connect(self.toeLoc.rx) settingsNode.side_side.connect(self.innerLoc.rz) settingsNode.side_side.connect(self.outerLoc.rz) pmc.transformLimits(self.heelLoc, rx=(-45, 0), erx=(0, 1)) pmc.transformLimits(self.toeLoc, rx=(0, 45), erx=(1, 0)) pmc.transformLimits(self.innerLoc, rz=(-45, 0), erz=(0, 1)) pmc.transformLimits(self.outerLoc, rz=(0, 45), erz=(1, 0)) con = pmc.parentConstraint(self.ankleLoc, self.fkConstGrp, self.constGrp, mo=0) pmc.connectAttr(blendAttr, '%s.%sW1' % (con.name(), self.fkConstGrp)) rev = coreUtils.reverse(blendAttr, name='rev_%sIkFkBlend_UTL' % self.name) rev.outputX.connect('%s.%sW0' % (con.name(), self.ankleLoc)) # connections self.exposeSockets({'ankle': self.ankleLoc}) if cleanup: self.cleanup()
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 buildLimb(self, joints, leg, cleanup, alignIkToJoints, flip=1): if not joints: return 'DrLimb: Please supply 4 joints to build limb from' # Make duplicate joint chains self.tripleChain = systemUtils.tripleChain(joints=joints, name=self.name, flip=flip) self.tripleChain['main_grp'].setParent(self.rig_grp) self.const_grp = coreUtils.addParent(self.tripleChain['main_grp'], 'group', '%s_const_grp' % self.name) # Orientation for controls and aim constraints axis = 'x' aimVec = (1, 0, 0) if self.tripleChain['resultChain'][1].tx.get() < 0.0: axis = '-x' aimVec = (-1, 0, 0) ctrlSize = coreUtils.getDistance( self.tripleChain['resultChain'][0], self.tripleChain['resultChain'][1]) * .25 # CONTROLS # settings ctrl self.settingsCtrl = controls.crossCtrl(name='%s_settings_CTRL' % self.name, size=ctrlSize) self.settingsCtrl.setParent(self.tripleChain['resultChain'][2]) settingsOffset = ctrlSize * 1.5 if self.tripleChain['resultChain'][2].tx.get() < 0.0: settingsOffset = ctrlSize * -1.5 if leg: settingsOffset = settingsOffset * -1 self.settingsCtrl.t.set((0, settingsOffset, 0)) self.settingsCtrl.r.set(0, 0, 0) self.settingsCtrl.setParent(self.ctrls_grp) pmc.parentConstraint(self.tripleChain['resultChain'][2], self.settingsCtrl, mo=1) self.ctrls.append(self.settingsCtrl) pmc.addAttr(self.settingsCtrl, ln='ik_fk_blend', at='double', k=1, h=0, minValue=0.0, maxValue=1.0) for bc in self.tripleChain['blendColors']: self.settingsCtrl.ik_fk_blend.connect(bc.blender) # fk top ctrl self.fkTopCtrl = controls.circleBumpCtrl(name='%s_top_fk_CTRL' % self.name, axis=axis, radius=ctrlSize) coreUtils.align(self.fkTopCtrl, self.tripleChain['fkChain'][0]) self.fkTopCtrl.setParent(self.ctrls_grp) self.fkCtrls_grp = coreUtils.addParent(self.fkTopCtrl, 'group', '%s_fkCtrls_grp' % self.name) self.fkCtrlsConst_grp = coreUtils.addParent( self.fkTopCtrl, 'group', '%s_fkConst_grp' % self.name) pmc.parentConstraint(self.fkCtrls_grp, self.const_grp) self.ctrls.append(self.fkTopCtrl) self.settingsCtrl.ik_fk_blend.connect(self.fkCtrls_grp.visibility) # fk mid ctrl self.fkMidCtrl = controls.circleBumpCtrl(name='%s_mid_fk_CTRL' % self.name, axis=axis, radius=ctrlSize) coreUtils.align(self.fkMidCtrl, self.tripleChain['fkChain'][1]) self.fkMidCtrl.setParent(self.fkTopCtrl) coreUtils.addParent(self.fkMidCtrl, 'group', '%s_mid_fkCtrl_ZERO' % self.name) self.ctrls.append(self.fkMidCtrl) # fk btm ctrl self.fkBtmCtrl = controls.circleBumpCtrl(name='%s_btm_fk_CTRL' % self.name, axis=axis, radius=ctrlSize) coreUtils.align(self.fkBtmCtrl, self.tripleChain['fkChain'][2]) self.fkBtmCtrl.setParent(self.fkMidCtrl) coreUtils.addParent(self.fkBtmCtrl, 'group', '%s_btm_fkCtrl_ZERO' % self.name) self.ctrls.append(self.fkBtmCtrl) # rotate order for node in [ self.fkMidCtrl, self.tripleChain['resultChain'][1], self.tripleChain['ikChain'][1], self.tripleChain['fkChain'][1] ]: node.rotateOrder.set(3) pmc.parentConstraint(self.fkTopCtrl, self.tripleChain['fkChain'][0]) pmc.parentConstraint(self.fkMidCtrl, self.tripleChain['fkChain'][1]).rotateOrder.set(4) pmc.parentConstraint(self.fkBtmCtrl, self.tripleChain['fkChain'][2]) # IK ctrl self.ikCtrl = controls.boxCtrl(name='%s_ik_CTRL' % self.name, size=ctrlSize) if alignIkToJoints: if leg: pmc.xform(self.ikCtrl, ws=1, m=coreUtils.getAimMatrix(start=joints[2], end=joints[3], axis='z', upAxis='y', worldUpAxis=alignIkToJoints, upNode=joints[2])) else: axis = '-x' if self.tripleChain['resultChain'][2].tx.get() < 0.0: axis = 'x' pmc.xform(self.ikCtrl, ws=1, m=coreUtils.getAimMatrix(start=joints[2], end=joints[3], axis=axis, upAxis='y', worldUpAxis=alignIkToJoints, upNode=joints[2])) else: coreUtils.align(self.ikCtrl, self.tripleChain['ikChain'][2], orient=0) self.ikCtrl.setParent(self.ctrls_grp) self.ikCtrls_grp = coreUtils.addParent(self.ikCtrl, 'group', '%s_ikCtrls_ZERO' % self.name) self.ctrls.append(self.ikCtrl) ik_fk_rev = coreUtils.reverse(self.settingsCtrl.ik_fk_blend, 'rev_%s_ik_fk_blend_UTL' % self.name) ik_fk_rev.outputX.connect(self.ikCtrls_grp.visibility) pmc.addAttr(self.ikCtrl, longName='stretch', at='double', minValue=0, maxValue=1, defaultValue=0, keyable=True) pmc.addAttr(self.ikCtrl, longName='twist', at='double', keyable=True) pmc.addAttr(self.ikCtrl, longName='soft', at='double', minValue=0, defaultValue=0, keyable=True) pmc.addAttr(self.ikCtrl, longName='mid_pin', at='double', keyable=True, minValue=0, maxValue=1) if flip: pmc.addAttr(self.ikCtrl, longName='flip_poleVector', at='bool', keyable=True, h=0) pmc.addAttr(self.ikCtrl, longName='force_straight', at='double', keyable=True, h=0, minValue=0.0, maxValue=1.0) for bc in self.tripleChain['flipBlendColors']: self.ikCtrl.flip_poleVector.connect(bc.blender) # Soft non-stretchy IK stuff ik_grp = coreUtils.addChild(self.rig_grp, 'group', name='%s_ik_GRP' % self.name) softBlend_loc = coreUtils.createAlignedNode(self.ikCtrl, 'locator', name='%s_ikSoftBlend_LOC' % self.name) softBlend_loc.setParent(ik_grp) self.ctrl_loc = coreUtils.createAlignedNode(self.ikCtrl, 'locator', name='%s_ikCtrl_LOC' % self.name) self.ctrl_loc.setParent(ik_grp) if not leg: pmc.parentConstraint(self.ikCtrl, self.ctrl_loc) aim_loc = coreUtils.addChild(self.const_grp, 'locator', name='%s_softIkaim_LOC' % self.name) pmc.aimConstraint(self.ctrl_loc, aim_loc, upVector=(0, 0, 0)) btm_loc = coreUtils.createAlignedNode(self.ikCtrl, 'locator', name='%s_ikBtm_LOC' % self.name) btm_loc.setParent(aim_loc) chainLen = abs(self.tripleChain['ikChain'][1].tx.get() + self.tripleChain['ikChain'][2].tx.get()) ctrlDist = coreUtils.distanceBetweenNodes(aim_loc, self.ctrl_loc, name='dist_%s_ikCtrl_UTL' % self.name) globalScaleDiv = coreUtils.divide(1.0, self.main_grp.globalScale, name='md_%s_globalScaleDiv_UTL' % self.name) isStretchedMult = coreUtils.multiply(ctrlDist.distance, globalScaleDiv.outputX, name='md_%s_isStretched_UTL' % self.name) softDist = coreUtils.distanceBetweenNodes(btm_loc, softBlend_loc, name='dist_%s_soft_UTL' % self.name) stretchDist = coreUtils.distanceBetweenNodes( aim_loc, softBlend_loc, name='dist_%s_stretch_UTL' % self.name) chainLenMinusSoft = coreUtils.minus( [chainLen, self.ikCtrl.soft], name='pma_%s_chainLenMinusSoft_UTL' % self.name) isStretchedCond = pmc.createNode('condition', name='cond_%s_isStretched_UTL' % self.name) isStretchedCond.operation.set(2) isStretchedMult.outputX.connect(isStretchedCond.firstTerm) chainLenMinusSoft.output1D.connect(isStretchedCond.secondTerm) isStretchedMult.outputX.connect(isStretchedCond.colorIfFalseR) isSoftCond = pmc.createNode('condition', name='cond_%s_isSoft_UTL' % self.name) isSoftCond.operation.set(2) self.ikCtrl.soft.connect(isSoftCond.firstTerm) isSoftCond.colorIfFalseR.set(chainLen) ctrlDistMinusSoftChain = coreUtils.minus( [isStretchedMult.outputX, chainLenMinusSoft.output1D], name='pmc_%s_ctrlDistMinusSoftChain_UTL' % self.name) divideBySoft = coreUtils.safeDivide(ctrlDistMinusSoftChain.output1D, self.ikCtrl.soft, name='md_%s_divideBySoft_UTL' % self.name) invert = coreUtils.multiply(divideBySoft.outputX, -1, name='md_%s_invertSoft_UTL' % self.name) exp = coreUtils.pow(2.718282, invert.outputX, name='md_%s_exponential_UTL' % self.name) multiplyBySoft = coreUtils.multiply(exp.outputX, self.ikCtrl.soft, name='md_%s_multiplyBySoft_UTL' % self.name) minusFromChainLen = coreUtils.minus( [chainLen, multiplyBySoft.outputX], name='md_%s_minusFromChainLen_UTL' % self.name) minusFromChainLen.output1D.connect(isSoftCond.colorIfTrueR) isSoftCond.outColorR.connect(isStretchedCond.colorIfTrueR) isStretchedCond.outColorR.connect(btm_loc.tx) # IK Solvers ikHandleGrp = coreUtils.createAlignedNode(self.ikCtrl, 'group', name='%s_ikHandle_GRP' % self.name) ikHandleGrp.setParent(softBlend_loc) pmc.orientConstraint(self.ikCtrl, ikHandleGrp, mo=1) ikHandle = pmc.ikHandle(solver='ikRPsolver', name='%s_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][0], endEffector=self.tripleChain['ikChain'][2], setupForRPsolver=1)[0] ikHandle.setParent(ikHandleGrp) self.ikCtrl.twist.connect(ikHandle.twist) endIkHandle = pmc.ikHandle(solver='ikSCsolver', name='%s_end_ikHandle' % self.name, startJoint=self.tripleChain['ikChain'][2], endEffector=self.tripleChain['ikChain'][3], setupForRPsolver=1)[0] endIkHandle.setParent(ikHandleGrp) # Flipped solvers if flip: self.tripleChain['flipChain'][1].preferredAngleY.set( self.tripleChain['flipChain'][1].ry.get()) flip_ikHandle = pmc.ikHandle( solver='ikRPsolver', name='%s_flip_ikHandle' % self.name, startJoint=self.tripleChain['flipChain'][0], endEffector=self.tripleChain['flipChain'][2], setupForRPsolver=1)[0] flip_ikHandle.setParent(ikHandleGrp) self.ikCtrl.twist.connect(flip_ikHandle.twist) flip_endIkHandle = pmc.ikHandle( solver='ikSCsolver', name='%s_flip_end_ikHandle' % self.name, startJoint=self.tripleChain['flipChain'][2], endEffector=self.tripleChain['flipChain'][3], setupForRPsolver=1)[0] flip_endIkHandle.setParent(ikHandleGrp) # Pole Vector pvAimGrp = coreUtils.addChild(self.const_grp, 'group', name='%s_pvAim_GRP' % self.name) if leg: pmc.aimConstraint(btm_loc, pvAimGrp, mo=0, u=(0, 1, 0), wu=(1, 0, 0), wut='objectRotation', wuo=self.ctrl_loc, aimVector=aimVec) else: pmc.aimConstraint(btm_loc, pvAimGrp, mo=0, u=(0, 0, 0), aimVector=aimVec) self.pvCtrl = controls.crossCtrl(name='%s_pv_CTRL' % self.name, size=ctrlSize) poleOffset = 3 if '-' in axis: poleOffset = -3 self.pvCtrl.setParent(self.tripleChain['ikChain'][1]) self.pvCtrl.t.set((0, 0, ctrlSize * poleOffset)) self.pvCtrl.setParent(self.ikCtrls_grp) self.pvZero = coreUtils.addParent(self.pvCtrl, 'group', '%s_pvCtrl_ZERO' % self.name) pmc.poleVectorConstraint(self.pvCtrl, ikHandle) self.ctrls.append(self.pvCtrl) if flip: self.flipPvCtrl = controls.crossCtrl(name='%s_flip_pv_CTRL' % self.name, size=ctrlSize) self.flipPvCtrl.setParent(self.tripleChain['flipChain'][1]) self.flipPvCtrl.t.set((0, 0, ctrlSize * (poleOffset * -1))) self.flipPvCtrl.setParent(self.pvZero) self.flipPvZero = coreUtils.addParent( self.flipPvCtrl, 'group', '%s_flipPvCtrl_ZERO' % self.name) pmc.poleVectorConstraint(self.flipPvCtrl, flip_ikHandle) self.ctrls.append(self.flipPvCtrl) # stretchy soft IK stuff pc = pmc.pointConstraint(btm_loc, self.ctrl_loc, softBlend_loc) stretchRev = coreUtils.reverse(self.ikCtrl.stretch, name='rev_%s_stretch_UTL' % self.name) stretchRev.outputX.connect('%s.%sW0' % (pc.nodeName(), btm_loc.nodeName())) self.ikCtrl.stretch.connect('%s.%sW1' % (pc.nodeName(), self.ctrl_loc.nodeName())) scaledSoftDist = coreUtils.multiply(globalScaleDiv.outputX, softDist.distance, name='md_%s_scaledSoftDist_UTL' % self.name) # Stretchy Mid midLen = coreUtils.multiply( (self.tripleChain['ikChain'][1].tx.get() / chainLen), scaledSoftDist.outputX, name='md_%s_midLen_UTL' % self.name) stretchMidLen = coreUtils.multiply(self.ikCtrl.stretch, midLen.outputX, name='md_%s_stretchMidLen_UTL' % self.name) stretchMidLenPlusBoneLen = coreUtils.add( [self.tripleChain['ikChain'][1].tx.get(), stretchMidLen.outputX], name='pma_%s_stretchMidLenPlusBoneLen_UTL' % self.name) pinUpperDist = coreUtils.distanceBetweenNodes( self.const_grp, self.pvCtrl, name='dist_%s_pinUpper_UTL' % self.name) pinMult = 1.0 if '-' in axis: pinMult = -1.0 pinUpper_uc = coreUtils.convert(pinUpperDist.distance, pinMult, name='uc_%s_pinUpperDist_UTL' % self.name) pinUpperGlobalScale = coreUtils.multiply( globalScaleDiv.outputX, pinUpper_uc.output, name='md_%s_pinUpperGlobalScale_UTL' % self.name) pinUpperBlend = coreUtils.blend( input1=pinUpperGlobalScale.outputX, input2=stretchMidLenPlusBoneLen.output1D, blendAttr=self.ikCtrl.mid_pin, name='bc_%s_pinUpper_UTL' % self.name) # pinUpperBlend.outputR.connect(self.tripleChain['ikChain'][1].tx) # pinUpperBlend.outputR.connect(self.tripleChain['flipChain'][1].tx) # Stretchy Bot botLen = coreUtils.multiply( (self.tripleChain['ikChain'][2].tx.get() / chainLen), scaledSoftDist.outputX, name='md_%s_botLen_UTL' % self.name) stretchBotLen = coreUtils.multiply(self.ikCtrl.stretch, botLen.outputX, name='md_%s_stretchBotLen_UTL' % self.name) stretchBotLenPlusBoneLen = coreUtils.add( [self.tripleChain['ikChain'][2].tx.get(), stretchBotLen.outputX], name='pma_%s_stretchBotLenPlusBoneLen_UTL' % self.name) pinLowerDist = coreUtils.distanceBetweenNodes( softBlend_loc, self.pvCtrl, name='dist_%s_pinLower_UTL' % self.name) pinLower_uc = coreUtils.convert(pinLowerDist.distance, pinMult, name='uc_%s_pinLowerDist_UTL' % self.name) pinLowerGlobalScale = coreUtils.multiply( globalScaleDiv.outputX, pinLower_uc.output, name='md_%s_pinLowerGlobalScale_UTL' % self.name) pinLowerBlend = coreUtils.blend( input1=pinLowerGlobalScale.outputX, input2=stretchBotLenPlusBoneLen.output1D, blendAttr=self.ikCtrl.mid_pin, name='bc_%s_pinLower_UTL' % self.name) # pinLowerBlend.outputR.connect(self.tripleChain['ikChain'][2].tx) # pinLowerBlend.outputR.connect(self.tripleChain['flipChain'][2].tx) # Add ability to force straight arm stretchDivGlobal_md = coreUtils.divide( stretchDist.distance, self.main_grp.globalScale, name='md_%s_stretchDivGlobalScale_UTL' % self.name) straightUpper_md = coreUtils.multiply( stretchDivGlobal_md.outputX, self.tripleChain['ikChain'][1].tx.get() / chainLen, name='md_%s_midLenTimesChainLen_UTL' % self.name) straightLower_md = coreUtils.multiply( stretchDivGlobal_md.outputX, self.tripleChain['ikChain'][2].tx.get() / chainLen, name='md_%s_botLenTimesChainLen_UTL' % self.name) straightUpperBlend = coreUtils.blend( input1=straightUpper_md.outputX, input2=pinUpperBlend.outputR, blendAttr=self.ikCtrl.force_straight, name='bc_%s_straightUpper_UTL' % self.name) straightLowerBlend = coreUtils.blend( input1=straightLower_md.outputX, input2=pinLowerBlend.outputR, blendAttr=self.ikCtrl.force_straight, name='bc_%s_straightLower_UTL' % self.name) straightUpperBlend.outputR.connect(self.tripleChain['ikChain'][1].tx) straightLowerBlend.outputR.connect(self.tripleChain['ikChain'][2].tx) if flip: straightUpperBlend.outputR.connect( self.tripleChain['flipChain'][1].tx) straightLowerBlend.outputR.connect( self.tripleChain['flipChain'][2].tx) # Extract twist self.topTwist = coreUtils.extractAxis( self.tripleChain['resultChain'][0], axis='x', name='%s_top_twist' % self.name, exposeNode=self.main_grp, exposeAttr='top_twist') self.topTwist['main_grp'].setParent(self.rig_grp) pmc.parentConstraint(self.const_grp, self.topTwist['main_grp']) self.midTwist = coreUtils.extractAxis( self.tripleChain['resultChain'][1], axis='x', name='%s_mid_twist' % self.name, exposeNode=self.main_grp, exposeAttr='mid_twist') self.midTwist['main_grp'].setParent(self.rig_grp) pmc.pointConstraint(self.tripleChain['resultChain'][1], self.midTwist['main_grp']) pmc.orientConstraint(self.topTwist['nonRoll'], self.midTwist['main_grp']) btmTwist = coreUtils.extractAxis(self.tripleChain['resultChain'][2], axis='x', name='%s_btm_twist' % self.name, exposeNode=self.main_grp, exposeAttr='btm_twist') btmTwist['main_grp'].setParent(self.rig_grp) pmc.pointConstraint(self.tripleChain['resultChain'][2], btmTwist['main_grp']) pmc.orientConstraint(self.tripleChain['resultChain'][1], btmTwist['main_grp']) # connections self.exposeSockets({'poleVectorAim': pvAimGrp}) self.exposeSockets({'ikCtrl': self.ikCtrl, 'fkCtrl': self.fkBtmCtrl}) self.exposeSockets({'wrist': self.tripleChain['resultChain'][2]}) if cleanup: self.cleanup()
def buildBrows(self, rtPos, lfPos): if not rtPos or not lfPos: rtPos, lfPos = (-5, 0, 0), (5, 0, 0) ctrlSize = coreUtils.getDistance(rtPos, lfPos) rtGrp = coreUtils.addChild(self.rig_grp, 'group', 'rt_brow_GRP') rtGrp.t.set(rtPos) lfGrp = coreUtils.addChild(self.rig_grp, 'group', 'lf_brow_GRP') lfGrp.t.set(lfPos) rtBrowZero = coreUtils.addChild(rtGrp, 'group', 'rt_brow_ZERO') lfBrowZero = coreUtils.addChild(lfGrp, 'group', 'lf_brow_ZERO') # 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) c.t.connect(g.t) 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) subs = {0: ['in', .33], 1: ['mid', 0], 2: ['out', -.33]} # rt brow c, g = _makeCtrl('rt_brow', 'red', (rtPos[0], rtPos[1] + (ctrlSize * .33), rtPos[2] + ctrlSize), rtBrowZero) _makeSubCtrls(c, 'rt_brow', 'red', g) subs = {0: ['in', .33], 1: ['mid', 0], 2: ['out', -.33]} # lf brow c, g = _makeCtrl('lf_brow', 'blue', (lfPos[0], lfPos[1] + (ctrlSize * .33), lfPos[2] + ctrlSize), lfBrowZero) c.getParent().sx.set(-1) g.getParent().sx.set(-1) _makeSubCtrls(c, 'lf_brow', 'blue', g) # centre joint j = coreUtils.addChild(self.rig_grp, 'joint', name='%s_mid_JNT' % self.name) self.joints.append(j) zero = coreUtils.addParent(j, 'group', '%s_mid_ZERO' % self.name) pmc.parentConstraint(self.joints[0].getParent(), self.joints[3].getParent(), zero, mo=0).interpType.set(2) pmc.pointConstraint(self.joints[0], self.joints[3], j, skip=('x', 'z'))
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()
def buildRail(self, crv, numCtrls, numSubCtrls, cleanup): if not crv: return 'Please provide a curve on which to build your rail' ctrlSize = coreUtils.getDistance(crv.getCV(0), crv.getCV(1)) * .25 self.noXform_grp = coreUtils.addChild(self.rig_grp, 'group', '%s_noXform_GRP' % self.name) self.noXform_grp.inheritsTransform.set(0) self.const_grp = coreUtils.addChild(self.rig_grp, 'group', '%s_CONST' % self.name) self.upLoc = coreUtils.addChild(self.rig_grp, 'locator', '%s_up_LOC' % self.name) up_vp = pmc.createNode('vectorProduct', name='vecProd_%s_up_UTL' % self.name) self.upLoc.worldMatrix[0].connect(up_vp.matrix) up_vp.operation.set(3) up_vp.input1.set((0, 1, 0)) mps = curveUtils.nodesAlongCurve(crv, numNodes=numCtrls, name='%s_tangent' % self.name) subPoints = [mp.allCoordinates.get() for mp in mps['mpNodes']] for i in range(numCtrls): mp = mps['grps'][i] mp.setParent(self.noXform_grp) num = str(i + 1).zfill(2) d = curveUtils.curveTangentMatrix(mp, up_vp, '%s_%s' % (self.name, num)) g = coreUtils.addChild(self.const_grp, 'group', '%s_rail_%s_GRP' % (self.name, num)) d.outputTranslate.connect(g.t) d.outputRotate.connect(g.r) c = controls.circleBumpCtrl(axis='z', radius=ctrlSize, name='%s_%s_CTRL' % (self.name, num)) coreUtils.align(c, g) c.setParent(self.ctrls_grp) zero = coreUtils.addParent(c, 'group', '%s_%sCtrl_ZERO' % (self.name, num)) const = coreUtils.addParent(zero, 'group', '%s_%sCtrl_CONST' % (self.name, num)) pmc.parentConstraint(g, const, mo=0) self.ctrls.append(c) pmc.addAttr(self.main_grp, ln='start_uValue', at='double', k=1, h=0, minValue=0.0, maxValue=1.0) pmc.addAttr(self.main_grp, ln='end_uValue', at='double', k=1, h=0, minValue=0.0, maxValue=1.0) self.main_grp.start_uValue.connect(mps['mpNodes'][0].uValue) self.main_grp.end_uValue.connect(mps['mpNodes'][-1].uValue) # Set up blending of sub curveInfo nodes between start and end for i in range(1, numCtrls - 1): mp = mps['mpNodes'][i] bc = coreUtils.blend(mps['mpNodes'][-1].uValue, mps['mpNodes'][0].uValue, name='blend_%s_%s_uValue_UTL' % (self.name, str(i + 1).zfill(2))) bc.blender.set((1.0 / (numCtrls - 1)) * i) bc.outputR.connect(mp.uValue) # Build sub curve locs_grp = coreUtils.addChild(self.rig_grp, 'group', '%s_subCrvLocs_GRP' % self.name) self.subCrv = curveUtils.curveThroughPoints(positions=subPoints, name='%s_sub' % self.name) self.subCrv.setParent(self.noXform_grp) self.locs = curveUtils.connectCurve(self.subCrv) for i in range(numCtrls): loc = self.locs[i] loc.setParent(locs_grp) driven = coreUtils.addParent(loc, 'group', loc.name().replace('_LOC', 'Loc_DRV')) zero = coreUtils.addParent(loc, 'group', loc.name().replace('_LOC', 'Loc_ZERO')) self.ctrls[i].t.connect(loc.t) self.ctrls[i].getParent().t.connect(zero.t) mps['mpNodes'][i].rotate.connect(driven.r) mps['mpNodes'][i].allCoordinates.connect(driven.t) # Create joints and subCtrls subMps = curveUtils.nodesAlongCurve(self.subCrv, numNodes=numSubCtrls, name='%s_subTangent' % self.name) subCtrls_grp = coreUtils.addChild(self.ctrls_grp, 'group', '%s_subCtrls_GRP' % self.name) for i in range(numSubCtrls): num = str(i + 1).zfill(2) mp = subMps['grps'][i] mp.setParent(self.noXform_grp) d = curveUtils.curveTangentMatrix(mp, up_vp, '%sSub_%s' % (self.name, num)) g = coreUtils.addChild(self.const_grp, 'group', '%s_subRail_%s_GRP' % (self.name, num)) d.outputTranslate.connect(g.t) d.outputRotate.connect(g.r) driven = coreUtils.addChild(self.noXform_grp, 'group', '%s_subRail_%s_DRV' % (self.name, num)) self.drivenGrps.append(driven) d.outputTranslate.connect(driven.t) d.outputRotate.connect(driven.r) c = controls.circleCtrl(axis='z', radius=ctrlSize * .33, name='%s_%s_sub_CTRL' % (self.name, num)) coreUtils.align(c, g) c.setParent(subCtrls_grp) zero = coreUtils.addParent(c, 'group', '%s_%sSubCtrl_ZERO' % (self.name, num)) const = coreUtils.addParent( zero, 'group', '%s_%sSubCtrl_CONST' % (self.name, num)) pmc.parentConstraint(g, const, mo=0) self.subCtrls.append(c) j = coreUtils.addChild(driven, 'joint', '%s_%s_JNT' % (self.name, num)) c.t.connect(j.t) c.r.connect(j.r) self.joints.append(j) pmc.addAttr(self.main_grp, ln='sub_ctrls_vis', at='bool', k=0, h=0) pmc.setAttr(self.main_grp.sub_ctrls_vis, channelBox=1) self.main_grp.sub_ctrls_vis.connect(subCtrls_grp.visibility) if cleanup: self.cleanup()