Exemplo n.º 1
0
def RMCircularControl(Obj, radius=1, NameConv=None, axis="X", name=""):
    Obj = RMRigTools.validate_pymel_nodes(Obj)
    if not NameConv:
        NameConv = nameConvention.NameConvention()
    if name == '':
        defaultName = "circularControl"
    else:
        defaultName = name
    if axis in "yY":
        Ctrl, Shape = pm.circle(normal=[0, 1, 0],
                                radius=radius,
                                name=defaultName)
    elif axis in "zZ":
        Ctrl, Shape = pm.circle(normal=[0, 0, 1],
                                radius=radius,
                                name=defaultName)
    elif axis in "xX":
        Ctrl, Shape = pm.circle(normal=[1, 0, 0],
                                radius=radius,
                                name=defaultName)

    if name == '' and NameConv.is_name_in_format(Obj):

        NameConv.rename_based_on_base_name(Obj, Ctrl)
    else:
        NameConv.rename_based_on_base_name(Obj, Ctrl, name=Ctrl)

    NameConv.rename_set_from_name(Ctrl, "control", "objectType")

    RMRigTools.RMAlign(Obj, Ctrl, 3)

    ResetGroup = RMRigTools.RMCreateGroupOnObj(Ctrl)

    return ResetGroup, Ctrl
Exemplo n.º 2
0
def addNoiseOnControl(Object, Control):
    if Object.__class__ == list:
        pass

    elif Object.__class__ in [str, unicode]:
        Object = [Object]

    else:
        "Not Valid Arguments on Add Noise"
        return None

    Expresion = '''//{0}
    {0}.rotateX=`noise((time+{2})*{1}.frequency)`*{1}.amplitud;
    {0}.rotateY=`noise((time+{2}+30)*{1}.frequency)`*{1}.amplitud;
    {0}.rotateZ=`noise((time+{2}+60)*{1}.frequency)`*{1}.amplitud;
    {0}.ty=`noise((time+{2}+90)*{1}.frequency)`*{1}.movY + {1}.movY;
    '''
    if not isNoiseControl(Control):
        addAttributes(Control)

    for eachObject in Object:
        constraints = constraintComponents(gessFrom=eachObject)
        ResetGroup = RMRigTools.RMCreateGroupOnObj(eachObject, Type="child")
        for eachkey in constraints.constraintDic:
            pm.delete(eachkey)
            pm.parentConstraint(ResetGroup,
                                constraints.constraintDic[eachkey]["affected"],
                                mo=True)
        ExpressionNode = pm.expression(name="NoiseMainExpresion",
                                       string=Expresion.format(
                                           ResetGroup, Control,
                                           random.uniform(0, 100)))
Exemplo n.º 3
0
def clavicleSpaceSwitch():
	kinematics = cmds.ls("kinematics")[0]
	Mover01 = cmds.ls("*_MD_mover00_ctr_Rig")[0]
	rightClavicleControl = cmds.ls("*RH_clavicle00_ctr_Rig")[0]
	leftClavicleControl = cmds.ls("*LF_clavicle00_ctr_Rig")[0]
	resetLeftClavicleControl = cmds.ls("*LF_clavicle01_grp_Rig")[0]
	resetRightClavicleControl = cmds.ls("*RH_clavicle01_grp_Rig")[0]
	LimbArmRightikControl= cmds.ls("*_RH_wristIK00_ctr_Rig")[0]
	LimbArmLeftikControl= cmds.ls("*_LF_wristIK00_ctr_Rig")[0]

	NameConv = nameConvention.NameConvention()

	moverWorld = cmds.group( empty = True, name ="moverWorld")
	cmds.parent(moverWorld, kinematics)
	cmds.parentConstraint( Mover01 , moverWorld )

	SPSW = RMSpaceSwitch.RMSpaceSwitch()

	LFShoulderFK = cmds.ls("*_LF_shoulder00_grp_Limbfk")[0]
	LFFKShoulder = cmds.ls("*_LF_clavicle01_jnt_Rig")[0]
	LFControlShoulder = cmds.ls("*_LF_shoulderFK00_ctr_Rig")[0]

	RHShoulderFK = cmds.ls("*_RH_shoulder00_grp_Limbfk")[0]
	RHFKShoulder = cmds.ls("*_RH_clavicle01_jnt_Rig")[0]
	RHControlShoulder = cmds.ls("*_RH_shoulderFK00_ctr_Rig")[0]

	LFWorldFKArm = cmds.group(empty = True, name = "ArmWorld" )
	LFWorldFKArm = NameConv.rename_based_on_base_name (LFShoulderFK, LFWorldFKArm, {'name': "world", 'system': "LFKArmSpaceSwitch"})
	RMRigTools.RMAlign(LFShoulderFK, LFWorldFKArm ,3)
	cmds.parent( LFWorldFKArm, moverWorld)
	LSpaceSwitchGroup = RMRigTools.RMCreateGroupOnObj(LFShoulderFK)
	SPSW.CreateSpaceSwitchReverse(LFShoulderFK,[LSpaceSwitchGroup, LFWorldFKArm],LFControlShoulder,sswtype = "float", Name="", mo = False, constraintType = "orient")

	RHWorldFKArm = cmds.group(empty = True, name = "ArmWorld" )
	RHWorldFKArm = NameConv.rename_based_on_base_name (RHShoulderFK, RHWorldFKArm, {'name': "world", 'system': "RFKArmSpaceSwitch"})
	RMRigTools.RMAlign(RHShoulderFK, RHWorldFKArm ,3)
	cmds.parent( RHWorldFKArm, moverWorld)
	RSpaceSwitchGroup = RMRigTools.RMCreateGroupOnObj(RHShoulderFK)
	SPSW.CreateSpaceSwitchReverse(RHShoulderFK,[RSpaceSwitchGroup, RHWorldFKArm],RHControlShoulder,sswtype = "float", Name="", mo = False , constraintType = "orient")

	SPSW.AddSpaceObject(LimbArmRightikControl,moverWorld)
	SPSW.AddSpaceObject(LimbArmLeftikControl,moverWorld)
Exemplo n.º 4
0
def RMCreateBoxCtrl(Obj,
                    NameConv=None,
                    Xratio=1,
                    Yratio=1,
                    Zratio=1,
                    ParentBaseSize=False,
                    customSize=0,
                    name="",
                    centered=False):
    if not NameConv:
        NameConv = nameConvention.NameConvention()
    if name == "":
        defaultName = "BoxControl"
    else:
        defaultName = name

    Parents = pm.listRelatives(Obj, parent=True)

    if Parents and len(Parents) != 0 and ParentBaseSize == True:
        JntLength = RMRigTools.RMLenghtOfBone(Parents[0])
        Ctrl = RMCreateCubeLine(JntLength * Xratio,
                                JntLength * Yratio,
                                JntLength * Zratio,
                                name=defaultName,
                                centered=centered)
    else:
        if customSize != 0:
            JntLength = customSize

        elif pm.objectType(Obj) == "joint":
            JntLength = RMRigTools.RMLenghtOfBone(Obj)

        else:
            JntLength = 1
        Ctrl = RMCreateCubeLine(JntLength * Xratio,
                                JntLength * Yratio,
                                JntLength * Zratio,
                                name=defaultName,
                                centered=centered)

    if name == '' and NameConv.is_name_in_format(Obj):
        NameConv.rename_based_on_base_name(Obj, Ctrl)
    else:
        NameConv.rename_based_on_base_name(Obj, Ctrl, name=Ctrl)

    NameConv.rename_set_from_name(Ctrl, "control", "objectType")

    RMRigTools.RMAlign(Obj, Ctrl, 3)

    ResetGroup = RMRigTools.RMCreateGroupOnObj(Ctrl)
    return ResetGroup, Ctrl
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
def RMImportMoveControl(Obj, scale=1, NameConv=None, name='', Type="move"):
    Obj = RMRigTools.validate_pymel_nodes(Obj)
    MoversTypeDic = {
        "move": {
            "filename": "ControlMover.mb",
            "object": "MoverControl"
        },
        "v": {
            "filename": "ControlV.mb",
            "object": "VControl"
        },
        "head": {
            "filename": "ControlHead.mb",
            "object": "HeadControl"
        },
        "circleDeform": {
            "filename": "ControlCircularDeform.mb",
            "object": "CircularDeform"
        }
    }
    if not NameConv:
        NameConv = nameConvention.NameConvention()
    path = os.path.dirname(RMRigTools.__file__)
    RMPYPATH = os.path.split(path)
    FinalPath = os.path.join(RMPYPATH[0], "RMPY\AutoRig\RigShapes",
                             MoversTypeDic[Type]["filename"])
    if os.path.isfile(FinalPath):
        print 'ready  to import'
        pm.importFile(FinalPath,
                      i=True,
                      type="mayaBinary",
                      ignoreVersion=True,
                      mergeNamespacesOnClash=False,
                      rpr="ControlMover",
                      pr=False)
        print 'imported !!'
    else:
        print "archivo no encontrado %s , %s, %s " % (path, RMPYPATH,
                                                      FinalPath)
        return None

    Ctrl = pm.ls(MoversTypeDic[Type]["object"])[0]
    if pm.objExists(Ctrl):
        if name != '':
            Ctrl = pm.rename(Ctrl, name)

        pm.setAttr(Ctrl + ".scale", scale, scale, scale)

        pm.makeIdentity(Ctrl, apply=True, t=1, r=1, s=1)

        if name != '' and NameConv.is_name_in_format(Obj):

            NameConv.rename_based_on_base_name(Obj, Ctrl)

        else:

            NameConv.rename_based_on_base_name(Obj, Ctrl, name=Ctrl)
        NameConv.rename_set_from_name(Ctrl, "control", "objectType")

        RMRigTools.RMAlign(Obj, Ctrl, 3)

        ParentGroup = RMRigTools.RMCreateGroupOnObj(Ctrl)
        return ParentGroup, Ctrl
    else:
        print "Error importing Shape File"
        return None
Exemplo n.º 8
0
def SinglePropRig(scene_object, referencePositionControl, centerPivot=False):
    #if Object.__class__ == list :
    #elif Object.__class__ in [str,unicode]:
    GRS = RMGenericRigStructure.genericRigStructure()

    NameConv = nameConvention.NameConvention()
    bbMesh = RMRigTools.boundingBoxInfo(scene_object)
    CtrlPosition = pm.xform(referencePositionControl,
                            q=True,
                            rp=True,
                            worldSpace=True)

    NameList = scene_object.split(".")
    cntrlToMeshX = bbMesh.position[0] - CtrlPosition[0]
    cntrlToMeshY = bbMesh.position[1] - CtrlPosition[1]
    cntrlToMeshZ = bbMesh.position[2] - CtrlPosition[2]

    if len(NameList) > 1:
        Ctrl = RMRigShapeControls.RMCreateCubeLine(
            bbMesh.lenX,
            bbMesh.lenY,
            bbMesh.lenZ,
            offsetX=-bbMesh.minDistanceToCenterX + cntrlToMeshX,
            offsetY=-bbMesh.minDistanceToCenterY + bbMesh.lenY / 2 +
            cntrlToMeshY,
            offsetZ=-bbMesh.minDistanceToCenterZ + bbMesh.lenZ / 2 +
            cntrlToMeshZ,
            name=NameList[1])
        if centerPivot == True:
            pm.xform(Ctrl, cp=1)
        joint = pm.joint(name=NameList[1] + "jnt")
    else:
        Ctrl = RMRigShapeControls.RMCreateCubeLine(
            bbMesh.lenX,
            bbMesh.lenY,
            bbMesh.lenZ,
            offsetX=-bbMesh.minDistanceToCenterX + cntrlToMeshX,
            offsetY=-bbMesh.minDistanceToCenterY + bbMesh.lenY / 2 +
            cntrlToMeshY,
            offsetZ=-bbMesh.minDistanceToCenterZ + bbMesh.lenZ / 2 +
            cntrlToMeshZ,
            name=NameList[0] + "Ctrl")
        if centerPivot == True:
            pm.xform(Ctrl, cp=1)
        joint = pm.joint(name=NameList[0] + "jnt")

    Ctrl = NameConv.rename_name_in_format(Ctrl, {'objectType': "control"})
    ResetGroup = RMRigTools.RMCreateGroupOnObj(Ctrl)
    pm.parent(ResetGroup, GRS.groups["controls"]["group"])
    rigJntGrp = pm.ls("*SimpleRigJoints*")
    if len(rigJntGrp) == 0:
        jointGroup = pm.group(empty=True, name="SimpleRigJoints")
        jointGroup = NameConv.rename_name_in_format(jointGroup, {})
        pm.parent(jointGroup, GRS.groups["rig"]['group'])
    else:
        jointGroup = rigJntGrp
    if centerPivot != True:
        RMRigTools.RMAlign(referencePositionControl, ResetGroup, 3)

    joint = NameConv.rename_name_in_format(joint, {})

    RMRigTools.RMAlign(referencePositionControl, joint, 3)
    ResetJoint = RMRigTools.RMCreateGroupOnObj(joint)
    pm.parent(ResetJoint, jointGroup)
    #if pm.objExists
    #for eachObject in Object:
    pm.parentConstraint(Ctrl, joint)
    pm.skinCluster(joint, scene_object)