def SpiralOfPoints(initRadius, endRadius, turns, numberOfPoints): loc1 = cmds.spaceLocator() loc2 = cmds.spaceLocator() cmds.parent(loc2[0], loc1[0]) cmds.setAttr(loc2[0] + ".translateX", float(initRadius)) groupPoints = cmds.group(empty=True) degreeTurns = float(turns * 360) degreeStep = float(degreeTurns) / (numberOfPoints - 1) posStep = (float(initRadius) - float(endRadius)) / (numberOfPoints - 1) spcLocArray = [] startRot = 0.0 startPos = float(initRadius) for point in range(0, numberOfPoints): NewLoc = cmds.spaceLocator() spcLocArray.append(NewLoc[0]) RMRigTools.RMAlign(loc2[0], spcLocArray[point], 3) startPos += (-posStep) cmds.setAttr(loc2[0] + ".translateX", startPos) startRot += degreeStep cmds.setAttr(loc1[0] + ".rotateZ", startRot) cmds.parent(NewLoc, groupPoints) jointArray = mel.eval('''source "RMRigTools.mel";\nsource "RMRigShapeControls.mel";\n RMCreateBonesAtPoints( ''' + melstringArray(spcLocArray) + ''');''') control = mel.eval('''RMCreaControl("''' + spcLocArray[0] + '''",''' + str(float(endRadius)) + ''');''') cmds.addAttr(control, longName="unfold", keyable=True, hasMinValue=True, hasMaxValue=True, maxValue=10, minValue=0) unfoldStep = 10.0 / numberOfPoints currentStep = 0.0 for joints in jointArray: currentrot = cmds.joint(joints, q=True, orientation=True) RMRigTools.connectWithLimits(control + ".unfold", joints + ".rotateZ", [[currentStep, 0], [currentStep + unfoldStep, abs(currentrot[2])]]) currentStep = currentStep + unfoldStep
def SpiralOfPointsStraight(initRadius, endRadius, numberOfPoints, startPoint, endPoint): RigTools = RMRigTools.RMRigTools() ShapeCntrl = RMRigShapeControls.RMRigShapeControls() distancia = RMRigTools.RMPointDistance(startPoint, endPoint) minLength = math.sin(math.pi / (numberOfPoints + 1)) * initRadius # initRadiusdistancia/numberOfPoints/10 print "minLength:%s" % minLength if minLength * numberOfPoints < distancia: # Locators = RigTools.RMCreateNLocatorsBetweenObjects( startPoint, endPoint, numberOfPoints ) Locators = RigTools.RMCreateBiasedLocatorsBetweenObjects(startPoint, endPoint, numberOfPoints, minLength) Locators.insert(0, startPoint) Locators.insert(len(Locators), endPoint) parentJoint, jointArray = RigTools.RMCreateBonesAtPoints(Locators) resetPnt, control = ShapeCntrl.RMCircularControl(startPoint, radius=initRadius) cmds.addAttr(control, longName="unfold", keyable=True, hasMinValue=True, hasMaxValue=True, maxValue=10, minValue=-10) unfoldStep = 10.0 / float(numberOfPoints + 1) currentStep = 10.0 index = 0 deltaRadius = (initRadius - endRadius) / numberOfPoints currentRadius = initRadius # jointArray.reverse() angle = 20 for joints in jointArray[:-1]: # angle = 180 - SegmentAngleInCircle(currentRadius, RMRigTools.lenght_of_bone(joints) ) if index > 0: angle = getAngle(currentRadius, joints, jointArray[index - 1]) else: angle = getAngle(currentRadius, joints, None) # angle = SpiralFunction (index, numberOfPoints, initRadius, endRadius, distancia) # angle = SpiralFunctionBiasedPoints (index, numberOfPoints, initRadius, endRadius, distancia, minLength) RMRigTools.connectWithLimits(control + ".unfold", joints + ".rotateY", [[-currentStep, angle], [-(currentStep - unfoldStep), 0], [currentStep - unfoldStep, 0], [currentStep, -angle]]) currentStep = currentStep - unfoldStep print currentRadius currentRadius = currentRadius - deltaRadius index += 1
def JawSetup(self): if cmds.objExists("Jaw"): RMRigTools.connectWithLimits( "Character_MD_JawOpen_ctrl_fc.translateY", "Jaw.rotateZ", [[0, 0], [-1, -20], [1, 7]]) RMRigTools.connectWithLimits( "Character_MD_JawFwd_ctrl_fc.translateX", "Jaw.rotateY", [[0, 0], [1, 20], [-1, -20]]) RMRigTools.connectWithLimits( "Character_MD_JawFwd_ctrl_fc.translateY", "Jaw.translateX", [[0, 0], [1, -1], [-1, 1]])
currentStep = currentStep + unfoldStep ''' ''' cmds.addAttr("PapirusControl",longName="SinAmplitude",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=0,maxValue=10) cmds.addAttr("PapirusControl",longName="SinPhase",keyable=1) cmds.addAttr("PapirusControl",longName="SinDecay",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=-10,maxValue=10) cmds.addAttr("PapirusControl",longName="SinDecayPos",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=0,maxValue=10) cmds.addAttr("PapirusControl",longName="SinWaveLen",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=0,maxValue=10) cmds.addAttr("PapirusControl",longName="BendFloor",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=-10,maxValue=10) cmds.addAttr("PapirusControl",longName="BendFloorDistance",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=0,maxValue=10) cmds.addAttr("PapirusControl",longName="BendDirection",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=-10,maxValue=10) cmds.addAttr("PapirusControl",longName="ExtraControls",attributeType="enum",enumName = "Off:On") ''' ''' RMRigTools.connectWithLimits("PapirusControl.BendRoll","RolledBend.curvature",[[-10,-180],[0,0],[10,180]]) cmds.connectAttr("PapirusControl.BendRollDirection","RollbendHandle.rotateY",force=True) RMRigTools.connectWithLimits("PapirusControl.BendFloor","FloorBend.curvature",[[-10,-180],[0,0],[10,180]]) RMRigTools.connectWithLimits("PapirusControl.BendFloorDistance","FloorBendHandle.translateZ",[[0,0],[10,-20]]) RMRigTools.connectWithLimits("PapirusControl.SinAmplitude","Wave.amplitude",[[0,0],[10,-20]]) cmds.connectAttr("PapirusControl.SinPhase","Wave.offset",force=True) RMRigTools.connectWithLimits("PapirusControl.SinDecay","Wave.dropoff",[[-10,-1] , [0,0] , [10,1]] ) RMRigTools.connectWithLimits("PapirusControl.SinDecayPos","sine1Handle.translateZ",[[0,0],[10,-20]]) RMRigTools.connectWithLimits("PapirusControl.SinWaveLen","Wave.wavelength",[[0,.1],[10,6]]) RMRigTools.connectWithLimits("PapirusControl.BendDirection","DirectionBend.curvature",[[-10,-90],[0,0],[10,90]]) cmds.connectAttr("PapirusControl.ExtraControls","curve1.visibility",force=True) ''' ''' cmds.addAttr("MainControl",longName="SinAmplitude",keyable=1,hasMinValue=1,hasMaxValue=1,minValue=0,maxValue=10) cmds.addAttr("MainControl",longName="SinPhase",keyable=1)
def LinkFacial(self, BSname="CharacterFacialBS"): self.checkExistance() cmds.blendShape("Character", name=BSname) NumBS = 0 for keys in sorted(self.FaceBlendShapeDic.iterkeys()): if cmds.objExists(keys): if keys == "LEyeCls" and cmds.objExists("LEyeHalfCls"): cmds.blendShape( BSname, edit=True, target=["Character", NumBS, "LEyeHalfCls", .5]) if keys == "REyeCls" and cmds.objExists("REyeHalfCls"): cmds.blendShape( BSname, edit=True, target=["Character", NumBS, "REyeHalfCls", .5]) cmds.blendShape(BSname, edit=True, target=["Character", NumBS, keys, 1.0]) self.FaceBlendShapeDic[keys]["index"] = NumBS self.FaceBlendShapeDic[keys]["Exists"] = True NumBS += 1 else: print "el objeto" + keys + " no fue encontrado." self.FaceBlendShapeDic[keys]["Exists"] = False if self.FaceBlendShapeDic["Incisibus"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_Incisibus_ctrl_fc.translateY", BSname + ".Incisibus", [[0, 0], [2, 1]]) if self.FaceBlendShapeDic["REyeCls"]["Exists"]: RMRigTools.connectWithLimits( "Character_RH_ReyeCls_ctrl_fc.translateY", BSname + ".REyeCls", [[0, 0], [-2, 1]]) if self.FaceBlendShapeDic["LEyeCls"]["Exists"]: RMRigTools.connectWithLimits( "Character_LF_LeyeCls_ctrl_fc.translateY", BSname + ".LEyeCls", [[0, 0], [-2, 1]]) if self.FaceBlendShapeDic["RBrowOutUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_RBrowOutUpDn_ctrl_fc.translateY", BSname + ".RBrowOutUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RBrowOutDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_RBrowOutUpDn_ctrl_fc.translateY", BSname + ".RBrowOutDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["RBrowInUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_RBrowOutUpDn_ctrl_fc.translateX", BSname + ".RBrowInUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RBrowInDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_RBrowOutUpDn_ctrl_fc.translateX", BSname + ".RBrowInDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["LBrowOutUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LBrowOutUpDn_ctrl_fc.translateY", BSname + ".LBrowOutUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LBrowOutDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LBrowOutUpDn_ctrl_fc.translateY", BSname + ".LBrowOutDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["LBrowInUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LBrowOutUpDn_ctrl_fc.translateX", BSname + ".LBrowInUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LBrowInDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LBrowOutUpDn_ctrl_fc.translateX", BSname + ".LBrowInDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["LBrowsqueeze"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_Browsqueeze_ctrl_fc.translateY", (BSname + ".LBrowsqueeze"), [[-1, -1], [0, 0], [1, 1]]) if self.FaceBlendShapeDic["RBrowsqueeze"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_Browsqueeze_ctrl_fc.translateX", (BSname + ".RBrowsqueeze"), [[-1, -1], [0, 0], [1, 1]]) if self.FaceBlendShapeDic["UprLipUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_UprLipUpDn_ctrl_fc.translateY", BSname + ".UprLipUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["UprLipDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_UprLipUpDn_ctrl_fc.translateY", BSname + ".UprLipDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["LwrLipUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LowerLipUpDn_ctrl_fc.translateY", BSname + ".LwrLipUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LwrLipDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_LowerLipUpDn_ctrl_fc.translateY", BSname + ".LwrLipDn", [[0, 0], [-1, 1]]) if cmds.objExists("LeyeLookAt") and cmds.objExists( "LeyeOrientacion" ) and self.FaceBlendShapeDic["LEyeRollLf"][ "Exists"] and self.FaceBlendShapeDic["LEyeRollRh"]["Exists"]: if not cmds.objExists("LEyesHzFinalRotationPlus"): cmds.shadingNode("plusMinusAverage", asUtility=True, name="LEyesHzFinalRotationPlus") cmds.connectAttr("LeyeLookAt.rotateY", "LEyesHzFinalRotationPlus.input1D[0]") cmds.connectAttr("LeyeOrientacion.rotateY", "LEyesHzFinalRotationPlus.input1D[1]") if self.FaceBlendShapeDic["LEyeRollLf"]["Exists"]: RMRigTools.connectWithLimits( "LEyesHzFinalRotationPlus.output1D", BSname + ".LEyeRollLf", [[0, 0], [45, 1]]) if self.FaceBlendShapeDic["LEyeRollRh"]["Exists"]: RMRigTools.connectWithLimits( "LEyesHzFinalRotationPlus.output1D", BSname + ".LEyeRollRh", [[0, 0], [-45, 1]]) if cmds.objExists("ReyeLookAt") and cmds.objExists( "ReyeOrientacion" ) and self.FaceBlendShapeDic["REyeRollLf"][ "Exists"] and self.FaceBlendShapeDic["REyeRollRh"]["Exists"]: if not cmds.objExists("REyesHorizontalFinalRotationPlus"): cmds.shadingNode("plusMinusAverage", asUtility=True, name="REyesHorizontalFinalRotationPlus") cmds.connectAttr( "ReyeLookAt.rotateY", "REyesHorizontalFinalRotationPlus.input1D[0]") cmds.connectAttr( "ReyeOrientacion.rotateY", "REyesHorizontalFinalRotationPlus.input1D[1]") if self.FaceBlendShapeDic["REyeRollLf"]["Exists"]: RMRigTools.connectWithLimits( "REyesHorizontalFinalRotationPlus.output1D", BSname + ".REyeRollLf", [[0, 0], [45, 1]]) if self.FaceBlendShapeDic["REyeRollRh"]["Exists"]: RMRigTools.connectWithLimits( "REyesHorizontalFinalRotationPlus.output1D", BSname + ".REyeRollRh", [[0, 0], [-45, 1]]) if cmds.objExists("ReyeLookAt") and cmds.objExists( "ReyeOrientacion" ) and self.FaceBlendShapeDic["REyeRollUp"][ "Exists"] and self.FaceBlendShapeDic["REyeRollDn"]["Exists"]: if not cmds.objExists("REyesVerticalFinalRotationPlus"): cmds.shadingNode("plusMinusAverage", asUtility=True, name="REyesVerticalFinalRotationPlus") cmds.connectAttr("ReyeLookAt.rotateX", "REyesVerticalFinalRotationPlus.input1D[0]") cmds.connectAttr("ReyeOrientacion.rotateX", "REyesVerticalFinalRotationPlus.input1D[1]") if self.FaceBlendShapeDic["REyeRollUp"]["Exists"]: RMRigTools.connectWithLimits( "REyesVerticalFinalRotationPlus.output1D", BSname + ".REyeRollUp", [[0, 0], [-45, 1]]) if self.FaceBlendShapeDic["REyeRollDn"]["Exists"]: RMRigTools.connectWithLimits( "REyesVerticalFinalRotationPlus.output1D", BSname + ".REyeRollDn", [[0, 0], [45, 1]]) if cmds.objExists("LeyeLookAt") and cmds.objExists( "LeyeOrientacion" ) and self.FaceBlendShapeDic["LEyeRollDn"][ "Exists"] and self.FaceBlendShapeDic["LEyeRollUp"]["Exists"]: if not cmds.objExists("LEyesVerticalFinalRotationPlus"): cmds.shadingNode("plusMinusAverage", asUtility=True, name="LEyesVerticalFinalRotationPlus") cmds.connectAttr("LeyeLookAt.rotateX", "LEyesVerticalFinalRotationPlus.input1D[0]") cmds.connectAttr("LeyeOrientacion.rotateX", "LEyesVerticalFinalRotationPlus.input1D[1]") if self.FaceBlendShapeDic["LEyeRollUp"]["Exists"]: RMRigTools.connectWithLimits( "LEyesVerticalFinalRotationPlus.output1D", BSname + ".LEyeRollUp", [[0, 0], [-45, 1]]) if self.FaceBlendShapeDic["LEyeRollDn"]["Exists"]: RMRigTools.connectWithLimits( "LEyesVerticalFinalRotationPlus.output1D", BSname + ".LEyeRollDn", [[0, 0], [45, 1]]) if self.FaceBlendShapeDic["Wide"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_JawOpen_ctrl_fc.translateX", BSname + ".Wide", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["Narrow"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_JawOpen_ctrl_fc.translateX", BSname + ".Narrow", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["Wide"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_JawOpen_ctrl_fc.translateX", BSname + ".Wide", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RSmile"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_MouthEmotion_ctrl_fc.translateY", BSname + ".RSmile", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RFrown"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_MouthEmotion_ctrl_fc.translateY", BSname + ".RFrown", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["LSmile"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_MouthEmotion_ctrl_fc.translateX", BSname + ".LSmile", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LFrown"]["Exists"]: RMRigTools.connectWithLimits( "Character_MD_MouthEmotion_ctrl_fc.translateX", BSname + ".LFrown", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["RSquint"]["Exists"]: RMRigTools.connectWithLimits( "Character_RH_RSquint_ctrl_fc.translateY", BSname + ".RSquint", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LSquint"]["Exists"]: RMRigTools.connectWithLimits( "Character_LF_LSquint_ctrl_fc.translateY", BSname + ".LSquint", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RSneer"]["Exists"]: RMRigTools.connectWithLimits( "Character_RH_RSneer_ctrl_fc.translateY", BSname + ".RSneer", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LSneer"]["Exists"]: RMRigTools.connectWithLimits( "Character_LF_LSneer_ctrl_fc.translateY", BSname + ".LSneer", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LBrowPositionUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_LF_LBrowPosition_ctrl_fc.translateY", BSname + ".LBrowPositionUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["RBrowPositionUp"]["Exists"]: RMRigTools.connectWithLimits( "Character_RH_RBrowPosition_ctrl_fc.translateY", BSname + ".RBrowPositionUp", [[0, 0], [1, 1]]) if self.FaceBlendShapeDic["LBrowPositionDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_LF_LBrowPosition_ctrl_fc.translateY", BSname + ".LBrowPositionDn", [[0, 0], [-1, 1]]) if self.FaceBlendShapeDic["RBrowPositionDn"]["Exists"]: RMRigTools.connectWithLimits( "Character_RH_RBrowPosition_ctrl_fc.translateY", BSname + ".RBrowPositionDn", [[0, 0], [-1, 1]])