def placeJoints(): placespineJoints() placeArmJoints() placeLegJoints() placeReverseFoot() #protect the user from themself mc.disable(placeJointsBtn, v=True) mc.disable(placeControlsBtn, v=False)
def finishAutoRig(): createspineJoints() createArmJoints() createLegJoints() createReverseFoot() createAndPlaceControls() connectJoints() deleteLocators() mc.select(clear=True) #selectMesh() #protect the user from themself mc.disable(autorigbtn, v=True)
def selectMesh(): global characterMesh characterMesh = mc.ls(sl=True) meshChildren = mc.ls(mc.listRelatives(characterMesh, ad=True, type="transform"), dag=True, lf=True, ni=True) print meshChildren #influences = [] #for i in SJ: #influences.append(i) #c = [] #c = mc.ls(mc.listRelatives(characterMesh, ad = True, type = "transform"), dag = True, lf = True, ni = True) #print c #for i in c: #print i #mc.skinCluster(influences,i, toSelectedBones=True, bindMethod=0, skinMethod=0, normalizeWeights=1) #WILL SMOOTH BIND INDIVIDUALLY. MAKE OPTION FOR UNNBIND #OR TELL THEM TO BIND SKIN THEN ENHANCE IT ###mc.skinCluster(characterMesh,mc.ls(sl=True), toSelectedBones=True, bindMethod=0, skinMethod=0, normalizeWeights=1, useGeometry = True) #mc.skinCluster(characterMesh,mc.ls(sl=True),smoothWeights = .1, bindMethod=0, skinMethod=0, normalizeWeights=1, weightDistribution = 0, dropoffRate = 1.0) tempSJ = [] tempSJ = LJR[:] + LJL[:] + AJR[:] + AJL[:] + SJ[1:] + RFL[:] + RFR[:] print "tempSJ: " + str(tempSJ) mc.bindSkin(characterMesh, tempSJ, tsb=True, cj=True) #cmds.select( ['pPlane1.vtx[5]', 'pPlane1.vtx[11]', 'pPlane1.vtx[17]', 'pPlane1.vtx[23]']) #cmds.percent( 'testCluster', v=0.5 ) #t = SJ[2:] #mc.flexor(t, type = "jointLattice", aj = True) mc.flexor(LJL[0], type="jointCluster", aj=True) mc.flexor(LJR[0], type="jointCluster", aj=True) mc.disable(bindMeshBtn, v=True)
def checkIfUpdateValid(arg): frame1 = cmds.intField(window_UI["first_frame"], query=True, value=True) frame2 = cmds.intField(window_UI["last_frame"], query=True, value=True) cmds.disable(window_UI["button"], v=frame1 >= frame2)
def controlsSetUp(): mc.select(clear=True) ##Make left arm Controls global shoulderLControl shoulderLControl = mc.circle(c=(0, 0, 0), r=3, nr=(1, 0, 0), n="shoulderLControl") mc.color(ud=2) global shoulderLControlGRP shoulderLControlGRP = mc.group(shoulderLControl, n="shoulderLControlGRP") global elbowLControl elbowLControl = mc.circle(c=(0, 0, 0), r=2, nr=(1, 0, 0), n="elbowLControl") mc.color(ud=2) global elbowLControlGRP elbowLControlGRP = mc.group(elbowLControl, n="elbowLControlGRP") global wristLControl wristLControl = mc.circle(c=(0, 0, 0), r=1, nr=(1, 0, 0), n="wristLControl") mc.color(ud=2) global wristLControlGRP wristLControlGRP = mc.group(wristLControl, n="wristLControlGRP") global armControlL armControlL = mc.curve( d=1, n="armControlL", p=((-0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5))) mc.color(ud=2) global armControlLGRP armControlLGRP = mc.group(armControlL, n="armControlRGRP") ##Position left arm Controls / Constrain Orientation/rotation #Note: Doesn't "work" if IK already exists(constraint that is) pos = mc.pointPosition(armJointsL[0]) mc.move(pos[0], pos[1], pos[2], shoulderLControlGRP) pos = mc.pointPosition(armJointsL[1]) mc.move(pos[0], pos[1], pos[2], elbowLControlGRP) #parent elbow group to shoulder so it doesn't bend weirdly pos = mc.pointPosition(armJointsL[2]) mc.move(pos[0], pos[1], pos[2], wristLControlGRP) pos = mc.pointPosition(armJointsL[2]) mc.move(pos[0], pos[1], pos[2], armControlLGRP) ##Make right arm Controls global shoulderRControl shoulderRControl = mc.circle(c=(0, 0, 0), r=3, nr=(1, 0, 0), n="shoulderRControl") mc.color(ud=2) global shoulderRControlGRP shoulderRControlGRP = mc.group(shoulderRControl, n="shoulderRControlGRP") global elbowRControl elbowRControl = mc.circle(c=(0, 0, 0), r=2, nr=(1, 0, 0), n="elbowRControl") mc.color(ud=2) global elbowRControlGRP elbowRControlGRP = mc.group(elbowRControl, n="elbowRControlGRP") global wristRControl wristRControl = mc.circle(c=(0, 0, 0), r=1, nr=(1, 0, 0), n="wristRControl") mc.color(ud=2) global wristRControlGRP wristRControlGRP = mc.group(wristRControl, n="wristRControlGRP") global armControlR armControlR = mc.curve( d=1, n="armControlR", p=((-0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5))) mc.color(ud=2) global armControlRGRP armControlRGRP = mc.group(armControlR, n="armControlRGRP") ##Position right arm Controls / Constrain Orientation/rotation pos = mc.pointPosition(armJointsR[0]) mc.move(pos[0], pos[1], pos[2], shoulderRControlGRP) pos = mc.pointPosition(armJointsR[1]) mc.move(pos[0], pos[1], pos[2], elbowRControlGRP) #parent elbow group to shoulder so it doesn't bend weirdly pos = mc.pointPosition(armJointsR[2]) mc.move(pos[0], pos[1], pos[2], wristRControlGRP) pos = mc.pointPosition(armJointsR[2]) mc.move(pos[0], pos[1], pos[2], armControlRGRP) #Make and position poleVectorarm/GRP control Left global PoleVectorControlElbowL PoleVectorControlElbowL = mc.circle(c=(0, 0, 0), r=2, nr=(0, 0, 1), n="PoleVectorControlElbowL") mc.color(ud=2) numSections = int(mc.circle(PoleVectorControlElbowL, q=True, s=True)) mc.select(clear=True) for i in range(0, numSections, 2): vtxName = PoleVectorControlElbowL[0] + ".cv[%d]" % i print vtxName mc.select(vtxName) mc.scale(.25, .25, .25) pos = mc.pointPosition(armJointsL[1]) global PoleVectorControlElbowLGRP PoleVectorControlElbowLGRP = mc.group(PoleVectorControlElbowL, n="PoleVectorControlElbowLGRP") mc.move(pos[0], pos[1], pos[2] - 7, PoleVectorControlElbowLGRP) #print ikarmL #creates constraint but make sure to use all functions #Make and position poleVectorarm/GRP control Right global PoleVectorControlElbowR PoleVectorControlElbowR = mc.circle(c=(0, 0, 0), r=2, nr=(0, 0, 1), n="PoleVectorControlElbowR") mc.color(ud=2) numSections = int(mc.circle(PoleVectorControlElbowR, q=True, s=True)) mc.select(clear=True) for i in range(0, numSections, 2): vtxName = PoleVectorControlElbowR[0] + ".cv[%d]" % i print vtxName mc.select(vtxName) mc.scale(.25, .25, .25) pos = mc.pointPosition(armJointsR[1]) global PoleVectorControlElbowRGRP PoleVectorControlElbowRGRP = mc.group(PoleVectorControlElbowR, n="PoleVectorControlElbowRGRP") mc.move(pos[0], pos[1], pos[2] - 7, PoleVectorControlElbowRGRP) #creates constraint #Make and position poleVectorleg/GRP control Left global PoleVectorControlKneeL PoleVectorControlKneeL = mc.circle(c=(0, 0, 0), r=2, nr=(0, 0, 1), n="PoleVectorControlKneeL") mc.color(ud=2) numSections = int(mc.circle(PoleVectorControlKneeL, q=True, s=True)) mc.select(clear=True) for i in range(0, numSections, 2): vtxName = PoleVectorControlKneeL[0] + ".cv[%d]" % i print vtxName mc.select(vtxName) mc.scale(.25, .25, .25) pos = mc.pointPosition(legJointsL[1]) global PoleVectorControlKneeLGRP PoleVectorControlKneeLGRP = mc.group(PoleVectorControlKneeL, n="PoleVectorControlKneeLRP") mc.move(pos[0], pos[1], pos[2] + 7, PoleVectorControlKneeLGRP) #creates constraint #Make and position poleVectorleg/GRP control Right global PoleVectorControlKneeR PoleVectorControlKneeR = mc.circle(c=(0, 0, 0), r=2, nr=(0, 0, 1), n="PoleVectorControlKneeR") mc.color(ud=2) numSections = int(mc.circle(PoleVectorControlKneeR, q=True, s=True)) mc.select(clear=True) for i in range(0, numSections, 2): vtxName = PoleVectorControlKneeR[0] + ".cv[%d]" % i print vtxName mc.select(vtxName) mc.scale(.25, .25, .25) pos = mc.pointPosition(legJointsR[1]) global PoleVectorControlKneeRGRP PoleVectorControlKneeRGRP = mc.group(PoleVectorControlKneeR, n="PoleVectorControlKneeRGRP") mc.move(pos[0], pos[1], pos[2] + 7, PoleVectorControlKneeRGRP) #creates constraint global footControlL footControlL = cmds.curve( d=3, n="footControlL", p=((-1.943975, 0, 0.0455116), (-1.793015, 0, 0.908818), (-1.823946, 0, 1.548806), (-2.057076, 0, 2.392609), (-2.460573, 0, 2.723015), (-3.024632, 0, 2.692013), (-3.700054, 0, 2.114125), (-3.994695, 0, 0.148922), (-3.454195, 0, -0.489267), (-3.478549, 0, -1.560035), (-3.48116, 0, -2.460689), (-2.992802, 0, -3.098902), (-2.240181, 0, -2.859905), (-1.947866, 0, -2.029168), (-2.022896, 0, -0.986165), (-2.162509, 0, -0.255072), (-1.943975, 0, 0.0455116))) mc.move(2.899, 0, 0, footControlL) mc.xform(cp=True) mc.makeIdentity(footControlL, apply=True) mc.color(rgb=(1, 1, 1)) global footControlLGRP footControlLGRP = mc.group(footControlL, n="footControlLGRP") mc.scale(-1, 1, 1, footControlLGRP) mc.makeIdentity(footControlLGRP, apply=True) pos = mc.pointPosition(reverseFootL[2]) mc.move(pos[0], 0, 0, footControlLGRP) pivLoc = mc.pointPosition(reverseFootL[0]) mc.xform(footControlL, piv=(pivLoc[0], pivLoc[1], pivLoc[2]), ws=True) global footControlR footControlR = cmds.curve( d=3, n="footControlR", p=((-1.943975, 0, 0.0455116), (-1.793015, 0, 0.908818), (-1.823946, 0, 1.548806), (-2.057076, 0, 2.392609), (-2.460573, 0, 2.723015), (-3.024632, 0, 2.692013), (-3.700054, 0, 2.114125), (-3.994695, 0, 0.148922), (-3.454195, 0, -0.489267), (-3.478549, 0, -1.560035), (-3.48116, 0, -2.460689), (-2.992802, 0, -3.098902), (-2.240181, 0, -2.859905), (-1.947866, 0, -2.029168), (-2.022896, 0, -0.986165), (-2.162509, 0, -0.255072), (-1.943975, 0, 0.0455116))) mc.move(2.899, 0, 0, footControlR) mc.xform(cp=True) mc.makeIdentity(footControlR, apply=True) mc.color(rgb=(1, 1, 1)) global footControlRGRP footControlRGRP = mc.group(footControlR, n="footControlRGRP") pos = mc.pointPosition(reverseFootR[2]) mc.move(pos[0], 0, 0, footControlRGRP) pivLoc = mc.pointPosition(reverseFootR[0]) mc.xform(footControlR, piv=(pivLoc[0], pivLoc[1], pivLoc[2]), ws=True) ##Head Control global headControl headControl = mc.circle(c=(0, 0, 0), r=4.25, nr=(0, 1, 1), n="headControl1") mc.color(ud=2) global headControlGRP headControlGRP = mc.group(headControl, n="headControlGRP1") pos = mc.pointPosition(spineJoints[7]) mc.move(pos[0], pos[1], pos[2] + 1, headControlGRP) mc.rotate(-20, 0, 0, headControlGRP) mc.makeIdentity(headControlGRP, apply=True) #back Control global backControl backControl = mc.curve(d=1, n="backControl1", p=[(-0.5, 0, 0), (-0.5, 0, 2), (-2, 0, 2), (0, 0, 4), (2, 0, 2), (0.5, 0, 2), (0.5, 0, 0), (0.5, 0, -2), (2, 0, -2), (0, 0, -4), (-2, 0, -2), (-0.5, 0, -2), (-0.5, 0, 0)]) mc.color(ud=2) mc.rotate(0, 0, 90, backControl) mc.scale(1.5, 1.5, 1.5, backControl) mc.makeIdentity(backControl, apply=True) global backControlGRP backControlGRP = mc.group(backControl, n="backControl1GRP") pos = mc.pointPosition(spineJoints[5]) mc.move(pos[0], pos[1], pos[2] - 10, backControlGRP) #hip sway global hipSwayControl hipSwayControl = mc.curve(d=1, n="hipSwayControl1", p=[(-0.5, 0, 0), (-0.5, 0, 2), (-2, 0, 2), (0, 0, 4), (2, 0, 2), (0.5, 0, 2), (0.5, 0, 0), (0.5, 0, -2), (2, 0, -2), (0, 0, -4), (-2, 0, -2), (-0.5, 0, -2), (-0.5, 0, 0)]) mc.color(ud=2) mc.rotate(0, 90, 0, hipSwayControl) mc.scale(1.5, 1.5, 1.5, hipSwayControl) mc.makeIdentity(hipSwayControl, apply=True) global hipSwayControlGRP hipSwayControlGRP = mc.group(hipSwayControl, n="hipSwayControl1GRP") pos = mc.pointPosition(spineJoints[0]) mc.move(pos[0], pos[1] + 2, pos[2] - 1, hipSwayControlGRP) #abs global abscontrol abscontrol = mc.curve( d=3, n="abscontrol1", p=((-0.800913, 0, 7.056141), (-0.265406, 0, 7.325259), (0.31672, 0, 7.381502), (0.764173, 0, 7.27759), (1.183554, 0, 7.139143), (1.516483, 0, 6.925935), (1.76147, 0, 6.690399), (2.254724, 0, 6.334697), (2.57931, 0, 5.947814), (3.076661, 0, 5.483984), (3.227577, 0, 4.977719), (3.300189, 0, 4.332524), (3.156193, 0, 4.004192), (2.940126, 0, 3.544301), (2.459935, 0, 2.906238), ( 1.896194, 0, 2.722403, ), (1.173682, 0, 2.752672), (0.684217, 0, 2.91142), (0.359928, 0, 3.021365), (-0.212499, 0, 2.901779), (-0.970966, 0, 2.743327), (-1.336932, 0, 2.71509), (-2.105246, 0, 2.809993), (-2.53423, 0, 3.129236), (-2.848996, 0, 3.602111), (-3.083789, 0, 4.152694), (-3.072619, 0, 4.767065), (-2.864968, 0, 5.335299), (-2.460608, 0, 5.822106), (-2.017293, 0, 6.187691), (-1.388328, 0, 6.681923), (-0.803558, 0, 7.068739))) mc.color(ud=2) mc.move(0, 0, -5, abscontrol) mc.xform(abscontrol, cp=True) mc.makeIdentity(abscontrol, apply=True) global abscontrolGRP abscontrolGRP = mc.group(abscontrol, n="abscontrol1GRP") pos = mc.pointPosition(spineJoints[1]) mc.move(pos[0], pos[1] + 2, pos[2], abscontrolGRP) #chest control global chestControl chestControl = mc.curve( d=1, n="chestControl1", p=((1.308362, 42.005806, -0.0656287), (4.160191, 39.377197, 0.987189), (3.880039, 39.364937, -4.688682), (1.153233, 42.340385, -3.206603), (1.308362, 42.005806, -0.0656287), (-1.146977, 41.999775, 0.132541), (-3.87119, 39.357468, 1.6354), (4.160191, 39.377197, 0.987189), (1.308362, 42.005806, -0.0656287), (-1.146977, 41.999775, 0.132541), (-1.302106, 42.334351, -3.008433), (1.153233, 42.340385, -3.206603), (3.880039, 39.364937, -4.688682), (-4.151342, 39.345207, -4.040471), (-1.302106, 42.334351, -3.008433), (-1.146977, 41.999775, 0.132541), (-3.87119, 39.357468, 1.6354), (-4.151342, 39.345207, -4.040471), (3.880039, 39.364937, -4.688682), (4.160191, 39.377197, 0.987189), (-3.87119, 39.357468, 1.6354), (-1.363567, 33.493797, 0.483978), (1.562515, 33.500984, 0.247815), (4.160191, 39.377197, 0.987189), (3.880039, 39.364937, -4.688682), (1.377832, 33.492905, -3.49385), (1.562515, 33.500984, 0.247815), (-1.363567, 33.493797, 0.483978), (-3.87119, 39.357468, 1.6354), (-4.151342, 39.345207, -4.040471), (-1.54825, 33.485714, -3.257687), (-1.363567, 33.493797, 0.483978), (1.562515, 33.500984, 0.247815), (1.377832, 33.492905, -3.49385), (-1.54825, 33.485714, -3.257687), (-4.151342, 39.345207, -4.040471), (3.880039, 39.364937, -4.688682), (1.377832, 33.492905, -3.49385))) mc.color(ud=2) mc.move(0, -40, 0, chestControl) mc.xform(chestControl, cp=True) mc.makeIdentity(chestControl, apply=True) global chestControlGRP chestControlGRP = mc.group(chestControl, n="chestControl1GRP") pos = mc.pointPosition(spineJoints[4]) mc.move(pos[0], pos[1] + 3, pos[2] + 2, chestControlGRP) #pelvis control global pelvisControl pelvisControl = mc.curve( d=1, n="pelvisControl1", p=((1.687394, 31.104399, 0.844462), (-2.107084, 31.088993, 1.042498), (-2.305122, 31.088993, -2.752012), (1.489357, 31.104399, -2.950047), (1.687394, 31.104399, 0.844462), (4.509414, 28.431793, 0.772943), (4.248509, 28.431793, -3.001678), (1.489357, 31.104399, -2.950047), (-2.305122, 31.088993, -2.752012), (-5.098434, 28.391262, -2.68199), (-4.837529, 28.391262, 1.09263), (-2.107084, 31.088993, 1.042498), (-2.305122, 31.088993, -2.752012), (-5.098434, 28.391262, -2.68199), (4.248509, 28.431793, -3.001678), (4.509414, 28.431793, 0.772943), (-4.837529, 28.391262, 1.09263), (-2.081861, 26.484615, 1.041182), (1.712618, 26.500021, 0.843146), (4.509414, 28.431793, 0.772943), (4.248509, 28.431793, -3.001678), (1.51458, 26.500021, -2.951364), (-2.279898, 26.484615, -2.753328), (-5.098434, 28.391262, -2.68199), (-4.837529, 28.391262, 1.09263), (-2.081861, 26.484615, 1.041182), (-2.279898, 26.484615, -2.753328), (1.51458, 26.500021, -2.951364), (1.712618, 26.500021, 0.843146), (-2.081861, 26.484615, 1.041182))) mc.color(ud=2) mc.move(0, -30, 0, pelvisControl) mc.xform(pelvisControl, cp=True) mc.makeIdentity(pelvisControl, apply=True) global pelvisControlGRP pelvisControlGRP = mc.group(pelvisControl, n="pelvisControl1GRP") pos = mc.pointPosition(spineJoints[1]) mc.move(pos[0], pos[1], pos[2] + 1, pelvisControlGRP) mc.disable(placeControlsBtn, v=True) mc.disable(autorigbtn, v=False)
#unBindBtn = mc.button(l = "Unbind", w = 150, h = 30, c = "unBind()") mc.text(l="Quit: ") mc.button(l="Exit", w=150, h=30, c="quitBtn()", bgc=(.45, 0, 0)) mc.menu(label='Help', tearOff=True) mc.menuItem(divider=True) aboutMenu = mc.menuItem('Application..."', label='About', itl=True, c="helpMenu()") mc.showWindow(myWindow) mc.disable(placeControlsBtn, v=True) mc.disable(autorigbtn, v=True) spineJoints = [] #positioning armJointsL = [] #positioning armJointsR = [] #positioning legJointsL = [] #positioning legJointsR = [] #positioning reverseFootL = [] #Reverse foot positioning reverseFootR = [] #Reverse foot positioning SJ = [] #spine joints RFL = [] #RF joint RFR = [] #RF joint AJL = [] #arm joint AJR = [] #arm joint LJL = [] #leg joint
def enableDisableIndivSelect(num,*args): btnList = ["bc_Btn", "rough_Btn", "metal_Btn", "norm_Btn", "opac_Btn", "trans_Btn", 'ao_Btn'] if num == 1: for btn in btnList : cmds.disable(btn , v = False) for shader in txtFieldList: cmds.textField( shader , edit = True, enable = True) cmds.textField("ShaderDirectory", edit = True, enable = False) cmds.disable("sd_Btn", v = True) elif num == 0: #Disable Btns and Dialog for btn in btnList : cmds.disable(btn , v = True) for shader in txtFieldList: cmds.textField( shader , edit = True, enable = False) cmds.textField("ShaderDirectory", edit = True, enable = True) cmds.disable("sd_Btn", v = False) elif num == 2: #Disable and clear Btns and Dialog for btn in btnList : cmds.disable(btn , v = True) for shader in txtFieldList: cmds.textField( shader , edit = True, text = "", enable = False) cmds.textField("Height", edit = True, text = "", enable = False) cmds.textField("ShaderDirectory", edit = True,text = "", enable = True) cmds.disable("sd_Btn", v = False) cmds.textField("texName", edit = True, text = "") cmds.checkBox("udimCB", edit = True, value = False) cmds.checkBox("indivFilesCB", edit = True, value = False)