def __init__(self,startJoint,numS,ctrlName,ctrlChoice,sx,sy,sz,color,nx=None,ny=None,nz=None,redi=None): SpineIkRig.__init__(self, startJoint, numS, ctrlName, ctrlChoice, sx, sy, sz, color, nx, ny, nz, redi) self.bipCtrls = ['cog','hip','waist','torso','chest'] shapeChoise = [5,4,1,5,1] shapeColor = [18,18,17,17,14] self.bipCtrlsG = [] spineInctrlG = [dt.findParent(self.jntCtrls[0]).parent[0],dt.findParent(self.jntCtrls[2]).parent[0],dt.findParent(self.jntCtrls[1]).parent[0]] parentOrder = [0,0,2,3,1,3,0,1,0] for i in range(0,len(self.bipCtrls)): co.MakeCtrl(self.bipCtrls[i]+'_ctrl',shapeChoise[i],3,3,3,shapeColor[i],1,self.bipCtrls[i],0,1,0,1) self.bipCtrlsG.append(km.ApplyConstrain(self.bipCtrls[i]).makeOffGrp(2)) self.bipCtrlsG.extend(spineInctrlG) for i in range(0,len(self.bipCtrlsG)-1): cmds.parent(self.bipCtrlsG[i+1],self.bipCtrls[parentOrder[i]]) hipRefPiv = km.ApplyConstrain(self.jntCtrls[1]).makeConGrp(2,'hipPiv') torsoRefPiv = km.ApplyConstrain(self.jntCtrls[1]).makeConGrp(2,'torsoPiv') km.ApplyConstrain(hipRefPiv,self.bipCtrlsG[-1]).parentCon(1) km.ApplyConstrain(torsoRefPiv,self.bipCtrlsG[-1]).parentCon(1) dt.parentIT(hipRefPiv,self.bipCtrls[1]) dt.parentIT(torsoRefPiv,self.bipCtrls[3]) for i in range(0,len(self.bipCtrlsG)): dt.LockHide(self.bipCtrlsG[i],1,1,1,1,1,1,1,1,1,1) dt.LockHide(self.bipCtrls[0],0,0,0,0,0,0,1,1,1,1,1) dt.LockHide(self.bipCtrls[1],0,0,0,0,0,0,1,1,1,1,1) dt.LockHide(self.bipCtrls[2],1,1,1,0,0,0,1,1,1,1,1) dt.LockHide(self.bipCtrls[3],0,0,0,0,0,0,1,1,1,1,1) dt.LockHide(self.bipCtrls[4],1,1,1,0,0,0,1,1,1,1,1)
def __init__(self,startJoint,numS,ctrlName,ctrlChoice,sx,sy,sz,color,nx=None,ny=None,nz=None,redi=None): JointRigInfo.__init__(self, startJoint) self.numS = numS self.ctrlChoice = ctrlChoice self.sx = sx self.sy = sy self.sz =sz self.color = color self.ctrlName = ctrlName self.ctrls = [] self.nx = nx self.ny = ny self.nz = nz self.redi = redi kmo = km.IKSpline(self.stEd[0], self.stEd[1]) self.ikH = kmo.applyIk(self.numS) crv = co.CurveOperation(self.ikH[2]) self.jntCtrls = crv.curveSkinCtrls(0,self.ctrlName) for i in range(0,len(self.jntCtrls)): kmg = km.ApplyConstrain(self.jntCtrls[i]) kmg.makeOffGrp(2) co.MakeCtrl(self.jntCtrls[i]+'_ctrl',self.ctrlChoice,self.sx,self.sy,self.sz,self.color,1,self.jntCtrls[i],self.nx,self.ny,self.nz,self.redi) comctrl = co.CtrlLib('dummy').addDummyShape() comShape = co.ShapeFinder(comctrl).shape comShape = cmds.rename(comShape,(self.ctrlName+'_commanAt')) cmds.select(comShape) cmds.addAttr( longName= 'stretchy', at = 'enum', en = ('off:on'), k =1) for i in range(0,len(self.jntCtrls)): cmds.parent(comShape,self.jntCtrls[i],add=1,s=1) cmds.delete(comctrl) con = km.MakeDisNode(self.ikH[2]).curveDisNode() cmds.connectAttr((comShape+'.stretchy'),(con+'.firstTerm')) conAttr = con+'.outColorR' jo.jointScale(self.allJnts,'sx',conAttr) twisterJnt = [self.jntCtrls[0],self.jntCtrls[-1]] twistJnt = [self.stEd[0],self.stEd[1]] for i in range(0,2): grp = cmds.group(em =1, n =(twistJnt[i]+'Twist_g')) delCon = km.ApplyConstrain(twistJnt[i],grp).pointOriCon(0) cmds.delete(delCon[0],delCon[1]) cmds.parent(grp,twisterJnt[i]) cmds.setAttr(self.ikH[0]+'.dTwistControlEnable',1) cmds.setAttr(self.ikH[0]+'.dWorldUpType',4) cmds.connectAttr((twistJnt[0]+'Twist_g.worldMatrix[0]'),(self.ikH[0]+'.dWorldUpMatrix'),f=1) cmds.connectAttr((twistJnt[1]+'Twist_g.worldMatrix[0]'),(self.ikH[0]+'.dWorldUpMatrixEnd'),f=1)
def makeRefLine(self,stCtrl,edCtrl): self.ctrl = cmds.curve(d=1,p=[(0,0,0),(0,0,12)],k = [0,1], n = (self.name)) self.stCtrl = stCtrl self.edCtrl = edCtrl cmds.select(self.ctrl+'.cv[0]') stClu = cmds.cluster(n=(self.ctrl+'st_clu')) cmds.select(self.ctrl+'.cv[1]') edClu = cmds.cluster(n=(self.ctrl+'ed_clu')) km.ApplyConstrain(self.stCtrl,stClu).parentCon(0) km.ApplyConstrain(self.edCtrl,edClu).parentCon(0) cmds.setAttr(self.ctrl+'.overrideEnabled', 1) cmds.setAttr(self.ctrl+'.overrideDisplayType', 2) self.hkG = cmds.group(n = (stClu[1]+'_g'),em =1) dt.parentIT(stClu[1],self.hkG) dt.parentIT(edClu[1],self.hkG) return self.hkG
def jointRecreate(self, joint): prifix = 'new_' cmds.select(cl=1) self.newJnt = self.makeJnt(prifix + joint) print joint, self.newJnt aa = km.ApplyConstrain(joint, self.newJnt).pointOriCon(0) cmds.delete(aa[0], aa[1]) cmds.makeIdentity(apply=True, t=1, r=1, s=1) print 'I am recreating all joints'
def __init__(self,startJoint,numS,ctrlName,ctrlChoice,sx,sy,sz,color,nx=None,ny=None,nz=None,redi=None): BipedSpineIKFKRig.__init__(self, startJoint, numS, ctrlName, ctrlChoice, sx, sy, sz, color, nx, ny, nz, redi) self.bipCtrls = self.bipCtrls.append('midChestFK') self.bipCtrlsG.append(km.ApplyConstrain(self.bipCtrls[-1]).makeOffGrp(2)) dt.parentIT(self.bipCtrlsG[5],self.bipCtrls[2]) dt.parentIT(self.bipCtrlsG[3],self.bipCtrls[5]) # sel = cmds.ls(sl=1) # for i in range(0,len(sel)): # FkCtrlRig(sel[0],2,1,1,1,6,1,0,0,5) #aa = SpineIkRig('joint1',25,'ropeCtrl',2,0.1,0.1,0.1,17) #aa = BipedSpineIKRig('joint1',2,'spine',3,1,1,1,14,nx=None,ny=None,nz=None,redi=None)
def __init__(self, rigName, startJoint, poleCtrl, ctrlColor, rigParent, gCtrl=None): self.startJont = startJoint self.poleCtrl = poleCtrl self.ikFkCon = [] self.ctrlColor = ctrlColor self.gCtrl = gCtrl self.rigName = rigName self.rigParent = rigParent self.sourceJnt = jo.JointOperation().jointsInfo(self.startJont, 1) self.topG = km.ApplyConstrain(self.startJont).makeOffGrp( 2, (self.startJont + 'Rig')) # making IkHendle Ctrl self.ikHJnt = jo.JointOperation().makeDuplicateJointChaines( self.sourceJnt[2], self.sourceJnt[2], '_Ikctrl') #adding attributes cmds.select(self.ikHJnt[0]) km.AddDriverAttr(self.ikHJnt[0], 'upperLimb', 0, -10, 10, 'float') km.AddDriverAttr(self.ikHJnt[0], 'lowerLimb', 0, -10, 10, 'float') cmds.addAttr(ln='ikFK', at='enum', en='Ik:fk', k=1) km.AddDriverAttr(self.ikHJnt[0], 'stretchy', None, None, None, 'bool') co.MakeCtrl(self.ikHJnt[0] + '_ctrl', 2, 0.5, 0.5, 0.5, ctrlColor, 1, self.ikHJnt[0]) self.ikHJntG = km.ApplyConstrain(self.ikHJnt[0]).makeOffGrp(2) #make ikFk Chain and connect it to ikHandle self.ikJnt = jo.JointOperation().makeDuplicateJointChaines( self.startJont, self.startJont, '_ik') self.ikJntG = km.ApplyConstrain(self.ikJnt[0]).makeOffGrp(2) self.fkJnt = jo.JointOperation().makeDuplicateJointChaines( self.startJont, self.startJont, '_fk') self.fkJntG = km.ApplyConstrain(self.fkJnt[0]).makeOffGrp(2) cmds.parent(self.ikJntG, self.topG) cmds.parent(self.fkJntG, self.topG) self.rev = cmds.createNode('reverse', n=(self.startJont + 'ikFk_rev')) cmds.connectAttr((self.ikHJnt[0] + '.ikFK'), (self.rev + '.inputX')) for i in range(0, len(self.sourceJnt)): self.ikCon = km.ApplyConstrain(self.ikJnt[i], self.sourceJnt[i]).parentCon(0) self.fkCon = km.ApplyConstrain(self.fkJnt[i], self.sourceJnt[i]).parentCon(0) conW = cmds.parentConstraint(self.ikCon, q=1, wal=1) cmds.connectAttr((self.rev + '.outputX'), (self.ikCon[0] + '.' + conW[0])) cmds.connectAttr((self.ikHJnt[0] + '.ikFK'), (self.ikCon[0] + '.' + conW[1])) #make FK rig sp.FkCtrlRig(self.fkJnt[0], 1, 1, 1, 1, self.ctrlColor, 1, 0, 0, 2) cmds.connectAttr((self.ikHJnt[0] + '.ikFK'), (self.fkJntG + '.visibility')) km.ApplyConstrain(self.ikHJnt[0], self.ikJnt[2]).orientCon(0) co.MakeCtrl(self.poleCtrl + '_ctrl', 2, 0.5, 0.5, 0.5, ctrlColor, 1, self.poleCtrl) self.refLine = co.MakeCtrl(self.ikJnt[1] + 'Ref_ctrl', 6, 1, 1, 1, 13, startConCtrl=self.ikJnt[1], endConCtrl=self.poleCtrl) ikH = km.twoJointIk(self.ikJnt[0], self.poleCtrl) cmds.parent(ikH.ikH[0], self.ikHJnt[0]) self.poleCtrlG = km.ApplyConstrain(self.poleCtrl).makeOffGrp(2) km.ApplyConstrain(self.ikJntG, self.poleCtrlG).pointCon(1) km.ApplyConstrain(self.ikHJnt, self.poleCtrlG).pointCon(1) cmds.connectAttr((self.rev + '.outputX'), (self.ikJntG + '.visibility')) cmds.connectAttr((self.rev + '.outputX'), (self.ikHJntG + '.visibility')) cmds.connectAttr((self.rev + '.outputX'), (self.poleCtrlG + '.visibility')) cmds.connectAttr((self.rev + '.outputX'), (self.refLine.name + '.visibility')) #make fkJoint stretchy makeStetchyFK(self,attrName,scaleAxies) km.makeStretchy(self.fkJnt[0]).makeStetchyFK('stretch', 'scaleX') km.makeStretchy(self.ikJnt[0], self.gCtrl).makeStretchyIK(self.ikHJnt[0]) #Housekeeping Groups rigCG = [self.topG, self.ikHJntG, self.poleCtrlG] rigPG = [self.rigParent, self.rigParent, self.rigParent] rigG = [rigCG, rigPG] kinematicsG = [(self.ikJntG + '_disNode_g'), self.refLine.hkG] helperG = [self.refLine.ctrl] km.rigHouseKeeping(self.rigName).rigParent(rigG, kinematicsG, helperG) cmds.setAttr((ikH.ikH[0] + '.visibility'), 0)