def createIK(self): # create IK RPs = ikHandleMaker( self.IkHindLegJointList[0], self.IkHindLegJointList[2], 'ikRPsolver' ) self.RPsName = cmds.rename( RPs[0], self.IkHindLegJointList[0].replace( 'JNT', 'RP_HDL' ) ) RPsEffectorName = cmds.rename( RPs[1], self.IkHindLegJointList[0].replace( 'JNT', 'RP_IKEFFECTOR' ) ) # subRP sRPs = ikHandleMaker( self.subIkJointList[1], self.subIkJointList[3], 'ikRPsolver' ) self.sRPsName = cmds.rename( sRPs[0], self.subIkJointList[0].replace( 'JNT', 'RP_HDL' ) ) sRPsEffectorName = cmds.rename( sRPs[1], self.subIkJointList[0].replace( 'JNT', 'SS_IKEFFECTOR' ) ) # sc self.SCsNameList = [] for x in range(3): SCs = ikHandleMaker( self.IkHindLegJointList[x+2], self.IkHindLegJointList[x+3], 'ikSCsolver' ) SCsName = cmds.rename( SCs[0], self.IkHindLegJointList[x+2].replace( 'JNT', 'SC_HDL' ) ) SCsEffectorName = cmds.rename( SCs[1], self.IkHindLegJointList[x+2].replace( 'JNT', 'SC_IKEFFECTOR' ) ) self.SCsNameList.append( SCsName )
def setIK(self,*jnt): buffer=[] copied=[] tmp=cmds.listRelatives (jnt[0],c=1,ad=1) c=jnt[0] buffer.append(c) for i in range(len(tmp)): if jnt[-1] in c: break else: c=cmds.listRelatives (c,c=True) buffer.append(c[0]) #조인트 복사 및 중복된 네임 정리 for e in buffer: name=e.split('_')[0]+'_IK_'+e.split('_')[2] dup= cmds.duplicate (e,n=name,rr=True,rc=True) tmp= setUniqueName(dup[0],'JNT') par= cmds.listRelatives (tmp,p=True,typ='joint') chi= cmds.listRelatives (tmp,c=True,typ='joint') if par is not None: if len(copied) is not 0: cmds.parent (tmp,copied[-1]) if cmds.connectionInfo (tmp+'.inverseScale',id=True) is False: cmds.connectAttr (copied[-1]+'.scale',tmp+'.inverseScale',f=True) if chi is not None: cmds.delete (chi) copied.append(tmp) cmds.parent(copied[0],'IKJoint_GRP') tmp= ikHandleMaker( copied[0], copied[-1], 'ikRPsolver' ) hdl= cmds.rename (tmp[0],copied[-1].replace('JNT','HDL')) cmds.setAttr (hdl+'.v',0) cmds.parent (hdl,'auxillary_GRP') self.IkCon=ikControllerMaker( copied[-1] ,hdl) #connect stretchy st=stretchyLock() if cmds.objExists (self.IkCon[0][1].replace('_CON','_LOC')) is True: st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2]) else: tempString= cmds.spaceLocator (n=self.IkCon[0][1].replace('_CON','_LOC')) cmds.parent (tempString,self.IkCon[0][1].replace('_CON','Sub_CON')) st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2]) return self.IkCon[0]
def createIK(self): # create IK RPs = ikHandleMaker(self.IkForeLegJointList[0], self.IkForeLegJointList[2], 'ikRPsolver') self.RPsName = cmds.rename( RPs[0], self.IkForeLegJointList[0].replace('JNT', 'RP_HDL')) RPsEffectorName = cmds.rename( RPs[1], self.IkForeLegJointList[0].replace('JNT', 'RP_IKEFFECTOR')) SCs1 = ikHandleMaker(self.IkForeLegJointList[2], self.IkForeLegJointList[3], 'ikSCsolver') self.SCs1Name = cmds.rename( SCs1[0], self.IkForeLegJointList[2].replace('JNT', 'SC_HDL')) SCs1EffectorName = cmds.rename( SCs1[1], self.IkForeLegJointList[2].replace('JNT', 'SC_IKEFFECTOR')) SCs2 = ikHandleMaker(self.IkForeLegJointList[3], self.IkForeLegJointList[4], 'ikSCsolver') self.SCs2Name = cmds.rename( SCs2[0], self.IkForeLegJointList[3].replace('JNT', 'SC_HDL')) SCs2EffectorName = cmds.rename( SCs2[1], self.IkForeLegJointList[3].replace('JNT', 'SC_IKEFFECTOR')) SCs3 = ikHandleMaker(self.IkForeLegJointList[4], self.IkForeLegJointList[5], 'ikSCsolver') self.SCs3Name = cmds.rename( SCs3[0], self.IkForeLegJointList[4].replace('JNT', 'SC_HDL')) SCs3EffectorName = cmds.rename( SCs3[1], self.IkForeLegJointList[4].replace('JNT', 'SC_IKEFFECTOR')) G_RP = ikHandleMaker(self.subIkJointList[0], self.subIkJointList[2], 'ikRPsolver') self.G_RPName = cmds.rename( G_RP[0], self.subIkJointList[0].replace('JNT', 'RP_HDL')) G_RPEffectorName = cmds.rename( G_RP[1], self.subIkJointList[0].replace('JNT', 'RP_IKEFFECTOR'))
def L_ikHindLegOP(): hindLegIkJointList = [ 'L_IK_hip_JNT', 'L_IK_knee_JNT', 'L_IK_ankle_JNT', 'L_IK_ball_JNT', 'L_IK_toe_JNT', 'L_IK_toeTip_JNT' ] footTemplateLocLict = [ 'L_hindLeg_inSideRollTemple', 'L_hindLeg_outSideRollTemple', 'L_hindLeg_heelRollTemple', 'L_hindLeg_toeRollTemple', 'L_hindLeg_footTwistTemple', 'L_hindLeg_ballRollTemple', 'L_hindLeg_toeTabTemple' ] # separate duplicate for ikSpringSolver sSJointList = [] dList = cmds.duplicate(hindLegIkJointList[0], renameChildren=True) for x in range(len(dList)): rN = cmds.rename(dList[x], dList[x].replace('IK', 'rig')[0:-1]) sSJointList.append(rN) cmds.delete(sSJointList[4]) del sSJointList[4:] # create IK RPs = ikHandleMaker(hindLegIkJointList[0], hindLegIkJointList[2], 'ikRPsolver') RPsName = cmds.rename(RPs[0], hindLegIkJointList[0].replace('JNT', 'RP_HDL')) RPsEffectorName = cmds.rename( RPs[1], hindLegIkJointList[0].replace('JNT', 'RP_IKEFFECTOR')) SCs1 = ikHandleMaker(hindLegIkJointList[2], hindLegIkJointList[3], 'ikSCsolver') SCs1Name = cmds.rename(RPs[0], hindLegIkJointList[2].replace('JNT', 'SC_HDL')) SCs1EffectorName = cmds.rename( RPs[1], hindLegIkJointList[2].replace('JNT', 'SC_IKEFFECTOR')) SCs2 = ikHandleMaker(hindLegIkJointList[3], hindLegIkJointList[4], 'ikSCsolver') SCs2Name = cmds.rename(RPs[0], hindLegIkJointList[3].replace('JNT', 'SC_HDL')) SCs2EffectorName = cmds.rename( RPs[1], hindLegIkJointList[3].replace('JNT', 'SC_IKEFFECTOR')) SCs3 = ikHandleMaker(hindLegIkJointList[4], hindLegIkJointList[5], 'ikSCsolver') SCs3Name = cmds.rename(RPs[0], hindLegIkJointList[4].replace('JNT', 'SC_HDL')) SCs3EffectorName = cmds.rename( RPs[1], hindLegIkJointList[4].replace('JNT', 'SC_IKEFFECTOR')) mel.eval('ikSpringSolver;') Ss = cmds.ikHandle(sj=sSJointList[0], ee=sSJointList[3], sol='ikSpringSolver') SsName = cmds.rename(RPs[0], sSJointList[0].replace('JNT', 'SS_HDL')) SsEffectorName = cmds.rename( RPs[1], sSJointList[0].replace('JNT', 'SS_IKEFFECTOR')) #################################################################################################################################### IST = footTemplateLocLict[0] OST = footTemplateLocLict[1] HRT = footTemplateLocLict[2] TRT = footTemplateLocLict[3] FTT = footTemplateLocLict[4] BRT = footTemplateLocLict[5] TTT = cmds.spaceLocator(n=footTemplateLocLict[6]) pSnap(TTT[0], hindLegIkJointList[-2]) #################################################################################################################################### # create pivot positon pivotList = [] pivotNulList = [] for x in range(len(footTemplateLocLict)): PL = cmds.group(em=True, n=footTemplateLocLict[x].replace('Temple', '_PIVOT')) pSnap(PL, footTemplateLocLict[x]) pivotList.append(PL) for x in range(len(pivotList) - 1): cmds.parent(pivotList[x + 1], pivotList[x]) for x in range(len(pivotList)): PH = homeNul(pivotList[x]) pivotNulList.append(PH) cmds.parent(SCs2Name, pivotList[5]) cmds.parent(SCs3Name, pivotList[-1]) anklePivotName = cmds.group(em=True, n='L_ankleRoll_main_PIVOT') anklePos = cmds.xform(hindLegIkJointList[3], t=True, ws=True, q=True) cmds.move(anklePos[0], anklePos[1], anklePos[2], anklePivotName) cmds.parent(anklePivotName, sSJointList[2]) homeNul(anklePivotName) # create controller haindLegControllerName = controllerShape( hindLegIkJointList[3].replace('ball_JNT', 'hindLeg_CON'), 'cube', 'blue') cmds.move(anklePos[0], anklePos[1], anklePos[2], haindLegControllerName) hipContollerName = controllerShape( hindLegIkJointList[0].replace('JNT', 'CON'), 'cube', 'blue') hipPos = cmds.xform(hindLegIkJointList[0], t=True, ws=True, q=True) cmds.move(hipPos[0], hipPos[1], hipPos[2], hipContollerName) kneePVContollerName = controllerShape( hindLegIkJointList[1].replace('JNT', 'CON'), 'sphere', 'blue') kneePVPos = cmds.xform(hindLegIkJointList[1], t=True, ws=True, q=True) cmds.move(kneePVPos[0], kneePVPos[1], kneePVPos[2], kneePVContollerName) # controller homeNull homeNul(haindLegControllerName) homeNul(hipContollerName) homeNul(kneePVContollerName) # constraints & grouping cmds.parent(pivotNulList[0], haindLegControllerName) cmds.pointConstraint(hipContollerName, hindLegIkJointList[0]) cmds.pointConstraint(hipContollerName, sSJointList[0]) cmds.poleVectorConstraint(kneePVContollerName, SsName) cmds.poleVectorConstraint(sSJointList[1], RPsName) cmds.parent(SsName, pivotList[5]) cmds.parent(RPsName, anklePivotName) # add Attr cmds.addAttr(haindLegControllerName, longName='foot', at='enum', en='Controls', keyable=True) cmds.setAttr('%s.foot' % haindLegControllerName, lock=True) cmds.addAttr(haindLegControllerName, longName='leg', at='enum', en='Angle', keyable=True) cmds.setAttr('%s.leg' % haindLegControllerName, lock=True) cmds.addAttr(haindLegControllerName, longName='angle', at='double', keyable=True, attributeType='float', min=-10, max=10, dv=0) SAB0 = cmds.createNode('setRange', n=haindLegControllerName.replace( '_CON', 'SAB0_RNG')) SAB1 = cmds.createNode('setRange', n=haindLegControllerName.replace( '_CON', 'SAB1_RNG')) cmds.setAttr('%s.minX' % SAB0, 0) cmds.setAttr('%s.maxX' % SAB0, 1) cmds.setAttr('%s.oldMinX' % SAB0, -10) cmds.setAttr('%s.oldMaxX' % SAB0, 10) cmds.setAttr('%s.minX' % SAB1, 1) cmds.setAttr('%s.maxX' % SAB1, 0) cmds.setAttr('%s.oldMinX' % SAB1, -10) cmds.setAttr('%s.oldMaxX' % SAB1, 10) cmds.connectAttr('%s.angle' % haindLegControllerName, '%s.valueX' % SAB0) cmds.connectAttr( '%s.outValue.outValueX' % SAB0, '%s.springAngleBias[0].springAngleBias_FloatValue' % SsName) cmds.connectAttr('%s.angle' % haindLegControllerName, '%s.valueX' % SAB1) cmds.connectAttr( '%s.outValue.outValueX' % SAB1, '%s.springAngleBias[1].springAngleBias_FloatValue' % SsName)
def setIK(self, *jnt): buffer = [] copied = [] crv = '' tmp = cmds.listRelatives(jnt[0], c=1, ad=1) c = jnt[0] buffer.append(c) for i in range(len(tmp)): if jnt[-1] in c: break else: c = cmds.listRelatives(c, c=True) buffer.append(c[0]) #조인트 복사 및 중복된 네임 정리 for e in buffer: name = e.split('_')[0] + '_IK_' + e.split('_')[2] dup = cmds.duplicate(e, n=name, rr=True, rc=True) tmp = setUniqueName(dup[0], 'JNT') par = cmds.listRelatives(tmp, p=True, typ='joint') chi = cmds.listRelatives(tmp, c=True, typ='joint') if par is not None: if len(copied) is not 0: cmds.parent(tmp, copied[-1]) if cmds.connectionInfo(tmp + '.inverseScale', id=True) is False: cmds.connectAttr(copied[-1] + '.scale', tmp + '.inverseScale', f=True) if chi is not None: cmds.delete(chi) copied.append(tmp) #커브 그리기 for i in range(len(copied)): pos = cmds.xform(copied[i], q=True, ws=True, t=True) if copied[i] is copied[0]: tmp = cmds.curve(n='C_IK_spineCurve', d=1, p=pos) crv = setUniqueName(tmp, 'CRV') else: cmds.curve(crv, a=True, p=pos) cmds.parent(copied[0], 'IKJoint_GRP') tmp = ikHandleMaker(copied[0], copied[-1], 'ikSplineSolver', crv) hdl = cmds.rename(tmp[0], copied[0].replace('JNT', 'HDL')) cmds.parent(crv, hdl, 'auxillary_GRP') #컨트롤러 생성 / 스플라인 커브 컨트롤 셋 self.IkCon = neckControllerMaker(crv, hdl) cmds.delete( cmds.orientConstraint(jnt[1], self.IkCon[1].replace('_CON', '_NUL'), w=True, o=(0, -90, -90))) cmds.orientConstraint(self.IkCon[1], copied[1], mo=True) #스플라인 스트레치 연결 st = splineStretchy() st.stretchy(self.IkCon[1], crv, copied[0]) return self.IkCon
def setIK(self,*jnt): buffer=[] copied=[] tmp=cmds.listRelatives (jnt[0],c=1,ad=1) c=jnt[0] buffer.append(c) for i in range(len(tmp)): if jnt[-1] in c: break else: c=cmds.listRelatives (c,c=True) buffer.append(c[0]) #조인트 복사 및 중복된 네임 정리 for e in buffer: name=e.split('_')[0]+'_IK_'+e.split('_')[2] dup= cmds.duplicate (e,n=name,rr=True,rc=True) tmp= setUniqueName(dup[0],'JNT') par= cmds.listRelatives (tmp,p=True,typ='joint') chi= cmds.listRelatives (tmp,c=True,typ='joint') if par is not None: if len(copied) is not 0: cmds.parent (tmp,copied[-1]) if cmds.connectionInfo (tmp+'.inverseScale',id=True) is False: cmds.connectAttr (copied[-1]+'.scale',tmp+'.inverseScale',f=True) if chi is not None: cmds.delete (chi) copied.append(tmp) cmds.parent(copied[0],'IKJoint_GRP') tmp= ikHandleMaker( copied[0], copied[-2], 'ikRPsolver' ) hdl= cmds.rename (tmp[0],copied[-2].replace('JNT','HDL')) cmds.setAttr (hdl+'.v',0) cmds.parent (hdl,'auxillary_GRP') self.IkCon=ikControllerMaker( copied[-2] ,hdl) otherCon= fkControllerMaker( 'circle', 'yellow', [copied[-1]] ) cmds.delete(otherCon[2]) cmds.orientConstraint (otherCon[0],copied[-1],w=True) ballUp= controllerShape(otherCon[0][0].replace('_CON','RollUp_CON'),'hexagon', 'yellow' ) ballUp_Nul= homeNul (ballUp) cmds.delete(cmds.pointConstraint (copied[-1],ballUp_Nul,w=True)) cmds.rotate (90,0,0,ballUp+'.cv[*]',os=1) heelUp= controllerShape(self.IkCon[0][1].replace('_CON','RollUp_CON'),'hexagon', 'yellow' ) heelUp_Nul= homeNul (heelUp) cmds.delete(cmds.pointConstraint (copied[-2],heelUp_Nul,offset=(0,-1,-1),w=True)) cmds.rotate (90,0,0,heelUp+'.cv[*]',os=1) self.IkCon[0].append(str(otherCon[0][0])) self.IkCon[1].append(str(otherCon[1][0])) cmds.parent (self.IkCon[1][3],ballUp_Nul,heelUp_Nul,self.IkCon[0][0]) #rolling up roll=addRollingUp() tmp=roll.rollUp(self.IkCon[0][1].replace('_CON','_LOC'),ballUp,heelUp) cmds.parent (tmp,'roll_GRP') #attach shoulder tmp=attachPart2(heelUp ,self.IkCon[1][3] , 'translate','rotate','scale','shear') cmds.parent(tmp,'attach_GRP') #connect stretchy st=stretchyLock() if cmds.objExists (self.IkCon[0][1].replace('_CON','_LOC')) is True: st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2]) else: tempString= cmds.spaceLocator (n=self.IkCon[0][1].replace('_CON','_LOC')) cmds.parent (tempString,self.IkCon[0][1].replace('_CON','Sub_CON')) st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2]) n=noneFlip() n.setup(self.IkCon[0][1].replace('_CON','_LOC'),copied[0],self.IkCon[0][2]) cmds.rotate (90,0,0,self.IkCon[0][3]+'.cv[*]',os=1) return self.IkCon[0]
def createController(self): # create controller foreLegControllerName = controllerShape( self.IkForeLegJointList[3].replace('foot1_JNT', 'foreLeg_CON'), 'cube', 'blue') cmds.move(self.wristPos[0], self.wristPos[1], self.wristPos[2], foreLegControllerName) shoulderContollerName = controllerShape( self.IkForeLegJointList[0].replace('JNT', 'CON'), 'rombus', 'blue') shoulderPos = cmds.xform(self.IkForeLegJointList[0], t=True, ws=True, q=True) cmds.move(shoulderPos[0], shoulderPos[1], shoulderPos[2], shoulderContollerName) elbowPVContollerName = controllerShape( self.IkForeLegJointList[1].replace('JNT', 'CON'), 'sphere', 'blue') elbowPVPos = cmds.xform(self.IkForeLegJointList[1], t=True, ws=True, q=True) cmds.move(elbowPVPos[0], elbowPVPos[1], elbowPVPos[2], elbowPVContollerName) # controller homeNull homeNul(foreLegControllerName) shoulderContollerNul = homeNul(shoulderContollerName) homeNul(elbowPVContollerName) # constraints & grouping cmds.parent(self.pivotNulList[0], foreLegControllerName) cmds.pointConstraint(self.clavicleIkJointList[1], self.IkForeLegJointList[0]) cmds.pointConstraint(self.clavicleIkJointList[1], self.subIkJointList[0]) cmds.poleVectorConstraint(elbowPVContollerName, self.G_RPName) cmds.poleVectorConstraint(elbowPVContollerName, self.RPsName) # add attr cmds.addAttr(foreLegControllerName, longName='foot', at='enum', en='Controls', keyable=True) cmds.setAttr('%s.foot' % foreLegControllerName, lock=True) ######################################################################################################################### # create clavicle controller clavicleControllerName = controllerShape( self.clavicleIkJointList[0].replace('JNT', 'CON'), 'cube', 'blue') Psnap(clavicleControllerName, self.clavicleIkJointList[0]) clavicleControllerRotZNul = homeNul( clavicleControllerName, clavicleControllerName.replace('_CON', 'RotZ_NUL')) clavicleControllerNul = homeNul( clavicleControllerRotZNul, clavicleControllerName.replace('_CON', '_NUL')) # create clavicle cmds.aimConstraint(foreLegControllerName, clavicleControllerRotZNul, mo=True, worldUpType='none', skip=['x', 'y']) cmds.setKeyframe('%s.rz' % clavicleControllerRotZNul) cmds.disconnectAttr('pairBlend1_inRotateZ1.output', 'pairBlend1.inRotateZ1') cmds.delete('pairBlend1_inRotateZ1') cmds.rename('pairBlend1', 'L_clvicleRotZ_PBD') # add attr autoClavicle cmds.addAttr(foreLegControllerName, longName='auto', at='enum', en='Shoulder', keyable=True) cmds.setAttr('%s.foot' % foreLegControllerName, lock=True) cmds.addAttr(foreLegControllerName, longName='front', at='double', keyable=True, attributeType='float', min=0, max=1, dv=0.5) # connection cmds.connectAttr('%s.front' % foreLegControllerName, '%s.blendAim1' % clavicleControllerRotZNul) clavicleSc = ikHandleMaker(self.clavicleIkJointList[0], self.clavicleIkJointList[1], 'ikSCsolver') clavicleScName = cmds.rename( clavicleSc[0], self.clavicleIkJointList[0].replace('JNT', 'SC_HDL')) clavicleScEffectorName = cmds.rename( clavicleSc[1], self.clavicleIkJointList[0].replace('JNT', 'SC_IKEFFECTOR')) cmds.pointConstraint(clavicleControllerName, self.clavicleIkJointList[0], mo=True) cmds.parent(clavicleScName, clavicleControllerName) cmds.pointConstraint(shoulderContollerName, clavicleScName, mo=True) cmds.parent(shoulderContollerNul, clavicleControllerName) # create foot controller wristPivotName wristRollCONT = controllerShape( self.wristPivotName.replace('PIVOT', 'CON'), 'cube', 'yellow') cvNum = cmds.getAttr('%s.spans' % wristRollCONT) + cmds.getAttr( '%s.degree' % wristRollCONT) cmds.select('%s.cv[0:%s]' % (wristRollCONT, cvNum - 1)) cmds.scale(0.5, 0.5, 0.5) cmds.select(cl=True) cmds.parent('%sShape' % wristRollCONT, self.wristPivotName, r=True, s=True) cmds.delete(wristRollCONT) wristRollCON = cmds.rename(self.wristPivotName, self.wristPivotName.replace('PIVOT', 'CON')) for x in range(len(self.pivotList)): CONT = controllerShape(self.pivotList[x].replace('PIVOT', 'CON'), 'cube', 'yellow') cvNum = cmds.getAttr('%s.spans' % CONT) + cmds.getAttr( '%s.degree' % CONT) cmds.select('%s.cv[0:%s]' % (CONT, cvNum - 1)) cmds.scale(0.5, 0.5, 0.5) cmds.select(cl=True) cmds.parent('%sShape' % CONT, self.pivotList[x], r=True, s=True) cmds.delete(CONT) wristRollCON = cmds.rename( self.pivotList[x], self.pivotList[x].replace('PIVOT', 'CON'))
def setIK(self, *jnt): buffer = [] copied = [] crv = '' tmp = cmds.listRelatives(jnt[0], c=1, ad=1) c = jnt[0] buffer.append(c) for i in range(len(tmp)): if jnt[-1] in c: break else: c = cmds.listRelatives(c, c=True) buffer.append(c[0]) #조인트 복사 및 중복된 네임 정리 for e in buffer: name = e.split('_')[0] + '_IK_' + e.split('_')[2] dup = cmds.duplicate(e, n=name, rr=True, rc=True) tmp = setUniqueName(dup[0], 'JNT') par = cmds.listRelatives(tmp, p=True, typ='joint') chi = cmds.listRelatives(tmp, c=True, typ='joint') if par is not None: if len(copied) is not 0: cmds.parent(tmp, copied[-1]) if cmds.connectionInfo(tmp + '.inverseScale', id=True) is False: cmds.connectAttr(copied[-1] + '.scale', tmp + '.inverseScale', f=True) if chi is not None: cmds.delete(chi) copied.append(tmp) #커브 그리기 for i in range(len(copied)): pos = cmds.xform(copied[i], q=True, ws=True, t=True) if i is 0: continue elif copied[i] is copied[1]: tmp = cmds.curve(n='C_IK_spineCurve', d=3, p=pos) crv = setUniqueName(tmp, 'CRV') else: cmds.curve(crv, a=True, p=pos) cmds.parent(copied[0], 'IKJoint_GRP') tmp = ikHandleMaker(copied[1], copied[-1], 'ikSplineSolver', crv) hdl = cmds.rename(tmp[0], copied[0].replace('JNT', 'HDL')) cmds.parent(crv, hdl, 'auxillary_GRP') #컨트롤러 생성 / 스플라인 커브 컨트롤 셋 cons = splineControllerMaker(crv, hdl) #스플라인 스트레치 연결 st = splineStretchy() st.stretchy(cons[1], crv, copied[1], copied[2], copied[3]) #힙 컨트롤러 생성 buf = controllerShape('C_IK_hip', 'square', 'yellow') hip = setUniqueName(buf, 'CON') hipNul = homeNul(hip) cmds.delete(cmds.parentConstraint(cons[0], hipNul, w=True)) cmds.parentConstraint(hip, copied[0], mo=True) cmds.parent(hipNul, cons[0]) cmds.orientConstraint(cons[1], copied[-1], mo=True) #루트 컨트롤러 생성 cmds.delete(cmds.parentConstraint(cons[0], 'root_NUL', w=True)) cons.append(hip) #return control curves return cons
def createIkSpineSet(self): IKH = ikHandleMaker(self.spineJointList[1], self.spineJointList[-1], 'ikSplineSolver') print IKH IKH = [u'ikHandle1', u'effector1', u'curve1'] handleName = cmds.rename(IKH[0], 'C_IK_spine1_HDL') effectorName = cmds.rename(IKH[1], 'C_IK_spine1_EFFECTOR') curveName = cmds.rename(IKH[2], 'C_IK_spine1_CRV') cmds.rebuildCurve(curveName, s=2, d=3) locatorName = curveToLocatorFix(curveName) print locatorName cmds.parent(curveName, w=True) for x in range(len(locatorName)): NUL = homeNul(locatorName[x]) self.locatorNulList.append(NUL) # Advanced Twist Controls Set upLoc = cmds.spaceLocator(n=self.upBody.replace('CON', 'aTwist_LOC')) POsnap(upLoc, self.spineJointList[-1]) cmds.parent(upLoc, self.upBodySubCon) #[u'C_IK_root_JNT', u'C_IK_spine1_JNT', u'C_IK_spine2_JNT', u'C_IK_spine3_JNT', u'C_IK_chest_JNT'] lowLoc = cmds.spaceLocator(n=self.lowBody.replace('CON', 'aTwist_LOC')) POsnap(lowLoc, self.spineJointList[1]) cmds.parent(lowLoc, self.lowBodySubCon) cmds.setAttr('%s.dTwistControlEnable' % handleName, 1) cmds.setAttr('%s.dWorldUpType' % handleName, 4) cmds.setAttr('%s.dWorldUpAxis' % handleName, 0) cmds.setAttr('%s.dWorldUpVectorX' % handleName, 0) cmds.setAttr('%s.dWorldUpVectorY' % handleName, 1) cmds.setAttr('%s.dWorldUpVectorZ' % handleName, 0) cmds.setAttr('%s.dWorldUpVectorEndX' % handleName, 0) cmds.setAttr('%s.dWorldUpVectorEndY' % handleName, 1) cmds.setAttr('%s.dWorldUpVectorEndZ' % handleName, 0) cmds.connectAttr('%s.worldMatrix' % lowLoc[0], '%s.dWorldUpMatrix' % handleName) cmds.connectAttr('%s.worldMatrix' % upLoc[0], '%s.dWorldUpMatrixEnd' % handleName) # cmds.orientConstraint(self.upBodySubCon, self.spineJointList[-1], mo=True) #print self.locatorNulList[u'C_IK_spine1_NUL', u'C_IK_spine2_NUL', u'C_IK_spine3_NUL', u'C_IK_spine4_NUL'] AP_low0 = attachPart(self.lowBodySubCon, self.locatorNulList[0], 'translate', 'rotate', 'scale', 'shear') AP_low1 = attachPart(self.lowBodySubCon, self.locatorNulList[1], 'translate', 'rotate', 'scale', 'shear') AP_up4 = attachPart(self.upBodySubCon, self.locatorNulList[3], 'translate', 'rotate', 'scale', 'shear') AP_up5 = attachPart(self.upBodySubCon, self.locatorNulList[4], 'translate', 'rotate', 'scale', 'shear') cmds.parentConstraint(self.hipCon, self.spineJointList[0], mo=True) #...... AP_lowBoy = attachPart(self.spineControllerList[0], self.lowBodyNul, 'translate', 'rotate', 'scale', 'shear') AP_upBoy = attachPart(self.spineControllerList[0], self.upBodyNul, 'translate', 'rotate', 'scale', 'shear') #... #noneScaleSpineGroup = cmds.group( handleName, curveName, self.locatorNulList[0], self.locatorNulList[1], self.locatorNulList[2], self.locatorNulList[3], # self.locatorNulList[4], self.locatorNulList[5], name='noneScaleSpine_GRP' ) """ cmds.parent( noneScaleSpineGroup, 'noneScale_GRP' ) cmds.parent( self.spineJointList[0], 'C_IK_spineJoint_GRP' ) cmds.parent( self.spineControllerNulList[0], 'C_move_CON' ) cmds.parent( self.lowBodyNul, 'C_IK_spineController_GRP' ) cmds.parent( self.upBodyNul, 'C_IK_spineController_GRP' ) cmds.parent( AP_low0, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_low1, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_low2, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_up3, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_up4, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_up5, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_lowBoy, 'C_IK_spineAttach_GRP' ) cmds.parent( AP_upBoy, 'C_IK_spineAttach_GRP' ) """ spineMiddleCon = controllerShape('C_IK_spineMiddle_CON', 'hexagon', 'yellow') print spineMiddleCon #POsnap( spineMiddleCon, self.locatorNulList[2] ) cmds.delete( cmds.parentConstraint(self.upBody, self.lowBody, spineMiddleCon)) spineMiddleConNul = homeNul(spineMiddleCon) cmds.parentConstraint(self.upBodySubCon, self.lowBodySubCon, spineMiddleConNul, mo=True) attachPart(spineMiddleCon, self.locatorNulList[2], 'translate', 'rotate', 'scale', 'shear') mySpineJnt1 = 'C_template_spine1_JNT' mySpineJnt2 = 'C_template_spine2_JNT' mySpineJnt3 = 'C_template_spine3_JNT' mySpineJnt4 = 'C_template_spine4_JNT' myChestJnt = 'C_template_chest_JNT' # make nul mySpineNul1 = cmds.group(em=True, name='C_FKsub_spine1_NUL') cmds.delete( cmds.parentConstraint(self.spineTempJointList[1], mySpineNul1)) mySpineNul2 = cmds.group(em=True, name='C_FKsub_spine2_NUL') cmds.delete( cmds.parentConstraint(self.spineTempJointList[1], self.spineTempJointList[4], mySpineNul2)) mySpineNul3 = cmds.group(em=True, name='C_FKsub_spine3_NUL') cmds.delete( cmds.parentConstraint(self.spineTempJointList[7], self.spineTempJointList[4], mySpineNul3)) myChestNul = cmds.group(em=True, name='C_FKsub_chest_NUL') cmds.delete( cmds.parentConstraint(self.spineTempJointList[7], myChestNul)) # nul parent cmds.parent(myChestNul, mySpineNul3) cmds.parent(mySpineNul3, mySpineNul2) cmds.parent(mySpineNul2, mySpineNul1)