def CreateHandRig(self, PalmReferencePoint, PalmControl=None): self.CreateHandStructure(PalmReferencePoint) for fingers in self.GHS.fingers: self.CreateFingerSquareRig(fingers) self.CreatePalmRig(PalmControl=PalmControl) RMRigTools.RMParentArray(self.PalmControl, self.fingerControlsReset) palmLen = RMRigTools.RMPointDistance(self.PalmControl, self.GHS.fingerRoots[0]) pm.parentConstraint(self.MainKinematics, self.GHS.palmJoint) pm.parentConstraint(self.MainKinematics, self.MainControl) self.NameConv.rename_set_from_name(self.GHS.palmJoint, "sknjnt", "objectType") for eachFinger in self.GHS.fingers: self.NameConv.rename_set_from_name(eachFinger, "sknjnt", "objectType")
def RMStretchyTwistJoints(self): locators , distanceNode = self.RMDistanceBetweenPointsMeasure(self.TwistOrigin, self.TwistEnd,"Twist" + self.NameConv.get_a_short_name(self.TwistOrigin).title()) stretchyRefGroup = pm.group(empty=True, name="StretchyRefPoints%s" % self.NameConv.get_a_short_name(self.TwistOrigin).title()) self.NameConv.rename_based_on_base_name(self.TwistOrigin, stretchyRefGroup, name= stretchyRefGroup) RMRigTools.RMParentArray(stretchyRefGroup, locators) TwistJointDivide = pm.shadingNode("multiplyDivide", asUtility=True, name="StretchyTwistJoint%s" % self.NameConv.get_a_short_name(self.TwistOrigin).title()) #self.NameConv.RMRenameNameInFormat(TwistJointDivide,{}) self.NameConv.rename_based_on_base_name(self.TwistOrigin, TwistJointDivide, name=TwistJointDivide) pm.connectAttr("%s.distance" % distanceNode, "%s.input1X" % TwistJointDivide) pm.setAttr("%s.input2X" % TwistJointDivide, (len(self.TwistJoints) - 1)) pm.setAttr("%s.operation" % TwistJointDivide, 2) for eachJoint in self.TwistJoints[1:]: pm.connectAttr("%s.outputX" % TwistJointDivide, "%s.translateX" % eachJoint) self.kinematics.append(stretchyRefGroup)
def FetTipRotationCorrect(side="RH"): # "Character_LF_TipGrp00_UDF_Rig" # "Character01_LF_ankleIK00_ctr_Rig" # "Character_LF_TipGrp00_grp_Rig" ArrayOfChildren = RMRigTools.RMRemoveChildren("Character_%s_TipGrp00_UDF_Rig" % side) childGroup = RMRigTools.RMCreateGroupOnObj("Character_%s_TipGrp00_UDF_Rig" % side, Type="world") ParentConst = cmds.listConnections("Character_%s_TipGrp00_grp_Rig" % side, type="parentConstraint") cmds.delete(ParentConst[0]) cmds.makeIdentity("Character_%s_TipGrp00_grp_Rig" % side) loc = cmds.spaceLocator(name="ReferencePoint")[0] RMRigTools.RMAlign("Character_%s_TipGrp00_grp_Rig" % side, loc, 2) cmds.setAttr("%s.rotateX" % loc, 0) # cmds.setAttr( "%s.rotateX"%loc, -90)f cmds.setAttr("%s.rotateZ" % loc, 0) RMRigTools.RMAlign(loc, "Character_%s_TipGrp00_grp_Rig" % side, 2) cmds.parentConstraint("Character01_%s_ankleIK00_ctr_Rig" % side, "Character_%s_TipGrp00_grp_Rig" % side, mo=True, name=ParentConst[0]) cmds.parent(childGroup, "Character_%s_TipGrp00_UDF_Rig" % side) RMRigTools.RMParentArray(childGroup, ArrayOfChildren) cmds.delete(loc)
def RMCreateSpineIKSystem(self): self.spineIK, effector, self.spineCurve = pm.ikHandle( startJoint=self.spineJoints[0], endEffector=self.spineJoints[len(self.spineJoints) - 1], createCurve=True, numSpans=len(self.spineJoints), solver="ikSplineSolver", name="spineIK") self.NameConv.rename_based_on_base_name( self.spineJoints[len(self.spineJoints) - 1], self.spineIK) self.NameConv.rename_based_on_base_name( self.spineJoints[len(self.spineJoints) - 1], effector, name="spineIKEffector") self.NameConv.rename_based_on_base_name( self.spineJoints[len(self.spineJoints) - 1], self.spineCurve, name="spineIKCurve") Clusters = RMRigTools.RMCreateClustersOnCurve(self.spineCurve) ClustersGroup = RMRigTools.RMCreateGroupOnObj(Clusters[0]) RMRigTools.RMParentArray(ClustersGroup, Clusters[1:]) self.kinematics.append(ClustersGroup) self.kinematics.append(self.spineIK) #ResetCOG, COG = RMRigShapeControls.create_box_ctrl(self.spineJoints[0],Yratio=3,Zratio=3) ResetCOG, COG = RMRigShapeControls.RMImportMoveControl( self.spineJoints[0], scale=RMRigTools.RMLenghtOfBone(self.spineJoints[0]) * 7) self.NameConv.rename_set_from_name(COG, "COG", "name") ResetChest, Chest = RMRigShapeControls.RMCreateBoxCtrl( self.spineJoints[len(self.spineJoints) - 1], Yratio=3, Zratio=3) self.NameConv.rename_set_from_name(Chest, "Chest", "name") SpineLength = RMRigTools.RMPointDistance(COG, Chest) ResetChestRotation, ChestRotation = RMRigShapeControls.RMCircularControl( Chest, radius=SpineLength, name="ChestRotation") pm.parent(ResetChestRotation, Chest) pm.parentConstraint(ChestRotation, self.chestJoint, mo=True) self.ResetChestRotationControl = ResetChestRotation self.ChestRotationControl = ChestRotation #pm.parent(ResetChest,COG) pm.setAttr(self.spineIK + ".dTwistControlEnable", 1) pm.setAttr(self.spineIK + ".dWorldUpType", 4) #pm.setAttr(self.spineIK + ".dForwardAxis",0)#Valid Option only in Maya 2016 pm.setAttr(self.spineIK + ".dWorldUpAxis", 0) pm.connectAttr(COG + ".worldMatrix[0]", self.spineIK + ".dWorldUpMatrix") pm.connectAttr(Chest + ".worldMatrix[0]", self.spineIK + ".dWorldUpMatrixEnd") locators = RMRigTools.RMCreateNLocatorsBetweenObjects(COG, Chest, 3, align="FirstObj") ChestControls = [] ChestGroups = [] AllSpine = [COG] spineControlGroup = pm.group(empty=True, name="SpineControls") self.NameConv.rename_name_in_format(spineControlGroup, name=spineControlGroup) self.secondaryControls for eachPosition in locators: ControlGroup, NewControl = RMRigShapeControls.RMImportMoveControl( eachPosition, scale=SpineLength) self.secondaryControls.append(NewControl) ChestGroups.append(ControlGroup) ChestControls.append(NewControl) AllSpine.append(NewControl) ResetTransformGroup = RMRigTools.RMCreateGroupOnObj(ControlGroup) print ResetTransformGroup print spineControlGroup pm.parent(ResetTransformGroup, spineControlGroup) pm.delete(eachPosition) RMRigTools.RMLockAndHideAttributes(NewControl, "111000000h") AllSpine.append(Chest) pm.parent(spineControlGroup, COG) ChestChildGroup = RMRigTools.RMCreateGroupOnObj(Chest, Type="child", NameConv=self.NameConv) pm.xform(ChestChildGroup, t=[-SpineLength / 2, 0, 0], os=True, relative=True) spineEnds = [COG, ChestChildGroup] self.RMRedistributeConstraint(AllSpine, Clusters, 3, ConstraintType="parent") self.RMRedistributeConstraint(spineEnds, ChestGroups, 3, ConstraintType="parent") DeformedShape, OrigShape = pm.listRelatives(self.spineCurve, children=True, shapes=True) curveInfoOriginal = pm.shadingNode('curveInfo', asUtility=True, name="SpineCurveOriginalInfo") curveInfoDeformed = pm.shadingNode('curveInfo', asUtility=True, name="SpineCurveDeformedInfo") self.NameConv.rename_name_in_format(curveInfoOriginal, name=curveInfoOriginal) self.NameConv.rename_name_in_format(curveInfoDeformed, name=curveInfoDeformed) pm.connectAttr(OrigShape + ".worldSpace[0]", curveInfoOriginal + ".inputCurve") pm.connectAttr(DeformedShape + ".worldSpace[0]", curveInfoDeformed + ".inputCurve") curveScaleRatio = pm.shadingNode('multiplyDivide', asUtility=True, name="SpineScaleRatio") self.NameConv.rename_name_in_format(curveScaleRatio, name=curveScaleRatio) pm.connectAttr(curveInfoDeformed + ".arcLength", curveScaleRatio + ".input1X") pm.connectAttr(curveInfoOriginal + ".arcLength", curveScaleRatio + ".input2X") pm.setAttr(curveScaleRatio + ".operation", 2) #preparation for Scale multiplication function of each spine joint pm.addAttr(Chest, at="float", sn="ssf", ln="spineSquashFactor", hnv=1, hxv=1, h=0, k=1, smn=-10, smx=10) GaussLen = len(self.spineJoints) center = len(self.spineJoints) / 2 powMaxValue = 5 powRate = powMaxValue / center index = 1 for eachJoint in self.spineJoints[1:]: #translate stretch multiplication functions of each spine joint SpineStretchMult = pm.shadingNode( 'multiplyDivide', asUtility=True, name="SpineTranslateStretchMult" + self.NameConv.get_a_short_name(eachJoint)) self.NameConv.rename_name_in_format(SpineStretchMult, name=SpineStretchMult) CurrentXPosition = pm.getAttr(eachJoint + ".translateX") pm.setAttr(SpineStretchMult + ".input2X", CurrentXPosition) pm.connectAttr(curveScaleRatio + ".outputX", SpineStretchMult + ".input1X") pm.connectAttr(SpineStretchMult + ".outputX", eachJoint + ".translateX") #Scale multiplication function of each spine joint if index >= center: PowValue = (GaussLen - 1 - index) else: PowValue = index SpineStretchRatio = pm.shadingNode( 'multiplyDivide', asUtility=True, name="SpineStretchRatio" + self.NameConv.get_a_short_name(eachJoint)) self.NameConv.rename_name_in_format(SpineStretchRatio, name=SpineStretchRatio) pm.connectAttr(Chest + ".spineSquashFactor ", SpineStretchRatio + ".input1X") pm.setAttr(SpineStretchRatio + ".input2X", PowValue) pm.setAttr(SpineStretchRatio + ".operation", 1) SpineScaleStretchPow = pm.shadingNode( 'multiplyDivide', asUtility=True, name="SpineScaleStretchPow" + self.NameConv.get_a_short_name(eachJoint)) self.NameConv.rename_name_in_format(SpineScaleStretchPow, name=SpineScaleStretchPow) pm.connectAttr(curveScaleRatio + ".outputX ", SpineScaleStretchPow + ".input1X") pm.connectAttr(SpineStretchRatio + ".outputX ", SpineScaleStretchPow + ".input2X") pm.setAttr(SpineScaleStretchPow + ".operation", 3) SpineInversScaleRatio = pm.shadingNode( 'multiplyDivide', asUtility=True, name="SpineInverseScaleRatio") self.NameConv.rename_name_in_format(SpineInversScaleRatio, name=SpineInversScaleRatio) pm.connectAttr(SpineScaleStretchPow + ".outputX ", SpineInversScaleRatio + ".input1X") pm.setAttr(SpineInversScaleRatio + ".input2X", -1) pm.setAttr(SpineInversScaleRatio + ".operation", 3) pm.connectAttr(SpineInversScaleRatio + ".outputX", eachJoint + ".scaleY") pm.connectAttr(SpineInversScaleRatio + ".outputX", eachJoint + ".scaleZ") index += 1 resetWaist, waist = RMRigShapeControls.RMCircularControl( AllSpine[1], radius=SpineLength * .8, name="waist") pm.parent(ResetChest, waist) pm.parent(resetWaist, COG) self.chestControl = Chest self.resetChestControl = ResetChest self.waistControl = waist self.resetWaistControl = resetWaist self.COG = COG self.ResetCOG = ResetCOG self.SpineLength = SpineLength