Ejemplo n.º 1
0
 def RMCreateHeadRig(self):
     headSize = RMRigTools.RMLenghtOfBone(self.HeadJoints[0])
     print '%s %s' % (self.rootHeadJoints, self.rootHeadJoints.__class__)
     resetHeadControl, headControl = RMRigShapeControls.RMImportMoveControl(
         self.rootHeadJoints, scale=headSize, name="head", Type="head")
     pm.parentConstraint(headControl, self.HeadJoints[0])
     return resetHeadControl, headControl
Ejemplo n.º 2
0
 def RMCreateHipSystem(self):
     #resetHipControl, hipControl = RMRigShapeControls.circular_control(self.rootHip,radius = self.SpineLength *.7,name = "hip")
     resetHipControl, hipControl = RMRigShapeControls.RMImportMoveControl(
         self.rootHip,
         scale=self.SpineLength,
         name="hip",
         Type="circleDeform")
     pm.parent(resetHipControl, self.COG)
     pm.parentConstraint(hipControl, self.hipJoints[0])
     pm.parent(self.rootHip, self.spineJoints[0])
     return resetHipControl, hipControl
Ejemplo n.º 3
0
    def StardardFeetFK(self, StandarFeetPointsDic, FeetControl=None):
        Side = self.NameConv.get_from_name(
            self.StandardFeetPointsDic["feet"][0], "side")
        self.rootFKJoints, StandardFeetFKJoints = self.StandardReverseFeetJointStructure(
            StandarFeetPointsDic)

        self.NameConv.rename_set_from_name(StandardFeetFKJoints,
                                           "FK",
                                           "name",
                                           mode="add")

        FootIn = self.StandardFeetPointsDic["limitIn"]
        FootOut = self.StandardFeetPointsDic["limitOut"]
        FootBK = self.StandardFeetPointsDic["limitBack"]
        Length = RMRigTools.RMPointDistance(
            self.StandardFeetPointsDic["feet"][2], FootBK)

        if not FeetControl:
            self.FirstLimbFeetResetControl, FeetControl = RMRigShapeControls.RMCircularControl(
                StandardFeetFKJoints[0], radius=Length, name="FKFeetControl")

        self.FeetControl = FeetControl

        SecondLimbfeetResetControl, SecondLimbFeetControl = RMRigShapeControls.RMCircularControl(
            StandardFeetFKJoints[1], radius=Length, name="FKTipFeetControl")

        pm.parentConstraint(FeetControl, StandardFeetFKJoints[0], mo=True)
        pm.parentConstraint(SecondLimbFeetControl,
                            StandardFeetFKJoints[1],
                            mo=True)
        pm.parentConstraint(StandardFeetFKJoints[0],
                            SecondLimbfeetResetControl,
                            mo=True)

        pm.parent(SecondLimbfeetResetControl, FeetControl)
        RMRigTools.RMLockAndHideAttributes(FeetControl, "000111000h")
        RMRigTools.RMLockAndHideAttributes(SecondLimbFeetControl, "000111000h")

        self.StandardFeetFKJoints = StandardFeetFKJoints
        self.SecondLimbFeetControl = SecondLimbFeetControl
        self.SecondLimbControlResetPoint = SecondLimbfeetResetControl
Ejemplo n.º 4
0
    def CreateJointChainSquareRig(self, JointChain, UDaxis="Y"):
        if self.NameConv.is_name_in_format(JointChain[0]):
            if self.NameConv.get_from_name(JointChain[0], "side") == "LF":
                sideVariation = 1
            else:
                sideVariation = -1
        else:
            sideVariation = 1

        if UDaxis in ["Y", "Z"]:
            BoxResetPoint, BoxControl = RMRigShapeControls.RMCreateBoxCtrl(
                JointChain[len(JointChain) - 1],
                ParentBaseSize=True,
                Xratio=.5,
                Yratio=.5,
                Zratio=.5)
            self.addChainParameters(BoxControl, len(JointChain) - 1)

            cmds.makeIdentity(BoxControl,
                              apply=True,
                              r=False,
                              t=True,
                              s=True,
                              n=0)

            cmds.parentConstraint(JointChain[len(JointChain) - 1],
                                  BoxResetPoint)

            RMRigTools.RMLockAndHideAttributes(BoxControl, "0000000000")

            if UDaxis == "Y":
                LRaxis = "Z"
            elif UDaxis == "Z":
                LRaxis = "Y"
            for eachjoint in range(len(JointChain) - 1):
                RMRigTools.RMConnectWithLimits(
                    BoxControl + ".UD" + str(eachjoint + 1),
                    JointChain[eachjoint] + (".rotate%s" % UDaxis),
                    [[-10, 100], [0, 0], [10, -100]])
                RMRigTools.RMConnectWithLimits(
                    BoxControl + ".LR" + str(eachjoint + 1),
                    JointChain[eachjoint] + (".rotate%s" % LRaxis),
                    [[-10, sideVariation * 100], [0, 0],
                     [10, sideVariation * -100]])
                RMRigTools.RMConnectWithLimits(
                    BoxControl + ".Twist" + str(eachjoint + 1),
                    JointChain[eachjoint] + ".rotateX",
                    [[-10, sideVariation * 100], [0, 0],
                     [10, sideVariation * -100]])
        else:
            print "Not Valid UD Axis Provided"
Ejemplo n.º 5
0
 def __init__(self, name_conv=None):
     if not name_conv:
         self.name_conv = nameConvention.NameConvention()
     else:
         self.name_conv = name_conv
     self.rig_controls = RMRigShapeControls.RMRigShapeControls(
         NameConv=name_conv)
     self.kinematics = []
     self.joints = []
     self.controls = []
     self.baseObjects = []
     self.jointStructure = []
     self.folicules = []
     self.resetControls = []
     self.allControls = []
Ejemplo n.º 6
0
    def CreateFingerSquareRig(self, Finger):

        if self.NameConv.get_from_name(Finger[0], "side") == "L":
            sideVariation = 1
        else:
            sideVariation = -1

        BoxResetPoint, BoxControl = RMRigShapeControls.RMCreateBoxCtrl(
            Finger[len(Finger) - 1],
            ParentBaseSize=True,
            Xratio=.5,
            Yratio=.5,
            Zratio=.5)
        self.RMaddFinguerControls(BoxControl)

        pm.makeIdentity(BoxControl, apply=True, r=False, t=True, s=True, n=0)
        pm.parentConstraint(Finger[len(Finger) - 1], BoxResetPoint)

        RMRigTools.RMLockAndHideAttributes(BoxControl, "0000000000")

        RMRigTools.RMConnectWithLimits("%s.MidUD" % BoxControl,
                                       "%s.rotateY" % Finger[0],
                                       [[-10, 100], [0, 0], [10, -100]])
        RMRigTools.RMConnectWithLimits(
            "%s.MidLR" % BoxControl, "%s.rotateZ" % Finger[0],
            [[-10, sideVariation * 120], [0, 0], [10, sideVariation * -127]])
        RMRigTools.RMConnectWithLimits(
            "%s.MidTwist" % BoxControl, "%s.rotateX" % Finger[0],
            [[-10, sideVariation * 90], [0, 0], [10, sideVariation * -90]])
        index = 1
        for eachjoint in range(0, len(Finger) - 1):
            RMRigTools.RMConnectWithLimits("%s.UD%s" % (BoxControl, index),
                                           "%s.rotateY" % Finger[eachjoint],
                                           [[-10, 100], [0, 0], [10, -100]])
            RMRigTools.RMConnectWithLimits("%s.LR%s" % (BoxControl, index),
                                           "%s.rotateZ" % Finger[eachjoint],
                                           [[-10, sideVariation * 120], [0, 0],
                                            [10, sideVariation * -127]])
            RMRigTools.RMConnectWithLimits(
                "%s.Twist%s" % (BoxControl, index),
                "%s.rotateX" % Finger[eachjoint],
                [[-10, sideVariation * 90], [0, 0], [10, sideVariation * -90]])
            index += 1
        self.fingerControlsReset.append(BoxResetPoint)
        self.fingerContols.append(BoxControl)
Ejemplo n.º 7
0
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
Ejemplo n.º 8
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
Ejemplo n.º 9
0
    def RMCreateTwist(self, TwistJoint, LookAtObject,  NumberOfTB = 3, LookAtAxis = "Y"):
        #LookAtObject = pm.listRelatives( TwistJoint,type = "transform",children=True)[]
    
        positionA = pm.xform(TwistJoint, q=True,ws=True,rp=True)
        positionB = pm.xform(LookAtObject, q=True,ws=True,rp=True)

        vectorA = om.MVector(positionA)
        vectorB = om.MVector(positionB)

        self.RMCreateBonesBetweenPoints(vectorA,vectorB,NumberOfTB, AlignObject=TwistJoint)

        Distance = RMRigTools.RMPointDistance( TwistJoint, LookAtObject)
        
        pm.parentConstraint (TwistJoint, self.TwistResetJoints)

        resetPoint , control = RMRigShapeControls.RMCreateBoxCtrl(self.TwistJoints[0],
                                                                  Xratio=.1,
                                                                  Yratio=.1,
                                                                  Zratio=.1,
                                                                  customSize=Distance/5,
                                                                  name="TwistOrigin%s" % self.NameConv.get_a_short_name(TwistJoint).title())
        #control = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , control,  NewName = self.NameConv.RMGetAShortName(control))
        #resetPoint = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , resetPoint,  NewName = self.NameConv.RMGetAShortName(resetPoint))
        
        sign = 1
        MoveDistance = Distance/5
        if "-" in LookAtAxis:
            sign = -1
        if "Z" in LookAtAxis or "z" in LookAtAxis:
            MoveList = [0,0, MoveDistance * sign]
            WUV = [0,0,sign]
        elif "Y" in LookAtAxis or "y" in LookAtAxis:
            MoveList = [0,MoveDistance * sign, 0]
            WUV = [0,sign,0]

        pm.xform( resetPoint, os = True, relative=True,  t = MoveList)

        pm.aimConstraint( LookAtObject,self.TwistJoints[0], aim = [1,0,0], worldUpVector = [0,0,1], worldUpType = "object", worldUpObject = control)

        TwistJointDivide = pm.shadingNode("multiplyDivide", asUtility=True,
                                          name="TwistJoint%s" % self.NameConv.get_a_short_name(TwistJoint).title())
        self.NameConv.rename_based_on_base_name(TwistJoint, TwistJointDivide,
                                                name=self.NameConv.get_a_short_name(TwistJointDivide))
        # TwistAddition = pm.shadingNode( "plusMinusAverage", asUtility = True, name = "TwistJointAdd" +
        # self.NameConv.get_a_short_name(TwistJoint).title())
        # self.NameConv.rename_based_on_base_name(TwistJoint, TwistAddition,
        # name=self.NameConv.get_a_short_name(TwistAddition))
        # NegativeLookAtRotation = pm.shadingNode("multiplyDivide", asUtility=True,
        # name="NegativeLookAtRotation%s" % self.NameConv.get_a_short_name(TwistJoint).title())
        # self.NameConv.rename_based_on_base_name(TwistJoint, NegativeLookAtRotation,
        # name=self.NameConv.get_a_short_name(NegativeLookAtRotation))
        # pm.connectAttr(LookAtObject + ".rotateX", NegativeLookAtRotation + ".input1X")
        # pm.setAttr("%s.input2X" % NegativeLookAtRotation, -1)
        # pm.setAttr("%s.operation" % NegativeLookAtRotation, 1)
        # pm.connectAttr("%s.rotateX" % self.TwistJoints[0], "%s.input1D[0]" % TwistAddition)
        # pm.connectAttr("%s.outputX" % NegativeLookAtRotation, "%s.input1D[1]" % TwistAddition)
        # pm.connectAttr("%s.output1D" % TwistAddition, "%s.input1X" % TwistJointDivide)

        pm.connectAttr("%s.rotateX" % self.TwistJoints[0], "%s.input1X" % TwistJointDivide)

        #pm.connectAttr(self.TwistJoints[0]+".rotateX", TwistJointDivide + ".input1X") in this case the rotation of the lookatNode was not affecting
        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.rotateX" % eachJoint)

        self.TwistControlResetPoint = resetPoint
        self.TwistControl = control
Ejemplo n.º 10
0
    def CreateBipedRig(self):
        try:
            CharacterName = self.MetaNameConv.AssetType + "_" + self.MetaNameConv.AssetName + "_rig"
        except:
            CharacterName = "MainCharacter"

        if pm.objExists(CharacterName):
            MainGroup = CharacterName
        else:
            MainGroup = pm.group(empty=True, name=CharacterName)

        if pm.objExists("mesh_grp"):
            mesh = pm.ls("mesh_grp")[0]
        else:
            mesh = pm.group(empty=True, name="mesh_grp")

        if pm.objExists("rig_grp"):
            rig = pm.ls("rig_grp")[0]
        else:
            rig = pm.group(empty=True, name="rig_grp")
        pm.setAttr("%s.visibility" % rig, False)

        for eachgroup in self.geometryGroups:
            if not pm.objExists(eachgroup):
                pm.group(empty=True, name=eachgroup)
                pm.parent(eachgroup, mesh)

        deformation = pm.group(empty=True, name="deformation")
        kinematics = pm.group(empty=True, name="kinematics")
        joints = pm.group(empty=True, name="joints")
        controls = pm.group(empty=True, name="controls_grp")
        self.world = pm.group(empty=True, name="world" + CharacterName)
        self.moverWorld = pm.group(empty=True,
                                   name="moverWorld" + CharacterName)

        self.Spine = RMSpine.RMSpine()
        self.LimbArmLeft = RMLimbIKFK.RMLimbIKFK(worldNode=self.world,
                                                 NameConv=self.NameConv)
        self.LimbLegRight = RMLimbIKFK.RMLimbIKFK(worldNode=self.world,
                                                  NameConv=self.NameConv)
        self.LimbLegLeft = RMLimbIKFK.RMLimbIKFK(worldNode=self.world,
                                                 NameConv=self.NameConv)
        self.LimbArmRight = RMLimbIKFK.RMLimbIKFK(worldNode=self.world,
                                                  NameConv=self.NameConv)
        self.LFfeet = RMFeet.RMFeetRig()
        self.RHfeet = RMFeet.RMFeetRig()

        self.kinematics = kinematics
        self.deformation = deformation
        self.joints = joints
        self.controls = controls

        pm.parent(self.world, self.kinematics)
        pm.parent(self.moverWorld, self.kinematics)

        meshp = pm.listRelatives(mesh, parent=True)
        if not meshp:
            pm.parent(mesh, MainGroup)
        rigp = pm.listRelatives(rig, parent=True)
        if not rigp:
            pm.parent(rig, MainGroup)

        pm.parent(controls, MainGroup)
        pm.parent(deformation, rig)
        pm.parent(kinematics, rig)
        pm.parent(joints, rig)

        #Creacion del spine
        spineJoints = [
            "C_Spine01_rig_pnt", "C_Spine02_rig_pnt", "C_Spine03_rig_pnt",
            "C_Spine04_rig_pnt", "C_Spine05_rig_pnt"
        ]
        hip = ["C_Spine01_rig_pnt", "C_Hip01_rig_pnt"]
        clavLF = ["L_clavicle01_rig_pnt", "L_shoulder01_rig_pnt"]
        clavRH = ["R_clavicle01_rig_pnt", "R_shoulder01_rig_pnt"]

        self.Spine.RMCreateSpineRig(spineJoints, hip, clavLF, clavRH)

        spineKinematics = pm.group(empty=True, name="spineKinematics")
        self.NameConv.rename_name_in_format(spineKinematics,
                                            system="kinematics")
        spineControls = pm.group(empty=True, name="spineControls")
        self.NameConv.rename_name_in_format(spineControls, system="controls")
        spineJoints = pm.group(empty=True, name="spineJoints")
        self.NameConv.rename_name_in_format(spineJoints, system="joints")

        pm.parent(spineKinematics, kinematics)
        pm.parent(spineControls, controls)
        pm.parent(spineJoints, deformation)

        pm.parent(self.Spine.ResetCOG, spineControls)
        pm.parent(self.Spine.kinematics, spineKinematics)
        pm.parent(self.Spine.rootSpineJoints, spineJoints)

        mover01Reset, self.Mover01 = RMRigShapeControls.RMCircularControl(
            self.world,
            axis="Y",
            radius=self.Spine.SpineLength * 1.5,
            name="mover02")
        mover02Reset, self.Mover02 = RMRigShapeControls.RMCircularControl(
            self.world,
            axis="Y",
            radius=self.Spine.SpineLength * 2,
            name="mover01")
        placerReset, self.placer = RMRigShapeControls.RMCircularControl(
            self.world,
            axis="Y",
            radius=self.Spine.SpineLength * 2.5,
            name="mainPlacer")

        self.mainMover = self.Mover01
        pm.parent(placerReset, controls)
        pm.parent(mover02Reset, self.placer)
        pm.parent(mover01Reset, self.Mover02)
        pm.parent(spineControls, self.Mover01)
        pm.parentConstraint(self.Mover01, self.moverWorld)
        '''
        WorldRClavicle = pm.group(empty = True, name = "clavicleWorld" )
        WorldRClavicle = self.NameConv.RMRenameBasedOnBaseName (self.Spine.rightClavicleControl, WorldRClavicle, NewName = "world", System = "RClavicleSpaceSwitch")
        RMRigTools.RMAlign(self.Spine.rightClavicleControl, WorldRClavicle ,3)
        pm.parent( WorldRClavicle, self.moverWorld)
        RSpaceSwitchGroup = RMRigTools.RMCreateGroupOnObj(self.Spine.rightClavicleControl)
        self.SPSW.CreateSpaceSwitch(RSpaceSwitchGroup,[self.Spine.resetRightClavicleControl, WorldRClavicle],self.Spine.rightClavicleControl, constraintType = "orient")

        WorldLClavicle = pm.group(empty = True, name = "clavicleWorld" )
        WorldLClavicle = self.NameConv.RMRenameBasedOnBaseName (self.Spine.leftClavicleControl, WorldLClavicle, NewName = "world", System = "LClavicleSpaceSwitch")
        RMRigTools.RMAlign(self.Spine.leftClavicleControl, WorldLClavicle ,3)
        pm.parent( WorldLClavicle, self.moverWorld)
        LSpaceSwitchGroup = RMRigTools.RMCreateGroupOnObj(self.Spine.leftClavicleControl)
        self.SPSW.CreateSpaceSwitch(LSpaceSwitchGroup,[self.Spine.resetLeftClavicleControl, WorldLClavicle],self.Spine.leftClavicleControl, constraintType = "orient")
        '''

        #Creacion de la cabeza

        neck = ["C_neck01_rig_pnt", "C_head01_rig_pnt"]
        Head = ["C_head01_rig_pnt", "C_headTip01_rig_pnt"]
        Jaw = ["C_jaw01_rig_pnt", "C_jawTip01_rig_pnt"]

        self.NeckHead.RMCreateHeadAndNeckRig(Head, neck, Jaw)
        pm.parent(self.NeckHead.RootNeckJoints, self.Spine.chestJoint)
        pm.parent(self.NeckHead.resetNeckControl,
                  self.Spine.ChestRotationControl)

        WorldHead = pm.group(empty=True, name="worldHead")
        self.NameConv.rename_based_on_base_name(self.NeckHead.headControl,
                                                WorldHead,
                                                name="world",
                                                system="HeadSpaceSwitch")
        RMRigTools.RMAlign(self.NeckHead.resetHeadControl, WorldHead, 3)
        pm.parent(WorldHead, self.world)

        HeadResetPoint = pm.group(empty=True, name="NeckOrientConstraint")
        self.NameConv.rename_based_on_base_name(self.NeckHead.headControl,
                                                HeadResetPoint,
                                                name="Neck",
                                                system="HeadSpaceSwitch")
        RMRigTools.RMAlign(self.NeckHead.resetHeadControl, HeadResetPoint, 3)
        pm.parent(HeadResetPoint, self.NeckHead.NeckJoints[1])

        self.SPSW.CreateSpaceSwitch(self.NeckHead.resetHeadControl,
                                    [HeadResetPoint, WorldHead],
                                    self.NeckHead.headControl,
                                    constraintType="orient",
                                    mo=True)

        #Creacion de Brazos
        #BrazoDerecho
        self.LimbArmRight.RMLimbRig("R_shoulder01_rig_pnt", FKAxisFree='010')
        RHArmDic = self.OrganizeLimb(self.LimbArmRight, "RH", "Arm",
                                     self.Spine.RightClavicleJoints[1],
                                     self.Spine.chestJoint)

        RHWorldFKArm = pm.group(empty=True, name="ArmWorld")
        self.NameConv.rename_based_on_base_name(
            self.LimbArmRight.FKparentGroup,
            RHWorldFKArm,
            name="world",
            system="RFKArmSpaceSwitch")
        RMRigTools.RMAlign(self.LimbArmRight.FKparentGroup, RHWorldFKArm, 3)
        pm.parent(RHWorldFKArm, self.moverWorld)
        RSpaceSwitchGroup = self.rig_tools.RMCreateGroupOnObj(
            self.LimbArmRight.FKparentGroup)
        self.SPSW.CreateSpaceSwitchReverse(
            self.LimbArmRight.FKparentGroup, [RSpaceSwitchGroup, RHWorldFKArm],
            self.LimbArmRight.FKFirstLimbControl,
            sswtype="float",
            Name="",
            mo=False,
            constraintType="orient")

        #BrazoIzquierdo
        self.LimbArmLeft.RMLimbRig("L_shoulder01_rig_pnt", FKAxisFree='010')
        RHArmDic = self.OrganizeLimb(self.LimbArmLeft, "LF", "Arm",
                                     self.Spine.LeftClavicleJoints[1],
                                     self.Spine.chestJoint)

        LFWorldFKArm = pm.group(empty=True, name="ArmWorld")
        self.NameConv.rename_based_on_base_name(self.LimbArmLeft.FKparentGroup,
                                                LFWorldFKArm,
                                                name="world",
                                                system="LFKArmSpaceSwitch")
        RMRigTools.RMAlign(self.LimbArmLeft.FKparentGroup, LFWorldFKArm, 3)
        pm.parent(LFWorldFKArm, self.moverWorld)
        LSpaceSwitchGroup = self.rig_tools.RMCreateGroupOnObj(
            self.LimbArmLeft.FKparentGroup)
        self.SPSW.CreateSpaceSwitchReverse(self.LimbArmLeft.FKparentGroup,
                                           [LSpaceSwitchGroup, LFWorldFKArm],
                                           self.LimbArmLeft.FKFirstLimbControl,
                                           sswtype="float",
                                           Name="",
                                           mo=False,
                                           constraintType="orient")

        #ManoDerecha
        self.GHRightRig = RMGenericHandRig.RMGenericHandRig()
        self.GHRightRig.CreateHandRig("R_palm01_rig_pnt",
                                      self.LimbArmRight.SpaceSwitchControl)

        #pm.group(name = "R_palmMover_grp_rig")
        RMRigTools.RMAlign("R_palm01_rig_pnt",
                           self.LimbArmRight.IKControlResetPoint, 3)
        RMRigTools.RMAlign("R_palm01_rig_pnt",
                           self.LimbArmRight.ThirdLimbParent, 3)

        self.LimbArmRight.SPSW.RMCreateListConstraintSwitch(
            [self.GHRightRig.MainKinematics],
            [self.LimbArmRight.IKjointStructure[2]],
            self.LimbArmRight.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch")
        self.LimbArmRight.SPSW.RMCreateListConstraintSwitch(
            [self.GHRightRig.MainKinematics],
            [self.LimbArmRight.FKTrirdLimbControl],
            self.LimbArmRight.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch",
            reverse=True)
        self.LimbArmLeft.SPSW.CreateSpaceSwitch(
            self.LimbArmRight.IKControlResetPoint, [
                self.Spine.rightClavicleControl, self.world, self.Spine.COG,
                self.Spine.hipJoints[0], self.NeckHead.HeadJoints[0],
                self.moverWorld
            ], self.LimbArmRight.ikControl)

        pm.parent(self.GHRightRig.MainKinematics, RHArmDic["kinematics"])
        pm.parent(
            self.GHRightRig.GHS.palmJoint,
            self.LimbArmRight.TJElbow.TwistJoints[
                len(self.LimbArmRight.TJElbow.TwistJoints) - 1])
        pm.parent(self.GHRightRig.PalmResetPoint, RHArmDic["controls"])

        #ManoIzquierda
        self.GHLeftRig = RMGenericHandRig.RMGenericHandRig()
        self.GHLeftRig.CreateHandRig(
            "L_palm01_rig_pnt",
            PalmControl=self.LimbArmLeft.SpaceSwitchControl)

        RMRigTools.RMAlign("L_palm01_rig_pnt",
                           self.LimbArmLeft.IKControlResetPoint, 3)
        RMRigTools.RMAlign("L_palm01_rig_pnt",
                           self.LimbArmLeft.ThirdLimbParent, 3)

        self.LimbArmLeft.SPSW.RMCreateListConstraintSwitch(
            [self.GHLeftRig.MainKinematics],
            [self.LimbArmLeft.IKjointStructure[2]],
            self.LimbArmLeft.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch")
        self.LimbArmLeft.SPSW.RMCreateListConstraintSwitch(
            [self.GHLeftRig.MainKinematics],
            [self.LimbArmLeft.FKTrirdLimbControl],
            self.LimbArmLeft.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch",
            reverse=True)
        self.LimbArmLeft.SPSW.CreateSpaceSwitch(
            self.LimbArmLeft.IKControlResetPoint, [
                self.Spine.leftClavicleControl, self.world, self.Spine.COG,
                self.Spine.hipJoints[0], self.NeckHead.HeadJoints[0],
                self.moverWorld
            ], self.LimbArmLeft.ikControl)

        pm.parent(self.GHLeftRig.MainKinematics, RHArmDic["kinematics"])
        pm.parent(
            self.GHLeftRig.GHS.palmJoint, self.LimbArmLeft.TJElbow.TwistJoints[
                len(self.LimbArmLeft.TJElbow.TwistJoints) - 1])
        pm.parent(self.GHLeftRig.PalmResetPoint, RHArmDic["controls"])

        #Creacion de pierna

        self.LimbLegRight.RMLimbRig("R_leg01_rig_pnt", FKAxisFree='001')
        RHLegDic = self.OrganizeLimb(self.LimbLegRight, "RH", "Leg",
                                     self.Spine.hipJoints[1],
                                     self.Spine.hipJoints[1])

        self.LimbLegLeft.RMLimbRig("L_leg01_rig_pnt", FKAxisFree='001')
        LFLegDic = self.OrganizeLimb(self.LimbLegLeft, "LF", "Leg",
                                     self.Spine.hipJoints[1],
                                     self.Spine.hipJoints[1])

        Locator = pm.spaceLocator(name="referenceLocator")

        RMRigTools.RMAlign("L_ball01_rig_pnt", Locator, 1)
        pm.setAttr(Locator + ".rotateX", 90)
        pm.setAttr(Locator + ".rotateZ", -90)

        RMRigTools.RMAlign(Locator, self.LimbLegLeft.IKControlResetPoint, 2)
        RMRigTools.RMAlign(Locator, self.LimbLegLeft.ThirdLimbParent, 2)
        RMRigTools.RMAlign(Locator, self.LimbLegRight.IKControlResetPoint, 2)
        RMRigTools.RMAlign(Locator, self.LimbLegRight.ThirdLimbParent, 2)

        pm.delete(Locator)

        StandarFeetLFPoints = {
            "feet":
            ["L_ankleFeet01_rig_pnt", "L_ball01_rig_pnt", "L_toe01_rig_pnt"],
            "limitBack":
            "L_footLimitBack01_rig_pnt",
            "limitOut":
            "L_footLimitOuter01_rig_pnt",
            "limitIn":
            "L_footLimitInner01_rig_pnt"
        }

        self.LFfeet.RigFeetIKFK(StandarFeetLFPoints,
                                self.LimbLegLeft.ikControl,
                                self.LimbLegLeft.FKTrirdLimbControl)

        self.LimbLegLeft.SPSW.RMCreateListConstraintSwitch(
            self.LFfeet.StandardFeetJoints,
            self.LFfeet.StandardFeetIKJoints,
            self.LimbLegLeft.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch")
        self.LimbLegLeft.SPSW.RMCreateListConstraintSwitch(
            self.LFfeet.StandardFeetJoints,
            self.LFfeet.StandardFeetFKJoints,
            self.LimbLegLeft.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch",
            reverse=True)

        pm.parent(
            self.LFfeet.rootJoints, self.LimbLegLeft.TJElbow.TwistJoints[
                len(self.LimbLegLeft.TJElbow.TwistJoints) - 1])

        feetJointsGroup = pm.group(empty=True, name="FeetJoints")
        self.NameConv.rename_name_in_format(feetJointsGroup, side="LF")
        pm.parent(self.LFfeet.MainFeetKinematics, feetJointsGroup)
        pm.parent(self.LFfeet.rootFKJoints, feetJointsGroup)
        pm.parent(feetJointsGroup, self.joints)

        pm.pointConstraint(self.LimbLegLeft.ikControl,
                           self.LimbLegLeft.IkHandle,
                           remove=True)
        pm.parent(self.LimbLegLeft.IkHandle, self.LFfeet.IKAttachPoint)

        pm.parent(self.LFfeet.rootIKJoints,
                  self.LimbLegLeft.IKjointStructure[2])

        StandarFeetRHPoints = {
            "feet":
            ["R_ankleFeet01_rig_pnt", "R_ball01_rig_pnt", "R_toe01_rig_pnt"],
            "limitBack":
            "R_footLimitBack01_rig_pnt",
            "limitOut":
            "R_footLimitOuter01_rig_pnt",
            "limitIn":
            "R_footLimitInner01_rig_pnt"
        }

        self.RHfeet.RigFeetIKFK(StandarFeetRHPoints,
                                self.LimbLegRight.ikControl,
                                self.LimbLegRight.FKTrirdLimbControl)

        self.LimbLegRight.SPSW.RMCreateListConstraintSwitch(
            self.RHfeet.StandardFeetJoints,
            self.RHfeet.StandardFeetIKJoints,
            self.LimbLegRight.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch")
        self.LimbLegRight.SPSW.RMCreateListConstraintSwitch(
            self.RHfeet.StandardFeetJoints,
            self.RHfeet.StandardFeetFKJoints,
            self.LimbLegRight.SpaceSwitchControl,
            SpaceSwitchName="IKFKSwitch",
            reverse=True)

        pm.parent(
            self.RHfeet.rootJoints, self.LimbLegRight.TJElbow.TwistJoints[
                len(self.LimbLegRight.TJElbow.TwistJoints) - 1])

        feetJointsGroup = pm.group(empty=True, name="FeetJoints")
        self.NameConv.rename_name_in_format(feetJointsGroup, side="right")
        pm.parent(self.RHfeet.MainFeetKinematics, feetJointsGroup)
        pm.parent(self.RHfeet.rootFKJoints, feetJointsGroup)
        pm.parent(feetJointsGroup, self.joints)

        pm.pointConstraint(self.LimbLegRight.ikControl,
                           self.LimbLegRight.IkHandle,
                           remove=True)
        pm.parent(self.LimbLegRight.IkHandle, self.RHfeet.IKAttachPoint)

        pm.parent(self.RHfeet.rootIKJoints,
                  self.LimbLegRight.IKjointStructure[2])

        #pm.parentConstraint(placer,self.kinematics)
        self.ColorCode()
        self.Visibility()
Ejemplo n.º 11
0
    def Visibility(self):
        '''self.Spine = None
        self.LimbArmLeft = None
        self.LimbLegRight = None
        self.LimbLegLeft = None
        self.LimbArmRight = None
        self.LFfeet = None
        self.RHfeet = None
        self.moverMain = None
        self.Mover01 = None
        self.Mover02 = None
        self.placer = None
        self.NeckHead
        self.GHRightRig = None
        self.GHLeftRig = None
        '''
        VisSwitch = RMVisibilitySwitch.RMVisibilitySwitch()

        Vgroup, VControl = RMRigShapeControls.RMImportMoveControl(
            self.NeckHead.HeadJoints[0],
            scale=RMRigTools.RMLenghtOfBone(self.NeckHead.HeadJoints[0]),
            Type="v")
        pm.setAttr("%s.rotateX" % Vgroup, 0)
        pm.setAttr("%s.rotateY" % Vgroup, 0)
        pm.setAttr("%s.rotateZ" % Vgroup, 0)

        RMRigTools.RMAlign(self.NeckHead.HeadJoints[1], Vgroup, 1)

        pm.parentConstraint(self.Mover01, Vgroup, mo=True)
        pm.parent(Vgroup, "controls_grp")

        VisSwitch.ConstraintVisibility([
            self.LimbArmLeft.PoleVectorControl, self.LimbArmLeft.ikControl,
            self.LimbArmLeft.FKFirstLimbControl,
            self.LimbArmLeft.FKSecondLimbControl,
            self.LimbArmLeft.FKTrirdLimbControl,
            self.LimbArmLeft.SpaceSwitchControl,
            self.LimbArmRight.PoleVectorControl, self.LimbArmRight.ikControl,
            self.LimbArmRight.FKFirstLimbControl,
            self.LimbArmRight.FKSecondLimbControl,
            self.LimbArmRight.FKTrirdLimbControl,
            self.LimbArmRight.SpaceSwitchControl,
            self.LimbLegLeft.PoleVectorControl, self.LimbLegLeft.ikControl,
            self.LimbLegLeft.FKFirstLimbControl,
            self.LimbLegLeft.FKSecondLimbControl,
            self.LimbLegLeft.FKTrirdLimbControl,
            self.LimbLegLeft.SpaceSwitchControl,
            self.LimbLegRight.PoleVectorControl, self.LimbLegRight.ikControl,
            self.LimbLegRight.FKFirstLimbControl,
            self.LimbLegRight.FKSecondLimbControl,
            self.LimbLegRight.FKTrirdLimbControl,
            self.LimbLegRight.SpaceSwitchControl,
            self.Spine.rightClavicleControl, self.Spine.leftClavicleControl,
            self.Spine.waistControl, self.Spine.chestControl,
            self.Spine.hipControl, self.Spine.COG,
            self.LFfeet.SecondLimbFeetControl,
            self.RHfeet.SecondLimbFeetControl, self.GHRightRig.MainControl,
            self.GHLeftRig.MainControl
        ],
                                       VControl,
                                       VisibilitySwitch="Controls",
                                       visibilityType="lodVisibility")
        #print self.LFfeet.feetMainMoveIK
        #print self.RHfeet.feetMainMoveIK
        VisSwitch.ConstraintVisibility([
            self.LimbArmLeft.TJArm.TwistControl,
            self.LimbArmLeft.TJElbow.TwistControl,
            self.LimbArmRight.TJArm.TwistControl,
            self.LimbArmRight.TJElbow.TwistControl,
            self.LimbLegLeft.TJArm.TwistControl,
            self.LimbLegLeft.TJElbow.TwistControl,
            self.LimbLegRight.TJArm.TwistControl,
            self.LimbLegRight.TJElbow.TwistControl
        ],
                                       VControl,
                                       VisibilitySwitch="Secondary",
                                       visibilityType="lodVisibility")

        VisSwitch.ConstraintVisibility(["body_grp"],
                                       VControl,
                                       VisibilitySwitch="Geometry")
        VisSwitch.AddAffectedObject(VControl,
                                    self.Spine.secondaryControls,
                                    VisibilitySwitch="Secondary",
                                    visibilityType="lodVisibility")
        VisSwitch.AddAffectedObject(VControl,
                                    self.GHRightRig.fingerControlsReset,
                                    VisibilitySwitch="Controls",
                                    visibilityType="lodVisibility")
        VisSwitch.AddAffectedObject(VControl,
                                    self.GHLeftRig.fingerControlsReset,
                                    VisibilitySwitch="Controls",
                                    visibilityType="lodVisibility")

        RMRigTools.RMLockAndHideAttributes(VControl, "0000000000")
        #VisSwitch.AddEnumParameters( VControl, VisibilitySwitch = "Facial"   )

        pass
Ejemplo n.º 12
0
    def CreatePalmRig(self, PalmControl=None):

        if self.NameConv.get_from_name(self.GHS.palmJoint, "side") == "L":
            sideVariation = -1
        else:
            sideVariation = 1

        self.CreatePalmReferencePoints()

        if PalmControl == None:
            palmResetPoint, PalmControl = RMRigShapeControls.RMCircularControl(
                self.GHS.palmJoint)
        else:
            palmResetPoint = pm.group(empty=True, name="palmControl")
            self.NameConv.rename_based_on_base_name(self.GHS.palmJoint,
                                                    palmResetPoint,
                                                    name=palmResetPoint)
            RMRigTools.RMAlign(self.GHS.palmJoint, palmResetPoint, 3)

        self.PalmControl = PalmControl
        self.PalmResetPoint = palmResetPoint
        self.MainControl = palmResetPoint

        # palmResetPoint = self.NameConv.RMRenameSetFromName(palmResetPoint,"palmControls","Name")

        self.RMaddPalmControls(self.PalmControl)
        RMRigTools.RMLockAndHideAttributes(self.PalmControl, "0000000000")

        pinky = self.GHS.fingerJointsByName("pinky")
        if pinky:
            self.PalmFingerControlGrp[
                "pinky"] = self.name_conv.RMCreateGroupOnObj(pinky[0])
            RMRigTools.RMChangeRotateOrder(pinky, "yxz")
            RMRigTools.RMConnectWithLimits(
                "%s.Spread" % self.PalmControl,
                '%s.rotateZ' % self.PalmFingerControlGrp["pinky"],
                [[-10, sideVariation * 10], [0, 0], [10, sideVariation * -60]])
        ring = self.GHS.fingerJointsByName("ring")
        if ring:
            self.PalmFingerControlGrp[
                "ring"] = self.name_conv.RMCreateGroupOnObj(ring[0])
            RMRigTools.RMChangeRotateOrder(ring, "yxz")
            RMRigTools.RMConnectWithLimits(
                "%s.Spread" % self.PalmControl,
                '%s.rotateZ' % self.PalmFingerControlGrp["ring"],
                [[-10, sideVariation * 5], [0, 0], [10, sideVariation * -30]])
        middle = self.GHS.fingerJointsByName("middle")
        if middle:
            self.PalmFingerControlGrp[
                "middle"] = self.name_conv.RMCreateGroupOnObj(middle[0])
            RMRigTools.RMChangeRotateOrder(middle, "yxz")
            RMRigTools.RMConnectWithLimits(
                "%s.Spread" % self.PalmControl,
                '%s.rotateZ' % self.PalmFingerControlGrp["middle"],
                [[-10, 0], [0, 0], [10, sideVariation * -5]])
        index = self.GHS.fingerJointsByName("index")
        if index:
            self.PalmFingerControlGrp[
                "index"] = self.name_conv.RMCreateGroupOnObj(index[0])
            RMRigTools.RMChangeRotateOrder(index, "yxz")
            RMRigTools.RMConnectWithLimits(
                "%s.Spread" % self.PalmControl,
                '%s.rotateZ' % self.PalmFingerControlGrp["index"],
                [[-10, sideVariation * -5], [0, 0], [10, sideVariation * 30]])
        thumb = self.GHS.fingerJointsByName("thumb")
        if thumb:
            self.PalmFingerControlGrp[
                "thumb"] = self.name_conv.RMCreateGroupOnObj(thumb[0])
            RMRigTools.RMChangeRotateOrder(thumb, "yxz")
            RMRigTools.RMConnectWithLimits(
                "%s.Spread" % self.PalmControl,
                '%s.rotateZ' % self.PalmFingerControlGrp["thumb"],
                [[-10, sideVariation * -10], [0, 0], [10, sideVariation * 60]])

        for eachFingerName in self.fingerRoot:
            if eachFingerName != 'thumb':
                RMRigTools.RMConnectWithLimits(
                    "%s.PalmBend" % self.PalmControl,
                    '%s.rotateY' % self.PalmFingerControlGrp[eachFingerName],
                    [[-10, 90], [0, 0], [10, -90]])
                RMRigTools.RMConnectWithLimits(
                    "%s.Twist" % self.PalmControl,
                    '%s.rotateX' % self.PalmReferencePoints[eachFingerName],
                    [[-10, sideVariation * 45], [0, 0],
                     [10, sideVariation * -45]])

        RMRigTools.RMConnectWithLimits(
            "%s.PalmCup" % self.PalmControl,
            '%s.rotateX' % self.PalmReferencePoints["pinky"],
            [[0, 0], [10, sideVariation * 50]])
        RMRigTools.RMConnectWithLimits(
            "%s.PalmCup" % self.PalmControl,
            '%s.rotateX' % self.PalmReferencePoints["ring"],
            [[0, 0], [10, sideVariation * 25]])
        RMRigTools.RMConnectWithLimits(
            "%s.PalmCup" % self.PalmControl,
            '%s.rotateX' % self.PalmReferencePoints["middle"],
            [[0, 0], [10, sideVariation * 5]])
        RMRigTools.RMConnectWithLimits(
            "%s.PalmCup" % self.PalmControl,
            '%s.rotateX' % self.PalmReferencePoints["index"],
            [[0, 0], [10, sideVariation * -30]])
        RMRigTools.RMConnectWithLimits(
            "%s.PalmCup" % self.PalmControl,
            '%s.rotateX' % self.PalmReferencePoints["thumb"],
            [[0, 0], [10, sideVariation * -60]])
Ejemplo n.º 13
0
    def StandardFeetIKRig(self, StandarFeetPointsDic, FeetControl=None):
        self.StandardFeetPointsDic = StandarFeetPointsDic

        Side = self.NameConv.get_from_name(
            self.StandardFeetPointsDic["feet"][0], "side")
        self.rootIKJoints, StandardFeetIKJoints = self.StandardReverseFeetJointStructure(
            StandarFeetPointsDic)
        self.NameConv.rename_set_from_name(StandardFeetIKJoints,
                                           "IK",
                                           "name",
                                           mode="add")

        FootIn = self.StandardFeetPointsDic["limitIn"]
        FootOut = self.StandardFeetPointsDic["limitOut"]
        FootBK = self.StandardFeetPointsDic["limitBack"]

        Length = RMRigTools.RMPointDistance(
            self.StandardFeetPointsDic["feet"][2], FootBK)
        Width = RMRigTools.RMPointDistance(FootIn, FootOut)

        BallGrp = pm.group(empty=True,
                           name=self.NameConv.set_name_in_format(name="Ball",
                                                                 side=Side))
        BallLift = pm.group(empty=True,
                            name=self.NameConv.set_name_in_format(
                                name="BallLift", side=Side))
        TapGrp = pm.group(empty=True,
                          name=self.NameConv.set_name_in_format(name="TapGrp",
                                                                side=Side))
        TipGrp = pm.group(empty=True,
                          name=self.NameConv.set_name_in_format(name="TipGrp",
                                                                side=Side))
        SideInGrp = pm.group(empty=True,
                             name=self.NameConv.set_name_in_format(
                                 name="SideInGrp", side=Side))
        SideOutGrp = pm.group(empty=True,
                              name=self.NameConv.set_name_in_format(
                                  name="SideOutGrp", side=Side))
        FeetOrient = pm.group(empty=True,
                              name=self.NameConv.set_name_in_format(
                                  name="FeetOrient", side=Side))
        FeetPalmOrient = pm.group(empty=True,
                                  name=self.NameConv.set_name_in_format(
                                      name="FeetPalmOrient", side=Side))

        RMRigTools.RMAlign(StandardFeetIKJoints[1], BallGrp, 3)
        RMRigTools.RMAlign(StandardFeetIKJoints[1], BallLift, 3)

        RMRigTools.RMAlign(StandardFeetIKJoints[1], TipGrp, 3)
        RMRigTools.RMAlign(StandardFeetIKJoints[2], TipGrp, 1)
        RMRigTools.RMAlign(StandardFeetIKJoints[1], TapGrp, 3)

        RMRigTools.RMAlign(FootIn, SideInGrp, 3)
        RMRigTools.RMAlign(FootOut, SideOutGrp, 3)
        RMRigTools.RMAlign(FootBK, TapGrp, 3)
        RMRigTools.RMAlign(BallGrp, FeetPalmOrient, 3)
        RMRigTools.RMAlign(StandardFeetIKJoints[0], FeetOrient, 3)

        pm.xform(FeetOrient, objectSpace=True, relative=True, t=[0, 0, Width])
        pm.xform(FeetPalmOrient,
                 objectSpace=True,
                 relative=True,
                 t=[0, 0, Width])

        BallIK, BallIkEffector = pm.ikHandle(
            sj=StandardFeetIKJoints[0],
            ee=StandardFeetIKJoints[1],
            name="BallIK")  # solver="ikRPsolver",
        TipIK, TipIkEffector = pm.ikHandle(
            sj=StandardFeetIKJoints[1],
            ee=StandardFeetIKJoints[2],
            name="TipIK")  # solver="ikRPsolver",

        self.NameConv.rename_name_in_format(BallIK, side=Side)
        self.NameConv.rename_name_in_format(TipIK, side=Side)
        self.NameConv.rename_name_in_format(BallIkEffector, side=Side)
        self.NameConv.rename_name_in_format(TipIkEffector, side=Side)

        # pm.poleVectorConstraint (FeetOrient, BallIK)
        # pm.poleVectorConstraint (FeetPalmOrient, TipIK)

        pm.parent(BallIK, BallLift)
        pm.parent(TipIK, BallLift)
        pm.parent(BallLift, SideInGrp)
        pm.parent(BallGrp, SideInGrp)
        pm.parent(SideInGrp, SideOutGrp)
        pm.parent(SideOutGrp, TapGrp)
        pm.parent(TapGrp, TipGrp)
        pm.parent(FeetOrient, BallGrp)
        pm.parent(FeetPalmOrient, BallLift)

        TipData = self.rig_tools.RMCreateGroupOnObj(TipGrp)
        MainFeet = self.rig_tools.RMCreateGroupOnObj(TipData)

        self.NameConv.rename_set_from_name(MainFeet, "MainFeet", "name")

        if not FeetControl:
            fetControlReset, FeetControl = RMRigShapeControls.RMCreateBoxCtrl(
                StandarFeetPointsDic["feet"][0],
                customSize=Length,
                Yratio=.6,
                Zratio=.3,
                name="FeetControl")
            self.fetControlReset = fetControlReset

        # self.feetMainMoveIK = TipData
        pm.parentConstraint(FeetControl, TipData, mo=True)

        self.RMStandardRigAttributes(FeetControl)

        pm.makeIdentity(BallGrp, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(BallLift, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(TapGrp, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(TipGrp, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(SideInGrp, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(SideOutGrp, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(FeetOrient, apply=True, t=1, r=1, s=1, n=0)
        pm.makeIdentity(FeetPalmOrient, apply=True, t=1, r=1, s=1, n=0)

        # pm.parent (self.rootIKJoints, BallGrp)

        RMRigTools.RMConnectWithLimits("%s.ToeLift" % FeetControl,
                                       "%s.rotateZ" % BallLift,
                                       [[-10, -70], [0, 0], [10, 70]])
        RMRigTools.RMConnectWithLimits("%s.BallPivot" % FeetControl,
                                       "%s.rotateZ" % BallGrp,
                                       [[-10, 70], [0, 0], [10, -70]])
        RMRigTools.RMConnectWithLimits("%s.HeelPivot" % FeetControl,
                                       "%s.rotateZ" % TapGrp,
                                       [[-10, -70], [0, 0], [10, 70]])
        RMRigTools.RMConnectWithLimits("%s.ToePivot" % FeetControl,
                                       "%s.rotateZ" % TipGrp,
                                       [[-10, 70], [0, 0], [10, -70]])
        if (Side == "L"):
            RMRigTools.RMConnectWithLimits("%s.Tilt" % FeetControl,
                                           "%s.rotateX" % SideInGrp,
                                           [[-10, 70], [0, 0]])
            RMRigTools.RMConnectWithLimits("%s.Tilt" % FeetControl,
                                           "%s.rotateX" % SideOutGrp,
                                           [[0, 0], [10, -70]])
            RMRigTools.RMConnectWithLimits("%s.ToePivotSide" % FeetControl,
                                           "%s.rotateY" % TipGrp,
                                           [[-10, 70], [0, 0], [10, -70]])
        # RMRigTools.RMConnectWithLimits( "%s.ToePivot" , TipGrp + ".rotateZ", [[-10,-70],[0,0],[10,70]])
        else:
            RMRigTools.RMConnectWithLimits("%s.Tilt" % FeetControl,
                                           "%s.rotateX" % SideInGrp,
                                           [[-10, -70], [0, 0]])
            RMRigTools.RMConnectWithLimits("%s.Tilt" % FeetControl,
                                           "%s.rotateX" % SideOutGrp,
                                           [[0, 0], [10, 70]])
            RMRigTools.RMConnectWithLimits("%s.ToePivotSide" % FeetControl,
                                           "%s.rotateY" % TipGrp,
                                           [[-10, -70], [0, 0], [10, 70]])
        # RMRigTools.RMCreateGroupOnObj( FeetControl)

        pm.scaleConstraint(FeetControl, MainFeet)

        self.MainFeetKinematics = MainFeet
        self.IKAttachPoint = BallGrp
        self.StandardFeetIKJoints = StandardFeetIKJoints
Ejemplo n.º 14
0
 def RMCreateNeckRig(self):
     resetNeckControl, NeckControl = RMRigShapeControls.RMCreateBoxCtrl(
         self.NeckJoints[0], name="neck")
     pm.parentConstraint(NeckControl, self.NeckJoints[0])
     return resetNeckControl, NeckControl
Ejemplo n.º 15
0
 def RMCreateClavicleSystem(self, rootClavicle, ClavicleJoints):
     resetClavicleControl, clavicleControl = RMRigShapeControls.RMCreateBoxCtrl(
         ClavicleJoints[0])
     pm.parent(resetClavicleControl, self.ChestRotationControl)
     pm.parentConstraint(clavicleControl, ClavicleJoints[0])
     return resetClavicleControl, clavicleControl
Ejemplo n.º 16
0
 def __init__(self, NameConv=None):
     self.joints = None
     self.controls = []
     self.rootControls = None
     self.rootJoints = None
     self.ShapeControls = RMRigShapeControls.RMRigShapeControls()
Ejemplo n.º 17
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)