def rigBook(containers): center = createJointChain(name='center') left = createJointChain(name='left') right = createJointChain(name='right') ctrl = containers["ctrl"] pm.addAttr(containers["ctrl"], ln="_", at="enum", en="______" ) pm.setAttr(containers["ctrl"]+"._", e=1, keyable=1) for page in range(pages): pageName = 'page'+str(page) skin = createJointChain(pageName+"_") rigPage(skin, center, left, right, ctrl, pageName) paper = createPaper(pageName) pm.select(skin, r=1, hi=1) pm.select(paper, add=1, ) pm.bindSkin(toAll = 1, colorJoints = 1) pm.select(cl=1) pm.parent(paper, containers["paper_grp"]) pm.parent(skin[0], containers["pages_grp"]) pm.select(cl=1) print "rigged: %s" % pageName pm.parent(center[0], containers["pageTargets_grp"]) pm.parent(left[0], containers["pageTargets_grp"]) pm.parent(right[0], containers["pageTargets_grp"])
def bind(skin_dict): unbind(skin_dict) for model,binds in skin_dict.iteritems(): print model if RIGID in binds: for joint_,meshes in binds[RIGID].iteritems(): joint_ = "%s%s" % (joint_,bind_post) meshes_named = [] for mesh in meshes: meshes_named.append("%s%s" % (model,mesh)) try: pm.bindSkin(joint_,meshes_named, toSelectedBones=True, doNotDescend=True) except Exception as e: print 'Rigid Bind:',e #print joint_, meshes_named if SMOOTH in binds: for mesh, joints in binds[SMOOTH].iteritems(): #mesh = "%s%s" % (model,mesh) joints_named = [] for joint_ in joints: joints_named.append('%s%s' % (joint_,bind_post)) try: print 'mesh',mesh #mesh = pm.select(mesh) #print 'pmmesh',mesh pm.skinCluster( mesh, joints_named, toSelectedBones=True, #maximumInfluences=len(joints_named)) maximumInfluences=2, frontOfChain=False) except Exception as e: print 'Smooth Bind:',e
def unbind(skin_dict): for model,binds in skin_dict.iteritems(): print model if RIGID in binds: for joint_,meshes in binds[RIGID].iteritems(): meshes_named = [] for mesh in meshes: meshes_named.append("%s%s" % (model,mesh)) try: pm.bindSkin(meshes_named, unbind=True) except Exception as e: print 'Rigid Unbind:',e #print joint_, meshes_named if SMOOTH in binds: for mesh, joints in binds[SMOOTH].iteritems(): try: pm.skinCluster("%s%s" % (model,mesh), edit=True,unbind=True) except Exception as e: print 'Smooth Unbind:',e
def make_chain_surface(cls, spans=10): count = 1 nurbs = pm.nurbsPlane(u=1, v=spans, lr=5, n="surface") geo = pm.PyNode(nurbs[0]) fols = [] fol_shapes = [] while count < spans: fol = pm.createNode('transform', n='follicle1', ss=True) fol_shape = pm.createNode('follicle', name="folicle_shape", p=fol, ss=True) pm.connectAttr(geo.local, fol_shape.inputSurface) pm.connectAttr(geo.worldMatrix[0], fol_shape.inputWorldMatrix) pm.connectAttr(fol_shape.outRotate, fol.rotate) pm.connectAttr(fol_shape.outTranslate, fol.translate) fol.inheritsTransform.set(False) fol_shape.parameterU.set(0.5) fol_shape.parameterV.set(0.1 * count) fols.append(fol) fol_shapes.append(fol_shapes) count += 1 nurbs_jnts = Chain.make_jnt_chain( fols, name_template="_surface_{number}_JNT") for nurbs_JNT, fol in zip(nurbs_jnts[0:], fols[:-1]): nurbs_JNT.setParent(fol) drivers = [] driver_a_jnt = pm.duplicate(nurbs_jnts[0], name="driver_A") driver_b_jnt = pm.duplicate(nurbs_jnts[(spans / 2) - 1], name="driver_B") driver_c_jnt = pm.duplicate(nurbs_jnts[-1], name="driver_C") drivers.append(driver_a_jnt) drivers.append(driver_b_jnt) drivers.append(driver_c_jnt) pm.parent(drivers, w=True) for driver in drivers: pm.setAttr(driver[0] + ".radius", 1.5) pm.bindSkin(nurbs, drivers)
def rigJacket(containers): pm.select(cl=1) baseJoint = pm.joint(p=(0,0,0), name="jacketBase") jacketRight = createJointChain(name='jacketRight') pm.select(jacketRight[0], r=1) pm.move(0, jacketBack/2, 0) pm.select(cl=1) pm.select(baseJoint, r=1) jacketLeft = createJointChain(name='jacketLeft') pm.select(jacketLeft[0], r=1) pm.move(0, ((jacketBack/2)*-1), 0) pm.select(cl=1) #create more attrs pm.addAttr(containers["ctrl"], ln="__", at="enum", en="______" ) pm.setAttr(containers["ctrl"]+".__", e=1, keyable=1) jacketAttrNames = [] #create new attr for attr in jacketAttr: attrName = containers["ctrl"]+"."+attr jacketAttrNames.append(attrName) pm.addAttr(containers["ctrl"], ln=attr, at="double", dv=0) pm.setAttr(attrName, e=1, keyable=1) pm.connectAttr( jacketAttrNames[0], jacketLeft[0].rz ) reverseConnectAttr( jacketAttrNames[1], jacketRight[0].rz ) #connect left jacket bend for joint in jacketLeft: firstJoint = jacketLeft[0] lastJoint = jacketLeft[-1] if joint == firstJoint or joint == lastJoint: continue pm.connectAttr( jacketAttrNames[2], joint.rz ) #connect right jacket bend for joint in jacketRight: firstJoint = jacketRight[0] lastJoint = jacketRight[-1] if joint == firstJoint or joint == lastJoint: continue reverseConnectAttr( jacketAttrNames[3], joint.rz ) #connect left jacket twist for joint in jacketLeft: firstJoint = jacketLeft[0] lastJoint = jacketLeft[-1] if joint == lastJoint: continue pm.connectAttr( jacketAttrNames[4], joint.ry ) #connect right jacket twist for joint in jacketRight: firstJoint = jacketRight[0] lastJoint = jacketRight[-1] if joint == lastJoint: continue reverseConnectAttr( jacketAttrNames[5], joint.ry ) pm.select(baseJoint, r=1, hi=1) pm.select(containers["jacket_geo"], add=1, ) pm.bindSkin(toAll = 1, colorJoints = 1) pm.select(cl=1) pm.parent(baseJoint, containers["jacket_grp"]) pm.select(cl=1)