def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp+".nJoints", 1) cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint") cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint")
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.addAttr(self.moduleGrp, longName="style", attributeType='enum', enumName=self.langDic[self.langName]['m042_default'] + ':' + self.langDic[self.langName]['m026_biped']) cmds.setAttr(self.moduleGrp + ".nJoints", 1) self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName + "_JointLoc1", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator( ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) # Edit GUIDE: cmds.setAttr(self.moduleGrp + ".rx", -90) cmds.setAttr(self.moduleGrp + ".ry", -90) cmds.setAttr(self.moduleGrp + "_RadiusCtrl.tx", 4)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.addAttr(self.moduleGrp, longName="indirectSkin", attributeType='bool') cmds.setAttr(self.moduleGrp+".indirectSkin", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint") cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint")
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp + ".nJoints", 1) cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName + "_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName + "_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1 + ".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator( ctrlName=self.guideName + "_JointEnd", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) ctrls.directConnect(self.cvJointLoc, self.jGuide1, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # change the number of falanges to 3: self.changeJointNumber(3) # create a base cvLoc to start the finger joints: self.cvBaseJoint, shapeSizeCH = ctrls.cvLocator( ctrlName=self.guideName + "_JointLoc0", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.setAttr(self.cvBaseJoint + ".translateZ", -1) cmds.parent(self.cvBaseJoint, self.moduleGrp) # transform cvLocs in order to put as a good finger guide: cmds.setAttr(self.moduleGrp + ".rotateX", 90) cmds.setAttr(self.moduleGrp + ".rotateZ", 90)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp + ".nJoints", 1) self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName + "_JointLoc1", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) # Edit GUIDE: cmds.setAttr(self.moduleGrp + ".rx", -90) cmds.setAttr(self.moduleGrp + ".ry", -90) cmds.setAttr(self.moduleGrp + "_RadiusCtrl.tx", 4)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp+".nJoints", 1) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) ctrls.directConnect(self.cvJointLoc, self.jGuide1, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # change the number of falanges to 3: self.changeJointNumber(3) # create a base cvLoc to start the finger joints: self.cvBaseJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointLoc0", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.setAttr(self.cvBaseJoint+".translateZ", -1) cmds.parent(self.cvBaseJoint, self.moduleGrp) # transform cvLocs in order to put as a good finger guide: cmds.setAttr(self.moduleGrp+".rotateX", 90) cmds.setAttr(self.moduleGrp+".rotateZ", 90)
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # create lists to be integrated: self.footCtrlList, self.revFootCtrlZeroFinalList, self.revFootCtrlShapeList, self.toLimbIkHandleGrpList, self.parentConstList, self.footJntList, self.ballRFList, self.middleFootCtrlList, self.reverseFootAttrList = [], [], [], [], [], [], [], [], [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate( self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename( self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side + self.userGuideName + "_Guide_Base" self.cvFootLoc = side + self.userGuideName + "_Guide_foot" self.cvRFALoc = side + self.userGuideName + "_Guide_RfA" self.cvRFBLoc = side + self.userGuideName + "_Guide_RfB" self.cvRFCLoc = side + self.userGuideName + "_Guide_RfC" self.cvRFDLoc = side + self.userGuideName + "_Guide_RfD" self.cvRFELoc = side + self.userGuideName + "_Guide_RfE" self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" # declaring attributes reading from dictionary: ankleRFAttr = self.langDic[self.langName]['c_leg_extrem'] middleRFAttr = self.langDic[self.langName]['c_RevFoot_middle'] outsideRFAttr = self.langDic[self.langName]['c_RevFoot_A'] insideRFAttr = self.langDic[self.langName]['c_RevFoot_B'] heelRFAttr = self.langDic[self.langName]['c_RevFoot_C'] toeRFAttr = self.langDic[self.langName]['c_RevFoot_D'] ballRFAttr = self.langDic[self.langName]['c_RevFoot_E'] footRFAttr = self.langDic[self.langName]['c_RevFoot_F'] sideRFAttr = self.langDic[self.langName]['c_RevFoot_G'] rfRoll = self.langDic[self.langName]['c_RevFoot_roll'] rfSpin = self.langDic[self.langName]['c_RevFoot_spin'] rfTurn = self.langDic[self.langName]['c_RevFoot_turn'] # creating joints: cmds.select(clear=True) self.footJnt = cmds.joint(name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_Jnt") self.middleFootJxt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jxt") self.endJnt = cmds.joint(name=side + self.userGuideName + "_JEnd") cmds.select(clear=True) self.middleFootJnt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jnt") self.endBJnt = cmds.joint(name=side + self.userGuideName + "B_JEnd") cmds.parent(self.middleFootJnt, self.middleFootJxt) cmds.addAttr(self.footJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.addAttr(self.middleFootJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.select(clear=True) # reverse foot joints: self.RFAJxt = cmds.joint(name=side + self.userGuideName + "_" + outsideRFAttr.capitalize() + "_Jxt") self.RFBJxt = cmds.joint(name=side + self.userGuideName + "_" + insideRFAttr.capitalize() + "_Jxt") self.RFCJxt = cmds.joint(name=side + self.userGuideName + "_" + heelRFAttr.capitalize() + "_Jxt") self.RFDJxt = cmds.joint(name=side + self.userGuideName + "_" + toeRFAttr.capitalize() + "_Jxt") self.RFEJxt = cmds.joint(name=side + self.userGuideName + "_" + ballRFAttr.capitalize() + "_Jxt") self.RFEndJxt = cmds.joint(name=side + self.userGuideName + "_RFEnd_Jxt") rfJointList = [ self.RFAJxt, self.RFBJxt, self.RFCJxt, self.RFDJxt, self.RFEJxt ] self.ballRFList.append(self.RFEJxt) # set as template using overrides in order to permit no template children: for rfJoint in rfJointList: cmds.setAttr(rfJoint + '.overrideEnabled', 1) cmds.setAttr(rfJoint + '.overrideDisplayType', 1) cmds.setAttr(self.footJnt + '.overrideEnabled', 1) cmds.setAttr(self.middleFootJnt + '.overrideEnabled', 1) # reverse foot zero out joints: self.RFEJzt = utils.zeroOutJoints([self.RFEJxt])[0] self.RFDJzt = utils.zeroOutJoints([self.RFDJxt])[0] self.RFCJzt = utils.zeroOutJoints([self.RFCJxt])[0] self.RFBJzt = utils.zeroOutJoints([self.RFBJxt])[0] self.RFAJzt = utils.zeroOutJoints([self.RFAJxt])[0] rfJointZeroList = [ self.RFAJzt, self.RFBJzt, self.RFCJzt, self.RFDJzt, self.RFEJzt ] # putting joints in the correct place: tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footJnt, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootJxt, maintainOffset=False) tempToDelC = cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False) tempToDelD = cmds.parentConstraint(self.cvEndJoint, self.endBJnt, maintainOffset=False) tempToDelE = cmds.parentConstraint(self.cvRFALoc, self.RFAJzt, maintainOffset=False) tempToDelF = cmds.parentConstraint(self.cvRFBLoc, self.RFBJzt, maintainOffset=False) tempToDelG = cmds.parentConstraint(self.cvRFCLoc, self.RFCJzt, maintainOffset=False) tempToDelH = cmds.parentConstraint(self.cvRFDLoc, self.RFDJzt, maintainOffset=False) tempToDelI = cmds.parentConstraint(self.cvRFELoc, self.RFEJzt, maintainOffset=False) tempToDelJ = cmds.parentConstraint(self.cvEndJoint, self.RFEndJxt, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB, tempToDelC, tempToDelD, tempToDelE, tempToDelF, tempToDelG, tempToDelH, tempToDelI, tempToDelJ) cmds.makeIdentity(rfJointZeroList, apply=True, translate=True, rotate=True, scale=True) # creating ikHandles: ikHandleAnkleList = cmds.ikHandle( name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_IkHandle", startJoint=self.footJnt, endEffector=self.middleFootJxt, solver='ikSCsolver') ikHandleMiddleList = cmds.ikHandle( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_IkHandle", startJoint=self.middleFootJxt, endEffector=self.endJnt, solver='ikSCsolver') cmds.rename(ikHandleAnkleList[1], ikHandleAnkleList[0] + "_Effector") cmds.rename(ikHandleMiddleList[1], ikHandleMiddleList[0] + "_Effector") cmds.setAttr(ikHandleAnkleList[0] + '.visibility', 0) cmds.setAttr(ikHandleMiddleList[0] + '.visibility', 0) # creating Fk controls: self.footCtrl = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_leg_extrem'] + "_Ctrl", ch=False, o=True, nr=(1, 0, 0), d=3, s=8, radius=self.ctrlRadius / 2.0)[0] self.footCtrlList.append(self.footCtrl) cmds.setAttr(self.footCtrl + ".rotateOrder", 1) self.revFootCtrlShapeList.append( cmds.listRelatives(self.footCtrl, children=True, type='nurbsCurve')[0]) self.middleFootCtrl = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[ self.langName]['c_RevFoot_middle'].capitalize() + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=1, s=8, radius=self.ctrlRadius / 2.0)[0] cmds.setAttr(self.middleFootCtrl + '.overrideEnabled', 1) cmds.setAttr(self.middleFootCtrl + ".rotateOrder", 4) tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footCtrl, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootCtrl, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB) self.footCtrlZeroList = utils.zeroOut( [self.footCtrl, self.middleFootCtrl]) self.revFootCtrlZeroFinalList.append(self.footCtrlZeroList[0]) self.middleFootCtrlList.append(self.middleFootCtrl) # mount hierarchy: cmds.parent(self.footCtrlZeroList[1], self.RFDJxt, absolute=True) cmds.parent(ikHandleMiddleList[0], self.middleFootCtrl, absolute=True) self.toLimbIkHandleGrp = cmds.group( empty=True, name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_leg_extrem'] + "_Grp") self.toLimbIkHandleGrpList.append(self.toLimbIkHandleGrp) cmds.parent(ikHandleAnkleList[0], self.toLimbIkHandleGrp, self.RFEJxt, absolute=True) cmds.makeIdentity(self.toLimbIkHandleGrp, apply=True, translate=True, rotate=True, scale=True) parentConst = cmds.parentConstraint(self.RFEJxt, self.footJnt, maintainOffset=True, name=self.footJnt + "_ParentConstraint")[0] self.parentConstList.append(parentConst) self.footJntList.append(self.footJnt) cmds.parent(self.RFAJzt, self.footCtrl, absolute=True) cmds.scaleConstraint(self.footCtrl, self.footJnt, maintainOffset=True, name=self.footJnt + "_ScaleConstraint") cmds.parentConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ParentConstraint") cmds.scaleConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ScaleConstraint") # add attributes to footCtrl and connect them to joint rotation: rfAttrList = [ outsideRFAttr, insideRFAttr, heelRFAttr, toeRFAttr, ballRFAttr ] rfTypeAttrList = [rfRoll, rfSpin] for j, rfAttr in enumerate(rfAttrList): for t, rfType in enumerate(rfTypeAttrList): if t == 1 and j == (len(rfAttrList) - 1): # create turn attr to ball cmds.addAttr(self.footCtrl, longName=rfAttr + "_" + rfTurn, attributeType='float', keyable=True) cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfTurn, rfJointList[j] + ".rotateX", force=True) self.reverseFootAttrList.append(rfAttr + "_" + rfTurn) cmds.addAttr(self.footCtrl, longName=rfAttr + "_" + rfType, attributeType='float', keyable=True) self.reverseFootAttrList.append(rfAttr + "_" + rfType) if t == 0: if j > 1: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateY", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateX", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateZ", force=True) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.footCtrl, attrString=self.base + ";" + self.cvFootLoc + ";" + self.cvRFALoc + ";" + self.cvRFBLoc + ";" + self.cvRFCLoc + ";" + self.cvRFDLoc) utils.originedFrom(objName=self.middleFootCtrl, attrString=self.cvRFELoc + ";" + self.cvEndJoint) # creating pre-defined attributes for footRoll and sideRoll attributes: cmds.addAttr(self.footCtrl, longName=footRFAttr + "_" + rfRoll, attributeType='float', keyable=True) cmds.addAttr(self.footCtrl, longName=sideRFAttr + "_" + rfRoll, attributeType='float', keyable=True) # create clampNodes in order to limit the side rotations: sideClamp = cmds.createNode("clamp", name=side + self.userGuideName + "_Side_Clp") # outside values in R cmds.setAttr(sideClamp + ".maxR", 360) # inside values in G cmds.setAttr(sideClamp + ".minG", -360) # connections: cmds.connectAttr(self.footCtrl + "." + sideRFAttr + "_" + rfRoll, sideClamp + ".inputR", force=True) cmds.connectAttr(self.footCtrl + "." + sideRFAttr + "_" + rfRoll, sideClamp + ".inputG", force=True) cmds.connectAttr(sideClamp + ".outputR", self.RFAJzt + ".rotateX", force=True) cmds.connectAttr(sideClamp + ".outputG", self.RFBJzt + ".rotateX", force=True) # for footRoll: footClamp = cmds.createNode("clamp", name=side + self.userGuideName + "_Foot_Clp") # heel values in R cmds.setAttr(footClamp + ".maxR", 360) cmds.connectAttr(self.footCtrl + "." + footRFAttr + "_" + rfRoll, footClamp + ".inputR", force=True) cmds.connectAttr(footClamp + ".outputR", self.RFCJzt + ".rotateY", force=True) # set driven keys cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=0, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-45, value=-45, inTangentType="spline", outTangentType="spline") cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-200, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-30, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-60, value=-30, inTangentType="spline", outTangentType="spline") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-360, value=-180, inTangentType="flat", outTangentType="flat") # organizing keyable attributes: ctrls.setLockHide([self.middleFootCtrl, self.footCtrl], ['v'], l=False) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group( self.footCtrlZeroList[0], name=side + self.userGuideName + "_Control_Grp") self.toScalableHookGrp = cmds.group( self.footJnt, name=side + self.userGuideName + "_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v' ]) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp+".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp+".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0]+'_', self.mirrorNames[len(self.mirrorNames)-1]+'_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side+self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side+self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side+self.userGuideName+'_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side+self.userGuideName+'_'+self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: if cmds.getAttr(self.moduleGrp+".flip") == 0: for axis in self.mirrorAxis: gotValue = cmds.getAttr(side+self.userGuideName+"_Guide_Base.translate"+axis) flipedValue = gotValue*(-2) cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.translate'+axis, flipedValue) else: for axis in self.mirrorAxis: cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.scale'+axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(self.userGuideName+'_Guide_Base', name="Guide_Base_Grp", relative=True) #for Maya2012: self.userGuideName+'_'+self.moduleGrp+"_Grp" # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName+'_'+self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.base = side+self.userGuideName+'_Guide_Base' cmds.select(clear=True) # declare guide: self.guide = side+self.userGuideName+"_Guide_JointLoc1" # create a joint: self.jnt = cmds.joint(name=side+self.userGuideName+"_Jnt", scaleCompensate=False) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) # create a control: if self.getHasIndirectSkin(): self.ctrl = cmds.circle(name=side+self.userGuideName+"_Ctrl", degree=3, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] else: self.ctrl = cmds.circle(name=side+self.userGuideName+"_Ctrl", degree=1, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] utils.originedFrom(objName=self.ctrl, attrString=self.base+";"+self.guide) # position and orientation of joint and control: cmds.delete(cmds.parentConstraint(self.guide, self.jnt, maintainOffset=False)) cmds.delete(cmds.parentConstraint(self.guide, self.ctrl, maintainOffset=False)) # zeroOut controls: zeroOutCtrlGrp = utils.zeroOut([self.ctrl])[0] # hide visibility attribute: cmds.setAttr(self.ctrl+'.visibility', keyable=False) # fixing flip mirror: if s == 1: if cmds.getAttr(self.moduleGrp+".flip") == 1: cmds.setAttr(zeroOutCtrlGrp+".scaleX", -1) cmds.setAttr(zeroOutCtrlGrp+".scaleY", -1) cmds.setAttr(zeroOutCtrlGrp+".scaleZ", -1) cmds.addAttr(self.ctrl, longName='scaleCompensate', attributeType="bool", keyable=True) cmds.setAttr(self.ctrl+".scaleCompensate", 1) cmds.connectAttr(self.ctrl+".scaleCompensate", self.jnt+".segmentScaleCompensate", force=True) if self.getHasIndirectSkin(): # create a fatherJoint: cmds.select(clear=True) jxtName = self.jnt.replace("_Jnt", "_Jxt") self.jxt = cmds.duplicate(self.jnt, name=jxtName)[0] cmds.deleteAttr(self.jxt, attribute="dpAR_joint") cmds.parent(self.jnt, self.jxt) attrList = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'] for attr in attrList: cmds.connectAttr(self.ctrl+'.'+attr, self.jnt+'.'+attr) else: # create parentConstraint from ctrl to jnt: cmds.parentConstraint(self.ctrl, self.jnt, maintainOffset=False, name=self.jnt+"_ParentConstraint") # create scaleConstraint from ctrl to jnt: cmds.scaleConstraint(self.ctrl, self.jnt, maintainOffset=True, name=self.jnt+"_ScaleConstraint") # create end joint: cmds.select(self.jnt) self.cvEndJoint = side+self.userGuideName+"_Guide_JointEnd" self.endJoint = cmds.joint(name=side+self.userGuideName+"_JEnd") cmds.delete(cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False)) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(side+self.userGuideName+"_Ctrl_Zero", name=side+self.userGuideName+"_Control_Grp") if self.getHasIndirectSkin(): locScale = cmds.spaceLocator(name=side+self.userGuideName+"_Scalable_DO_NOT_DELETE")[0] self.toScalableHookGrp = cmds.group(locScale, name=side+self.userGuideName+"_IndirectSkin_Grp") jxtGrp = cmds.group(side+self.userGuideName+"_Jxt", name=side+self.userGuideName+"_Joint_Grp") self.toStaticHookGrp = cmds.group(jxtGrp, self.toScalableHookGrp, self.toCtrlHookGrp, name=side+self.userGuideName+"_Grp") else: self.toScalableHookGrp = cmds.group(side+self.userGuideName+"_Jnt", name=side+self.userGuideName+"_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side+self.userGuideName+"_Grp") # create a locator in order to avoid delete static or scalable group loc = cmds.spaceLocator(name=side+self.userGuideName+"_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc+".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp+'.dpAR_count', dpAR_count) if hideJoints: cmds.setAttr(self.toScalableHookGrp+".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side+self.userGuideName+'_'+self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp+".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp+".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0]+'_', self.mirrorNames[len(self.mirrorNames)-1]+'_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side+self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side+self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side+self.userGuideName+'_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side+self.userGuideName+'_'+self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: if cmds.getAttr(self.moduleGrp+".flip") == 0: for axis in self.mirrorAxis: gotValue = cmds.getAttr(side+self.userGuideName+"_Guide_Base.translate"+axis) flipedValue = gotValue*(-2) cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.translate'+axis, flipedValue) else: for axis in self.mirrorAxis: cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.scale'+axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(self.userGuideName+'_Guide_Base', name="Guide_Base_Grp", relative=True) #for Maya2012: self.userGuideName+'_'+self.moduleGrp+"_Grp" # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName+'_'+self.mirrorGrp) # store the number of this guide by module type: dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # create a list to export: self.eyeScaleGrpList = [] # create the main control: self.eyeCtrl = cmds.circle(name=self.userGuideName+"_A_Ctrl", radius=(2.25*self.ctrlRadius), normal=(0,0,1), degree=3, constructionHistory=False)[0] cmds.addAttr(self.eyeCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', keyable=True, minValue=0, maxValue=1) cmds.setAttr(self.eyeCtrl+"."+self.langDic[self.langName]['c_Follow'], 1) cmds.move(0,-1,0, self.eyeCtrl+".cv[1]", relative=True) cmds.move(0,1,0, self.eyeCtrl+".cv[5]", relative=True) cmds.delete(cmds.parentConstraint(sideList[0]+self.userGuideName+"_Guide_JointEnd", self.eyeCtrl, maintainOffset=False)) cmds.setAttr(self.eyeCtrl+".translateX", 0) self.eyeGrp = cmds.group(self.eyeCtrl, name=self.userGuideName+"_A_Grp") utils.zeroOut([self.eyeCtrl]) self.upLocGrp = cmds.group(name=self.userGuideName+"_UpLoc_Grp", empty=True) # run for all sides: for s, side in enumerate(sideList): cmds.select(clear=True) self.base = side+self.userGuideName+'_Guide_Base' # declare guide: self.guide = side+self.userGuideName+"_Guide_JointLoc1" # create a joint: self.jxt = cmds.joint(name=side+self.userGuideName+"_1_Jxt", scaleCompensate=False) self.jnt = cmds.joint(name=side+self.userGuideName+"_1_Jnt", scaleCompensate=False) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) self.fkEyeCtrl = cmds.circle(name=side+self.userGuideName+"_Fk_Ctrl", radius=self.ctrlRadius, normal=(0,0,1), degree=1, sections=6, constructionHistory=False)[0] utils.originedFrom(objName=self.fkEyeCtrl, attrString=self.base+";"+self.guide) self.baseEyeCtrl = ctrls.cvBox(ctrlName=side+self.userGuideName+"_Base_Ctrl", r=self.ctrlRadius) utils.originedFrom(objName=self.baseEyeCtrl, attrString=self.base+";"+self.guide) # position and orientation of joint and control: cmds.delete(cmds.parentConstraint(self.guide, self.jxt, maintainOffset=False)) cmds.delete(cmds.parentConstraint(self.guide, self.fkEyeCtrl, maintainOffset=False)) cmds.delete(cmds.parentConstraint(self.guide, self.baseEyeCtrl, maintainOffset=False)) cmds.makeIdentity(self.baseEyeCtrl, self.fkEyeCtrl, apply=True) # zeroOut controls: eyeZeroList = utils.zeroOut([self.baseEyeCtrl, self.fkEyeCtrl]) cmds.parent(eyeZeroList[1], self.baseEyeCtrl) # hide visibility attribute: cmds.setAttr(self.fkEyeCtrl+'.visibility', keyable=False) ctrls.setLockHide([self.fkEyeCtrl], ['tx', 'ty', 'tz']) # create end joint: self.cvEndJoint = side+self.userGuideName+"_Guide_JointEnd" self.endJoint = cmds.joint(name=side+self.userGuideName+"_JEnd") cmds.delete(cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False)) cmds.parent(self.endJoint, self.jnt, absolute=True) # create parentConstraint from ctrl to jxt: cmds.parentConstraint(self.fkEyeCtrl, self.jxt, maintainOffset=False, name=self.jnt+"_ParentConstraint") # create scaleConstraint from ctrl to jnt: cmds.scaleConstraint(self.fkEyeCtrl, self.jxt, maintainOffset=True, name=self.jnt+"_ScaleConstraint") # lookAt control: self.lookAtCtrl = cmds.circle(name=side+self.userGuideName+"_LookAt_Ctrl", radius=self.ctrlRadius, normal=(0,0,1), degree=3, constructionHistory=False)[0] cmds.delete(cmds.parentConstraint(self.cvEndJoint, self.lookAtCtrl, maintainOffset=False)) cmds.parent(self.lookAtCtrl, self.eyeCtrl, relative=False) cmds.makeIdentity(self.lookAtCtrl, apply=True) cmds.addAttr(self.lookAtCtrl, longName="active", attributeType="bool", defaultValue=1, keyable=True) # up locator: self.lUpGrpLoc = cmds.group(name=side+self.userGuideName+"_Up_Loc_Grp", empty=True) cmds.delete(cmds.parentConstraint(self.jnt, self.lUpGrpLoc, maintainOffset=False)) self.lUpLoc = cmds.spaceLocator(name=side+self.userGuideName+"_Up_Loc")[0] cmds.delete(cmds.parentConstraint(self.jnt, self.lUpLoc, maintainOffset=False)) cmds.move(cmds.getAttr(self.guideName+"_JointEnd.translateZ"), self.lUpLoc, moveY=True, relative=True) cmds.parent(self.lUpLoc, self.lUpGrpLoc, relative=False) cmds.parent(self.lUpGrpLoc, self.upLocGrp, relative=False) # look at aim constraint: aimConst = cmds.aimConstraint(self.lookAtCtrl, self.fkEyeCtrl+"_Zero", worldUpType="object", worldUpObject=self.upLocGrp+"|"+self.lUpGrpLoc+"|"+self.lUpLoc, maintainOffset=True)[0] cmds.connectAttr(self.lookAtCtrl+".active", aimConst+"."+self.lookAtCtrl+"W0", force=True) # eye aim rotation cmds.addAttr(self.fkEyeCtrl, longName="aimRotation", attributeType="float", keyable=True) cmds.connectAttr(self.fkEyeCtrl+".aimRotation", self.jnt+".rotateZ", force=True) cmds.pointConstraint(self.baseEyeCtrl, self.lUpGrpLoc, maintainOffset=True, name=self.lUpGrpLoc+"_PointConstraint") # create eyeScale setup: cmds.select(clear=True) self.eyeScaleJnt = cmds.joint(name=side+self.userGuideName+"Scale_1_Jnt", scaleCompensate=False) cmds.addAttr(self.eyeScaleJnt, longName='dpAR_joint', attributeType='float', keyable=False) # jointScale position: cmds.delete(cmds.parentConstraint(self.guide, self.eyeScaleJnt, maintainOffset=False)) # create endScale joint: self.endScaleJoint = cmds.joint(name=side+self.userGuideName+"Scale_JEnd") cmds.delete(cmds.parentConstraint(self.eyeScaleJnt, self.endScaleJoint, maintainOffset=False)) cmds.setAttr(self.endScaleJoint+".translateZ", 1) # create constraints to eyeScale: cmds.pointConstraint(self.jnt, self.eyeScaleJnt, maintainOffset=False, name=self.eyeScaleJnt+"_PointConstraint") cmds.scaleConstraint(self.jnt, self.eyeScaleJnt, maintainOffset=True, name=self.eyeScaleJnt+"_ScaleConstraint") self.eyeScaleGrp = cmds.group(self.eyeScaleJnt, name=self.eyeScaleJnt+"_Grp") self.eyeScaleGrpList.append(self.eyeScaleGrp) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(eyeZeroList[0], name=side+self.userGuideName+"_Control_Grp") self.toScalableHookGrp = cmds.group(self.jxt, self.eyeScaleGrp, name=side+self.userGuideName+"_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side+self.userGuideName+"_Grp") if s == 0: cmds.parent(self.eyeGrp, self.toCtrlHookGrp) cmds.parent(self.upLocGrp, self.toScalableHookGrp) # create a locator in order to avoid delete static group: loc = cmds.spaceLocator(name=side+self.userGuideName+"_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc+".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp+'.dpAR_count', dpAR_count) if hideJoints: cmds.setAttr(self.toScalableHookGrp+".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side+self.userGuideName+'_'+self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') # create cvJointLoc and cvLocators: self.cvNeckLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName + "_neck", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvHeadLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_head", r=0.4) self.connectShapeSize(shapeSizeCH) self.cvJawLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_jaw", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvChinLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_chin", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvLLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_lLip", r=0.1) self.connectShapeSize(shapeSizeCH) self.cvRLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_rLip", r=0.1) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideNeck = cmds.joint(name=self.guideName + "_JGuideNeck", radius=0.001) self.jGuideHead = cmds.joint(name=self.guideName + "_JGuideHead", radius=0.001) self.jGuideJaw = cmds.joint(name=self.guideName + "_JGuideJaw", radius=0.001) self.jGuideChin = cmds.joint(name=self.guideName + "_JGuideChin", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideNeck + ".template", 1) cmds.setAttr(self.jGuideHead + ".template", 1) cmds.setAttr(self.jGuideJaw + ".template", 1) cmds.setAttr(self.jGuideChin + ".template", 1) cmds.parent(self.jGuideNeck, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator( ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvChinLoc) cmds.setAttr(self.cvEndJoint + ".tz", ctrls.dpCheckLinearUnit(1.3)) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.parent(self.jGuideEnd, self.jGuideChin) # make parents between cvLocs: cmds.parent(self.cvNeckLoc, self.moduleGrp) cmds.parent(self.cvHeadLoc, self.cvNeckLoc) cmds.parent(self.cvJawLoc, self.cvHeadLoc) cmds.parent(self.cvChinLoc, self.cvJawLoc) cmds.parent(self.cvLLipLoc, self.cvJawLoc) cmds.parent(self.cvRLipLoc, self.cvJawLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvNeckLoc, self.jGuideNeck, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvHeadLoc, self.jGuideHead, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvJawLoc, self.jGuideJaw, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvChinLoc, self.jGuideChin, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # transform cvLocs in order to put as a good head guide: cmds.setAttr(self.cvNeckLoc + ".rotateY", -10) cmds.setAttr(self.cvHeadLoc + ".translateZ", 2) cmds.setAttr(self.cvHeadLoc + ".rotateY", 5) cmds.setAttr(self.cvJawLoc + ".translateX", -0.5) cmds.setAttr(self.cvJawLoc + ".translateZ", 1.25) cmds.setAttr(self.cvJawLoc + ".rotateY", -95) cmds.setAttr(self.cvChinLoc + ".translateZ", 0.25) cmds.setAttr(self.moduleGrp + ".rotateX", -90) cmds.setAttr(self.moduleGrp + ".rotateY", 90) # lip cvLocs: cmds.setAttr(self.cvLLipLoc + ".translateY", -0.5) cmds.setAttr(self.cvLLipLoc + ".translateZ", 1) self.lipMD = cmds.createNode("multiplyDivide", name=self.guideName + "_lip_MD") cmds.connectAttr(self.cvLLipLoc + ".translateX", self.lipMD + ".input1X", force=True) cmds.connectAttr(self.cvLLipLoc + ".translateY", self.lipMD + ".input1Y", force=True) cmds.connectAttr(self.cvLLipLoc + ".translateZ", self.lipMD + ".input1Z", force=True) cmds.connectAttr(self.lipMD + ".outputX", self.cvRLipLoc + ".translateX", force=True) cmds.connectAttr(self.lipMD + ".outputY", self.cvRLipLoc + ".translateY", force=True) cmds.connectAttr(self.lipMD + ".outputZ", self.cvRLipLoc + ".translateZ", force=True) cmds.setAttr(self.lipMD + ".input2Y", -1)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') # create cvJointLoc and cvLocators: self.cvFootLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName + "_foot", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFALoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfA", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFBLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfB", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFCLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfC", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFDLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfD", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFELoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfE", r=0.3) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideFoot = cmds.joint(name=self.guideName + "_JGuideFoot", radius=0.001) self.jGuideRFE = cmds.joint(name=self.guideName + "_JGuideRfE", radius=0.001) cmds.select(clear=True) self.jGuideRFA = cmds.joint(name=self.guideName + "_JGuideRfA", radius=0.001) self.jGuideRFD = cmds.joint(name=self.guideName + "_JGuideRfD", radius=0.001) self.jGuideRFB = cmds.joint(name=self.guideName + "_JGuideRfB", radius=0.001) self.jGuideRFC = cmds.joint(name=self.guideName + "_JGuideRfC", radius=0.001) self.jGuideRFAC = cmds.joint(name=self.guideName + "_JGuideRfAC", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideFoot + ".template", 1) cmds.setAttr(self.jGuideRFA + ".template", 1) cmds.setAttr(self.jGuideRFB + ".template", 1) cmds.setAttr(self.jGuideRFC + ".template", 1) cmds.setAttr(self.jGuideRFD + ".template", 1) cmds.setAttr(self.jGuideRFE + ".template", 1) cmds.parent(self.jGuideFoot, self.jGuideRFA, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvRFELoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.parent(self.jGuideEnd, self.jGuideRFE) # make parents between cvLocs: cmds.parent(self.cvFootLoc, self.cvRFALoc, self.cvRFBLoc, self.cvRFCLoc, self.cvRFDLoc, self.moduleGrp) cmds.parent(self.cvRFELoc, self.cvFootLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvFootLoc, self.jGuideFoot, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) cmds.parentConstraint(self.cvRFALoc, self.jGuideRFA, maintainOffset=False, name=self.jGuideRFA + "_ParentConstraint") cmds.parentConstraint(self.cvRFBLoc, self.jGuideRFB, maintainOffset=False, name=self.jGuideRFB + "_ParentConstraint") cmds.parentConstraint(self.cvRFCLoc, self.jGuideRFC, maintainOffset=False, name=self.jGuideRFC + "_ParentConstraint") cmds.parentConstraint(self.cvRFDLoc, self.jGuideRFD, maintainOffset=False, name=self.jGuideRFD + "_ParentConstraint") cmds.parentConstraint(self.cvRFELoc, self.jGuideRFE, maintainOffset=False, name=self.jGuideRFE + "_ParentConstraint") cmds.parentConstraint(self.cvRFALoc, self.jGuideRFAC, maintainOffset=False, name=self.jGuideRFAC + "_ParentConstraint") ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # transform cvLocs in order to put as a good foot guide: cmds.setAttr(self.cvFootLoc + ".translateZ", 2) cmds.setAttr(self.cvFootLoc + ".rotateY", -90) cmds.setAttr(self.cvRFELoc + ".translateX", -1) cmds.setAttr(self.cvRFELoc + ".translateZ", 2.5) cmds.setAttr(self.cvRFCLoc + ".translateX", 1) cmds.setAttr(self.cvRFALoc + ".translateX", -0.6) cmds.setAttr(self.cvRFALoc + ".translateY", -1) cmds.setAttr(self.cvRFBLoc + ".translateX", -0.6) cmds.setAttr(self.cvRFBLoc + ".translateY", 1) cmds.setAttr(self.cvRFDLoc + ".translateX", -3.5) cmds.setAttr(self.moduleGrp + ".rotateX", -90) cmds.setAttr(self.moduleGrp + ".rotateY", 90)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') # create cvJointLoc and cvLocators: self.cvNeckLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_neck", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvHeadLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_head", r=0.4) self.connectShapeSize(shapeSizeCH) self.cvJawLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_jaw", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvChinLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_chin", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvLLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_lLip", r=0.1) self.connectShapeSize(shapeSizeCH) self.cvRLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_rLip", r=0.1) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideNeck = cmds.joint(name=self.guideName+"_JGuideNeck", radius=0.001) self.jGuideHead = cmds.joint(name=self.guideName+"_JGuideHead", radius=0.001) self.jGuideJaw = cmds.joint(name=self.guideName+"_JGuideJaw", radius=0.001) self.jGuideChin = cmds.joint(name=self.guideName+"_JGuideChin", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideNeck+".template", 1) cmds.setAttr(self.jGuideHead+".template", 1) cmds.setAttr(self.jGuideJaw+".template", 1) cmds.setAttr(self.jGuideChin+".template", 1) cmds.parent(self.jGuideNeck, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvChinLoc) cmds.setAttr(self.cvEndJoint+".tz", ctrls.dpCheckLinearUnit(1.3)) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.parent(self.jGuideEnd, self.jGuideChin) # make parents between cvLocs: cmds.parent(self.cvNeckLoc, self.moduleGrp) cmds.parent(self.cvHeadLoc, self.cvNeckLoc) cmds.parent(self.cvJawLoc, self.cvHeadLoc) cmds.parent(self.cvChinLoc, self.cvJawLoc) cmds.parent(self.cvLLipLoc, self.cvJawLoc) cmds.parent(self.cvRLipLoc, self.cvJawLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvNeckLoc, self.jGuideNeck, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvHeadLoc, self.jGuideHead, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvJawLoc, self.jGuideJaw, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvChinLoc, self.jGuideChin, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # transform cvLocs in order to put as a good head guide: cmds.setAttr(self.cvNeckLoc+".rotateY", -10) cmds.setAttr(self.cvHeadLoc+".translateZ", 2) cmds.setAttr(self.cvHeadLoc+".rotateY", 5) cmds.setAttr(self.cvJawLoc+".translateX", -0.5) cmds.setAttr(self.cvJawLoc+".translateZ", 1.25) cmds.setAttr(self.cvJawLoc+".rotateY", -95) cmds.setAttr(self.cvChinLoc+".translateZ", 0.25) cmds.setAttr(self.moduleGrp+".rotateX", -90) cmds.setAttr(self.moduleGrp+".rotateY", 90) # lip cvLocs: cmds.setAttr(self.cvLLipLoc+".translateY", -0.5) cmds.setAttr(self.cvLLipLoc+".translateZ", 1) self.lipMD = cmds.createNode("multiplyDivide", name=self.guideName+"_lip_MD") cmds.connectAttr(self.cvLLipLoc+".translateX", self.lipMD+".input1X", force=True) cmds.connectAttr(self.cvLLipLoc+".translateY", self.lipMD+".input1Y", force=True) cmds.connectAttr(self.cvLLipLoc+".translateZ", self.lipMD+".input1Z", force=True) cmds.connectAttr(self.lipMD+".outputX", self.cvRLipLoc+".translateX", force=True) cmds.connectAttr(self.lipMD+".outputY", self.cvRLipLoc+".translateY", force=True) cmds.connectAttr(self.lipMD+".outputZ", self.cvRLipLoc+".translateZ", force=True) cmds.setAttr(self.lipMD+".input2Y", -1)
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # declare lists to store names and attributes: self.worldRefList, self.headCtrlList = [], [] self.aCtrls = [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp+".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp+".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0]+'_', self.mirrorNames[len(self.mirrorNames)-1]+'_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side+self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side+self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side+self.userGuideName+'_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side+self.userGuideName+'_'+self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.scale'+axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(self.userGuideName+'_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName+'_'+self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side+self.userGuideName+"_Guide_Base" self.cvNeckLoc = side+self.userGuideName+"_Guide_neck" self.cvHeadLoc = side+self.userGuideName+"_Guide_head" self.cvJawLoc = side+self.userGuideName+"_Guide_jaw" self.cvChinLoc = side+self.userGuideName+"_Guide_chin" self.cvLLipLoc = side+self.userGuideName+"_Guide_lLip" self.cvRLipLoc = side+self.userGuideName+"_Guide_rLip" self.cvEndJoint = side+self.userGuideName+"_Guide_JointEnd" # creating joints: self.neckJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_neck']+"_Jnt") self.headJxt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Jxt") cmds.select(clear=True) self.headJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Jnt", scaleCompensate=False) self.jawJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_jaw']+"_Jnt", scaleCompensate=False) self.chinJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_chin']+"_Jnt", scaleCompensate=False) self.endJnt = cmds.joint(name=side+self.userGuideName+"_JEnd", scaleCompensate=False) cmds.select(clear=True) self.lLipJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p002_left']+"_"+self.langDic[self.langName]['c_lip']+"_Jnt", scaleCompensate=False) cmds.select(clear=True) self.rLipJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p003_right']+"_"+self.langDic[self.langName]['c_lip']+"_Jnt", scaleCompensate=False) dpARJointList = [self.neckJnt, self.headJnt, self.jawJnt, self.chinJnt, self.lLipJnt, self.rLipJnt] for dpARJoint in dpARJointList: cmds.addAttr(dpARJoint, longName='dpAR_joint', attributeType='float', keyable=False) # creating controls: self.neckCtrl = ctrls.cvNeck(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_neck']+"_Ctrl", r=self.ctrlRadius/2.0) self.headCtrl = ctrls.cvHead(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Ctrl", r=self.ctrlRadius/2.0) self.jawCtrl = ctrls.cvJaw( ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_jaw']+"_Ctrl", r=self.ctrlRadius/2.0) self.chinCtrl = ctrls.cvChin(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_chin']+"_Ctrl", r=self.ctrlRadius/2.0) self.lLipCtrl = cmds.circle(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p002_left']+"_"+self.langDic[self.langName]['c_lip']+"_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.rLipCtrl = cmds.circle(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p003_right']+"_"+self.langDic[self.langName]['c_lip']+"_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.headCtrlList.append(self.headCtrl) self.aCtrls.append([self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl, self.lLipCtrl, self.rLipCtrl]) #Setup Axis Order if self.rigType == Base.RigType.quadruped: cmds.setAttr(self.neckCtrl + ".rotateOrder", 1) cmds.setAttr(self.headCtrl + ".rotateOrder", 1) cmds.setAttr(self.jawCtrl + ".rotateOrder", 1) else: cmds.setAttr(self.neckCtrl + ".rotateOrder", 4) cmds.setAttr(self.headCtrl + ".rotateOrder", 4) cmds.setAttr(self.jawCtrl + ".rotateOrder", 4) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.neckCtrl, attrString=self.base+";"+self.cvNeckLoc) utils.originedFrom(objName=self.headCtrl, attrString=self.cvHeadLoc) utils.originedFrom(objName=self.jawCtrl, attrString=self.cvJawLoc) utils.originedFrom(objName=self.chinCtrl, attrString=self.cvChinLoc+";"+self.cvEndJoint) # orientation of controls: ctrls.setAndFreeze(nodeName=self.neckCtrl, rx=90, rz=-90) ctrls.setAndFreeze(nodeName=self.headCtrl, rx=90, rz=-90) ctrls.setAndFreeze(nodeName=self.jawCtrl, rz=-90) ctrls.setAndFreeze(nodeName=self.chinCtrl, rz=-90) # edit the mirror shape to a good direction of controls: ctrlList = [ self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl ] if s == 1: for ctrl in ctrlList: if self.mirrorAxis == 'X': cmds.setAttr(ctrl+'.rotateY', 180) elif self.mirrorAxis == 'Y': cmds.setAttr(ctrl+'.rotateY', 180) elif self.mirrorAxis == 'Z': cmds.setAttr(ctrl+'.rotateX', 180) cmds.setAttr(ctrl+'.rotateZ', 180) elif self.mirrorAxis == 'XYZ': cmds.setAttr(ctrl+'.rotateX', 180) cmds.setAttr(ctrl+'.rotateZ', 180) cmds.makeIdentity(ctrlList, apply=True, translate=False, rotate=True, scale=False) # temporary parentConstraints: tempDelNeck = cmds.parentConstraint(self.cvNeckLoc, self.neckCtrl, maintainOffset=False) tempDelHead = cmds.parentConstraint(self.cvHeadLoc, self.headCtrl, maintainOffset=False) tempDelJaw = cmds.parentConstraint(self.cvJawLoc, self.jawCtrl, maintainOffset=False) tempDelChin = cmds.parentConstraint(self.cvChinLoc, self.chinCtrl, maintainOffset=False) tempDelLLip = cmds.parentConstraint(self.cvLLipLoc, self.lLipCtrl, maintainOffset=False) tempDelRLip = cmds.parentConstraint(self.cvRLipLoc, self.rLipCtrl, maintainOffset=False) cmds.delete(tempDelNeck, tempDelHead, tempDelJaw, tempDelChin, tempDelLLip, tempDelRLip) # zeroOut controls: self.zeroLipCtrlList = utils.zeroOut([self.lLipCtrl, self.rLipCtrl]) self.lLipGrp = cmds.group(self.lLipCtrl, name=self.lLipCtrl+"_Grp") self.rLipGrp = cmds.group(self.rLipCtrl, name=self.rLipCtrl+"_Grp") self.zeroCtrlList = utils.zeroOut([self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl, self.zeroLipCtrlList[0], self.zeroLipCtrlList[1]]) # make joints be ride by controls: cmds.makeIdentity(self.neckJnt, self.headJxt, self.headJnt, self.jawJnt, self.chinJnt, self.endJnt, rotate=True, apply=True) cmds.parentConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt+"_ParentConstraint") cmds.scaleConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt+"_ScaleConstraint") cmds.delete(cmds.parentConstraint(self.headCtrl, self.headJxt, maintainOffset=False)) cmds.parentConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt+"_ParentConstraint") cmds.parentConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt+"_ParentConstraint") cmds.parentConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt+"_ParentConstraint") cmds.parentConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt+"_ParentConstraint") cmds.parentConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt+"_ParentConstraint") cmds.scaleConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt+"_ScaleConstraint") cmds.scaleConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt+"_ScaleConstraint") cmds.scaleConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt+"_ScaleConstraint") cmds.scaleConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt+"_ScaleConstraint") cmds.scaleConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt+"_ScaleConstraint") cmds.delete(cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False)) cmds.setAttr(self.jawJnt+".segmentScaleCompensate", 0) # create interations between neck and head: self.grpNeck = cmds.group(self.zeroCtrlList[0], name=self.neckCtrl+"_Grp") self.grpHeadA = cmds.group(empty=True, name=self.headCtrl+"_A_Grp") self.grpHead = cmds.group(self.grpHeadA, name=self.headCtrl+"_Grp") # arrange pivots: self.neckPivot = cmds.xform(self.neckCtrl, query=True, worldSpace=True, translation=True) self.headPivot = cmds.xform(self.headCtrl, query=True, worldSpace=True, translation=True) cmds.xform(self.grpNeck, pivots=(self.neckPivot[0], self.neckPivot[1], self.neckPivot[2])) cmds.xform(self.grpHead, self.grpHeadA, pivots=(self.headPivot[0], self.headPivot[1], self.headPivot[2])) self.worldRef = cmds.group(empty=True, name=side+self.userGuideName+"_WorldRef") self.worldRefList.append(self.worldRef) cmds.delete(cmds.parentConstraint(self.neckCtrl, self.worldRef, maintainOffset=False)) cmds.parentConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, skipRotate=["x", "y", "z"], name=self.grpHeadA+"_ParentConstraint") orientConst = cmds.orientConstraint(self.neckCtrl, self.worldRef, self.grpHeadA, maintainOffset=False, name=self.grpHeadA+"_OrientConstraint")[0] cmds.scaleConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, name=self.grpHeadA+"_ScaleConstraint") cmds.parent(self.zeroCtrlList[1], self.grpHeadA, absolute=True) # connect reverseNode: cmds.addAttr(self.headCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, keyable=True) cmds.connectAttr(self.headCtrl+'.'+self.langDic[self.langName]['c_Follow'], orientConst+"."+self.neckCtrl+"W0", force=True) self.headRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_Rev") cmds.connectAttr(self.headCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.headRevNode+".inputX", force=True) cmds.connectAttr(self.headRevNode+'.outputX', orientConst+"."+self.worldRef+"W1", force=True) # mount controls hierarchy: cmds.parent(self.zeroCtrlList[3], self.jawCtrl, absolute=True) # jaw follow head or root ctrl (using worldRef) jawParentConst = cmds.parentConstraint(self.headCtrl, self.worldRef, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2]+"_ParentConstraint")[0] cmds.setAttr(jawParentConst+".interpType", 2) #Shortest, no flip cause problem with scrubing cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType="float", minValue=0, maxValue=1, defaultValue=1, keyable=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_Follow'], jawParentConst+"."+self.headCtrl+"W0", force=True) jawFollowRev = cmds.createNode("reverse", name=self.jawCtrl+"_Rev") cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_Follow'], jawFollowRev+".inputX", force=True) cmds.connectAttr(jawFollowRev+".outputX", jawParentConst+"."+self.worldRef+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2]+"_ScaleConstraint")[0] # setup jaw auto translation self.jawSdkGrp = cmds.group(self.jawCtrl, name=self.jawCtrl+"_SDK_Grp") cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity']+"Y", attributeType='float', keyable=True) cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity']+"Z", attributeType='float', keyable=True) cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveStartRotation'], attributeType='float', keyable=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", 0.01) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", 0.02) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], -10) self.jawIntensityMD = cmds.createNode('multiplyDivide', name="JawMoveIntensity_MD") self.jawIntensityZMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityZ_MD") self.jawIntensityZInvMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityZInv_MD") self.jawStartIntensityMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityStart_MD") self.jawIntensityPMA = cmds.createNode('plusMinusAverage', name="JawMoveIntensity_PMA") self.jawIntensityCnd = cmds.createNode('condition', name="JawMoveIntensity_Cnd") cmds.connectAttr(self.jawCtrl+".rotateY", self.jawIntensityMD+".input1Y", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", self.jawIntensityMD+".input2Y", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", self.jawStartIntensityMD+".input1X", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], self.jawStartIntensityMD+".input2X", force=True) cmds.setAttr(self.jawIntensityPMA+".operation", 2) cmds.connectAttr(self.jawIntensityMD+".outputY", self.jawIntensityPMA+".input1D[0]", force=True) cmds.connectAttr(self.jawStartIntensityMD+".outputX", self.jawIntensityPMA+".input1D[1]", force=True) cmds.connectAttr(self.jawIntensityPMA+".output1D", self.jawIntensityCnd+".colorIfTrueG", force=True) cmds.connectAttr(self.jawCtrl+".rotateY", self.jawIntensityCnd+".firstTerm", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], self.jawIntensityCnd+".secondTerm", force=True) cmds.setAttr(self.jawIntensityCnd+".operation", 4) cmds.setAttr(self.jawIntensityCnd+".colorIfFalseG", 0) cmds.connectAttr(self.jawIntensityCnd+".outColorG", self.jawSdkGrp+".translateX", force=True) cmds.connectAttr(self.jawIntensityCnd+".outColorG", self.jawIntensityZMD+".input1Z", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", self.jawIntensityZMD+".input2Z", force=True) cmds.connectAttr(self.jawIntensityZMD+".outputZ", self.jawIntensityZInvMD+".input1Z", force=True) cmds.setAttr(self.jawIntensityZInvMD+".input2Z", -1) cmds.connectAttr(self.jawIntensityZInvMD+".outputZ", self.jawSdkGrp+".translateZ", force=True) # create lip setup: # left side lip: lLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp+"_ParentConstraint")[0] cmds.setAttr(lLipParentConst+".interpType", 2) cmds.addAttr(self.lLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.lLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], lLipParentConst+"."+self.jawCtrl+"W0", force=True) self.lLipRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_"+self.langDic[self.langName]['p002_left']+"_"+self.langDic[self.langName]['c_lip']+"_Rev") cmds.connectAttr(self.lLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.lLipRevNode+".inputX", force=True) cmds.connectAttr(self.lLipRevNode+'.outputX', lLipParentConst+"."+self.headCtrl+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp+"_ScaleConstraint")[0] # right side lip: rLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp+"_ParentConstraint")[0] cmds.setAttr(rLipParentConst+".interpType", 2) cmds.addAttr(self.rLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.rLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], rLipParentConst+"."+self.jawCtrl+"W0", force=True) self.rLipRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_"+self.langDic[self.langName]['p003_right']+"_"+self.langDic[self.langName]['c_lip']+"_Rev") cmds.connectAttr(self.rLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.rLipRevNode+".inputX", force=True) cmds.connectAttr(self.rLipRevNode+'.outputX', rLipParentConst+"."+self.headCtrl+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp+"_ScaleConstraint")[0] # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side+self.userGuideName+"_DO_NOT_DELETE")[0] cmds.parent(loc, self.worldRef, absolute=True) cmds.setAttr(loc+".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) # hiding visibility attributes: ctrls.setLockHide([self.headCtrl, self.neckCtrl, self.jawCtrl, self.chinCtrl], ['v'], l=False) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(self.grpNeck, self.grpHead, self.zeroCtrlList[2], self.zeroCtrlList[4], self.zeroCtrlList[5], name=side+self.userGuideName+"_Control_Grp") self.toScalableHookGrp = cmds.group(self.neckJnt, self.headJnt, self.lLipJnt, self.rLipJnt, name=side+self.userGuideName+"_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, self.grpHead, self.worldRef, name=side+self.userGuideName+"_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp+'.dpAR_count', dpAR_count) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.grpHead, hookType='rootHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') if hideJoints: cmds.setAttr(self.toScalableHookGrp+".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side+self.userGuideName+'_'+self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # declaring lists to send information for integration: self.scalableGrpList, self.ikCtrlZeroList = [], [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp+".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp+".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0]+'_', self.mirrorNames[len(self.mirrorNames)-1]+'_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side+self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side+self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side+self.userGuideName+'_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side+self.userGuideName+'_'+self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.scale'+axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(self.userGuideName+'_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName+'_'+self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.skinJointList = [] self.base = side+self.userGuideName+'_Guide_Base' # get the number of joints to be created: self.nJoints = cmds.getAttr(self.base+".nJoints") for n in range(0, self.nJoints+1): cmds.select(clear=True) # declare guide: self.guide = side+self.userGuideName+"_Guide_JointLoc"+str(n) # create a joint: self.jnt = cmds.joint(name=side+self.userGuideName+"_"+str(n)+"_Jnt", scaleCompensate=False) self.skinJointList.append(self.jnt) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) # create a control: if n == 1: self.ctrl = ctrls.cvFinger(ctrlName=side+self.userGuideName+"_"+str(n)+"_Ctrl", r=self.ctrlRadius) cmds.setAttr(self.ctrl + ".rotateOrder", 1) utils.originedFrom(objName=self.ctrl, attrString=self.base+";"+self.guide) # edit the mirror shape to a good direction of controls: if s == 1: if self.mirrorAxis == 'X': cmds.setAttr(self.ctrl+'.rotateZ', 180) elif self.mirrorAxis == 'Y': cmds.setAttr(self.ctrl+'.rotateY', 180) elif self.mirrorAxis == 'Z': cmds.setAttr(self.ctrl+'.rotateZ', 180) elif self.mirrorAxis == 'XY': cmds.setAttr(self.ctrl+'.rotateX', 180) elif self.mirrorAxis == 'XYZ': cmds.setAttr(self.ctrl+'.rotateZ', 180) cmds.makeIdentity(self.ctrl, apply=True, translate=False, rotate=True, scale=False) else: self.ctrl = cmds.circle(name=side+self.userGuideName+"_"+str(n)+"_Ctrl", degree=1, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] cmds.setAttr(self.ctrl + ".rotateOrder", 1) utils.originedFrom(objName=self.ctrl, attrString=self.guide) # scaleCompensate attribute: if n > 0 or self.nJoints == 2: cmds.addAttr(self.ctrl, longName="scaleCompensate", attributeType='bool', keyable=True) scaleCompensateCond = cmds.createNode("condition", name=side+self.userGuideName+"_"+str(n)+"_ScaleCompensate_Cnd") cmds.setAttr(scaleCompensateCond+".secondTerm", 1) cmds.connectAttr(self.ctrl+".scaleCompensate", scaleCompensateCond+".colorIfTrueR", force=True) cmds.connectAttr(scaleCompensateCond+".outColorR", self.jnt+".segmentScaleCompensate", force=True) # hide visibility attribute: cmds.setAttr(self.ctrl+'.visibility', keyable=False) # put another group over the control in order to use this to connect values from mainFingerCtrl: self.sdkGrp = cmds.group(self.ctrl, name=side+self.userGuideName+"_"+str(n)+"_SDKGrp") if n == 1: # change pivot of this group to control pivot: pivotPos = cmds.xform(self.ctrl, query=True, worldSpace=True, rotatePivot=True) cmds.setAttr(self.sdkGrp+'.rotatePivotX', pivotPos[0]) cmds.setAttr(self.sdkGrp+'.rotatePivotY', pivotPos[1]) cmds.setAttr(self.sdkGrp+'.rotatePivotZ', pivotPos[2]) # position and orientation of joint and control: tempDel = cmds.parentConstraint(self.guide, self.jnt, maintainOffset=False) cmds.delete(tempDel) tempDel = cmds.parentConstraint(self.guide, self.sdkGrp, maintainOffset=False) cmds.delete(tempDel) # zeroOut controls: utils.zeroOut([self.sdkGrp]) # create end joint: self.cvEndJoint = side+self.userGuideName+"_Guide_JointEnd" self.endJoint = cmds.joint(name=side+self.userGuideName+"_JEnd", scaleCompensate=False) tempDel = cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False) cmds.delete(tempDel) cmds.parent(self.endJoint, side+self.userGuideName+"_"+str(self.nJoints)+"_Jnt", absolute=True) # grouping: for n in range(0, self.nJoints+1): self.jnt = side+self.userGuideName+"_"+str(n)+"_Jnt" self.ctrl = side+self.userGuideName+"_"+str(n)+"_Ctrl" self.zeroCtrl = side+self.userGuideName+"_"+str(n)+"_SDKGrp_Zero" if n > 0: if n == 1: if not cmds.objExists(self.ctrl+'.ikFkBlend'): cmds.addAttr(self.ctrl, longName="ikFkBlend", attributeType='float', keyable=True, minValue=0.0, maxValue=1.0, defaultValue=1.0) self.ikFkRevNode = cmds.createNode("reverse", name=side+self.userGuideName+"_ikFk_Rev") cmds.connectAttr(self.ctrl+".ikFkBlend", self.ikFkRevNode+".inputX", force=True) if not cmds.objExists(self.ctrl+'.'+self.langDic[self.langName]['c_showControls']): cmds.addAttr(self.ctrl, longName=self.langDic[self.langName]['c_showControls'], attributeType='float', keyable=True, minValue=0.0, maxValue=1.0, defaultValue=0.0) self.ctrlShape0 = cmds.listRelatives(side+self.userGuideName+"_0_Ctrl", children=True, type='nurbsCurve')[0] cmds.connectAttr(self.ctrl+"."+self.langDic[self.langName]['c_showControls'], self.ctrlShape0+".visibility", force=True) cmds.setAttr(self.ctrl+'.'+self.langDic[self.langName]['c_showControls'], keyable=False, channelBox=True) for j in range(1, self.nJoints+1): cmds.addAttr(self.ctrl, longName=self.langDic[self.langName]['c_falange']+str(j), attributeType='float', keyable=True) # parent joints as a simple chain (line) self.fatherJnt = side+self.userGuideName+"_"+str(n-1)+"_Jnt" cmds.parent(self.jnt, self.fatherJnt, absolute=True) # parent zeroCtrl Group to the before ctrl: self.fatherCtrl = side+self.userGuideName+"_"+str(n-1)+"_Ctrl" cmds.parent(self.zeroCtrl, self.fatherCtrl, absolute=True) # freeze joints rotation cmds.makeIdentity(self.jnt, apply=True) # create parent and scale constraints from ctrl to jnt: cmds.delete(cmds.parentConstraint(self.ctrl, self.jnt, maintainOffset=False, name=self.jnt+"_ParentConstraint")) # make first falange be leads from base finger control: cmds.parentConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_1_SDKGrp_Zero", maintainOffset=True, name=side+self.userGuideName+"_1_SDKGrp_Zero"+"_ParentConstraint") cmds.scaleConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_1_SDKGrp_Zero", maintainOffset=True, name=side+self.userGuideName+"_1_SDKGrp_Zero"+"_ScaleConstraint") if self.nJoints != 2: cmds.parentConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_0_Jnt", maintainOffset=True, name=side+self.userGuideName+"_ParentConstraint") cmds.scaleConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_0_Jnt", maintainOffset=True, name=side+self.userGuideName+"_ScaleConstraint") # connecting the attributes from control 1 to falanges rotate: for n in range(1, self.nJoints+1): self.ctrl = side+self.userGuideName+"_1_Ctrl" self.sdkGrp = side+self.userGuideName+"_"+str(n)+"_SDKGrp" cmds.connectAttr(self.ctrl+"."+self.langDic[self.langName]['c_falange']+str(n), self.sdkGrp+".rotateY", force=True) if n > 1: self.ctrlShape = cmds.listRelatives(side+self.userGuideName+"_"+str(n)+"_Ctrl", children=True, type='nurbsCurve')[0] cmds.connectAttr(self.ctrl+"."+self.langDic[self.langName]['c_showControls'], self.ctrlShape+".visibility", force=True) # ik and Fk setup if self.nJoints == 2: dupIk = cmds.duplicate(self.skinJointList[0])[0] dupFk = cmds.duplicate(self.skinJointList[0])[0] else: dupIk = cmds.duplicate(self.skinJointList[1])[0] dupFk = cmds.duplicate(self.skinJointList[1])[0] # ik setup childrenIkList = cmds.listRelatives(dupIk, children=True, allDescendents=True, fullPath=True) if childrenIkList: for child in childrenIkList: if not cmds.objectType(child) == "joint": cmds.delete(child) jointIkList = cmds.listRelatives(dupIk, children=True, allDescendents=True, fullPath=True) for jointNode in jointIkList: if "_Jnt" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|")+1:].replace("_Jnt", "_Ik_Jxt")) elif "_JEnd" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|")+1:].replace("_JEnd", "_Ik_JEnd")) ikBaseJoint = cmds.rename(dupIk, dupIk.replace("_Jnt1", "_Ik_Jxt")) ikJointList = cmds.listRelatives(ikBaseJoint, children=True, allDescendents=True) ikJointList.append(ikBaseJoint) # Fk setup childrenFkList = cmds.listRelatives(dupFk, children=True, allDescendents=True, fullPath=True) if childrenFkList: for child in childrenFkList: if not cmds.objectType(child) == "joint": cmds.delete(child) jointFkList = cmds.listRelatives(dupFk, children=True, allDescendents=True, fullPath=True) for jointNode in jointFkList: if "_Jnt" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|")+1:].replace("_Jnt", "_Fk_Jxt")) elif "_JEnd" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|")+1:].replace("_JEnd", "_Fk_JEnd")) fkBaseJoint = cmds.rename(dupFk, dupFk.replace("_Jnt2", "_Fk_Jxt")) fkJointList = cmds.listRelatives(fkBaseJoint, children=True, allDescendents=True) fkJointList.append(fkBaseJoint) # ik fk blend connnections for i, ikJoint in enumerate(ikJointList): if not "_JEnd" in ikJoint: if cmds.objExists(ikJoint+".dpAR_joint"): cmds.deleteAttr(ikJoint+".dpAR_joint") fkJoint = ikJoint.replace("_Ik_Jxt", "_Fk_Jxt") skinJoint = ikJoint.replace("_Ik_Jxt", "_Jnt") self.ctrl = side+self.userGuideName+"_1_Ctrl" scaleCompensateCond = ikJoint.replace("_Ik_Jxt", "_ScaleCompensate_Cnd") ikFkParentConst = cmds.parentConstraint(ikJoint, fkJoint, skinJoint, maintainOffset=True, name=skinJoint+"_ParentConstraint")[0] ikFkScaleConst = cmds.scaleConstraint(ikJoint, fkJoint, skinJoint, maintainOffset=True, name=skinJoint+"_ScaleConstraint")[0] cmds.connectAttr(self.ctrl+".ikFkBlend", ikFkParentConst+"."+fkJoint+"W1", force=True) cmds.connectAttr(self.ikFkRevNode+".outputX", ikFkParentConst+"."+ikJoint+"W0", force=True) cmds.connectAttr(self.ctrl+".ikFkBlend", ikFkScaleConst+"."+fkJoint+"W1", force=True) cmds.connectAttr(self.ikFkRevNode+".outputX", ikFkScaleConst+"."+ikJoint+"W0", force=True) cmds.setAttr(ikJoint+".segmentScaleCompensate", 1) cmds.connectAttr(self.ctrl+".ikFkBlend", scaleCompensateCond+".firstTerm", force=True) # fk control drives fk joints for i, fkJoint in enumerate(fkJointList): if not "_JEnd" in fkJoint: if cmds.objExists(fkJoint+".dpAR_joint"): cmds.deleteAttr(fkJoint+".dpAR_joint") fkCtrl = fkJoint.replace("_Fk_Jxt", "_Ctrl") scaleCompensateCond = fkCtrl.replace("_Ctrl", "_ScaleCompensate_Cnd") cmds.parentConstraint(fkCtrl, fkJoint, maintainOffset=True, name=fkJoint+"_ParentConstraint") cmds.scaleConstraint(fkCtrl, fkJoint, maintainOffset=True, name=fkJoint+"_ScaleConstraint") cmds.connectAttr(fkCtrl+".scaleCompensate", fkJoint+".segmentScaleCompensate", force=True) cmds.setAttr(fkCtrl + ".rotateOrder", 1) # ik handle if self.nJoints >= 2: if self.nJoints == 2: ikHandleList = cmds.ikHandle(startJoint=side+self.userGuideName+"_0_Ik_Jxt", endEffector=side+self.userGuideName+"_"+str(self.nJoints)+"_Ik_Jxt", solver="ikRPsolver", name=side+self.userGuideName+"_IkHandle") else: ikHandleList = cmds.ikHandle(startJoint=side+self.userGuideName+"_1_Ik_Jxt", endEffector=side+self.userGuideName+"_"+str(self.nJoints)+"_Ik_Jxt", solver="ikRPsolver", name=side+self.userGuideName+"_IkHandle") cmds.rename(ikHandleList[1], side+self.userGuideName+"_Effector") endIkHandleList = cmds.ikHandle(startJoint=side+self.userGuideName+"_"+str(self.nJoints)+"_Ik_Jxt", endEffector=side+self.userGuideName+"_Ik_JEnd", solver="ikSCsolver", name=side+self.userGuideName+"_EndIkHandle") cmds.rename(endIkHandleList[1], side+self.userGuideName+"_EndEffector") self.ikCtrl = ctrls.cvBox(ctrlName=side+self.userGuideName+"_Ik_Ctrl", r=self.ctrlRadius) cmds.addAttr(self.ikCtrl, longName='twist', attributeType='float', keyable=True) cmds.connectAttr(self.ikCtrl+".twist", ikHandleList[0]+".twist", force=True) cmds.delete(cmds.parentConstraint(side+self.userGuideName+"_Ik_JEnd", self.ikCtrl)) cmds.setAttr(self.ikCtrl + ".rotateOrder", 1) self.ikCtrlZero = utils.zeroOut([self.ikCtrl])[0] self.ikCtrlZeroList.append(self.ikCtrlZero) cmds.connectAttr(self.ikFkRevNode+".outputX", self.ikCtrlZero+".visibility", force=True) for q in range(2, self.nJoints): cmds.connectAttr(side+self.userGuideName+"_1_Ctrl.ikFkBlend", side+self.userGuideName+"_"+str(q)+"_Ctrl.visibility", force=True) cmds.parentConstraint(self.ikCtrl, ikHandleList[0], name=side+self.userGuideName+"_IkHandle_ParentConstraint", maintainOffset=True) cmds.parentConstraint(self.ikCtrl, endIkHandleList[0], name=side+self.userGuideName+"_EndIkHandle_ParentConstraint", maintainOffset=True) ikHandleGrp = cmds.group(ikHandleList[0], endIkHandleList[0], name=side+self.userGuideName+"_IkHandle_Grp") ctrls.setLockHide([self.ikCtrl], ['sx', 'sy', 'sz', 'v']) if self.nJoints == 2: cmds.parentConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_0_Ik_Jxt", maintainOffset=True, name=side+self.userGuideName+"_0_Ik_Jxt_ParentConstraint") cmds.scaleConstraint(side+self.userGuideName+"_0_Ctrl", side+self.userGuideName+"_0_Ik_Jxt", maintainOffset=True, name=side+self.userGuideName+"_0_Ik_Jxt_ScaleConstraint") # stretch cmds.addAttr(self.ikCtrl, longName='stretchable', attributeType='float', minValue=0, maxValue=1, defaultValue=0, keyable=True) stretchNormMD = cmds.createNode("multiplyDivide", name=side+self.userGuideName+"_StretchNormalize_MD") cmds.setAttr(stretchNormMD+".operation", 2) distBetweenList = ctrls.distanceBet(side+self.userGuideName+"_0_Ctrl", self.ikCtrl, name=side+self.userGuideName+"_DistBet", keep=True) cmds.connectAttr(self.ikFkRevNode+".outputX", distBetweenList[5]+"."+self.ikCtrl+"W0", force=True) cmds.connectAttr(self.ctrl+".ikFkBlend", distBetweenList[5]+"."+distBetweenList[4]+"W1", force=True) cmds.connectAttr(distBetweenList[1]+".distance", stretchNormMD+".input1X", force=True) cmds.setAttr(stretchNormMD+".input2X", distBetweenList[0]) stretchScaleMD = cmds.createNode("multiplyDivide", name=side+self.userGuideName+"_StretchScale_MD") cmds.connectAttr(stretchNormMD+".outputX", stretchScaleMD+".input1X", force=True) cmds.connectAttr(self.ikCtrl+".stretchable", stretchScaleMD+".input2X", force=True) stretchCond = cmds.createNode("condition", name=side+self.userGuideName+"_Stretch_Cnd") cmds.connectAttr(stretchScaleMD+".outputX", stretchCond+".firstTerm", force=True) cmds.setAttr(stretchCond+".secondTerm", 1) cmds.setAttr(stretchCond+".operation", 2) cmds.connectAttr(stretchScaleMD+".outputX", stretchCond+".colorIfTrueR", force=True) for i, ikJoint in enumerate(ikJointList): if not "_JEnd" in ikJoint: if self.nJoints == 2 and i == 0: pass else: cmds.connectAttr(stretchCond+".outColorR", ikJoint+".scaleZ", force=True) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(self.ikCtrlZero, side+self.userGuideName+"_0_SDKGrp_Zero", side+self.userGuideName+"_1_SDKGrp_Zero", name=side+self.userGuideName+"_Control_Grp") if self.nJoints == 2: self.toScalableHookGrp = cmds.group(side+self.userGuideName+"_0_Jnt", ikBaseJoint, fkBaseJoint, ikHandleGrp, distBetweenList[2], distBetweenList[3], distBetweenList[4], name=side+self.userGuideName+"_Joint_Grp") else: self.toScalableHookGrp = cmds.group(side+self.userGuideName+"_0_Jnt", ikHandleGrp, distBetweenList[2], distBetweenList[3], distBetweenList[4], name=side+self.userGuideName+"_Joint_Grp") else: self.toCtrlHookGrp = cmds.group(side+self.userGuideName+"_0_SDKGrp_Zero", side+self.userGuideName+"_1_SDKGrp_Zero", name=side+self.userGuideName+"_Control_Grp") self.toScalableHookGrp = cmds.group(side+self.userGuideName+"_0_Jnt", name=side+self.userGuideName+"_Joint_Grp") self.scalableGrpList.append(self.toScalableHookGrp) self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side+self.userGuideName+"_Grp") # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp+'.dpAR_count', dpAR_count) # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side+self.userGuideName+"_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc+".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) if hideJoints: cmds.setAttr(self.toScalableHookGrp+".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side+self.userGuideName+'_'+self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 self.currentStyle = cmds.getAttr(self.moduleGrp + ".style") # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_'] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.base = side + self.userGuideName + '_Guide_Base' # get the number of joints to be created: self.nJoints = cmds.getAttr(self.base + ".nJoints") # create controls: self.hipsA = ctrls.cvBox(ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_hips'] + "A_Ctrl", r=self.ctrlRadius, h=(self.ctrlRadius * 0.25)) self.hipsB = cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_hips'] + "B_Ctrl", ch=False, o=True, nr=(0, 1, 0), d=1, s=8, radius=self.ctrlRadius)[0] self.chestA = ctrls.cvBox(ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chest'] + "A_Ctrl", r=self.ctrlRadius, h=(self.ctrlRadius * 0.25)) self.chestB = cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chest'] + "B_Ctrl", ch=False, o=True, nr=(0, 1, 0), d=1, s=8, radius=self.ctrlRadius)[0] cmds.addAttr(self.hipsA, longName=side + self.userGuideName + '_' + self.langDic[self.langName]['c_volumeVariation'], attributeType="float", defaultValue=1, keyable=True) cmds.addAttr(self.hipsA, longName=side + self.userGuideName + '_active_' + self.langDic[self.langName]['c_volumeVariation'], attributeType="float", defaultValue=1, keyable=True) cmds.addAttr(self.hipsA, longName=side + self.userGuideName + '_masterScale_' + self.langDic[self.langName]['c_volumeVariation'], attributeType="float", defaultValue=1, keyable=True) ctrls.setLockHide([self.hipsA, self.hipsB, self.chestA, self.chestB], ['v'], l=False) self.aHipsAList.append(self.hipsA) self.aChestAList.append(self.chestA) self.aVolVariationAttrList.append(side + self.userGuideName + '_' + self.langDic[self.langName]['c_volumeVariation']) self.aActVolVariationAttrList.append(side + self.userGuideName + '_active_' + self.langDic[self.langName]['c_volumeVariation']) self.aMScaleVolVariationAttrList.append(side + self.userGuideName + '_masterScale_' + self.langDic[self.langName]['c_volumeVariation']) # Setup axis order if self.rigType == Base.RigType.quadruped: cmds.setAttr(self.hipsA + ".rotateOrder", 1) cmds.setAttr(self.hipsB + ".rotateOrder", 1) cmds.setAttr(self.chestA + ".rotateOrder", 1) cmds.setAttr(self.chestB + ".rotateOrder", 1) cmds.rotate(90, 0, 0, self.hipsA, self.hipsB, self.chestA, self.chestB) cmds.makeIdentity(self.hipsA, self.hipsB, self.chestA, self.chestB, apply=True, rotate=True) else: cmds.setAttr(self.hipsA + ".rotateOrder", 3) cmds.setAttr(self.hipsB + ".rotateOrder", 3) cmds.setAttr(self.chestA + ".rotateOrder", 3) cmds.setAttr(self.chestB + ".rotateOrder", 3) # Keep a list of ctrls we want to colorize a certain way self.aFkCtrl.append([self.hipsB, self.chestB]) self.aIkCtrl.append([self.hipsA, self.chestA]) # organize hierarchy: cmds.parent(self.hipsB, self.hipsA) cmds.parent(self.chestB, self.chestA) if self.currentStyle == 0: #default cmds.rotate(-90, 0, 0, self.hipsA, self.chestA) cmds.makeIdentity(self.hipsA, self.chestA, apply=True, rotate=True) # position of controls: bottomLocGuide = side + self.userGuideName + "_Guide_JointLoc1" topLocGuide = side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints) # snap controls to guideLocators: cmds.delete(cmds.parentConstraint(bottomLocGuide, self.hipsA, maintainOffset=False)) cmds.delete(cmds.parentConstraint(topLocGuide, self.chestA, maintainOffset=False)) # change axis orientation for biped stype if self.currentStyle == 1: #biped cmds.rotate(0, 0, 0, self.hipsA, self.chestA) cmds.makeIdentity(self.hipsA, self.chestA, apply=True, rotate=True) cmds.parent(self.chestA, self.hipsA) # zeroOut transformations: utils.zeroOut([self.hipsA, self.chestA]) # modify the pivots of chest controls: upPivotPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints - 1), query=True, worldSpace=True, translation=True) cmds.move(upPivotPos[0], upPivotPos[1], upPivotPos[2], self.chestA + ".scalePivot", self.chestA + ".rotatePivot") # , self.chestB+".scalePivot", self.chestB+".rotatePivot") # add originedFrom attributes to hipsA, hipsB and chestB: utils.originedFrom(objName=self.hipsA, attrString=self.base) utils.originedFrom(objName=self.hipsB, attrString=bottomLocGuide) utils.originedFrom(objName=self.chestB, attrString=topLocGuide) # create a simple spine ribbon: returnedRibbonList = ctrls.createSimpleRibbon(name=side + self.userGuideName,totalJoints=(self.nJoints - 1)) rbnNurbsPlane = returnedRibbonList[0] rbnNurbsPlaneShape = returnedRibbonList[1] rbnJointGrpList = returnedRibbonList[2] self.aRbnJointList = returnedRibbonList[3] # position of ribbon nurbs plane: cmds.setAttr(rbnNurbsPlane + ".tz", -4) cmds.move(0, 0, 0, rbnNurbsPlane + ".scalePivot", rbnNurbsPlane + ".rotatePivot") cmds.rotate(90, 90, 0, rbnNurbsPlane) cmds.makeIdentity(rbnNurbsPlane, apply=True, translate=True, rotate=True) downLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc1", query=True, worldSpace=True, translation=True) upLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints), query=True, worldSpace=True, translation=True) cmds.move(downLocPos[0], downLocPos[1], downLocPos[2], rbnNurbsPlane) # create up and down clusters: downCluster = cmds.cluster(rbnNurbsPlane + ".cv[0:3][0:1]", name=side + self.userGuideName + '_Down_Cls')[1] upCluster = cmds.cluster(rbnNurbsPlane + ".cv[0:3][" + str(self.nJoints) + ":" + str(self.nJoints + 1) + "]", name=side + self.userGuideName + '_Up_Cls')[1] # get positions of joints from ribbon nurbs plane: startRbnJointPos = cmds.xform(side + self.userGuideName + "_00_Jnt", query=True, worldSpace=True, translation=True) endRbnJointPos = cmds.xform(side + self.userGuideName + "_%02d_Jnt"%(self.nJoints - 1), query=True, worldSpace=True, translation=True) # move pivots of clusters to start and end positions: cmds.move(startRbnJointPos[0], startRbnJointPos[1], startRbnJointPos[2], downCluster + ".scalePivot", downCluster + ".rotatePivot") cmds.move(endRbnJointPos[0], endRbnJointPos[1], endRbnJointPos[2], upCluster + ".scalePivot", upCluster + ".rotatePivot") # snap clusters to guideLocators: tempDel = cmds.parentConstraint(bottomLocGuide, downCluster, maintainOffset=False) cmds.delete(tempDel) tempDel = cmds.parentConstraint(topLocGuide, upCluster, maintainOffset=False) cmds.delete(tempDel) # rotate clusters to compensate guide: upClusterRot = cmds.xform(upCluster, query=True, worldSpace=True, rotation=True) downClusterRot = cmds.xform(downCluster, query=True, worldSpace=True, rotation=True) cmds.xform(upCluster, worldSpace=True, rotation=(upClusterRot[0] + 90, upClusterRot[1], upClusterRot[2])) cmds.xform(downCluster, worldSpace=True, rotation=(downClusterRot[0] + 90, downClusterRot[1], downClusterRot[2])) # scaleY of the clusters in order to avoid great extremity deforms: rbnHeight = ctrls.distanceBet(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints), side + self.userGuideName + "_Guide_JointLoc1", keep=False)[0] cmds.setAttr(upCluster + ".sy", rbnHeight / 10) cmds.setAttr(downCluster + ".sy", rbnHeight / 10) # parent clusters in controls (up and down): cmds.parentConstraint(self.hipsB, downCluster, maintainOffset=True, name=downCluster + "_ParentConstraint") cmds.parentConstraint(self.chestB, upCluster, maintainOffset=True, name=upCluster + "_ParentConstraint") # organize a group of clusters: clustersGrp = cmds.group(name=side + self.userGuideName + "_Rbn_Clusters_Grp", empty=True) self.aClusterGrp.append(clustersGrp) if hideJoints: cmds.setAttr(clustersGrp + ".visibility", 0) cmds.parent(downCluster, upCluster, clustersGrp, relative=True) # make ribbon joints groups scalable: for r, rbnJntGrp in enumerate(rbnJointGrpList): if ((r > 0) and (r < (len(rbnJointGrpList) - 1))): scaleGrp = cmds.group(rbnJntGrp, name=rbnJntGrp.replace("_Grp", "_Scale_Grp")) ctrls.directConnect(scaleGrp, rbnJntGrp, ['sx', 'sz']) cmds.scaleConstraint(clustersGrp, scaleGrp, maintainOffset=True, name=rbnJntGrp + "_Scale") else: cmds.scaleConstraint(clustersGrp, rbnJntGrp, maintainOffset=True, name=rbnJntGrp + "_Scale") # calculate the distance to volumeVariation: arcLenShape = cmds.createNode('arcLengthDimension', name=side + self.userGuideName + "_Rbn_ArcLenShape") arcLenFather = cmds.listRelatives(arcLenShape, parent=True)[0] arcLen = cmds.rename(arcLenFather, side + self.userGuideName + "_Rbn_ArcLen") arcLenShape = cmds.listRelatives(arcLen, children=True, shapes=True)[0] cmds.setAttr(arcLen + '.visibility', 0) # connect nurbsPlaneShape to arcLength node: cmds.connectAttr(rbnNurbsPlaneShape + '.worldSpace[0]', arcLenShape + '.nurbsGeometry') cmds.setAttr(arcLenShape + '.vParamValue', 1) # avoid undesired squash if rotateZ the nurbsPlane: cmds.setAttr(arcLenShape + '.uParamValue', 0.5) arcLenValue = cmds.getAttr(arcLenShape + '.arcLengthInV') # create a multiplyDivide to output the squashStretch values: rbnMD = cmds.createNode('multiplyDivide', name=side + self.userGuideName + "_Rbn_MD") cmds.connectAttr(arcLenShape + '.arcLengthInV', rbnMD + '.input2X') cmds.setAttr(rbnMD + '.input1X', arcLenValue) cmds.setAttr(rbnMD + '.operation', 2) # create a blendColor, a condition and a multiplyDivide in order to get the correct result value of volumeVariation: rbnBlendColors = cmds.createNode('blendColors', name=side + self.userGuideName + "_Rbn_BlendColor") cmds.connectAttr(self.hipsA + '.' + side + self.userGuideName + '_' + self.langDic[self.langName]['c_volumeVariation'], rbnBlendColors + '.blender') rbnCond = cmds.createNode('condition', name=side+self.userGuideName+'_Rbn_Cond') cmds.connectAttr(self.hipsA + '.' + side + self.userGuideName + '_active_' + self.langDic[self.langName]['c_volumeVariation'], rbnCond + '.firstTerm') cmds.connectAttr(rbnBlendColors+'.outputR', rbnCond + '.colorIfTrueR') cmds.connectAttr(rbnMD + '.outputX', rbnBlendColors + '.color1R') rbnVVMD = cmds.createNode('multiplyDivide', name=side + self.userGuideName + "_Rbn_VV_MD") cmds.connectAttr(self.hipsA + '.' + side + self.userGuideName + '_masterScale_' + self.langDic[self.langName]['c_volumeVariation'], rbnVVMD + '.input2X') cmds.connectAttr(rbnVVMD + '.outputX', rbnCond + '.colorIfFalseR') cmds.setAttr(rbnVVMD + '.operation', 2) cmds.setAttr(rbnBlendColors + '.color2R', 1) cmds.setAttr(rbnCond+".secondTerm", 1) # middle ribbon setup: for n in range(1, self.nJoints - 1): if self.currentStyle == 0: #default self.middle = cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_middle'] + str(n) + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=self.ctrlRadius)[0] cmds.setAttr(self.middle + ".rotateOrder", 4) else: #biped self.middle = cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_middle'] + str(n) + "_Ctrl", ch=False, o=True, nr=(0, 1, 0), d=3, s=8, radius=self.ctrlRadius)[0] cmds.setAttr(self.middle + ".rotateOrder", 3) self.aFkCtrl[s].append(self.middle) ctrls.setLockHide([self.middle], ['sx', 'sy', 'sz']) cmds.setAttr(self.middle + '.visibility', keyable=False) cmds.parent(self.middle, self.hipsA) middleLocGuide = side + self.userGuideName + "_Guide_JointLoc" + str(n + 1) cmds.delete(cmds.parentConstraint(middleLocGuide, self.middle, maintainOffset=False)) if self.currentStyle == 1: #biped cmds.rotate(0, 0, 0, self.middle) if self.rigType == Base.RigType.quadruped: cmds.rotate(90, 0, 0, self.middle) cmds.makeIdentity(self.middle, apply=True, rotate=True) utils.zeroOut([self.middle]) middleCluster = cmds.cluster(rbnNurbsPlane + ".cv[0:3][" + str(n + 1) + "]", name=side + self.userGuideName + '_Middle_Cls')[1] middleLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(n), query=True, worldSpace=True, translation=True) tempDel = cmds.parentConstraint(middleLocGuide, middleCluster, maintainOffset=False) cmds.delete(tempDel) middleClusterRot = cmds.xform(middleCluster, query=True, worldSpace=True, rotation=True) cmds.xform(middleCluster, worldSpace=True, rotation=(middleClusterRot[0] + 90, middleClusterRot[1], middleClusterRot[2])) cmds.parentConstraint(self.middle, middleCluster, maintainOffset=True, name=middleCluster + "_ParentConstraint") # parenting constraints like guide locators: self.parentConst = cmds.parentConstraint(self.hipsB, self.chestB, self.middle + "_Zero", name=self.middle + "_ParentConstraint", maintainOffset=True)[0] nParentValue = (n) / float(self.nJoints - 1) cmds.setAttr(self.parentConst + "." + self.hipsB + "W0", 1 - nParentValue) cmds.setAttr(self.parentConst + "." + self.chestB + "W1", nParentValue) cmds.parent(middleCluster, clustersGrp, relative=True) # add originedFrom attribute to this middle ctrl: utils.originedFrom(objName=self.middle, attrString=middleLocGuide) # apply volumeVariation to joints in the middle ribbon setup: cmds.connectAttr(rbnCond + '.outColorR', self.aRbnJointList[n] + '.scaleX') cmds.connectAttr(rbnCond + '.outColorR', self.aRbnJointList[n] + '.scaleZ') # update spine volume variation setup currentVV = cmds.getAttr(rbnMD + '.outputX') cmds.setAttr(rbnVVMD + '.input1X', currentVV) # organize groups: self.rbnRigGrp = cmds.group(name=side + self.userGuideName + "_Grp", empty=True) self.rbnControlGrp = cmds.group(name=side + self.userGuideName + "_Control_Grp", empty=True) cmds.parent(self.hipsA + "_Zero", self.rbnControlGrp, relative=True) cmds.parent(clustersGrp, side + self.userGuideName + "_Rbn_RibbonJoint_Grp", self.rbnControlGrp, arcLen, self.rbnRigGrp, relative=True) if hideJoints: cmds.setAttr(side + self.userGuideName + "_Rbn_RibbonJoint_Grp.visibility", 0) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.rbnControlGrp, hookType='ctrlHook') utils.addHook(objName=clustersGrp, hookType='scalableHook') utils.addHook(objName=self.rbnRigGrp, hookType='staticHook') cmds.addAttr(self.rbnRigGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.rbnRigGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.rbnRigGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.rbnRigGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.rbnRigGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.rbnRigGrp + '.dpAR_count', dpAR_count) # lockHide scale of up and down controls: ctrls.setLockHide([self.hipsA, self.hipsB, self.chestA, self.chestB], ['sx', 'sy', 'sz']) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def changeJointNumber(self, enteredNJoints, *args): """ Edit the number of joints in the guide. """ utils.useDefaultRenderLayer() # get the number of joints entered by user: if enteredNJoints == 0: try: self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True) except: return else: self.enteredNJoints = enteredNJoints # get the number of joints existing: self.currentNJoints = cmds.getAttr(self.moduleGrp + ".nJoints") # start analisys the difference between values: if self.enteredNJoints != self.currentNJoints: self.cvEndJoint = self.guideName + "_JointEnd" if self.currentNJoints > 1: # delete current point constraints: for n in range(2, self.currentNJoints): cmds.delete(self.guideName + "_ParentConstraint" + str(n)) # verify if the nJoints is greather or less than the current if self.enteredNJoints > self.currentNJoints: # add the new cvLocators: for n in range(self.currentNJoints + 1, self.enteredNJoints + 1): # create another N cvLocator: self.cvLocator, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointLoc" + str(n), r=0.3) self.connectShapeSize(shapeSizeCH) # set its nJoint value as n: cmds.setAttr(self.cvLocator + ".nJoint", n) # parent its group to the first cvJointLocator: self.cvLocGrp = cmds.group(self.cvLocator, name=self.cvLocator + "_Grp") cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc" + str(n - 1), relative=True) cmds.setAttr(self.cvLocGrp + ".translateZ", 2) if n > 2: cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc1", absolute=True) elif self.enteredNJoints < self.currentNJoints: # re-parent cvEndJoint: self.cvLocator = self.guideName + "_JointLoc" + str(self.enteredNJoints) cmds.parent(self.cvEndJoint, world=True) # delete difference of nJoints: for n in range(self.enteredNJoints, self.currentNJoints): # re-parent the children guides: childrenGuideBellowList = utils.getGuideChildrenList( self.guideName + "_JointLoc" + str(n + 1) + "_Grp") if childrenGuideBellowList: for childGuide in childrenGuideBellowList: cmds.parent(childGuide, self.cvLocator) cmds.delete(self.guideName + "_JointLoc" + str(n + 1) + "_Grp") # re-parent cvEndJoint: cmds.parent(self.cvEndJoint, self.cvLocator) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) cmds.setAttr(self.cvEndJoint + ".visibility", 0) # re-create parentConstraints: if self.enteredNJoints > 1: for n in range(2, self.enteredNJoints): self.parentConst = cmds.parentConstraint(self.guideName + "_JointLoc1", self.cvEndJoint, self.guideName + "_JointLoc" + str(n) + "_Grp", name=self.guideName + "_ParentConstraint" + str(n), maintainOffset=True)[0] nParentValue = (n - 1) / float(self.enteredNJoints - 1) cmds.setAttr(self.parentConst + ".Guide_JointLoc1W0", 1 - nParentValue) cmds.setAttr(self.parentConst + ".Guide_JointEndW1", nParentValue) ctrls.setLockHide([self.guideName + "_JointLoc" + str(n)], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # actualise the nJoints in the moduleGrp: cmds.setAttr(self.moduleGrp + ".nJoints", self.enteredNJoints) self.currentNJoints = self.enteredNJoints # re-build the preview mirror: Layout.LayoutClass.createPreviewMirror(self) cmds.select(self.moduleGrp)
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # declaring lists to send information for integration: self.scalableGrpList, self.ikCtrlZeroList = [], [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_'] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.skinJointList = [] self.base = side + self.userGuideName + '_Guide_Base' # get the number of joints to be created: self.nJoints = cmds.getAttr(self.base + ".nJoints") for n in range(0, self.nJoints + 1): cmds.select(clear=True) # declare guide: self.guide = side + self.userGuideName + "_Guide_JointLoc" + str(n) # create a joint: self.jnt = cmds.joint(name=side + self.userGuideName + "_" + str(n) + "_Jnt", scaleCompensate=False) self.skinJointList.append(self.jnt) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) # create a control: if n == 1: self.ctrl = ctrls.cvFinger(ctrlName=side + self.userGuideName + "_" + str(n) + "_Ctrl", r=self.ctrlRadius) cmds.setAttr(self.ctrl + ".rotateOrder", 1) utils.originedFrom(objName=self.ctrl, attrString=self.base + ";" + self.guide) # edit the mirror shape to a good direction of controls: if s == 1: if self.mirrorAxis == 'X': cmds.setAttr(self.ctrl + '.rotateZ', 180) elif self.mirrorAxis == 'Y': cmds.setAttr(self.ctrl + '.rotateY', 180) elif self.mirrorAxis == 'Z': cmds.setAttr(self.ctrl + '.rotateZ', 180) elif self.mirrorAxis == 'XY': cmds.setAttr(self.ctrl + '.rotateX', 180) elif self.mirrorAxis == 'XYZ': cmds.setAttr(self.ctrl + '.rotateZ', 180) cmds.makeIdentity(self.ctrl, apply=True, translate=False, rotate=True, scale=False) else: self.ctrl = \ cmds.circle(name=side + self.userGuideName + "_" + str(n) + "_Ctrl", degree=1, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] cmds.setAttr(self.ctrl + ".rotateOrder", 1) utils.originedFrom(objName=self.ctrl, attrString=self.guide) # scaleCompensate attribute: #Not needed in Maya 2016 since we need to deactivate scale compensate on all finger bone if (int(cmds.about(version=True)[:4]) < 2016): if n > 0 or self.nJoints == 2: cmds.addAttr(self.ctrl, longName="scaleCompensate", attributeType='bool', keyable=True) scaleCompensateCond = cmds.createNode("condition", name=side + self.userGuideName + "_" + str( n) + "_ScaleCompensate_Cnd") cmds.setAttr(scaleCompensateCond + ".secondTerm", 1) cmds.connectAttr(self.ctrl + ".scaleCompensate", scaleCompensateCond + ".colorIfTrueR", force=True) cmds.connectAttr(scaleCompensateCond + ".outColorR", self.jnt + ".segmentScaleCompensate", force=True) # hide visibility attribute: cmds.setAttr(self.ctrl + '.visibility', keyable=False) # put another group over the control in order to use this to connect values from mainFingerCtrl: self.sdkGrp = cmds.group(self.ctrl, name=side + self.userGuideName + "_" + str(n) + "_SDKGrp") if n == 1: # change pivot of this group to control pivot: pivotPos = cmds.xform(self.ctrl, query=True, worldSpace=True, rotatePivot=True) cmds.setAttr(self.sdkGrp + '.rotatePivotX', pivotPos[0]) cmds.setAttr(self.sdkGrp + '.rotatePivotY', pivotPos[1]) cmds.setAttr(self.sdkGrp + '.rotatePivotZ', pivotPos[2]) # position and orientation of joint and control: tempDel = cmds.parentConstraint(self.guide, self.jnt, maintainOffset=False) cmds.delete(tempDel) tempDel = cmds.parentConstraint(self.guide, self.sdkGrp, maintainOffset=False) cmds.delete(tempDel) # zeroOut controls: utils.zeroOut([self.sdkGrp]) # create end joint: self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" self.endJoint = cmds.joint(name=side + self.userGuideName + "_JEnd", scaleCompensate=False) tempDel = cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False) cmds.delete(tempDel) cmds.parent(self.endJoint, side + self.userGuideName + "_" + str(self.nJoints) + "_Jnt", absolute=True) # grouping: for n in range(0, self.nJoints + 1): self.jnt = side + self.userGuideName + "_" + str(n) + "_Jnt" self.ctrl = side + self.userGuideName + "_" + str(n) + "_Ctrl" self.zeroCtrl = side + self.userGuideName + "_" + str(n) + "_SDKGrp_Zero" if n > 0: if n == 1: if not cmds.objExists(self.ctrl + '.ikFkBlend'): cmds.addAttr(self.ctrl, longName="ikFkBlend", attributeType='float', keyable=True, minValue=0.0, maxValue=1.0, defaultValue=1.0) self.ikFkRevNode = cmds.createNode("reverse", name=side + self.userGuideName + "_ikFk_Rev") cmds.connectAttr(self.ctrl + ".ikFkBlend", self.ikFkRevNode + ".inputX", force=True) if not cmds.objExists(self.ctrl + '.' + self.langDic[self.langName]['c_showControls']): cmds.addAttr(self.ctrl, longName=self.langDic[self.langName]['c_showControls'], attributeType='float', keyable=True, minValue=0.0, maxValue=1.0, defaultValue=0.0) self.ctrlShape0 = \ cmds.listRelatives(side + self.userGuideName + "_0_Ctrl", children=True, type='nurbsCurve')[0] cmds.connectAttr(self.ctrl + "." + self.langDic[self.langName]['c_showControls'], self.ctrlShape0 + ".visibility", force=True) cmds.setAttr(self.ctrl + '.' + self.langDic[self.langName]['c_showControls'], keyable=False, channelBox=True) for j in range(1, self.nJoints + 1): cmds.addAttr(self.ctrl, longName=self.langDic[self.langName]['c_falange'] + str(j), attributeType='float', keyable=True) # parent joints as a simple chain (line) self.fatherJnt = side + self.userGuideName + "_" + str(n - 1) + "_Jnt" cmds.parent(self.jnt, self.fatherJnt, absolute=True) # parent zeroCtrl Group to the before ctrl: self.fatherCtrl = side + self.userGuideName + "_" + str(n - 1) + "_Ctrl" cmds.parent(self.zeroCtrl, self.fatherCtrl, absolute=True) # freeze joints rotation cmds.makeIdentity(self.jnt, apply=True) # create parent and scale constraints from ctrl to jnt: cmds.delete(cmds.parentConstraint(self.ctrl, self.jnt, maintainOffset=False, name=self.jnt + "_ParentConstraint")) # make first falange be leads from base finger control: cmds.parentConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_1_SDKGrp_Zero", maintainOffset=True, name=side + self.userGuideName + "_1_SDKGrp_Zero" + "_ParentConstraint") cmds.scaleConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_1_SDKGrp_Zero", maintainOffset=True, name=side + self.userGuideName + "_1_SDKGrp_Zero" + "_ScaleConstraint") if self.nJoints != 2: cmds.parentConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_0_Jnt", maintainOffset=True, name=side + self.userGuideName + "_ParentConstraint") cmds.scaleConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_0_Jnt", maintainOffset=True, name=side + self.userGuideName + "_ScaleConstraint") # connecting the attributes from control 1 to falanges rotate: for n in range(1, self.nJoints + 1): self.ctrl = side + self.userGuideName + "_1_Ctrl" self.sdkGrp = side + self.userGuideName + "_" + str(n) + "_SDKGrp" cmds.connectAttr(self.ctrl + "." + self.langDic[self.langName]['c_falange'] + str(n), self.sdkGrp + ".rotateY", force=True) if n > 1: self.ctrlShape = \ cmds.listRelatives(side + self.userGuideName + "_" + str(n) + "_Ctrl", children=True, type='nurbsCurve')[0] cmds.connectAttr(self.ctrl + "." + self.langDic[self.langName]['c_showControls'], self.ctrlShape + ".visibility", force=True) # ik and Fk setup if self.nJoints == 2: dupIk = cmds.duplicate(self.skinJointList[0])[0] dupFk = cmds.duplicate(self.skinJointList[0])[0] else: dupIk = cmds.duplicate(self.skinJointList[1])[0] dupFk = cmds.duplicate(self.skinJointList[1])[0] # hide ik and fk joints in order to be rigger friendly whe skinning cmds.setAttr(dupIk+".visibility", 0) cmds.setAttr(dupFk+".visibility", 0) # ik setup childrenIkList = cmds.listRelatives(dupIk, children=True, allDescendents=True, fullPath=True) if childrenIkList: for child in childrenIkList: if not cmds.objectType(child) == "joint": cmds.delete(child) jointIkList = cmds.listRelatives(dupIk, children=True, allDescendents=True, fullPath=True) for jointNode in jointIkList: if "_Jnt" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|") + 1:].replace("_Jnt", "_Ik_Jxt")) elif "_JEnd" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|") + 1:].replace("_JEnd", "_Ik_JEnd")) ikBaseJoint = cmds.rename(dupIk, dupIk.replace("_Jnt1", "_Ik_Jxt")) ikJointList = cmds.listRelatives(ikBaseJoint, children=True, allDescendents=True) ikJointList.append(ikBaseJoint) # Fk setup childrenFkList = cmds.listRelatives(dupFk, children=True, allDescendents=True, fullPath=True) if childrenFkList: for child in childrenFkList: if not cmds.objectType(child) == "joint": cmds.delete(child) jointFkList = cmds.listRelatives(dupFk, children=True, allDescendents=True, fullPath=True) for jointNode in jointFkList: if "_Jnt" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|") + 1:].replace("_Jnt", "_Fk_Jxt")) elif "_JEnd" in jointNode[jointNode.rfind("|"):]: cmds.rename(jointNode, jointNode[jointNode.rfind("|") + 1:].replace("_JEnd", "_Fk_JEnd")) fkBaseJoint = cmds.rename(dupFk, dupFk.replace("_Jnt2", "_Fk_Jxt")) fkJointList = cmds.listRelatives(fkBaseJoint, children=True, allDescendents=True) fkJointList.append(fkBaseJoint) # ik fk blend connnections for i, ikJoint in enumerate(ikJointList): if not "_JEnd" in ikJoint: if cmds.objExists(ikJoint + ".dpAR_joint"): cmds.deleteAttr(ikJoint + ".dpAR_joint") fkJoint = ikJoint.replace("_Ik_Jxt", "_Fk_Jxt") skinJoint = ikJoint.replace("_Ik_Jxt", "_Jnt") self.ctrl = side + self.userGuideName + "_1_Ctrl" scaleCompensateCond = ikJoint.replace("_Ik_Jxt", "_ScaleCompensate_Cnd") ikFkParentConst = cmds.parentConstraint(ikJoint, fkJoint, skinJoint, maintainOffset=True, name=skinJoint + "_ParentConstraint")[0] ikFkScaleConst = cmds.scaleConstraint(ikJoint, fkJoint, skinJoint, maintainOffset=True, name=skinJoint + "_ScaleConstraint")[0] cmds.connectAttr(self.ctrl + ".ikFkBlend", ikFkParentConst + "." + fkJoint + "W1", force=True) cmds.connectAttr(self.ikFkRevNode + ".outputX", ikFkParentConst + "." + ikJoint + "W0", force=True) cmds.connectAttr(self.ctrl + ".ikFkBlend", ikFkScaleConst + "." + fkJoint + "W1", force=True) cmds.connectAttr(self.ikFkRevNode + ".outputX", ikFkScaleConst + "." + ikJoint + "W0", force=True) cmds.setAttr(ikJoint + ".segmentScaleCompensate", 1) #Condition for scale compensate will not exist in maya 2016 since we need to have the compensate #off for almost every joint if (int(cmds.about(version=True)[:4]) < 2016): cmds.connectAttr(self.ctrl + ".ikFkBlend", scaleCompensateCond + ".firstTerm", force=True) # fk control drives fk joints for i, fkJoint in enumerate(fkJointList): if not "_JEnd" in fkJoint: if cmds.objExists(fkJoint + ".dpAR_joint"): cmds.deleteAttr(fkJoint + ".dpAR_joint") fkCtrl = fkJoint.replace("_Fk_Jxt", "_Ctrl") scaleCompensateCond = fkCtrl.replace("_Ctrl", "_ScaleCompensate_Cnd") cmds.parentConstraint(fkCtrl, fkJoint, maintainOffset=True, name=fkJoint + "_ParentConstraint") cmds.scaleConstraint(fkCtrl, fkJoint, maintainOffset=True, name=fkJoint + "_ScaleConstraint") #Not needed in Maya 2016 since we need to deactivate scale compensate on all finger bone if (int(cmds.about(version=True)[:4]) < 2016): cmds.connectAttr(fkCtrl + ".scaleCompensate", fkJoint + ".segmentScaleCompensate", force=True) else: cmds.setAttr(fkJoint + ".segmentScaleCompensate", 0) cmds.setAttr(fkCtrl + ".rotateOrder", 1) #Force Scale compensate to prevent scale problem in Maya 2016 for nJnt in self.skinJointList: if (int(cmds.about(version=True)[:4]) >= 2016): cmds.setAttr(nJnt + ".segmentScaleCompensate", 0) # ik handle if self.nJoints >= 2: if self.nJoints == 2: ikHandleList = cmds.ikHandle(startJoint=side + self.userGuideName + "_0_Ik_Jxt", endEffector=side + self.userGuideName + "_" + str( self.nJoints) + "_Ik_Jxt", solver="ikRPsolver", name=side + self.userGuideName + "_IkHandle") else: ikHandleList = cmds.ikHandle(startJoint=side + self.userGuideName + "_1_Ik_Jxt", endEffector=side + self.userGuideName + "_" + str( self.nJoints) + "_Ik_Jxt", solver="ikRPsolver", name=side + self.userGuideName + "_IkHandle") cmds.rename(ikHandleList[1], side + self.userGuideName + "_Effector") endIkHandleList = cmds.ikHandle( startJoint=side + self.userGuideName + "_" + str(self.nJoints) + "_Ik_Jxt", endEffector=side + self.userGuideName + "_Ik_JEnd", solver="ikSCsolver", name=side + self.userGuideName + "_EndIkHandle") cmds.rename(endIkHandleList[1], side + self.userGuideName + "_EndEffector") self.ikCtrl = ctrls.cvBox(ctrlName=side + self.userGuideName + "_Ik_Ctrl", r=self.ctrlRadius) cmds.addAttr(self.ikCtrl, longName='twist', attributeType='float', keyable=True) cmds.connectAttr(self.ikCtrl + ".twist", ikHandleList[0] + ".twist", force=True) cmds.delete(cmds.parentConstraint(side + self.userGuideName + "_Ik_JEnd", self.ikCtrl)) cmds.setAttr(self.ikCtrl + ".rotateOrder", 1) self.ikCtrlZero = utils.zeroOut([self.ikCtrl])[0] self.ikCtrlZeroList.append(self.ikCtrlZero) cmds.connectAttr(self.ikFkRevNode + ".outputX", self.ikCtrlZero + ".visibility", force=True) for q in range(2, self.nJoints): cmds.connectAttr(side + self.userGuideName + "_1_Ctrl.ikFkBlend", side + self.userGuideName + "_" + str(q) + "_Ctrl.visibility", force=True) cmds.parentConstraint(self.ikCtrl, ikHandleList[0], name=side + self.userGuideName + "_IkHandle_ParentConstraint", maintainOffset=True) cmds.parentConstraint(self.ikCtrl, endIkHandleList[0], name=side + self.userGuideName + "_EndIkHandle_ParentConstraint", maintainOffset=True) ikHandleGrp = cmds.group(ikHandleList[0], endIkHandleList[0], name=side + self.userGuideName + "_IkHandle_Grp") cmds.setAttr(ikHandleGrp+".visibility", 0) ctrls.setLockHide([self.ikCtrl], ['sx', 'sy', 'sz', 'v']) if self.nJoints == 2: cmds.parentConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_0_Ik_Jxt", maintainOffset=True, name=side + self.userGuideName + "_0_Ik_Jxt_ParentConstraint") cmds.scaleConstraint(side + self.userGuideName + "_0_Ctrl", side + self.userGuideName + "_0_Ik_Jxt", maintainOffset=True, name=side + self.userGuideName + "_0_Ik_Jxt_ScaleConstraint") # stretch cmds.addAttr(self.ikCtrl, longName='stretchable', attributeType='float', minValue=0, maxValue=1, defaultValue=0, keyable=True) stretchNormMD = cmds.createNode("multiplyDivide", name=side + self.userGuideName + "_StretchNormalize_MD") cmds.setAttr(stretchNormMD + ".operation", 2) distBetweenList = ctrls.distanceBet(side + self.userGuideName + "_0_Ctrl", self.ikCtrl, name=side + self.userGuideName + "_DistBet", keep=True) cmds.connectAttr(self.ikFkRevNode + ".outputX", distBetweenList[5] + "." + self.ikCtrl + "W0", force=True) cmds.connectAttr(self.ctrl + ".ikFkBlend", distBetweenList[5] + "." + distBetweenList[4] + "W1", force=True) cmds.connectAttr(distBetweenList[1] + ".distance", stretchNormMD + ".input1X", force=True) cmds.setAttr(stretchNormMD + ".input2X", distBetweenList[0]) stretchScaleMD = cmds.createNode("multiplyDivide", name=side + self.userGuideName + "_StretchScale_MD") cmds.connectAttr(stretchNormMD + ".outputX", stretchScaleMD + ".input1X", force=True) cmds.connectAttr(self.ikCtrl + ".stretchable", stretchScaleMD + ".input2X", force=True) stretchCond = cmds.createNode("condition", name=side + self.userGuideName + "_Stretch_Cnd") cmds.connectAttr(stretchScaleMD + ".outputX", stretchCond + ".firstTerm", force=True) cmds.setAttr(stretchCond + ".secondTerm", 1) cmds.setAttr(stretchCond + ".operation", 2) cmds.connectAttr(stretchScaleMD + ".outputX", stretchCond + ".colorIfTrueR", force=True) for i, ikJoint in enumerate(ikJointList): if not "_JEnd" in ikJoint: if self.nJoints == 2 and i == 0: pass else: cmds.connectAttr(stretchCond + ".outColorR", ikJoint + ".scaleZ", force=True) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(self.ikCtrlZero, side + self.userGuideName + "_0_SDKGrp_Zero", side + self.userGuideName + "_1_SDKGrp_Zero", name=side + self.userGuideName + "_Control_Grp") if self.nJoints == 2: self.toScalableHookGrp = cmds.group(side + self.userGuideName + "_0_Jnt", ikBaseJoint, fkBaseJoint, ikHandleGrp, distBetweenList[2], distBetweenList[3], distBetweenList[4], name=side + self.userGuideName + "_Joint_Grp") else: self.toScalableHookGrp = cmds.group(side + self.userGuideName + "_0_Jnt", ikHandleGrp, distBetweenList[2], distBetweenList[3], distBetweenList[4], name=side + self.userGuideName + "_Joint_Grp") else: self.toCtrlHookGrp = cmds.group(side + self.userGuideName + "_0_SDKGrp_Zero", side + self.userGuideName + "_1_SDKGrp_Zero", name=side + self.userGuideName + "_Control_Grp") self.toScalableHookGrp = cmds.group(side + self.userGuideName + "_0_Jnt", name=side + self.userGuideName + "_Joint_Grp") self.scalableGrpList.append(self.toScalableHookGrp) self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') # create cvJointLoc and cvLocators: self.cvFootLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName + "_foot", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFALoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfA", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFBLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfB", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFCLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfC", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFDLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfD", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFELoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfE", r=0.3) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideFoot = cmds.joint(name=self.guideName + "_JGuideFoot", radius=0.001) self.jGuideRFE = cmds.joint(name=self.guideName + "_JGuideRfE", radius=0.001) cmds.select(clear=True) self.jGuideRFA = cmds.joint(name=self.guideName + "_JGuideRfA", radius=0.001) self.jGuideRFD = cmds.joint(name=self.guideName + "_JGuideRfD", radius=0.001) self.jGuideRFB = cmds.joint(name=self.guideName + "_JGuideRfB", radius=0.001) self.jGuideRFC = cmds.joint(name=self.guideName + "_JGuideRfC", radius=0.001) self.jGuideRFAC = cmds.joint(name=self.guideName + "_JGuideRfAC", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideFoot + ".template", 1) cmds.setAttr(self.jGuideRFA + ".template", 1) cmds.setAttr(self.jGuideRFB + ".template", 1) cmds.setAttr(self.jGuideRFC + ".template", 1) cmds.setAttr(self.jGuideRFD + ".template", 1) cmds.setAttr(self.jGuideRFE + ".template", 1) cmds.parent(self.jGuideFoot, self.jGuideRFA, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator( ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvRFELoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.parent(self.jGuideEnd, self.jGuideRFE) # make parents between cvLocs: cmds.parent(self.cvFootLoc, self.cvRFALoc, self.cvRFBLoc, self.cvRFCLoc, self.cvRFDLoc, self.moduleGrp) cmds.parent(self.cvRFELoc, self.cvFootLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvFootLoc, self.jGuideFoot, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) cmds.parentConstraint(self.cvRFALoc, self.jGuideRFA, maintainOffset=False, name=self.jGuideRFA + "_ParentConstraint") cmds.parentConstraint(self.cvRFBLoc, self.jGuideRFB, maintainOffset=False, name=self.jGuideRFB + "_ParentConstraint") cmds.parentConstraint(self.cvRFCLoc, self.jGuideRFC, maintainOffset=False, name=self.jGuideRFC + "_ParentConstraint") cmds.parentConstraint(self.cvRFDLoc, self.jGuideRFD, maintainOffset=False, name=self.jGuideRFD + "_ParentConstraint") cmds.parentConstraint(self.cvRFELoc, self.jGuideRFE, maintainOffset=False, name=self.jGuideRFE + "_ParentConstraint") cmds.parentConstraint(self.cvRFALoc, self.jGuideRFAC, maintainOffset=False, name=self.jGuideRFAC + "_ParentConstraint") ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # transform cvLocs in order to put as a good foot guide: cmds.setAttr(self.cvFootLoc + ".translateZ", 2) cmds.setAttr(self.cvFootLoc + ".rotateY", -90) cmds.setAttr(self.cvRFELoc + ".translateX", -1) cmds.setAttr(self.cvRFELoc + ".translateZ", 2.5) cmds.setAttr(self.cvRFCLoc + ".translateX", 1) cmds.setAttr(self.cvRFALoc + ".translateX", -0.6) cmds.setAttr(self.cvRFALoc + ".translateY", -1) cmds.setAttr(self.cvRFBLoc + ".translateX", -0.6) cmds.setAttr(self.cvRFBLoc + ".translateY", 1) cmds.setAttr(self.cvRFDLoc + ".translateX", -3.5) cmds.setAttr(self.moduleGrp + ".rotateX", -90) cmds.setAttr(self.moduleGrp + ".rotateY", 90)
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # create lists to be integrated: # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_'] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side + self.userGuideName + "_Guide_Base" self.cvFootLoc = side + self.userGuideName + "_Guide_foot" self.cvRFALoc = side + self.userGuideName + "_Guide_RfA" self.cvRFBLoc = side + self.userGuideName + "_Guide_RfB" self.cvRFCLoc = side + self.userGuideName + "_Guide_RfC" self.cvRFDLoc = side + self.userGuideName + "_Guide_RfD" self.cvRFELoc = side + self.userGuideName + "_Guide_RfE" self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" # declaring attributes reading from dictionary: ankleRFAttr = self.langDic[self.langName]['c_leg_extrem'] middleRFAttr = self.langDic[self.langName]['c_RevFoot_middle'] outsideRFAttr = self.langDic[self.langName]['c_RevFoot_A'] insideRFAttr = self.langDic[self.langName]['c_RevFoot_B'] heelRFAttr = self.langDic[self.langName]['c_RevFoot_C'] toeRFAttr = self.langDic[self.langName]['c_RevFoot_D'] ballRFAttr = self.langDic[self.langName]['c_RevFoot_E'] footRFAttr = self.langDic[self.langName]['c_RevFoot_F'] sideRFAttr = self.langDic[self.langName]['c_RevFoot_G'] rfRoll = self.langDic[self.langName]['c_RevFoot_roll'] rfSpin = self.langDic[self.langName]['c_RevFoot_spin'] rfTurn = self.langDic[self.langName]['c_RevFoot_turn'] # creating joints: cmds.select(clear=True) self.footJnt = cmds.joint(name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_Jnt") self.middleFootJxt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jxt") self.endJnt = cmds.joint(name=side + self.userGuideName + "_JEnd") cmds.select(clear=True) self.middleFootJnt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jnt") self.endBJnt = cmds.joint(name=side + self.userGuideName + "B_JEnd") cmds.parent(self.middleFootJnt, self.middleFootJxt) cmds.addAttr(self.footJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.addAttr(self.middleFootJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.select(clear=True) ''' Deactivate the segment scale compensate on the bone to prevent scaling problem in maya 2016 It will prevent a double scale problem that will come from the upper parent in the rig ''' if (int(cmds.about(version=True)[:4]) >= 2016): cmds.setAttr(self.footJnt+".segmentScaleCompensate", 0) cmds.setAttr(self.middleFootJxt+".segmentScaleCompensate", 0) cmds.setAttr(self.middleFootJnt+".segmentScaleCompensate", 0) # reverse foot groups: self.RFAJxt = cmds.group(name=side + self.userGuideName + "_" + outsideRFAttr.capitalize() + "_Grp", empty=True) self.RFBJxt = cmds.group(name=side + self.userGuideName + "_" + insideRFAttr.capitalize() + "_Grp", empty=True) self.RFCJxt = cmds.group(name=side + self.userGuideName + "_" + heelRFAttr.capitalize() + "_Grp", empty=True) self.RFDJxt = cmds.group(name=side + self.userGuideName + "_" + toeRFAttr.capitalize() + "_Grp", empty=True) self.RFEJxt = cmds.group(name=side + self.userGuideName + "_" + ballRFAttr.capitalize() + "_Grp", empty=True) self.RFEndJxt = cmds.group(name=side + self.userGuideName + "_RFEnd_Grp", empty=True) rfJointList = [self.RFAJxt, self.RFBJxt, self.RFCJxt, self.RFDJxt, self.RFEJxt] self.ballRFList.append(self.RFEJxt) cmds.parent(self.RFBJxt, self.RFAJxt) cmds.parent(self.RFCJxt, self.RFBJxt) cmds.parent(self.RFDJxt, self.RFCJxt) cmds.parent(self.RFEJxt, self.RFDJxt) cmds.parent(self.RFEndJxt, self.RFEJxt) # reverse foot zero out groups: self.RFEJzt = utils.zeroOut([self.RFEJxt])[0] self.RFDJzt = utils.zeroOut([self.RFDJxt])[0] self.RFCJzt = utils.zeroOut([self.RFCJxt])[0] self.RFBJzt = utils.zeroOut([self.RFBJxt])[0] self.RFAJzt = utils.zeroOut([self.RFAJxt])[0] self.RFAJztExtra = utils.zeroOut([self.RFAJzt])[0] rfJointZeroList = [self.RFAJzt, self.RFBJzt, self.RFCJzt, self.RFDJzt, self.RFEJzt] # putting groups in the correct place: tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footJnt, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootJxt, maintainOffset=False) tempToDelC = cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False) tempToDelD = cmds.parentConstraint(self.cvEndJoint, self.endBJnt, maintainOffset=False) tempToDelE = cmds.parentConstraint(self.cvRFALoc, self.RFAJztExtra, maintainOffset=False) tempToDelF = cmds.parentConstraint(self.cvRFBLoc, self.RFBJzt, maintainOffset=False) tempToDelG = cmds.parentConstraint(self.cvRFCLoc, self.RFCJzt, maintainOffset=False) tempToDelH = cmds.parentConstraint(self.cvRFDLoc, self.RFDJzt, maintainOffset=False) tempToDelI = cmds.parentConstraint(self.cvRFELoc, self.RFEJzt, maintainOffset=False) tempToDelJ = cmds.parentConstraint(self.cvEndJoint, self.RFEndJxt, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB, tempToDelC, tempToDelD, tempToDelE, tempToDelF, tempToDelG, tempToDelH, tempToDelI, tempToDelJ) cmds.makeIdentity(rfJointZeroList, apply=True, translate=False, rotate=True, scale=True) # creating ikHandles: ikHandleAnkleList = cmds.ikHandle( name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_IkHandle", startJoint=self.footJnt, endEffector=self.middleFootJxt, solver='ikSCsolver') ikHandleMiddleList = cmds.ikHandle( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_IkHandle", startJoint=self.middleFootJxt, endEffector=self.endJnt, solver='ikSCsolver') cmds.rename(ikHandleAnkleList[1], ikHandleAnkleList[0] + "_Effector") cmds.rename(ikHandleMiddleList[1], ikHandleMiddleList[0] + "_Effector") cmds.setAttr(ikHandleAnkleList[0] + '.visibility', 0) cmds.setAttr(ikHandleMiddleList[0] + '.visibility', 0) # creating Fk controls: self.footCtrl = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_leg_extrem'] + "_Ctrl", ch=False, o=True, nr=(1, 0, 0), d=3, s=8, radius=self.ctrlRadius / 2.0)[0] self.footCtrlList.append(self.footCtrl) cmds.setAttr(self.footCtrl + ".rotateOrder", 1) self.revFootCtrlShapeList.append(cmds.listRelatives(self.footCtrl, children=True, type='nurbsCurve')[0]) self.middleFootCtrl = cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName][ 'c_RevFoot_middle'].capitalize() + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=1, s=8, radius=self.ctrlRadius / 2.0)[0] cmds.setAttr(self.middleFootCtrl + '.overrideEnabled', 1) cmds.setAttr(self.middleFootCtrl + ".rotateOrder", 4) tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footCtrl, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootCtrl, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB) self.footCtrlZeroList = utils.zeroOut([self.footCtrl, self.middleFootCtrl]) self.revFootCtrlZeroFinalList.append(self.footCtrlZeroList[0]) self.middleFootCtrlList.append(self.middleFootCtrl) # mount hierarchy: cmds.parent(self.footCtrlZeroList[1], self.RFDJxt, absolute=True) cmds.parent(ikHandleMiddleList[0], self.middleFootCtrl, absolute=True) self.toLimbIkHandleGrp = cmds.group(empty=True, name=side + self.userGuideName + "_" + self.langDic[self.langName][ 'c_leg_extrem'] + "_Grp") self.toLimbIkHandleGrpList.append(self.toLimbIkHandleGrp) cmds.parent(ikHandleAnkleList[0], self.toLimbIkHandleGrp, self.RFEJxt, absolute=True) cmds.makeIdentity(self.toLimbIkHandleGrp, apply=True, translate=True, rotate=True, scale=True) parentConst = cmds.parentConstraint(self.RFEJxt, self.footJnt, maintainOffset=True, name=self.footJnt + "_ParentConstraint")[0] self.parentConstList.append(parentConst) self.footJntList.append(self.footJnt) cmds.parent(self.RFAJztExtra, self.footCtrl, absolute=True) scaleConst = cmds.scaleConstraint(self.footCtrl, self.footJnt, maintainOffset=True, name=self.footJnt + "_ScaleConstraint") self.scaleConstList.append(scaleConst) cmds.parentConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ParentConstraint") cmds.scaleConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ScaleConstraint") # add attributes to footCtrl and connect them to reverseFoot groups rotation: rfAttrList = [outsideRFAttr, insideRFAttr, heelRFAttr, toeRFAttr, ballRFAttr] rfTypeAttrList = [rfRoll, rfSpin] for j, rfAttr in enumerate(rfAttrList): for t, rfType in enumerate(rfTypeAttrList): if t == 1 and j == (len(rfAttrList) - 1): # create turn attr to ball cmds.addAttr(self.footCtrl, longName=rfAttr + "_" + rfTurn, attributeType='float', keyable=True) cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfTurn, rfJointList[j] + ".rotateX", force=True) self.reverseFootAttrList.append(rfAttr + "_" + rfTurn) cmds.addAttr(self.footCtrl, longName=rfAttr + "_" + rfType, attributeType='float', keyable=True) self.reverseFootAttrList.append(rfAttr + "_" + rfType) if t == 0: if j > 1: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateY", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateX", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + "_" + rfType, rfJointList[j] + ".rotateZ", force=True) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.footCtrl, attrString=self.base + ";" + self.cvFootLoc + ";" + self.cvRFALoc + ";" + self.cvRFBLoc + ";" + self.cvRFCLoc + ";" + self.cvRFDLoc) utils.originedFrom(objName=self.middleFootCtrl, attrString=self.cvRFELoc + ";" + self.cvEndJoint) # creating pre-defined attributes for footRoll and sideRoll attributes: cmds.addAttr(self.footCtrl, longName=footRFAttr + "_" + rfRoll, attributeType='float', keyable=True) cmds.addAttr(self.footCtrl, longName=sideRFAttr + "_" + rfRoll, attributeType='float', keyable=True) # create clampNodes in order to limit the side rotations: sideClamp = cmds.createNode("clamp", name=side + self.userGuideName + "_Side_Clp") # outside values in R cmds.setAttr(sideClamp + ".maxR", 360) # inside values in G cmds.setAttr(sideClamp + ".minG", -360) # connections: cmds.connectAttr(self.footCtrl + "." + sideRFAttr + "_" + rfRoll, sideClamp + ".inputR", force=True) cmds.connectAttr(self.footCtrl + "." + sideRFAttr + "_" + rfRoll, sideClamp + ".inputG", force=True) cmds.connectAttr(sideClamp + ".outputR", self.RFAJzt + ".rotateX", force=True) cmds.connectAttr(sideClamp + ".outputG", self.RFBJzt + ".rotateX", force=True) # for footRoll: footClamp = cmds.createNode("clamp", name=side + self.userGuideName + "_Foot_Clp") # heel values in R cmds.setAttr(footClamp + ".maxR", 360) cmds.connectAttr(self.footCtrl + "." + footRFAttr + "_" + rfRoll, footClamp + ".inputR", force=True) cmds.connectAttr(footClamp + ".outputR", self.RFCJzt + ".rotateY", force=True) # set driven keys cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=0, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-45, value=-45, inTangentType="spline", outTangentType="spline") cmds.setDrivenKeyframe(self.RFEJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-200, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-30, value=0, inTangentType="flat", outTangentType="flat") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-60, value=-30, inTangentType="spline", outTangentType="spline") cmds.setDrivenKeyframe(self.RFDJzt + ".rotateY", currentDriver=self.footCtrl + "." + footRFAttr + "_" + rfRoll, driverValue=-360, value=-180, inTangentType="flat", outTangentType="flat") # organizing keyable attributes: ctrls.setLockHide([self.middleFootCtrl, self.footCtrl], ['v'], l=False) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(self.footCtrlZeroList[0], name=side + self.userGuideName + "_Control_Grp") self.toScalableHookGrp = cmds.createNode("transform", name=side + self.userGuideName + "_Joint_Grp") mWorldFoot = cmds.getAttr(self.footJnt + ".worldMatrix") cmds.xform(self.toScalableHookGrp, m=mWorldFoot, ws=True) cmds.parent(self.footJnt, self.toScalableHookGrp, absolute=True) #Remove the Joint orient to make sure the bone is at the same orientation than it's parent cmds.setAttr(self.footJnt + ".jointOrientX", 0) cmds.setAttr(self.footJnt + ".jointOrientY", 0) cmds.setAttr(self.footJnt + ".jointOrientZ", 0) #self.toScalableHookGrp = cmds.group(self.footJnt, name=side + self.userGuideName + "_Joint_Grp") self.aScalableGrp.append(self.toScalableHookGrp) self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate( self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename( self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: if cmds.getAttr(self.moduleGrp + ".flip") == 0: for axis in self.mirrorAxis: gotValue = cmds.getAttr( side + self.userGuideName + "_Guide_Base.translate" + axis) flipedValue = gotValue * (-2) cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.translate' + axis, flipedValue) else: for axis in self.mirrorAxis: cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) #for Maya2012: self.userGuideName+'_'+self.moduleGrp+"_Grp" # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type: dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # create a list to export: self.eyeScaleGrpList = [] # create the main control: self.eyeCtrl = cmds.circle(name=self.userGuideName + "_A_Ctrl", radius=(2.25 * self.ctrlRadius), normal=(0, 0, 1), degree=3, constructionHistory=False)[0] cmds.addAttr(self.eyeCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', keyable=True, minValue=0, maxValue=1) cmds.setAttr( self.eyeCtrl + "." + self.langDic[self.langName]['c_Follow'], 1) cmds.move(0, -1, 0, self.eyeCtrl + ".cv[1]", relative=True) cmds.move(0, 1, 0, self.eyeCtrl + ".cv[5]", relative=True) cmds.delete( cmds.parentConstraint(sideList[0] + self.userGuideName + "_Guide_JointEnd", self.eyeCtrl, maintainOffset=False)) cmds.setAttr(self.eyeCtrl + ".translateX", 0) self.eyeGrp = cmds.group(self.eyeCtrl, name=self.userGuideName + "_A_Grp") utils.zeroOut([self.eyeCtrl]) self.upLocGrp = cmds.group(name=self.userGuideName + "_UpLoc_Grp", empty=True) # run for all sides: for s, side in enumerate(sideList): cmds.select(clear=True) self.base = side + self.userGuideName + '_Guide_Base' # declare guide: self.guide = side + self.userGuideName + "_Guide_JointLoc1" # create a joint: self.jxt = cmds.joint(name=side + self.userGuideName + "_1_Jxt", scaleCompensate=False) self.jnt = cmds.joint(name=side + self.userGuideName + "_1_Jnt", scaleCompensate=False) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) self.fkEyeCtrl = cmds.circle(name=side + self.userGuideName + "_Fk_Ctrl", radius=self.ctrlRadius, normal=(0, 0, 1), degree=1, sections=6, constructionHistory=False)[0] utils.originedFrom(objName=self.fkEyeCtrl, attrString=self.base + ";" + self.guide) self.baseEyeCtrl = ctrls.cvBox( ctrlName=side + self.userGuideName + "_Base_Ctrl", r=self.ctrlRadius) utils.originedFrom(objName=self.baseEyeCtrl, attrString=self.base + ";" + self.guide) # position and orientation of joint and control: cmds.delete( cmds.parentConstraint(self.guide, self.jxt, maintainOffset=False)) cmds.delete( cmds.parentConstraint(self.guide, self.fkEyeCtrl, maintainOffset=False)) cmds.delete( cmds.parentConstraint(self.guide, self.baseEyeCtrl, maintainOffset=False)) cmds.makeIdentity(self.baseEyeCtrl, self.fkEyeCtrl, apply=True) # zeroOut controls: eyeZeroList = utils.zeroOut([self.baseEyeCtrl, self.fkEyeCtrl]) cmds.parent(eyeZeroList[1], self.baseEyeCtrl) # hide visibility attribute: cmds.setAttr(self.fkEyeCtrl + '.visibility', keyable=False) ctrls.setLockHide([self.fkEyeCtrl], ['tx', 'ty', 'tz']) # create end joint: self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" self.endJoint = cmds.joint(name=side + self.userGuideName + "_JEnd") cmds.delete( cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False)) cmds.parent(self.endJoint, self.jnt, absolute=True) # create parentConstraint from ctrl to jxt: cmds.parentConstraint(self.fkEyeCtrl, self.jxt, maintainOffset=False, name=self.jnt + "_ParentConstraint") # create scaleConstraint from ctrl to jnt: cmds.scaleConstraint(self.fkEyeCtrl, self.jxt, maintainOffset=True, name=self.jnt + "_ScaleConstraint") # lookAt control: self.lookAtCtrl = cmds.circle(name=side + self.userGuideName + "_LookAt_Ctrl", radius=self.ctrlRadius, normal=(0, 0, 1), degree=3, constructionHistory=False)[0] cmds.delete( cmds.parentConstraint(self.cvEndJoint, self.lookAtCtrl, maintainOffset=False)) cmds.parent(self.lookAtCtrl, self.eyeCtrl, relative=False) cmds.makeIdentity(self.lookAtCtrl, apply=True) cmds.addAttr(self.lookAtCtrl, longName="active", attributeType="bool", defaultValue=1, keyable=True) # up locator: self.lUpGrpLoc = cmds.group(name=side + self.userGuideName + "_Up_Loc_Grp", empty=True) cmds.delete( cmds.parentConstraint(self.jnt, self.lUpGrpLoc, maintainOffset=False)) self.lUpLoc = cmds.spaceLocator( name=side + self.userGuideName + "_Up_Loc")[0] cmds.delete( cmds.parentConstraint(self.jnt, self.lUpLoc, maintainOffset=False)) cmds.move(cmds.getAttr(self.guideName + "_JointEnd.translateZ"), self.lUpLoc, moveY=True, relative=True) cmds.parent(self.lUpLoc, self.lUpGrpLoc, relative=False) cmds.parent(self.lUpGrpLoc, self.upLocGrp, relative=False) # look at aim constraint: aimConst = cmds.aimConstraint(self.lookAtCtrl, self.fkEyeCtrl + "_Zero", worldUpType="object", worldUpObject=self.upLocGrp + "|" + self.lUpGrpLoc + "|" + self.lUpLoc, maintainOffset=True)[0] cmds.connectAttr(self.lookAtCtrl + ".active", aimConst + "." + self.lookAtCtrl + "W0", force=True) # eye aim rotation cmds.addAttr(self.fkEyeCtrl, longName="aimRotation", attributeType="float", keyable=True) cmds.connectAttr(self.fkEyeCtrl + ".aimRotation", self.jnt + ".rotateZ", force=True) cmds.pointConstraint(self.baseEyeCtrl, self.lUpGrpLoc, maintainOffset=True, name=self.lUpGrpLoc + "_PointConstraint") # create eyeScale setup: cmds.select(clear=True) self.eyeScaleJnt = cmds.joint(name=side + self.userGuideName + "Scale_1_Jnt", scaleCompensate=False) cmds.addAttr(self.eyeScaleJnt, longName='dpAR_joint', attributeType='float', keyable=False) # jointScale position: cmds.delete( cmds.parentConstraint(self.guide, self.eyeScaleJnt, maintainOffset=False)) # create endScale joint: self.endScaleJoint = cmds.joint( name=side + self.userGuideName + "Scale_JEnd") cmds.delete( cmds.parentConstraint(self.eyeScaleJnt, self.endScaleJoint, maintainOffset=False)) cmds.setAttr(self.endScaleJoint + ".translateZ", 1) # create constraints to eyeScale: cmds.pointConstraint(self.jnt, self.eyeScaleJnt, maintainOffset=False, name=self.eyeScaleJnt + "_PointConstraint") cmds.scaleConstraint(self.jnt, self.eyeScaleJnt, maintainOffset=True, name=self.eyeScaleJnt + "_ScaleConstraint") self.eyeScaleGrp = cmds.group(self.eyeScaleJnt, name=self.eyeScaleJnt + "_Grp") self.eyeScaleGrpList.append(self.eyeScaleGrp) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group( eyeZeroList[0], name=side + self.userGuideName + "_Control_Grp") self.toScalableHookGrp = cmds.group( self.jxt, self.eyeScaleGrp, name=side + self.userGuideName + "_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") if s == 0: cmds.parent(self.eyeGrp, self.toCtrlHookGrp) cmds.parent(self.upLocGrp, self.toScalableHookGrp) # create a locator in order to avoid delete static group: loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v' ]) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_'] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.base = side + self.userGuideName + '_Guide_Base' # get the number of joints to be created: self.nJoints = cmds.getAttr(self.base + ".nJoints") # create controls: self.hipsA = ctrls.cvBox( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_hips'] + "A_Ctrl", r=self.ctrlRadius, h=(self.ctrlRadius * 0.25)) self.hipsB = \ cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_hips'] + "B_Ctrl", ch=False, o=True, nr=(0, 1, 0), d=1, s=8, radius=self.ctrlRadius)[0] self.chestA = ctrls.cvBox( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chest'] + "A_Ctrl", r=self.ctrlRadius, h=(self.ctrlRadius * 0.25)) self.chestB = \ cmds.circle(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chest'] + "B_Ctrl", ch=False, o=True, nr=(0, 1, 0), d=1, s=8, radius=self.ctrlRadius)[0] cmds.addAttr(self.hipsA, longName=side + self.userGuideName + '_' + self.langDic[self.langName][ 'c_volumeVariation'], attributeType="float", defaultValue=1, keyable=True) ctrls.setLockHide([self.hipsA, self.hipsB, self.chestA, self.chestB], ['v'], l=False) self.aHipsAList.append(self.hipsA) self.aChestAList.append(self.chestA) self.aVolVariationAttrList.append( side + self.userGuideName + '_' + self.langDic[self.langName]['c_volumeVariation']) # Setup axis order if self.rigType == Base.RigType.quadruped: cmds.setAttr(self.hipsA + ".rotateOrder", 1) cmds.setAttr(self.hipsB + ".rotateOrder", 1) cmds.setAttr(self.chestA + ".rotateOrder", 1) cmds.setAttr(self.chestB + ".rotateOrder", 1) else: cmds.setAttr(self.hipsA + ".rotateOrder", 4) cmds.setAttr(self.hipsB + ".rotateOrder", 4) cmds.setAttr(self.chestA + ".rotateOrder", 4) cmds.setAttr(self.chestB + ".rotateOrder", 4) # Keep a list of ctrls we want to colorize a certain way self.aFkCtrl.append([self.hipsB, self.chestB]) self.aIkCtrl.append([self.hipsA, self.chestA]) # organize hierarchy: cmds.parent(self.hipsB, self.hipsA) cmds.parent(self.chestB, self.chestA) cmds.parent(self.chestA, self.hipsA) cmds.rotate(-90, 0, 0, self.hipsA) cmds.makeIdentity(self.hipsA, apply=True, rotate=True) # position of controls: bottomLocGuide = side + self.userGuideName + "_Guide_JointLoc1" topLocGuide = side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints) # snap controls to guideLocators: tempDel = cmds.parentConstraint(bottomLocGuide, self.hipsA, maintainOffset=False) cmds.delete(tempDel) tempDel = cmds.parentConstraint(topLocGuide, self.chestA, maintainOffset=False) cmds.delete(tempDel) # zeroOut transformations: utils.zeroOut([self.hipsA, self.chestA]) # modify the pivots of chest controls: upPivotPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints - 1), query=True, worldSpace=True, translation=True) cmds.move(upPivotPos[0], upPivotPos[1], upPivotPos[2], self.chestA + ".scalePivot", self.chestA + ".rotatePivot") # , self.chestB+".scalePivot", self.chestB+".rotatePivot") # add originedFrom attributes to hipsA, hipsB and chestB: utils.originedFrom(objName=self.hipsA, attrString=self.base) utils.originedFrom(objName=self.hipsB, attrString=bottomLocGuide) utils.originedFrom(objName=self.chestB, attrString=topLocGuide) # create a simple spine ribbon: returnedRibbonList = ctrls.createSimpleRibbon(name=side + self.userGuideName + '_Rbn', totalJoints=(self.nJoints - 1)) rbnNurbsPlane = returnedRibbonList[0] rbnNurbsPlaneShape = returnedRibbonList[1] rbnJointGrpList = returnedRibbonList[2] self.aRbnJointList = returnedRibbonList[3] # position of ribbon nurbs plane: cmds.setAttr(rbnNurbsPlane + ".tz", -4) cmds.move(0, 0, 0, rbnNurbsPlane + ".scalePivot", rbnNurbsPlane + ".rotatePivot") cmds.rotate(90, 90, 0, rbnNurbsPlane) cmds.makeIdentity(rbnNurbsPlane, apply=True, translate=True, rotate=True) downLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc1", query=True, worldSpace=True, translation=True) upLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints), query=True, worldSpace=True, translation=True) cmds.move(downLocPos[0], downLocPos[1], downLocPos[2], rbnNurbsPlane) # create up and down clusters: downCluster = \ cmds.cluster(rbnNurbsPlane + ".cv[0:3][0:1]", name=side + self.userGuideName + '_Down_Cls')[1] upCluster = \ cmds.cluster(rbnNurbsPlane + ".cv[0:3][" + str(self.nJoints) + ":" + str(self.nJoints + 1) + "]", name=side + self.userGuideName + '_Up_Cls')[1] # get positions of joints from ribbon nurbs plane: startRbnJointPos = cmds.xform(side + self.userGuideName + "_Rbn0_Jnt", query=True, worldSpace=True, translation=True) endRbnJointPos = cmds.xform(side + self.userGuideName + "_Rbn" + str(self.nJoints - 1) + "_Jnt", query=True, worldSpace=True, translation=True) # move pivots of clusters to start and end positions: cmds.move(startRbnJointPos[0], startRbnJointPos[1], startRbnJointPos[2], downCluster + ".scalePivot", downCluster + ".rotatePivot") cmds.move(endRbnJointPos[0], endRbnJointPos[1], endRbnJointPos[2], upCluster + ".scalePivot", upCluster + ".rotatePivot") # snap clusters to guideLocators: tempDel = cmds.parentConstraint(bottomLocGuide, downCluster, maintainOffset=False) cmds.delete(tempDel) tempDel = cmds.parentConstraint(topLocGuide, upCluster, maintainOffset=False) cmds.delete(tempDel) # rotate clusters to compensate guide: upClusterRot = cmds.xform(upCluster, query=True, worldSpace=True, rotation=True) downClusterRot = cmds.xform(downCluster, query=True, worldSpace=True, rotation=True) cmds.xform(upCluster, worldSpace=True, rotation=(upClusterRot[0] + 90, upClusterRot[1], upClusterRot[2])) cmds.xform(downCluster, worldSpace=True, rotation=(downClusterRot[0] + 90, downClusterRot[1], downClusterRot[2])) # scaleY of the clusters in order to avoid great extremity deforms: rbnHeight = ctrls.distanceBet(side + self.userGuideName + "_Guide_JointLoc" + str(self.nJoints), side + self.userGuideName + "_Guide_JointLoc1", keep=False)[0] cmds.setAttr(upCluster + ".sy", rbnHeight / 10) cmds.setAttr(downCluster + ".sy", rbnHeight / 10) # parent clusters in controls (up and down): cmds.parentConstraint(self.hipsB, downCluster, maintainOffset=True, name=downCluster + "_ParentConstraint") cmds.parentConstraint(self.chestB, upCluster, maintainOffset=True, name=upCluster + "_ParentConstraint") # organize a group of clusters: clustersGrp = cmds.group(name=side + self.userGuideName + "_Rbn_Clusters_Grp", empty=True) self.aClusterGrp.append(clustersGrp) if hideJoints: cmds.setAttr(clustersGrp + ".visibility", 0) cmds.parent(downCluster, upCluster, clustersGrp, relative=True) # make ribbon joints groups scalable: for r, rbnJntGrp in enumerate(rbnJointGrpList): if ((r >= 0) and (r < (len(rbnJointGrpList) - 1))): scaleGrp = cmds.group(rbnJntGrp, name=rbnJntGrp.replace("_Grp", "_Scale_Grp")) ctrls.directConnect(scaleGrp, rbnJntGrp, ['sx', 'sz']) cmds.scaleConstraint(clustersGrp, scaleGrp, maintainOffset=True, name=rbnJntGrp + "_Scale") else: cmds.scaleConstraint(clustersGrp, rbnJntGrp, maintainOffset=True, name=rbnJntGrp + "_Scale") # calculate the distance to volumeVariation: arcLenShape = cmds.createNode('arcLengthDimension', name=side + self.userGuideName + "_Rbn_ArcLenShape") arcLenFather = cmds.listRelatives(arcLenShape, parent=True)[0] arcLen = cmds.rename(arcLenFather, side + self.userGuideName + "_Rbn_ArcLen") arcLenShape = cmds.listRelatives(arcLen, children=True, shapes=True)[0] cmds.setAttr(arcLen + '.visibility', 0) # connect nurbsPlaneShape to arcLength node: cmds.connectAttr(rbnNurbsPlaneShape + '.worldSpace[0]', arcLenShape + '.nurbsGeometry') cmds.setAttr(arcLenShape + '.vParamValue', 1) # avoid undesired squash if rotateZ the nurbsPlane: cmds.setAttr(arcLenShape + '.uParamValue', 0.5) arcLenValue = cmds.getAttr(arcLenShape + '.arcLengthInV') # create a multiplyDivide to output the squashStretch values: rbnMD = cmds.createNode('multiplyDivide', name=side + self.userGuideName + "_Rbn_MD") cmds.connectAttr(arcLenShape + '.arcLengthInV', rbnMD + '.input2X') cmds.setAttr(rbnMD + '.input1X', arcLenValue) cmds.setAttr(rbnMD + '.operation', 2) # create a blendColor in order to get the correct result value of volumeVariation: rbnBlendColors = cmds.createNode('blendColors', name=side + self.userGuideName + "_Rbn_BlendColor") cmds.connectAttr(self.hipsA + '.' + side + self.userGuideName + '_' + self.langDic[self.langName][ 'c_volumeVariation'], rbnBlendColors + '.blender') cmds.connectAttr(rbnMD + '.outputX', rbnBlendColors + '.color1R') cmds.setAttr(rbnBlendColors + '.color2R', 1) # middle ribbon setup: for n in range(1, self.nJoints - 1): self.middle = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_middle'] + str( n) + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=self.ctrlRadius)[0] cmds.setAttr(self.middle + ".rotateOrder", 4) self.aFkCtrl[s].append(self.middle) ctrls.setLockHide([self.middle], ['sx', 'sy', 'sz']) cmds.setAttr(self.middle + '.visibility', keyable=False) cmds.parent(self.middle, self.hipsA) middleLocGuide = side + self.userGuideName + "_Guide_JointLoc" + str(n + 1) tempDel = cmds.parentConstraint(middleLocGuide, self.middle, maintainOffset=False) cmds.delete(tempDel) utils.zeroOut([self.middle]) middleCluster = cmds.cluster(rbnNurbsPlane + ".cv[0:3][" + str(n + 1) + "]", name=side + self.userGuideName + '_Middle_Cls')[1] middleLocPos = cmds.xform(side + self.userGuideName + "_Guide_JointLoc" + str(n), query=True, worldSpace=True, translation=True) tempDel = cmds.parentConstraint(middleLocGuide, middleCluster, maintainOffset=False) cmds.delete(tempDel) middleClusterRot = cmds.xform(middleCluster, query=True, worldSpace=True, rotation=True) cmds.xform(middleCluster, worldSpace=True, rotation=(middleClusterRot[0] + 90, middleClusterRot[1], middleClusterRot[2])) cmds.parentConstraint(self.middle, middleCluster, maintainOffset=True, name=middleCluster + "_ParentConstraint") # parenting constraints like guide locators: self.parentConst = cmds.parentConstraint(self.hipsB, self.chestB, self.middle + "_Zero", name=self.middle + "_ParentConstraint", maintainOffset=True)[0] nParentValue = (n) / float(self.nJoints - 1) cmds.setAttr(self.parentConst + "." + self.hipsB + "W0", 1 - nParentValue) cmds.setAttr(self.parentConst + "." + self.chestB + "W1", nParentValue) cmds.parent(middleCluster, clustersGrp, relative=True) # add originedFrom attribute to this middle ctrl: utils.originedFrom(objName=self.middle, attrString=middleLocGuide) # apply volumeVariation to joints in the middle ribbon setup: cmds.connectAttr(rbnBlendColors + '.outputR', self.aRbnJointList[n] + '.scaleX') cmds.connectAttr(rbnBlendColors + '.outputR', self.aRbnJointList[n] + '.scaleZ') # create a multiplyDivide to use the Stretch/Squash value on the first bone of the spine # lesser than the middle rbnFirstJntMD = cmds.createNode('multiplyDivide', name=side + self.userGuideName + "_Rbn_FirstJnt_MD") cmds.connectAttr(rbnBlendColors + '.outputR', rbnFirstJntMD + '.input2X') cmds.setAttr(rbnFirstJntMD + '.input1X', 0.8) cmds.setAttr(rbnFirstJntMD + '.operation', 1) # apply volumeVariation to the first joint of the ribbon: cmds.connectAttr(rbnFirstJntMD + '.outputX', self.aRbnJointList[0] + '.scaleX') cmds.connectAttr(rbnFirstJntMD + '.outputX', self.aRbnJointList[0] + '.scaleZ') # organize groups: self.rbnRigGrp = cmds.group(name=side + self.userGuideName + "_Grp", empty=True) self.rbnControlGrp = cmds.group(name=side + self.userGuideName + "_Control_Grp", empty=True) cmds.parent(self.hipsA + "_Zero", self.rbnControlGrp, relative=True) cmds.parent(clustersGrp, side + self.userGuideName + "_Rbn_RibbonJoint_Grp", self.rbnControlGrp, arcLen, self.rbnRigGrp, relative=True) if hideJoints: cmds.setAttr(side + self.userGuideName + "_Rbn_RibbonJoint_Grp.visibility", 0) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.rbnControlGrp, hookType='ctrlHook') utils.addHook(objName=clustersGrp, hookType='scalableHook') utils.addHook(objName=self.rbnRigGrp, hookType='staticHook') cmds.addAttr(self.rbnRigGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.rbnRigGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.rbnRigGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.rbnRigGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.rbnRigGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.rbnRigGrp + '.dpAR_count', dpAR_count) # lockHide scale of up and down controls: ctrls.setLockHide([self.hipsA, self.hipsB, self.chestA, self.chestB], ['sx', 'sy', 'sz']) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate( self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename( self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: if cmds.getAttr(self.moduleGrp + ".flip") == 0: for axis in self.mirrorAxis: gotValue = cmds.getAttr( side + self.userGuideName + "_Guide_Base.translate" + axis) flipedValue = gotValue * (-2) cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.translate' + axis, flipedValue) else: for axis in self.mirrorAxis: cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) #for Maya2012: self.userGuideName+'_'+self.moduleGrp+"_Grp" # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): self.base = side + self.userGuideName + '_Guide_Base' cmds.select(clear=True) # declare guide: self.guide = side + self.userGuideName + "_Guide_JointLoc1" # create a joint: self.jnt = cmds.joint(name=side + self.userGuideName + "_Jnt", scaleCompensate=False) cmds.addAttr(self.jnt, longName='dpAR_joint', attributeType='float', keyable=False) # create a control: if self.getHasIndirectSkin(): self.ctrl = cmds.circle(name=side + self.userGuideName + "_Ctrl", degree=3, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] else: self.ctrl = cmds.circle(name=side + self.userGuideName + "_Ctrl", degree=1, normal=(0, 0, 1), r=self.ctrlRadius, s=6, ch=False)[0] utils.originedFrom(objName=self.ctrl, attrString=self.base + ";" + self.guide) # position and orientation of joint and control: cmds.delete( cmds.parentConstraint(self.guide, self.jnt, maintainOffset=False)) cmds.delete( cmds.parentConstraint(self.guide, self.ctrl, maintainOffset=False)) # zeroOut controls: zeroOutCtrlGrp = utils.zeroOut([self.ctrl])[0] # hide visibility attribute: cmds.setAttr(self.ctrl + '.visibility', keyable=False) # fixing flip mirror: if s == 1: if cmds.getAttr(self.moduleGrp + ".flip") == 1: cmds.setAttr(zeroOutCtrlGrp + ".scaleX", -1) cmds.setAttr(zeroOutCtrlGrp + ".scaleY", -1) cmds.setAttr(zeroOutCtrlGrp + ".scaleZ", -1) cmds.addAttr(self.ctrl, longName='scaleCompensate', attributeType="bool", keyable=True) cmds.setAttr(self.ctrl + ".scaleCompensate", 1) cmds.connectAttr(self.ctrl + ".scaleCompensate", self.jnt + ".segmentScaleCompensate", force=True) if self.getHasIndirectSkin(): # create a fatherJoint: cmds.select(clear=True) jxtName = self.jnt.replace("_Jnt", "_Jxt") self.jxt = cmds.duplicate(self.jnt, name=jxtName)[0] cmds.deleteAttr(self.jxt, attribute="dpAR_joint") cmds.parent(self.jnt, self.jxt) attrList = [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz' ] for attr in attrList: cmds.connectAttr(self.ctrl + '.' + attr, self.jnt + '.' + attr) else: # create parentConstraint from ctrl to jnt: cmds.parentConstraint(self.ctrl, self.jnt, maintainOffset=False, name=self.jnt + "_ParentConstraint") # create scaleConstraint from ctrl to jnt: cmds.scaleConstraint(self.ctrl, self.jnt, maintainOffset=True, name=self.jnt + "_ScaleConstraint") # create end joint: cmds.select(self.jnt) self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" self.endJoint = cmds.joint(name=side + self.userGuideName + "_JEnd") cmds.delete( cmds.parentConstraint(self.cvEndJoint, self.endJoint, maintainOffset=False)) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group( side + self.userGuideName + "_Ctrl_Zero", name=side + self.userGuideName + "_Control_Grp") if self.getHasIndirectSkin(): locScale = cmds.spaceLocator(name=side + self.userGuideName + "_Scalable_DO_NOT_DELETE")[0] self.toScalableHookGrp = cmds.group( locScale, name=side + self.userGuideName + "_IndirectSkin_Grp") jxtGrp = cmds.group(side + self.userGuideName + "_Jxt", name=side + self.userGuideName + "_Joint_Grp") self.toStaticHookGrp = cmds.group( jxtGrp, self.toScalableHookGrp, self.toCtrlHookGrp, name=side + self.userGuideName + "_Grp") else: self.toScalableHookGrp = cmds.group( side + self.userGuideName + "_Jnt", name=side + self.userGuideName + "_Joint_Grp") self.toStaticHookGrp = cmds.group( self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") # create a locator in order to avoid delete static or scalable group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v' ]) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # declare lists to store names and attributes: self.worldRefList, self.headCtrlList = [], [] self.aCtrls = [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate( self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename( self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side + self.userGuideName + "_Guide_Base" self.cvNeckLoc = side + self.userGuideName + "_Guide_neck" self.cvHeadLoc = side + self.userGuideName + "_Guide_head" self.cvJawLoc = side + self.userGuideName + "_Guide_jaw" self.cvChinLoc = side + self.userGuideName + "_Guide_chin" self.cvLLipLoc = side + self.userGuideName + "_Guide_lLip" self.cvRLipLoc = side + self.userGuideName + "_Guide_rLip" self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" # creating joints: self.neckJnt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_neck'] + "_Jnt") self.headJxt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_head'] + "_Jxt") cmds.select(clear=True) self.headJnt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_head'] + "_Jnt", scaleCompensate=False) self.jawJnt = cmds.joint(name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_jaw'] + "_Jnt", scaleCompensate=False) self.chinJnt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chin'] + "_Jnt", scaleCompensate=False) self.endJnt = cmds.joint(name=side + self.userGuideName + "_JEnd", scaleCompensate=False) cmds.select(clear=True) self.lLipJnt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['p002_left'] + "_" + self.langDic[self.langName]['c_lip'] + "_Jnt", scaleCompensate=False) cmds.select(clear=True) self.rLipJnt = cmds.joint( name=side + self.userGuideName + "_" + self.langDic[self.langName]['p003_right'] + "_" + self.langDic[self.langName]['c_lip'] + "_Jnt", scaleCompensate=False) dpARJointList = [ self.neckJnt, self.headJnt, self.jawJnt, self.chinJnt, self.lLipJnt, self.rLipJnt ] for dpARJoint in dpARJointList: cmds.addAttr(dpARJoint, longName='dpAR_joint', attributeType='float', keyable=False) # creating controls: self.neckCtrl = ctrls.cvNeck( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_neck'] + "_Ctrl", r=self.ctrlRadius / 2.0) self.headCtrl = ctrls.cvHead( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_head'] + "_Ctrl", r=self.ctrlRadius / 2.0) self.jawCtrl = ctrls.cvJaw( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_jaw'] + "_Ctrl", r=self.ctrlRadius / 2.0) self.chinCtrl = ctrls.cvChin( ctrlName=side + self.userGuideName + "_" + self.langDic[self.langName]['c_chin'] + "_Ctrl", r=self.ctrlRadius / 2.0) self.lLipCtrl = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[self.langName]['p002_left'] + "_" + self.langDic[self.langName]['c_lip'] + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.rLipCtrl = cmds.circle( name=side + self.userGuideName + "_" + self.langDic[self.langName]['p003_right'] + "_" + self.langDic[self.langName]['c_lip'] + "_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.headCtrlList.append(self.headCtrl) self.aCtrls.append([ self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl, self.lLipCtrl, self.rLipCtrl ]) #Setup Axis Order if self.rigType == Base.RigType.quadruped: cmds.setAttr(self.neckCtrl + ".rotateOrder", 1) cmds.setAttr(self.headCtrl + ".rotateOrder", 1) cmds.setAttr(self.jawCtrl + ".rotateOrder", 1) else: cmds.setAttr(self.neckCtrl + ".rotateOrder", 4) cmds.setAttr(self.headCtrl + ".rotateOrder", 4) cmds.setAttr(self.jawCtrl + ".rotateOrder", 4) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.neckCtrl, attrString=self.base + ";" + self.cvNeckLoc) utils.originedFrom(objName=self.headCtrl, attrString=self.cvHeadLoc) utils.originedFrom(objName=self.jawCtrl, attrString=self.cvJawLoc) utils.originedFrom(objName=self.chinCtrl, attrString=self.cvChinLoc + ";" + self.cvEndJoint) # orientation of controls: ctrls.setAndFreeze(nodeName=self.neckCtrl, rx=90, rz=-90) ctrls.setAndFreeze(nodeName=self.headCtrl, rx=90, rz=-90) ctrls.setAndFreeze(nodeName=self.jawCtrl, rz=-90) ctrls.setAndFreeze(nodeName=self.chinCtrl, rz=-90) # edit the mirror shape to a good direction of controls: ctrlList = [ self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl ] if s == 1: for ctrl in ctrlList: if self.mirrorAxis == 'X': cmds.setAttr(ctrl + '.rotateY', 180) elif self.mirrorAxis == 'Y': cmds.setAttr(ctrl + '.rotateY', 180) elif self.mirrorAxis == 'Z': cmds.setAttr(ctrl + '.rotateX', 180) cmds.setAttr(ctrl + '.rotateZ', 180) elif self.mirrorAxis == 'XYZ': cmds.setAttr(ctrl + '.rotateX', 180) cmds.setAttr(ctrl + '.rotateZ', 180) cmds.makeIdentity(ctrlList, apply=True, translate=False, rotate=True, scale=False) # temporary parentConstraints: tempDelNeck = cmds.parentConstraint(self.cvNeckLoc, self.neckCtrl, maintainOffset=False) tempDelHead = cmds.parentConstraint(self.cvHeadLoc, self.headCtrl, maintainOffset=False) tempDelJaw = cmds.parentConstraint(self.cvJawLoc, self.jawCtrl, maintainOffset=False) tempDelChin = cmds.parentConstraint(self.cvChinLoc, self.chinCtrl, maintainOffset=False) tempDelLLip = cmds.parentConstraint(self.cvLLipLoc, self.lLipCtrl, maintainOffset=False) tempDelRLip = cmds.parentConstraint(self.cvRLipLoc, self.rLipCtrl, maintainOffset=False) cmds.delete(tempDelNeck, tempDelHead, tempDelJaw, tempDelChin, tempDelLLip, tempDelRLip) # zeroOut controls: self.zeroLipCtrlList = utils.zeroOut( [self.lLipCtrl, self.rLipCtrl]) self.lLipGrp = cmds.group(self.lLipCtrl, name=self.lLipCtrl + "_Grp") self.rLipGrp = cmds.group(self.rLipCtrl, name=self.rLipCtrl + "_Grp") self.zeroCtrlList = utils.zeroOut([ self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl, self.zeroLipCtrlList[0], self.zeroLipCtrlList[1] ]) # make joints be ride by controls: cmds.makeIdentity(self.neckJnt, self.headJxt, self.headJnt, self.jawJnt, self.chinJnt, self.endJnt, rotate=True, apply=True) cmds.parentConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt + "_ParentConstraint") cmds.scaleConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt + "_ScaleConstraint") cmds.delete( cmds.parentConstraint(self.headCtrl, self.headJxt, maintainOffset=False)) cmds.parentConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt + "_ParentConstraint") cmds.parentConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt + "_ParentConstraint") cmds.parentConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt + "_ParentConstraint") cmds.parentConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt + "_ParentConstraint") cmds.parentConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt + "_ParentConstraint") cmds.scaleConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt + "_ScaleConstraint") cmds.scaleConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt + "_ScaleConstraint") cmds.scaleConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt + "_ScaleConstraint") cmds.scaleConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt + "_ScaleConstraint") cmds.scaleConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt + "_ScaleConstraint") cmds.delete( cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False)) cmds.setAttr(self.jawJnt + ".segmentScaleCompensate", 0) # create interations between neck and head: self.grpNeck = cmds.group(self.zeroCtrlList[0], name=self.neckCtrl + "_Grp") self.grpHeadA = cmds.group(empty=True, name=self.headCtrl + "_A_Grp") self.grpHead = cmds.group(self.grpHeadA, name=self.headCtrl + "_Grp") # arrange pivots: self.neckPivot = cmds.xform(self.neckCtrl, query=True, worldSpace=True, translation=True) self.headPivot = cmds.xform(self.headCtrl, query=True, worldSpace=True, translation=True) cmds.xform(self.grpNeck, pivots=(self.neckPivot[0], self.neckPivot[1], self.neckPivot[2])) cmds.xform(self.grpHead, self.grpHeadA, pivots=(self.headPivot[0], self.headPivot[1], self.headPivot[2])) self.worldRef = cmds.group(empty=True, name=side + self.userGuideName + "_WorldRef") self.worldRefList.append(self.worldRef) cmds.delete( cmds.parentConstraint(self.neckCtrl, self.worldRef, maintainOffset=False)) cmds.parentConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, skipRotate=["x", "y", "z"], name=self.grpHeadA + "_ParentConstraint") orientConst = cmds.orientConstraint(self.neckCtrl, self.worldRef, self.grpHeadA, maintainOffset=False, name=self.grpHeadA + "_OrientConstraint")[0] cmds.scaleConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, name=self.grpHeadA + "_ScaleConstraint") cmds.parent(self.zeroCtrlList[1], self.grpHeadA, absolute=True) # connect reverseNode: cmds.addAttr(self.headCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, keyable=True) cmds.connectAttr(self.headCtrl + '.' + self.langDic[self.langName]['c_Follow'], orientConst + "." + self.neckCtrl + "W0", force=True) self.headRevNode = cmds.createNode('reverse', name=side + self.userGuideName + "_Rev") cmds.connectAttr(self.headCtrl + '.' + self.langDic[self.langName]['c_Follow'], self.headRevNode + ".inputX", force=True) cmds.connectAttr(self.headRevNode + '.outputX', orientConst + "." + self.worldRef + "W1", force=True) # mount controls hierarchy: cmds.parent(self.zeroCtrlList[3], self.jawCtrl, absolute=True) # jaw follow head or root ctrl (using worldRef) jawParentConst = cmds.parentConstraint( self.headCtrl, self.worldRef, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2] + "_ParentConstraint")[0] cmds.setAttr(jawParentConst + ".interpType", 2) #Shortest, no flip cause problem with scrubing cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType="float", minValue=0, maxValue=1, defaultValue=1, keyable=True) cmds.connectAttr(self.jawCtrl + "." + self.langDic[self.langName]['c_Follow'], jawParentConst + "." + self.headCtrl + "W0", force=True) jawFollowRev = cmds.createNode("reverse", name=self.jawCtrl + "_Rev") cmds.connectAttr(self.jawCtrl + "." + self.langDic[self.langName]['c_Follow'], jawFollowRev + ".inputX", force=True) cmds.connectAttr(jawFollowRev + ".outputX", jawParentConst + "." + self.worldRef + "W1", force=True) cmds.scaleConstraint(self.headCtrl, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2] + "_ScaleConstraint")[0] # setup jaw auto translation self.jawSdkGrp = cmds.group(self.jawCtrl, name=self.jawCtrl + "_SDK_Grp") cmds.addAttr( self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity'] + "Y", attributeType='float', keyable=True) cmds.addAttr( self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity'] + "Z", attributeType='float', keyable=True) cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName] ['c_moveStartRotation'], attributeType='float', keyable=True) cmds.setAttr(self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Y", keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Z", keyable=False, channelBox=True) cmds.setAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveStartRotation'], keyable=False, channelBox=True) cmds.setAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Y", 0.01) cmds.setAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Z", 0.02) cmds.setAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveStartRotation'], -10) self.jawIntensityMD = cmds.createNode( 'multiplyDivide', name="JawMoveIntensity_MD") self.jawIntensityZMD = cmds.createNode( 'multiplyDivide', name="JawMoveIntensityZ_MD") self.jawIntensityZInvMD = cmds.createNode( 'multiplyDivide', name="JawMoveIntensityZInv_MD") self.jawStartIntensityMD = cmds.createNode( 'multiplyDivide', name="JawMoveIntensityStart_MD") self.jawIntensityPMA = cmds.createNode( 'plusMinusAverage', name="JawMoveIntensity_PMA") self.jawIntensityCnd = cmds.createNode( 'condition', name="JawMoveIntensity_Cnd") cmds.connectAttr(self.jawCtrl + ".rotateY", self.jawIntensityMD + ".input1Y", force=True) cmds.connectAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Y", self.jawIntensityMD + ".input2Y", force=True) cmds.connectAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Y", self.jawStartIntensityMD + ".input1X", force=True) cmds.connectAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveStartRotation'], self.jawStartIntensityMD + ".input2X", force=True) cmds.setAttr(self.jawIntensityPMA + ".operation", 2) cmds.connectAttr(self.jawIntensityMD + ".outputY", self.jawIntensityPMA + ".input1D[0]", force=True) cmds.connectAttr(self.jawStartIntensityMD + ".outputX", self.jawIntensityPMA + ".input1D[1]", force=True) cmds.connectAttr(self.jawIntensityPMA + ".output1D", self.jawIntensityCnd + ".colorIfTrueG", force=True) cmds.connectAttr(self.jawCtrl + ".rotateY", self.jawIntensityCnd + ".firstTerm", force=True) cmds.connectAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveStartRotation'], self.jawIntensityCnd + ".secondTerm", force=True) cmds.setAttr(self.jawIntensityCnd + ".operation", 4) cmds.setAttr(self.jawIntensityCnd + ".colorIfFalseG", 0) cmds.connectAttr(self.jawIntensityCnd + ".outColorG", self.jawSdkGrp + ".translateX", force=True) cmds.connectAttr(self.jawIntensityCnd + ".outColorG", self.jawIntensityZMD + ".input1Z", force=True) cmds.connectAttr( self.jawCtrl + "." + self.langDic[self.langName]['c_moveIntensity'] + "Z", self.jawIntensityZMD + ".input2Z", force=True) cmds.connectAttr(self.jawIntensityZMD + ".outputZ", self.jawIntensityZInvMD + ".input1Z", force=True) cmds.setAttr(self.jawIntensityZInvMD + ".input2Z", -1) cmds.connectAttr(self.jawIntensityZInvMD + ".outputZ", self.jawSdkGrp + ".translateZ", force=True) # create lip setup: # left side lip: lLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp + "_ParentConstraint")[0] cmds.setAttr(lLipParentConst + ".interpType", 2) cmds.addAttr(self.lLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.lLipCtrl + '.' + self.langDic[self.langName]['c_Follow'], lLipParentConst + "." + self.jawCtrl + "W0", force=True) self.lLipRevNode = cmds.createNode( 'reverse', name=side + self.userGuideName + "_" + self.langDic[self.langName]['p002_left'] + "_" + self.langDic[self.langName]['c_lip'] + "_Rev") cmds.connectAttr(self.lLipCtrl + '.' + self.langDic[self.langName]['c_Follow'], self.lLipRevNode + ".inputX", force=True) cmds.connectAttr(self.lLipRevNode + '.outputX', lLipParentConst + "." + self.headCtrl + "W1", force=True) cmds.scaleConstraint(self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp + "_ScaleConstraint")[0] # right side lip: rLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp + "_ParentConstraint")[0] cmds.setAttr(rLipParentConst + ".interpType", 2) cmds.addAttr(self.rLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.rLipCtrl + '.' + self.langDic[self.langName]['c_Follow'], rLipParentConst + "." + self.jawCtrl + "W0", force=True) self.rLipRevNode = cmds.createNode( 'reverse', name=side + self.userGuideName + "_" + self.langDic[self.langName]['p003_right'] + "_" + self.langDic[self.langName]['c_lip'] + "_Rev") cmds.connectAttr(self.rLipCtrl + '.' + self.langDic[self.langName]['c_Follow'], self.rLipRevNode + ".inputX", force=True) cmds.connectAttr(self.rLipRevNode + '.outputX', rLipParentConst + "." + self.headCtrl + "W1", force=True) cmds.scaleConstraint(self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp + "_ScaleConstraint")[0] # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.worldRef, absolute=True) cmds.setAttr(loc + ".visibility", 0) ctrls.setLockHide([loc], [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v' ]) # hiding visibility attributes: ctrls.setLockHide([ self.headCtrl, self.neckCtrl, self.jawCtrl, self.chinCtrl ], ['v'], l=False) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group( self.grpNeck, self.grpHead, self.zeroCtrlList[2], self.zeroCtrlList[4], self.zeroCtrlList[5], name=side + self.userGuideName + "_Control_Grp") self.toScalableHookGrp = cmds.group( self.neckJnt, self.headJnt, self.lLipJnt, self.rLipJnt, name=side + self.userGuideName + "_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, self.grpHead, self.worldRef, name=side + self.userGuideName + "_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.grpHead, hookType='rootHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()