def rigAll(self): neck, neckMiddle, head, eyeL, eyeR, eyeAimPiv = self.HeadInitCtlData.getSortList( ) aimObject = rigbase.makeAimObject(head, neck, axis=1, replaceTarget='InitCTL', replace='InitCtl')[0] aimObject = cmds.rename(aimObject, aimObject.replace('AimObj', 'AimGrp')) rigbase.betweenRigInAimObject(neckMiddle, aimObject, replaceTarget='InitCTL', replace='InitCtl') rigbase.AttrEdit(neckMiddle).lockAttrs('tx') aimObjectNeck = rigbase.makeAimObject(neckMiddle, neck, axis=1, replaceTarget='InitCTL', replace='InitCtl')[0] aimObjectNeckMiddle = rigbase.makeAimObject(head, neckMiddle, axis=1, replaceTarget='InitCTL', replace='InitCtl')[0] cmds.parent(eyeL, eyeR, eyeAimPiv, head) self.outputTransform = [neck, neckMiddle, head, eyeL, eyeR, eyeAimPiv]
def rigOther(self): collar_L, collar_R = self.torsoInitCtlData.getSortList()[-2:] shoulder_L = self.armInitCtlData.getSortList( '_L_' )[0] shoulder_R = self.armInitCtlData.getSortList( '_R_' )[0] aimObjectL = rigbase.makeAimObject( shoulder_L, collar_L, replaceTarget = 'InitCTL', replace='InitCtl' )[0] aimObjectR = rigbase.makeAimObject( shoulder_R, collar_R, replaceTarget = 'InitCTL', replace='InitCtl', inverseAim=1 )[0] rigbase.AttrEdit( aimObjectL, aimObjectR ).lockAttrs( 's' ) self.outputTransform += [ aimObjectL, aimObjectR ]
def rigLegPart(self, side ): inverseAim = False inverseUp = True globalMult = 1 if side.find( 'R' ) != -1: inverseAim= True inverseUp = False globalMult = -1 hip, knee, ankle, poleV = self.legInitCtlData.getSortList( side )[:4] upperLeg, lowerLeg = self.legInitCtlAdd.getSortList( side ) aimObjectOptions = { 'axis':0, 'upAxis':2, 'inverseAim':inverseAim, 'inverseUp':inverseUp, 'upType':'object', 'upObject':poleV, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } aimObject, anklePoseMltDcmp = rigbase.makeAimObject( ankle, hip, **aimObjectOptions ) aimObject = cmds.rename( aimObject, aimObject.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( knee, aimObject, dcmp = anklePoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) rigbase.AttrEdit( knee ).lockAttrs( 'ty' ) aimObjectKnee = rigbase.makeAimObject( ankle, knee, **aimObjectOptions )[0] aimObjectHip = rigbase.makeAimObject( knee, hip, **aimObjectOptions )[0] cmds.parent( upperLeg, aimObjectHip ) cmds.parent( lowerLeg, aimObjectKnee ) upperLegGrp = rigbase.addParent( upperLeg ) lowerLegGrp = rigbase.addParent( lowerLeg ) upperMtxDcmp = rigbase.getChildMtxDcmp( knee, aimObjectHip ) lowerMtxDcmp = rigbase.getChildMtxDcmp( ankle, aimObjectKnee ) upperMultMiddle = cmds.createNode( 'multiplyDivide', n=upperLeg.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) lowerMultMiddle = cmds.createNode( 'multiplyDivide', n=lowerLeg.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) cmds.connectAttr( upperMtxDcmp+'.ot', upperMultMiddle+'.input1' ) cmds.connectAttr( lowerMtxDcmp+'.ot', lowerMultMiddle+'.input1' ) cmds.setAttr( upperMultMiddle+'.input2', .5,.5,.5 ) cmds.setAttr( lowerMultMiddle+'.input2', .5,.5,.5 ) cmds.connectAttr( upperMultMiddle+'.output', upperLegGrp+'.t' ) cmds.connectAttr( lowerMultMiddle+'.output', lowerLegGrp+'.t' ) cmds.setAttr( upperLegGrp+'.r', 0,0,0 ) cmds.setAttr( lowerLegGrp+'.r', 0,0,0 ) if side.find( 'L' ) != -1: self.outputTransformL = [ aimObjectHip, aimObjectKnee, ankle, poleV ] self.outputAddTrL = [ upperLeg, lowerLeg ] cmds.transformLimits( knee, tz= [0.01,1], etz=[True, False] ) else: self.outputTransformR = [ aimObjectHip, aimObjectKnee, ankle, poleV ] self.outputAddTrR = [ upperLeg, lowerLeg ] cmds.transformLimits( knee, tz= [-1,0.01], etz=[False, True] )
def rigSide(self, side ): inverseAim = False inverseUp = False globalMult = 1 if side.find( 'R' ) != -1: inverseAim = True inverseUp = True globalMult = -1 shoulder, elbow, wrist, poleV = self.armInitCtlData.getSortList( side ) upperArm, lowerArm = self.armInitCtlAdd.getSortList( side ) aimObjectOptions = { 'axis':0, 'upAxis':2, 'inverseAim':inverseAim, 'inverseUp':inverseUp, 'upType':'object', 'upObject':poleV, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } aimObject, wristPoseMltDcmp = rigbase.makeAimObject( wrist, shoulder, **aimObjectOptions ) aimObject = cmds.rename( aimObject, aimObject.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( elbow, aimObject, dcmp = wristPoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) rigbase.AttrEdit( elbow ).lockAttrs( 'ty' ) aimObjectElbow = rigbase.makeAimObject( wrist, elbow, **aimObjectOptions )[0] aimObjectShoulder = rigbase.makeAimObject( elbow, shoulder, **aimObjectOptions )[0] cmds.parent( upperArm, aimObjectShoulder ) cmds.parent( lowerArm, aimObjectElbow ) upperArmGrp = rigbase.addParent( upperArm ) lowerArmGrp = rigbase.addParent( lowerArm ) upperMtxDcmp = rigbase.getChildMtxDcmp( elbow, aimObjectShoulder ) lowerMtxDcmp = rigbase.getChildMtxDcmp( wrist, aimObjectElbow ) upperMultMiddle = cmds.createNode( 'multiplyDivide', n=upperArm.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) lowerMultMiddle = cmds.createNode( 'multiplyDivide', n=lowerArm.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) cmds.connectAttr( upperMtxDcmp+'.ot', upperMultMiddle+'.input1' ) cmds.connectAttr( lowerMtxDcmp+'.ot', lowerMultMiddle+'.input1' ) cmds.setAttr( upperMultMiddle+'.input2', .5,.5,.5 ) cmds.setAttr( lowerMultMiddle+'.input2', .5,.5,.5 ) cmds.connectAttr( upperMultMiddle+'.output', upperArmGrp+'.t' ) cmds.connectAttr( lowerMultMiddle+'.output', lowerArmGrp+'.t' ) cmds.setAttr( upperArmGrp+'.r', 0,0,0 ) cmds.setAttr( lowerArmGrp+'.r', 0,0,0 ) if side.find( 'L' ) != -1: self.outputTransformL = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrL = [ upperArm, lowerArm ] cmds.transformLimits( elbow, tz= [-1,0.01], etz=[False, True] ) else: self.outputTransformR = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrR = [ upperArm, lowerArm ] cmds.transformLimits( elbow, tz= [0.01,1], etz=[True, False] )
def rigAll(self): neck, neckMiddle, head, eyeL, eyeR, eyeAimPiv = self.HeadInitCtlData.getSortList() aimObject= rigbase.makeAimObject( head, neck, axis=1, replaceTarget = 'InitCTL', replace='InitCtl' )[0] aimObject = cmds.rename( aimObject, aimObject.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( neckMiddle, aimObject, replaceTarget='InitCTL', replace='InitCtl' ) rigbase.AttrEdit( neckMiddle ).lockAttrs( 'tx' ) aimObjectNeck = rigbase.makeAimObject( neckMiddle, neck, axis=1, replaceTarget = 'InitCTL', replace='InitCtl' )[0] aimObjectNeckMiddle = rigbase.makeAimObject( head, neckMiddle, axis=1, replaceTarget = 'InitCTL', replace='InitCtl' )[0] cmds.parent( eyeL, eyeR, eyeAimPiv, head ) self.outputTransform = [ neck, neckMiddle, head, eyeL, eyeR, eyeAimPiv ]
def rigSelf(self): root, waist, chest = self.torsoInitCtlData.getSortList()[:3] aimObject = rigbase.makeAimObject( chest, root, axis=1, replaceTarget = 'InitCTL', replace='InitCtl' )[0] rigbase.betweenRigInAimObject( waist, aimObject, replaceTarget='InitCTL', replace='InitCtl' ) rigbase.AttrEdit( root, waist, chest ).lockAttrs( 'r', 's', 'tx' ) self.outputTransform = [ root, waist, chest ]
def rigOther(self): collar_L, collar_R = self.torsoInitCtlData.getSortList()[-2:] shoulder_L = self.armInitCtlData.getSortList('_L_')[0] shoulder_R = self.armInitCtlData.getSortList('_R_')[0] aimObjectL = rigbase.makeAimObject(shoulder_L, collar_L, replaceTarget='InitCTL', replace='InitCtl')[0] aimObjectR = rigbase.makeAimObject(shoulder_R, collar_R, replaceTarget='InitCTL', replace='InitCtl', inverseAim=1)[0] rigbase.AttrEdit(aimObjectL, aimObjectR).lockAttrs('s') self.outputTransform += [aimObjectL, aimObjectR]
def create(self, ctls ): inverse = False if ctls[0].name.find( '_R_' ) != -1: inverse = True self.aimObjs = [] for i in range( len( ctls )-1 ): base = ctls[i].name aimTarget = ctls[i+1].name aimObj, childDcmp = rigbase.makeAimObject( aimTarget, base, inverseAim=inverse ) self.aimObjs.append( aimObj )
def rigEachPart( self, index, side ): outputTransform = [] inverseAim = False globalMult = 1 if side.find( 'R' ) != -1: inverseAim = True globalMult = -1 aimObjectOptions = { 'axis':0, 'inverseAim':inverseAim, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } fingerInitCtlNameList = self.fingerInitCtlData.getEachFingerList( index, side ) firstFingerInitCtl = fingerInitCtlNameList[0] secondFingerInitCtl = fingerInitCtlNameList[1] betweenFingerInitCtls = fingerInitCtlNameList[2:-1] endFingerInitCtl = fingerInitCtlNameList[-1] aimObject0= rigbase.makeAimObject( secondFingerInitCtl, firstFingerInitCtl, **aimObjectOptions )[0] outputTransform.append( aimObject0 ) aimObject1 = rigbase.makeAimObject( endFingerInitCtl, secondFingerInitCtl, **aimObjectOptions )[0] aimObject1 = cmds.rename( aimObject1, aimObject1.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( betweenFingerInitCtls, aimObject1, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) for fingerInitCtl in betweenFingerInitCtls: rigbase.AttrEdit( fingerInitCtl ).lockAttrs( 'tz' ) if side.find( 'L' ) != -1: cmds.transformLimits( fingerInitCtl, ty= [0.01,1], ety=[True, False] ) else: cmds.transformLimits( fingerInitCtl, ty= [-1,0.01], ety=[False, True] ) betweenFingerInitCtls.append( endFingerInitCtl ) aimObjectParent = secondFingerInitCtl for fingerInitCtl in betweenFingerInitCtls: aimObject = rigbase.makeAimObject( fingerInitCtl, aimObjectParent, **aimObjectOptions )[0] aimObjectParent = fingerInitCtl outputTransform.append( aimObject ) outputTransform.append( endFingerInitCtl ) return outputTransform
def create(self, ctls): inverse = False if ctls[0].name.find('_R_') != -1: inverse = True self.aimObjs = [] for i in range(len(ctls) - 1): base = ctls[i].name aimTarget = ctls[i + 1].name aimObj, childDcmp = rigbase.makeAimObject(aimTarget, base, inverseAim=inverse) self.aimObjs.append(aimObj)
def rigSelf(self): root, waist, chest = self.torsoInitCtlData.getSortList()[:3] aimObject = rigbase.makeAimObject(chest, root, axis=1, replaceTarget='InitCTL', replace='InitCtl')[0] rigbase.betweenRigInAimObject(waist, aimObject, replaceTarget='InitCTL', replace='InitCtl') rigbase.AttrEdit(root, waist, chest).lockAttrs('r', 's', 'tx') self.outputTransform = [root, waist, chest]
def collarJointSet( self, jntNum, side ): if side == 'L': inverse = False si = 0 elif side == 'R': inverse = True si = 1 shoulderCtlList = [self.shoulderLCtl,self.shoulderRCtl] collarCtlList = [self.collarLCtl, self.collarRCtl] collarJntList = [self.collarLJnts, self.collarRJnts ] aimObject = rigbase.makeAimObject( shoulderCtlList[si], collarCtlList[si], inverseAim = inverse )[0] aimObject = cmds.rename( aimObject, "Shoulder_%s_CTL_AimObj" % side ) mtxDcmp = rigbase.getChildMtxDcmp( shoulderCtlList[si], aimObject ) cmds.setAttr( mtxDcmp+'.inverseDistance', inverse ) distSep = cmds.createNode( 'distanceSeparator', n='Collar_%s_DistSep' % side ) cmds.connectAttr( mtxDcmp+'.outputDistance', distSep+'.inputDistance' ) cmds.select( self.splineJnts[-1] ) collarJntList[si].append( cmds.joint( n='Collar0_%s_RJT' % side, radius=1.5 ) ) rigbase.constraint( aimObject, collarJntList[si][0] ) twistMult = cmds.createNode( 'multDoubleLinear', n='Collar_%s_twistMult' % side ) cmds.setAttr( twistMult+'.input2', 1.0/(len( collarJntList )-1) ) cmds.connectAttr( shoulderCtlList[si]+'.twistCollar', twistMult+'.input1' ) cmds.select( collarJntList[si][0] ) for i in range( jntNum-1 ): prValue = float(i+1)/jntNum jnt = cmds.joint( n='Collar%d_%s_RJT' %( i+1, side ), radius=1.5 ) collarJntList[si].append( jnt ) cmds.addAttr( jnt, ln='parameter', min=0, max=1, dv=prValue ) cmds.setAttr( jnt+'.parameter', e=1, k=1 ) cmds.connectAttr( jnt+'.parameter', distSep+'.pr[%d]' % (i+1) ) cmds.connectAttr( distSep+'.sd[%d]' % (i+1), jnt+'.tx', f=1 ) cmds.connectAttr( twistMult+'.output', jnt+'.rx' )
def rigLegPart(self, side): inverseAim = False inverseUp = True globalMult = 1 if side.find('R') != -1: inverseAim = True inverseUp = False globalMult = -1 hip, knee, ankle, poleV = self.legInitCtlData.getSortList(side)[:4] upperLeg, lowerLeg = self.legInitCtlAdd.getSortList(side) aimObjectOptions = { 'axis': 0, 'upAxis': 2, 'inverseAim': inverseAim, 'inverseUp': inverseUp, 'upType': 'object', 'upObject': poleV, 'replaceTarget': 'InitCTL', 'replace': 'InitCtl' } aimObject, anklePoseMltDcmp = rigbase.makeAimObject( ankle, hip, **aimObjectOptions) aimObject = cmds.rename(aimObject, aimObject.replace('AimObj', 'AimGrp')) rigbase.betweenRigInAimObject(knee, aimObject, dcmp=anklePoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult=globalMult) rigbase.AttrEdit(knee).lockAttrs('ty') aimObjectKnee = rigbase.makeAimObject(ankle, knee, **aimObjectOptions)[0] aimObjectHip = rigbase.makeAimObject(knee, hip, **aimObjectOptions)[0] cmds.parent(upperLeg, aimObjectHip) cmds.parent(lowerLeg, aimObjectKnee) upperLegGrp = rigbase.addParent(upperLeg) lowerLegGrp = rigbase.addParent(lowerLeg) upperMtxDcmp = rigbase.getChildMtxDcmp(knee, aimObjectHip) lowerMtxDcmp = rigbase.getChildMtxDcmp(ankle, aimObjectKnee) upperMultMiddle = cmds.createNode('multiplyDivide', n=upperLeg.replace( 'InitCTL', 'InitCtlMiddleMult')) lowerMultMiddle = cmds.createNode('multiplyDivide', n=lowerLeg.replace( 'InitCTL', 'InitCtlMiddleMult')) cmds.connectAttr(upperMtxDcmp + '.ot', upperMultMiddle + '.input1') cmds.connectAttr(lowerMtxDcmp + '.ot', lowerMultMiddle + '.input1') cmds.setAttr(upperMultMiddle + '.input2', .5, .5, .5) cmds.setAttr(lowerMultMiddle + '.input2', .5, .5, .5) cmds.connectAttr(upperMultMiddle + '.output', upperLegGrp + '.t') cmds.connectAttr(lowerMultMiddle + '.output', lowerLegGrp + '.t') cmds.setAttr(upperLegGrp + '.r', 0, 0, 0) cmds.setAttr(lowerLegGrp + '.r', 0, 0, 0) if side.find('L') != -1: self.outputTransformL = [aimObjectHip, aimObjectKnee, ankle, poleV] self.outputAddTrL = [upperLeg, lowerLeg] cmds.transformLimits(knee, tz=[0.01, 1], etz=[True, False]) else: self.outputTransformR = [aimObjectHip, aimObjectKnee, ankle, poleV] self.outputAddTrR = [upperLeg, lowerLeg] cmds.transformLimits(knee, tz=[-1, 0.01], etz=[False, True])
def getMtxDcmpInNeckSet(self): initAimObject = rigbase.makeAimObject( self.headInit, self.neckInit, axis=1, addName='AimObject' )[0] return rigbase.getChildMtxDcmp( self.neckMiddleInit, initAimObject )
def rigSide(self, side): inverseAim = False inverseUp = False globalMult = 1 if side.find('R') != -1: inverseAim = True inverseUp = True globalMult = -1 shoulder, elbow, wrist, poleV = self.armInitCtlData.getSortList(side) upperArm, lowerArm = self.armInitCtlAdd.getSortList(side) aimObjectOptions = { 'axis': 0, 'upAxis': 2, 'inverseAim': inverseAim, 'inverseUp': inverseUp, 'upType': 'object', 'upObject': poleV, 'replaceTarget': 'InitCTL', 'replace': 'InitCtl' } aimObject, wristPoseMltDcmp = rigbase.makeAimObject( wrist, shoulder, **aimObjectOptions) aimObject = cmds.rename(aimObject, aimObject.replace('AimObj', 'AimGrp')) rigbase.betweenRigInAimObject(elbow, aimObject, dcmp=wristPoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult=globalMult) rigbase.AttrEdit(elbow).lockAttrs('ty') aimObjectElbow = rigbase.makeAimObject(wrist, elbow, **aimObjectOptions)[0] aimObjectShoulder = rigbase.makeAimObject(elbow, shoulder, **aimObjectOptions)[0] cmds.parent(upperArm, aimObjectShoulder) cmds.parent(lowerArm, aimObjectElbow) upperArmGrp = rigbase.addParent(upperArm) lowerArmGrp = rigbase.addParent(lowerArm) upperMtxDcmp = rigbase.getChildMtxDcmp(elbow, aimObjectShoulder) lowerMtxDcmp = rigbase.getChildMtxDcmp(wrist, aimObjectElbow) upperMultMiddle = cmds.createNode('multiplyDivide', n=upperArm.replace( 'InitCTL', 'InitCtlMiddleMult')) lowerMultMiddle = cmds.createNode('multiplyDivide', n=lowerArm.replace( 'InitCTL', 'InitCtlMiddleMult')) cmds.connectAttr(upperMtxDcmp + '.ot', upperMultMiddle + '.input1') cmds.connectAttr(lowerMtxDcmp + '.ot', lowerMultMiddle + '.input1') cmds.setAttr(upperMultMiddle + '.input2', .5, .5, .5) cmds.setAttr(lowerMultMiddle + '.input2', .5, .5, .5) cmds.connectAttr(upperMultMiddle + '.output', upperArmGrp + '.t') cmds.connectAttr(lowerMultMiddle + '.output', lowerArmGrp + '.t') cmds.setAttr(upperArmGrp + '.r', 0, 0, 0) cmds.setAttr(lowerArmGrp + '.r', 0, 0, 0) if side.find('L') != -1: self.outputTransformL = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrL = [upperArm, lowerArm] cmds.transformLimits(elbow, tz=[-1, 0.01], etz=[False, True]) else: self.outputTransformR = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrR = [upperArm, lowerArm] cmds.transformLimits(elbow, tz=[0.01, 1], etz=[True, False])
def getMtxDcmpInNeckSet(self): initAimObject = rigbase.makeAimObject(self.headInit, self.neckInit, axis=1, addName='AimObject')[0] return rigbase.getChildMtxDcmp(self.neckMiddleInit, initAimObject)
def rigEachPart(self, index, side): outputTransform = [] inverseAim = False globalMult = 1 if side.find('R') != -1: inverseAim = True globalMult = -1 aimObjectOptions = { 'axis': 0, 'inverseAim': inverseAim, 'replaceTarget': 'InitCTL', 'replace': 'InitCtl' } fingerInitCtlNameList = self.fingerInitCtlData.getEachFingerList( index, side) firstFingerInitCtl = fingerInitCtlNameList[0] secondFingerInitCtl = fingerInitCtlNameList[1] betweenFingerInitCtls = fingerInitCtlNameList[2:-1] endFingerInitCtl = fingerInitCtlNameList[-1] aimObject0 = rigbase.makeAimObject(secondFingerInitCtl, firstFingerInitCtl, **aimObjectOptions)[0] outputTransform.append(aimObject0) aimObject1 = rigbase.makeAimObject(endFingerInitCtl, secondFingerInitCtl, **aimObjectOptions)[0] aimObject1 = cmds.rename(aimObject1, aimObject1.replace('AimObj', 'AimGrp')) rigbase.betweenRigInAimObject(betweenFingerInitCtls, aimObject1, replaceTarget='InitCTL', replace='InitCtl', globalMult=globalMult) for fingerInitCtl in betweenFingerInitCtls: rigbase.AttrEdit(fingerInitCtl).lockAttrs('tz') if side.find('L') != -1: cmds.transformLimits(fingerInitCtl, ty=[0.01, 1], ety=[True, False]) else: cmds.transformLimits(fingerInitCtl, ty=[-1, 0.01], ety=[False, True]) betweenFingerInitCtls.append(endFingerInitCtl) aimObjectParent = secondFingerInitCtl for fingerInitCtl in betweenFingerInitCtls: aimObject = rigbase.makeAimObject(fingerInitCtl, aimObjectParent, **aimObjectOptions)[0] aimObjectParent = fingerInitCtl outputTransform.append(aimObject) outputTransform.append(endFingerInitCtl) return outputTransform