def rigSpine (crvName,tailCntrlJoints,waveControlObject,splitJoints): """ Rebuild curve - with actual curve in it!""" """ first have to make our reg spine""" mc.rebuildCurve (crvName, ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(splitJoints), d=1, tol=5) """ Make joint chains""" spineJoints = joints.createJointsFromCurve (crvName,'spine') """ set joint radius """ joints.setGoodJointRadius (spineJoints,1) """ Orienting the joint chain """ joints.orientJointChain (spineJoints, 'xyz', 'zup') """ Renaming the joint chain """ spineJointsBuffer = names.renameJointChainList (spineJoints, 'tailStart', 'tail') spineJoints = spineJointsBuffer """ removing initial bind from the spine curve """ mc.delete ('bindPose1') mc.delete ('skinCluster1') """ Makes our control surface """ controlSurface = makeJointControlSurfaceFish(spineJoints[0],tailCntrlJoints,'y','tail') """ parenting the tail joints """ rigging.parentListToHeirarchy (tailCntrlJoints) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>auto swim stuff """ Creating our deformation surface """ deformMeshBuffer = mc.duplicate (controlSurface) deformMesh = mc.rename (deformMeshBuffer[0],(controlSurface[0]+'_defmesh')) """ Creates our wave deformer """ deformerBuffer = mc.nonLinear (deformMesh, type = 'wave', name = 'swimWave') waveDeformer = mc.rename (deformerBuffer[0], 'waveDeformer') waveDeformerHandle = mc.rename (deformerBuffer[1], 'waveDeformerHandle') """ move the handle """ position.movePointSnap (waveDeformerHandle,spineJoints[0]) mc.setAttr ((waveDeformerHandle+'.rx'),90) mc.setAttr ((waveDeformerHandle+'.ry'),90) """ set some variables """ mc.setAttr ((waveDeformer+'.dropoff'),1) mc.setAttr ((waveDeformer+'.dropoffPosition'),1) mc.setAttr ((waveDeformer+'.maxRadius'),2) """ make our blendshape node and reorder things""" blendshapeNode = mc.blendShape (deformMesh, controlSurface[0], name = 'swim_bsNode' ) mc.reorderDeformers ("tweak2", blendshapeNode[0],controlSurface[0]) """ add some attrs to our wave control object """ attributes.addSectionBreakAttrToObj (waveControlObject, 'swim') attributes.addFloatAttributeToObject (waveControlObject, 'auto', min = 0, max = 1, dv =0) attributes.addFloatAttributeToObject (waveControlObject, 'speed', -100, 100, 0) attributes.addFloatAttributeToObject (waveControlObject, 'wavelength', 0, 10, 5) attributes.addFloatAttributeToObject (waveControlObject, 'amplitude', 0, 10, 0) attributes.addFloatAttributeToObject (waveControlObject, 'dropoff', 0, 1, 1) attributes.addFloatAttributeToObject (waveControlObject, 'dropoffPosition', 0, 1, 0) attributes.addFloatAttributeToObject (waveControlObject, 'minRadius', 0, 10, 0) attributes.addFloatAttributeToObject (waveControlObject, 'maxRadius', 0, 10, 10) """ connect a few attrs """ mc.connectAttr ((waveControlObject+'.auto'),(blendshapeNode[0]+'.'+deformMesh)) mc.connectAttr ((waveControlObject+'.wavelength'),(waveDeformer+'.wavelength')) mc.connectAttr ((waveControlObject+'.amplitude'),(waveDeformer+'.amplitude')) mc.connectAttr ((waveControlObject+'.dropoff'),(waveDeformer+'.dropoff')) mc.connectAttr ((waveControlObject+'.dropoffPosition'),(waveDeformer+'.dropoffPosition')) mc.connectAttr ((waveControlObject+'.minRadius'),(waveDeformer+'.minRadius')) mc.connectAttr ((waveControlObject+'.maxRadius'),(waveDeformer+'.maxRadius')) """ set some good base values """ mc.setAttr ((waveControlObject+'.speed'),1) mc.setAttr ((waveControlObject+'.wavelength'),4) mc.setAttr ((waveControlObject+'.amplitude'),.3) mc.setAttr ((waveControlObject+'.dropoff'),1) mc.setAttr ((waveControlObject+'.dropoffPosition'),1) mc.setAttr ((waveControlObject+'.maxRadius'),2) """ sets up swim speed """ nodes.offsetCycleSpeedControlNodeSetup (waveDeformer,(waveControlObject+'.speed'),90,-10) #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Head control and joint headJointBuffer = mc.duplicate ('head_anim') headJoint = mc.rename (headJointBuffer, 'head_jnt') headCtrlGrp = rigging.groupMeObject ('head_anim',True) #mc.parent (headJoint, spineJoints[0]) mc.parent (headJoint, 'move_anim') contsBuffer = mc.parentConstraint (spineJoints[0], headCtrlGrp, maintainOffset = True) mc.rename (contsBuffer,(headCtrlGrp+'_prntConst')) contsBuffer = mc.parentConstraint ('head_anim', headJoint, maintainOffset = True) mc.rename (contsBuffer,(headJoint+'_prntConst')) mc.parent (headCtrlGrp,'move_anim') #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Clean stuff """ deform group """ deformGrp = mc.group (n= 'swimDeform_grp', w=True, empty=True) mc.parent (waveDeformerHandle,deformGrp) mc.parent (deformMesh,deformGrp) mc.setAttr ((deformGrp+'.v'), 0) mc.setAttr ((controlSurface[0]+'.v'),0) """ delete placement stuff """ mc.delete ('curvePlacementStuff') mc.parent (tailCntrlJoints[0],waveControlObject) mc.parent (deformGrp, 'rigStuff_grp') #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Ctrl Joints to Ctrls ctrlSize = (distance.returnAverageDistanceBetweenObjects (tailCntrlJoints)) curves.parentShape ('head_anim', 'sampleCtrlZ') for ctrl in tailCntrlJoints: rigging.makeObjCtrl (ctrl,ctrlSize) #>>>>>>>>>>>>>>>>>>>>>Store skin joint data """ check for master skin info group """ name = 'spine' if mc.objExists ('master_skinJntList_grp'): masterSkinJointList = ('master_skinJntList_grp') else: masterSkinJointList = mc.group (n= ('master_skinJntList_grp'), w=True, empty=True) mc.parent(masterSkinJointList,'rigStuff_grp') """ check for segment skin info group """ if mc.objExists (name+'_skinJntList_grp'): skinJointList = (name+'_skinJntList_grp') else: skinJointList = mc.group (n= (name+'_skinJntList_grp'), w=True, empty=True) mc.parent (skinJointList,masterSkinJointList) attributes.storeObjNameToMessage (skinJointList,masterSkinJointList) """ store the skin joint data """ for jnt in spineJoints: attributes.storeObjNameToMessage (jnt,skinJointList) attributes.storeObjNameToMessage (headJoint,skinJointList)
#>>> connect_singleDriverAttrToMulti #======================================================= reload(rUtils) drivenAttr = 'noseBase_bodyShaper_parentConstraint_grp.scale' driverAttrs = ['lwrFace_bodyShaper.sx','mouth_bodyShaper.sx'] drivenAttr = 'l_eyeOrb_bodyShaper_scale_parentConstraint_grp.scale' driverAttrs = 'cranium_bodyShaper.sx' driverAttrs = ['cranium_bodyShaper.sx'] rUtils.connect_singleDriverAttrToMulti(drivenAttr ,driverAttrs) #>>> Stretch IK #======================================================= jointList = mc.ls(sl=True) joints.orientJointChain(jointList,'zyx','zdown') rUtils.IKHandle_create(jointList[0],jointList[-1],lockMid=False, nameSuffix = 'noFlip',rpHandle=True,controlObject='joint3_loc',addLengthMulti=True,globalScaleAttr='null1.sy', stretch='translate') rUtils.createCGMSegment(jointList) start = 'l_left_index_2_ik_jnt' end = 'l_left_index_4_ik_jnt' mc.ikHandle( sj=start, ee=end,solver = 'ikSpringSolver', forceSolver = True,snapHandleFlagToggle=True )
def surfRigger(objectNull,anchor,worldScale,mirror,mode,jointsPerChain,deformChains,ctrlChains): """ Get variables""" nullBase = names.stripSuffixObj (objectNull) templateNull = (nullBase + '_templateNull') moverNull = (nullBase + '_mover') templateNullMessageData = [] templateNullMessageData = attributes.returnMessageAttrs (templateNull) templateObjects = [] coreNamesList = [] spineJointNumber = int(mc.getAttr (objectNull+'.rollJoints')) #spineChainList = search.returnChildrenJoints (spineChain) spineChainList = [] spineChainList.append (anchor) jointChains = [] for set in templateNullMessageData: templateObjects.append (set[1]) coreNamesList.append (set[0]) #>>>>>>>>>>>>>>>>>>>>>Store skin joint data """ check for master skin info group """ if mc.objExists ('master_skinJntList_grp'): masterSkinJointList = ('master_skinJntList_grp') else: masterSkinJointList = mc.group (n= ('master_skinJntList_grp'), w=True, empty=True) mc.parent(masterSkinJointList,'rigStuff_grp') """ check for segment skin info group """ if mc.objExists (nullBase+'_skinJntList_grp'): skinJointListGrp = (nullBase+'_skinJntList_grp') else: skinJointListGrp = mc.group (n= (nullBase+'_skinJntList_grp'), w=True, empty=True) attributes.storeObjNameToMessage (skinJointListGrp,masterSkinJointList) mc.parent (skinJointListGrp,masterSkinJointList) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ Rebuild curve - with actual curve in it!""" mc.rebuildCurve ((templateObjects[3]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5) mc.rebuildCurve ((templateObjects[7]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5) mc.rebuildCurve ((templateObjects[11]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5) """ Reverse the curve """ mc.reverseCurve ((templateObjects[3]),ch=False,rpo=True) mc.reverseCurve ((templateObjects[7]),ch=False,rpo=True) mc.reverseCurve ((templateObjects[11]),ch=False,rpo=True) """ loft our surface to figure out joint positions, then delete it""" controlSurface = mc.loft ([templateObjects[3],templateObjects[7],templateObjects[11]],name=(nullBase+'_surf'),ss=(ctrlChains-mode),ch=1,u=1,c=0,ar=1,d=3,rn=0,po=0,rsn=True) mc.select (cl=True) jointChains = joints.createJointChainsFromLoftSurface (nullBase,controlSurface[0],2,False) frontChain = jointChains[0] backChain = jointChains[-1] """ Chain - orienting, sizing """ for chain in jointChains: joints.orientJointChain (chain, 'xyz', 'zup') joints.setGoodJointRadius(chain,.5) #IF we have mode 0, gotta make a main ctrl if mode == 0: midChain = [] if (len(jointChains)) > 3: midChain = jointChains[int(len(jointChains)/2)] else: midChain = jointChains[1] jointChains.remove(midChain) if ctrlChains > 2: masterCtrlBuffer = mc.duplicate (midChain[0],parentOnly=True) else: masterCtrlBuffer = midChain[0] mc.delete (midChain[1]) masterCtrl = mc.rename (masterCtrlBuffer,(nullBase+'_master_anim')) position.movePointSnap(masterCtrl,moverNull) """ temp parenting the master control for mirroring purposes """ spineHookJoint = distance.returnClosestObject (masterCtrl, spineChainList) mc.parent (masterCtrl,spineHookJoint) mc.delete (controlSurface[0]) #>>>>>>>>>>>>Parent time """ Get closest joint """ if mode == 0: for chain in jointChains: mc.parent (chain[0],masterCtrl) else: for chain in jointChains: tailHookJoint = distance.returnClosestObject (chain[0], spineChainList) mc.parent (chain[0],tailHookJoint) #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Ctrl Joints to Ctrls cnt = 0 for chain in jointChains: ctrlSize = (distance.returnAverageDistanceBetweenObjects (chain)/2) for jnt in chain[0:-1]: rigging.makeObjCtrl (jnt,ctrlSize) """ adds our Anim tag """ chainBuffer = [] chainBuffer = names.addSuffixList ('anim', chain) jointChains[cnt]= chainBuffer cnt +=1 #>>>>>>>>>>>>>>>>>>>Mirroring while getting chain info """ If mirroring ....""" if mirror == True: # if we have a main control leftSkinChains = [] rightSkinChains = [] masterCtrls = [] if mode == 0: leftChain = [] rightChain = [] finHeirarchy = [] finHeirarchy.append (masterCtrl) children = search.returnChildrenJoints (masterCtrl) finHeirarchy += children leftChain = names.addPrefixList ('left',finHeirarchy) masterCtrl = leftChain [0] rightChainBuffer = mc.mirrorJoint (masterCtrl,mirrorYZ=True,mirrorBehavior=True, searchReplace =['left','right']) rightChainJointBuffer = mc.ls (rightChainBuffer,type='joint') rightChain = rightChainJointBuffer leftSkinChains.append(leftChain) rightSkinChains.append(rightChain) masterCtrls.append(leftChain[0]) masterCtrls.append(rightChain[0]) else: for chain in jointChains: leftChain =[] leftChain = names.addPrefixList ('left',chain) rightChainBuffer = (mc.mirrorJoint (leftChain[0],mirrorYZ=True,mirrorBehavior=True, searchReplace =['left','right'])) rightChainJointBuffer = mc.ls (rightChainBuffer,type='joint') rightChain = rightChainJointBuffer rightSkinChains.append (rightChainJointBuffer) leftSkinChains.append (leftChain) """ complile our chains to lists of skin joints """ leftSkinJointList=[] rightSkinJointList=[] for chain in leftSkinChains: for jnt in chain: leftSkinJointList.append (jnt) for chain in rightSkinChains: for jnt in chain: rightSkinJointList.append (jnt) """if we're not mirroring, let's return our skin joints for the deformation surface""" else: skinJointList = [] skinChains = [] for chain in jointChains: skinChains.append (chain) for jnt in chain: skinJointList.append (jnt) #>>>>>>>>>>>>>>>>>>>>>>>>>>Time to make the deformation surface stuff """ Rebuild curve - with actual curve in it!""" #mc.rebuildCurve ((templateObjects[3]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(3), d=1, tol=5) #mc.rebuildCurve ((templateObjects[7]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(3), d=1, tol=5) """ loft our surface to figure out joint positions, then delete it""" deformSurface = mc.loft ([templateObjects[3],templateObjects[7],templateObjects[11]],name=(nullBase+'_surf'),ss=(deformChains-1),ch=0,u=1,c=0,ar=1,d=3,rn=0,po=0,rsn=True) if mirror == True: deformSurfaceNameBuffer = deformSurface[0] """we have a surface to mirror...""" surfaceMirrorBuffer = mc.duplicate (deformSurface[0]) mc.setAttr ((surfaceMirrorBuffer[0]+'.sx'),-1) leftBuffer = mc.rename (deformSurface[0],('left_'+deformSurfaceNameBuffer)) rightBuffer = mc.rename (surfaceMirrorBuffer[0],('right_'+deformSurfaceNameBuffer)) deformSurface[0]=leftBuffer deformSurface.append(rightBuffer) leftDeformJointChains = joints.createJointChainsFromLoftSurface (('left_'+nullBase),deformSurface[0],2,False) rightDeformJointChains = joints.createJointChainsFromLoftSurface (('right_'+nullBase),deformSurface[1],2,False) """ Connecting to surface """ for chain in leftDeformJointChains: attachSurfaceReturn = joints.attachJointChainToSurface (chain,deformSurface[0],'xyz','zup') tailHookJoint = distance.returnClosestObject (chain[0], spineChainList) """ break the connection so we can parent it""" """first return the original thing to follow""" parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate')) attributes.doBreakConnection (chain[0]+'.translate') #mc.parent (chain[0],tailHookJoint) """ reconstrain it to the driver""" constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True) mc.rename (constraintBuffer[0],(chain[0]+'_pointConst')) """ store the skin joint data """ for jnt in chain: attributes.storeObjNameToMessage (jnt,skinJointListGrp) for chain in rightDeformJointChains: attachSurfaceMirrorReturn = joints.attachJointChainToSurface (chain,deformSurface[1],'xyz','zup') tailHookJoint = distance.returnClosestObject (chain[0], spineChainList) """ break the connection s we can parent it""" """first return the original thing to follow""" parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate')) attributes.doBreakConnection (chain[0]+'.translate') #mc.parent (chain[0],tailHookJoint) """ reconstrain it to the driver""" constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True) mc.rename (constraintBuffer[0],(chain[0]+'_pointConst')) """ store the skin joint data """ for jnt in chain: attributes.storeObjNameToMessage (jnt,skinJointListGrp) """ parent the scale stuff to rig stuff grp""" mc.select (cl=True) for item in attachSurfaceReturn[0]: mc.parent(item,'rigStuff_grp') for item in attachSurfaceMirrorReturn[0]: mc.parent(item,'rigStuff_grp') """ hook up world scale """ mc.connectAttr (worldScale,attachSurfaceReturn[1]) mc.connectAttr (worldScale,attachSurfaceMirrorReturn[1]) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Skin in the control joints """ Time to set skin our surface to our control joints """ mc.skinCluster (leftSkinJointList,deformSurface[0],tsb=True, n=(deformSurface[0]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1) mc.skinCluster (rightSkinJointList,deformSurface[1],tsb=True, n=(deformSurface[1]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1) #>>>>>If we,re not mirrored, let's make our deform setup else: deformJointChains = [] deformJointChains = joints.createJointChainsFromLoftSurface (nullBase,deformSurface[0],2,False) """ Connecting to surface """ for chain in deformJointChains: attachSurfaceReturn = joints.attachJointChainToSurface (chain,deformSurface[0],'xyz','zup') tailHookJoint = distance.returnClosestObject (chain[0], spineChainList) """ break the connection so we can parent it""" """first return the original thing to follow""" parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate')) attributes.doBreakConnection (chain[0]+'.translate') #mc.parent (chain[0],tailHookJoint) """ reconstrain it to the driver""" constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True) mc.rename (constraintBuffer[0],(chain[0]+'_pointConst')) """ store the skin joint data """ for jnt in chain: attributes.storeObjNameToMessage (jnt,skinJointListGrp) """ hook up world scale """ partScaleBuffer = attachSurfaceReturn[1] mc.connectAttr (worldScale, partScaleBuffer) """ parent the scale stuff to rig stuff grp""" mc.select (cl=True) for item in attachSurfaceReturn[0]: mc.parent(item,'rigStuff_grp') """ Time to set skin our surface to our control joints """ mc.skinCluster (skinJointList,deformSurface[0],tsb=True, n=(deformSurface[0]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1) """ Setting up the joint starts""" if mode == 0: if mirror == True: for ctrl in masterCtrls: rigging.makeObjCtrl (ctrl,(ctrlSize*4)) masterCtrlGrp = rigging.groupMeObject (ctrl,True) """ Get closest joint and connect the Cntrl """ spineHookJoint = distance.returnClosestObject (masterCtrlGrp, spineChainList) mc.parent(masterCtrlGrp,spineHookJoint) else: rigging.makeObjCtrl (masterCtrl,(ctrlSize*4)) masterCtrlGrp = rigging.groupMeObject (masterCtrl,True) """ Get closest joint and connect the Cntrl """ spineHookJoint = distance.returnClosestObject (masterCtrlGrp, spineChainList) mc.parent(masterCtrlGrp,spineHookJoint) #else we need to connect the individual chains to the spine else: if mirror == True: for chain in leftSkinChains: chainCtrlGrp = rigging.groupMeObject (chain[0],True) spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList) mc.parent(chainCtrlGrp,spineHookJoint) for chain in rightSkinChains: chainCtrlGrp = rigging.groupMeObject (chain[0],True) spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList) mc.parent(chainCtrlGrp,spineHookJoint) else: for chain in skinChains: chainCtrlGrp = rigging.groupMeObject (chain[0],True) spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList) mc.parent(chainCtrlGrp,spineHookJoint)
def rigArm(objectNull): """return variables""" nullBase = names.stripSuffixObj(objectNull) templateNull = (nullBase + '_templateNull') templateNullMessageData = [] templateNullMessageData = attributes.returnMessageAttrs(templateNull) templateObjects = [] coreNamesList = [] for set in templateNullMessageData: templateObjects.append(set[1]) coreNamesList.append(set[0]) """ return rid of locators on our template objects so they don't screw up the distance locators""" templateObjects.remove(templateObjects[-1]) coreNamesList.remove(coreNamesList[-1]) for obj in templateObjects: if mc.objExists(obj + '_loc'): mc.delete(obj + '_loc') """make joint chains""" fkJoints = joints.createJointsFromObjPositions(templateObjects, 'fk') mc.select(cl=True) ikJoints = joints.createJointsFromObjPositions(templateObjects, 'ik') """orient joints""" joints.orientJointChain(fkJoints, 'xyz', 'yup') joints.orientJointChain(ikJoints, 'xyz', 'yup') """set rotation order - CHANGE to go for the names later and optional orientation schemes""" joints.setRotationOrderOnJoint(fkJoints[0], 'xyz') joints.setRotationOrderOnJoint(fkJoints[1], 'xzy') joints.setRotationOrderOnJoint(fkJoints[2], 'zyx') joints.setRotationOrderOnJoint(ikJoints[0], 'xyz') joints.setRotationOrderOnJoint(ikJoints[1], 'xzy') joints.setRotationOrderOnJoint(ikJoints[2], 'zyx') """ create hand_anim locs """ hand_animRegBuffer = locators.locMeObject(ikJoints[2]) hand_animPinnedBuffer = locators.locMeObject(ikJoints[2]) hand_animReg = mc.rename(hand_animRegBuffer, (coreNamesList[2] + '_anim')) hand_animPinned = mc.rename(hand_animPinnedBuffer, (coreNamesList[2] + '_elbow_anim')) """ creating measure stuff """ # Had to move this up here because distanceDimension doesn't let you specify which locator to use. Need to modify script to account for that uprArmMeasureLocBuffer = locators.locMeObject(ikJoints[0]) handMeasureLocBuffer = locators.locMeObject(ikJoints[2]) elbowMeasureLocBuffer = locators.locMeObject(ikJoints[1]) uprArmMeasureLoc = mc.rename(uprArmMeasureLocBuffer, (coreNamesList[0] + '_dist_loc')) handMeasureLoc = mc.rename(handMeasureLocBuffer, (coreNamesList[2] + '_dist_loc')) elbowMeasureLoc = mc.rename(elbowMeasureLocBuffer, (coreNamesList[1] + '_dist_loc')) measureFullLength = [uprArmMeasureLoc, handMeasureLoc] fullLengthMeassureObj = distance.createDistanceObjectsBetweenObjectList( measureFullLength) measureShoulderToElbow = [uprArmMeasureLoc, elbowMeasureLoc] uprLengthMeassureObj = distance.createDistanceObjectsBetweenObjectList( measureShoulderToElbow) measureElbowToHand = [elbowMeasureLoc, handMeasureLoc] lwrLengthMeassureObj = distance.createDistanceObjectsBetweenObjectList( measureElbowToHand) """>>>Set up Rotation Isolation for FK Mode """ """creates our locator parent""" UprArmRoot = locators.locMeObject(fkJoints[0]) """ Create 4 target locators""" UprArmTorsoOrientBuffer = mc.duplicate(UprArmRoot) UprArmBodyOrientBuffer = mc.duplicate(UprArmRoot) UprArmTorsoOrientDriverBuffer = mc.duplicate(UprArmRoot) UprArmBodyOrientDriverBuffer = mc.duplicate(UprArmRoot) UprArmOrientBuffer = mc.duplicate(UprArmRoot) """names our loctators intelligently""" uprArmTorsoOrient = mc.rename(UprArmTorsoOrientBuffer[0], (coreNamesList[0] + '_torso_orient')) uprArmBodyOrient = mc.rename(UprArmBodyOrientBuffer[0], (coreNamesList[0] + '_body_orient')) uprArmTorsoOrientDriver = mc.rename( UprArmTorsoOrientDriverBuffer[0], (coreNamesList[0] + '_torso_orient_driver')) uprArmBodyOrientDriver = mc.rename( UprArmBodyOrientDriverBuffer[0], (coreNamesList[0] + '_body_orient_driver')) UprArmOrient = mc.rename(UprArmOrientBuffer[0], (coreNamesList[0] + '_orient_anim')) """orients the orient_anim control placeholder""" attributes.setRotationOrderObj(UprArmOrient, 'xzy') """parents orient control loc to top node""" mc.parent(UprArmOrient, UprArmRoot) """parents arm to top loc""" mc.parent(fkJoints[0], UprArmOrient) """parents top loc and torso orient loc to torso diver""" mc.parent(UprArmRoot, uprArmTorsoOrientDriver) mc.parent(uprArmTorsoOrient, uprArmTorsoOrientDriver) mc.parent(uprArmBodyOrient, uprArmBodyOrientDriver) """ makes orient constraint for the fk arm""" orConstBuffer = mc.orientConstraint([uprArmBodyOrient, uprArmTorsoOrient], UprArmRoot, mo=True, weight=1) orConst = mc.rename(orConstBuffer, (fkJoints[0] + '_orConst')) """ adds our constraint toggle """ mc.addAttr(fkJoints[0], ln='orient', at='enum', en='torso:body:') mc.setAttr((fkJoints[0] + '.orient'), keyable=True) """ return our orient constraint channels """ orConstAttrs = (mc.listAttr(orConst, userDefined=True)) """ setups up toggle to change orientation """ mc.setDrivenKeyframe((orConst + '.' + orConstAttrs[0]), currentDriver=(fkJoints[0] + '.orient'), driverValue=0, value=0) mc.setDrivenKeyframe((orConst + '.' + orConstAttrs[1]), currentDriver=(fkJoints[0] + '.orient'), driverValue=0, value=1) mc.setDrivenKeyframe((orConst + '.' + orConstAttrs[0]), currentDriver=(fkJoints[0] + '.orient'), driverValue=1, value=1) mc.setDrivenKeyframe((orConst + '.' + orConstAttrs[1]), currentDriver=(fkJoints[0] + '.orient'), driverValue=1, value=0) """ >>>Sets up fk arm scaling """ """ adds our length attribute""" mc.addAttr(fkJoints[0], ln='length', at='float', minValue=0, defaultValue=1) mc.setAttr((fkJoints[0] + '.length'), keyable=True) mc.addAttr(fkJoints[1], ln='length', at='float', minValue=0, defaultValue=1) mc.setAttr((fkJoints[1] + '.length'), keyable=True) """ connects length to child joint length """ currentLength = mc.getAttr(fkJoints[1] + '.translateX') mc.setDrivenKeyframe((fkJoints[1] + '.translateX'), currentDriver=(fkJoints[0] + '.length'), driverValue=1, value=currentLength, inTangentType='linear', outTangentType='linear') mc.setDrivenKeyframe((fkJoints[1] + '.translateX'), currentDriver=(fkJoints[0] + '.length'), driverValue=0, value=0, inTangentType='linear', outTangentType='linear') currentLength = mc.getAttr(fkJoints[2] + '.translateX') mc.setDrivenKeyframe((fkJoints[2] + '.translateX'), currentDriver=(fkJoints[1] + '.length'), driverValue=1, value=currentLength, inTangentType='linear', outTangentType='linear') mc.setDrivenKeyframe((fkJoints[2] + '.translateX'), currentDriver=(fkJoints[1] + '.length'), driverValue=0, value=0, inTangentType='linear', outTangentType='linear') """ set sdk curves to infinity """ mc.setInfinity((fkJoints[1] + '.translateX'), pri='constant', poi='linear') mc.setInfinity((fkJoints[2] + '.translateX'), pri='constant', poi='linear') """ lockin stuff down on the fk end """ for jnt in fkJoints: attributes.doSetLockHideKeyableAttr( jnt, True, False, False, ['ty', 'tz', 'sx', 'sy', 'sz', 'v']) attributes.doSetLockHideKeyableAttr( UprArmOrient, True, False, False, ['tx', 'ty', 'tz', 'sx', 'sy', 'sz', 'v']) attributes.doSetLockHideKeyableAttr(fkJoints[1], False, False, False, ['tx']) attributes.doSetLockHideKeyableAttr(fkJoints[2], False, False, False, ['tx']) """ >>>IK arm time!""" """make elbow loc and a hand loc""" elbowIKLoc = locators.locMeObject(ikJoints[1]) handIKLoc = locators.locMeObject(ikJoints[2]) """set preferred rotation channel on elbow""" #---------------------->>>> Need to figure out how to generate this! mc.setAttr((ikJoints[1] + '.ry'), -30) mc.joint(ikJoints[1], edit=True, setPreferredAngles=True) mc.setAttr((ikJoints[1] + '.ry'), 0) """set up the ik handle""" ikHandleName = (nullBase + '_ikHandle') mc.ikHandle(name=ikHandleName, startJoint=ikJoints[0], endEffector=ikJoints[2], sol='ikRPsolver', snapHandleFlagToggle=True) """Polevector constraint""" mc.poleVectorConstraint(elbowIKLoc, ikHandleName, name=(nullBase + '.pvConst'), weight=1.0) mc.parent(ikHandleName, handIKLoc) """ >>> IK Stretch stuff""" """connecting measure stuff""" mc.parent(handMeasureLoc, handIKLoc) uprArmLength = mc.getAttr(ikJoints[1] + '.tx') lwrArmLength = mc.getAttr(ikJoints[2] + '.tx') fullLength = (uprArmLength + lwrArmLength) driver = (fullLengthMeassureObj[0] + 'Shape.distance') """sets base sdk key for length""" mc.setDrivenKeyframe((ikJoints[1] + '.tx'), currentDriver=driver, driverValue=fullLength, value=uprArmLength, inTangentType='linear', outTangentType='linear') mc.setDrivenKeyframe((ikJoints[2] + '.tx'), currentDriver=driver, driverValue=fullLength, value=lwrArmLength, inTangentType='linear', outTangentType='linear') """sets stetch sdk key for length""" mc.setDrivenKeyframe((ikJoints[1] + '.tx'), currentDriver=driver, driverValue=(fullLength * 2), value=(uprArmLength * 2), inTangentType='linear', outTangentType='linear') mc.setDrivenKeyframe((ikJoints[2] + '.tx'), currentDriver=driver, driverValue=(fullLength * 2), value=(lwrArmLength * 2), inTangentType='linear', outTangentType='linear') mc.setInfinity((ikJoints[1] + '.tx'), pri='constant', poi='linear') mc.setInfinity((ikJoints[2] + '.tx'), pri='constant', poi='linear') """ >>> Set up pinning""" """ creates blend node """ """upr""" uprBlendNode = mc.createNode('blendTwoAttr', name='upr_Choice_blendTwoNode', skipSelect=True) uprSDKCurve = mc.listConnections((ikJoints[1] + '.tx'), source=True) mc.connectAttr((uprSDKCurve[0] + '.output'), (uprBlendNode + '.input[0]'), force=True) mc.connectAttr((uprLengthMeassureObj[0] + 'Shape.distance'), (uprBlendNode + '.input[1]'), force=True) mc.connectAttr((uprBlendNode + '.output'), (ikJoints[1] + '.tx'), force=True) """lwr""" lwrBlendNode = mc.createNode('blendTwoAttr', name='lwr_Choice_blendTwoNode', skipSelect=True) lwrSDKCurve = mc.listConnections((ikJoints[2] + '.tx'), source=True) mc.connectAttr((lwrSDKCurve[0] + '.output'), (lwrBlendNode + '.input[0]'), force=True) mc.connectAttr((lwrLengthMeassureObj[0] + 'Shape.distance'), (lwrBlendNode + '.input[1]'), force=True) mc.connectAttr((lwrBlendNode + '.output'), (ikJoints[2] + '.tx'), force=True) """adds stetch attrs""" mc.addAttr(elbowIKLoc, ln='pin', at='float', minValue=0, defaultValue=1) mc.setAttr((elbowIKLoc + '.pin'), keyable=True) mc.connectAttr((elbowIKLoc + '.pin'), (uprBlendNode + '.attributesBlender')) mc.connectAttr((elbowIKLoc + '.pin'), (lwrBlendNode + '.attributesBlender')) mc.setAttr((elbowIKLoc + '.pin'), 0) mc.parent(elbowMeasureLoc, elbowIKLoc) """ >>> FK lower limb control setup """ """ creates our pinned lower limb fk joint """ pinnedLwrLimcgmuffer = mc.duplicate(ikJoints[1], renameChildren=True) nonJointStuff = search.returnNonJointObjsInHeirarchy(pinnedLwrLimcgmuffer) for item in nonJointStuff: mc.delete(item) """ name the joint we'll be using """ pinnedLwrLimb = mc.rename(pinnedLwrLimcgmuffer[0], (coreNamesList[1] + '_pinned_fk_anim')) mc.parent(pinnedLwrLimb, elbowIKLoc) pinnedLwrLimbEndBuffer = mc.listRelatives(pinnedLwrLimb, children=True) mc.rename(pinnedLwrLimbEndBuffer[0], (coreNamesList[1] + '_pinned_fk_end')) """ make the hand anim loc """ mc.parent(hand_animPinned, elbowIKLoc) ptConstBuffer = mc.pointConstraint([hand_animReg, hand_animPinned], handIKLoc, mo=False, weight=1) """ make the attr to drive it """ mc.addAttr(elbowIKLoc, ln='forearm', at='enum', en='fk:ik:') mc.setAttr((elbowIKLoc + '.forearm'), keyable=True) mc.setAttr((elbowIKLoc + '.forearm'), 1) """ connect it """ mc.connectAttr((elbowIKLoc + '.forearm'), (ptConstBuffer[0] + '.' + hand_animReg + 'W0')) revNodeBuffer = mc.createNode('reverse', name='hand_revNode') mc.connectAttr((elbowIKLoc + '.forearm'), (revNodeBuffer + '.inputX')) mc.connectAttr((revNodeBuffer + '.outputX'), (ptConstBuffer[0] + '.' + hand_animPinned + 'W1'))