Esempio n. 1
0
    def EyeLidsSetUp(self, EyeNode):

        Rigtools = RMRigTools.RMRigTools()
        EyeNodeBB = RMRigTools.boundingBoxInfo(EyeNode)
        eyeRadius = (EyeNodeBB.zmax - EyeNodeBB.zmin) / 2

        # eyeScale = cmds.getAttr("%s.scale"%EyeNode) [0]
        # cmds.setAttr ( EyeNode + ".scale", 1.0, 1.0, 1.0)


        MainUpperLid = cmds.joint(name="EyeUpperLid", rad=eyeRadius / 5)
        UpperLid = cmds.joint(name="EyeUpperLidTip", rad=eyeRadius / 5)
        MainLowerLid = cmds.joint(name="EyeLowerLid", rad=eyeRadius / 5)
        LowerLid = cmds.joint(name="EyeLowerLidTip", rad=eyeRadius / 5)

        RMRigTools.RMAlign(EyeNode, MainUpperLid, 3)
        EyeParent = Rigtools.RMCreateGroupOnObj(MainUpperLid, Type='parent')
        EyeParent = self.NameConv.rename_set_from_name(EyeParent, "EyeLidSpin", Token='name')
        MainEye = Rigtools.RMCreateGroupOnObj(EyeParent, Type='parent')
        MainEye = self.NameConv.rename_set_from_name(MainEye, "Eye", Token='name')

        upperLidParent = Rigtools.RMCreateGroupOnObj(MainUpperLid)
        upperLidParent = self.NameConv.rename_set_from_name(upperLidParent, "EyeUpperLidReset", Token='name')

        cmds.parent(MainLowerLid, EyeParent)
        LowerLidParent = Rigtools.RMCreateGroupOnObj(MainLowerLid)

        RMRigTools.RMAlign(EyeParent, LowerLid, 3)

        MiddleMainUpperLid = cmds.joint(name="EyeMiddleMainUpperLid", rad=eyeRadius / 5)
        MiddleUpperLid = cmds.joint(name="EyeMiddleUpperLidTip", rad=eyeRadius / 5)
        MiddleMainLowerLid = cmds.joint(name="EyeMiddleLowerLid", rad=eyeRadius / 5)
        MiddleLowerLid = cmds.joint(name="EyeMiddleLowerLidTip", rad=eyeRadius / 5)

        RMRigTools.RMAlign(EyeParent, MiddleMainUpperLid, 3)

        cmds.parent(MiddleMainUpperLid, upperLidParent)
        cmds.parent(MiddleMainLowerLid, LowerLidParent)

        cmds.setAttr("%s.translateX" % UpperLid, eyeRadius)
        cmds.setAttr("%s.translateX" % LowerLid, eyeRadius)
        cmds.setAttr("%s.translateX" % MiddleUpperLid, eyeRadius)
        cmds.setAttr("%s.translateX" % MiddleLowerLid, eyeRadius)

        mDUpper = cmds.shadingNode("multiplyDivide", asUtility=True, name="EyeUpperMultDiv")

        cmds.connectAttr("%s.rotate" % MainUpperLid, "%s.input1" % mDUpper)
        cmds.setAttr("%s.input2" % mDUpper, .5, .5, .5)
        cmds.connectAttr("%s.output" % mDUpper, "%s.rotate" % MiddleMainUpperLid)

        mDLower = cmds.shadingNode("multiplyDivide", asUtility=True, name="EyeLowerMultDiv")
        cmds.connectAttr("%s.rotate" % MainLowerLid, "%s.input1" % mDLower)
        cmds.setAttr("%s.input2" % mDLower, .5, .5, .5)
        cmds.connectAttr("%s.output" % mDLower, "%s.rotate" % MiddleMainLowerLid)

        # cmds.setAttr(EyeParent +".scale",eyeScale[0],eyeScale[1],eyeScale[2])
        cmds.setAttr("%s.rotateY" % MainEye, -90)
        cmds.select(EyeNode, replace=True)
        # latticeAttr, lattice, latticeBase = cmds.lattice(name = "EyeLattice", oc= True, dv = [2, 2, 2], ol =  2, ofd = (eyeRadius/3) )
        # latticeScale = cmds.getAttr(lattice+".scale")[0]


        # cmds.setAttr ( lattice + ".scale", float(latticeScale[0]) + float(eyeScale[0]), float(latticeScale[1]) + float(eyeScale[1]), float(latticeScale[2]) + float(eyeScale[2]))

        # renamingto NameConvention.
        if self.NameConv.is_name_in_format(EyeNode):
            side = self.NameConv.get_from_name(EyeNode, Token="Side")
        else:
            side = "MD"
        # latticeAttr, lattice, latticeBase,
        self.NameConv.rename_name_in_format(
            [mDUpper, mDLower, UpperLid, LowerLid, MiddleMainUpperLid, MiddleMainLowerLid], {'side':side})
        self.NameConv.rename_set_from_name([EyeParent, LowerLidParent, upperLidParent], side, Token="side")
        MainEye = self.NameConv.rename_set_from_name(MainEye, side, Token="side")

        self.NameConv.rename_name_in_format([MiddleUpperLid, MiddleLowerLid], {'objectType': "sknjnt", 'side': side})
        MainLowerLid = self.NameConv.rename_name_in_format(MainLowerLid, {'objectType': "sknjnt", 'side': side})
        MainUpperLid = self.NameConv.rename_name_in_format(MainUpperLid, {'objectType': "sknjnt", 'side': side})

        if not cmds.objExists("Character_MD_EyesRig00_grp_rig"):
            EyesRig = self.NameConv.set_name_in_format("EyesRig", Type="grp", System="rig")
            cmds.group(empty=True, name=EyesRig)
            RMRigTools.RMChangeRotateOrder(EyesRig, "xzy")
            cmds.setAttr("%s.rotateY" % EyesRig, -90)
        else:
            EyesRig = "Character_MD_EyesRig00_grp_rig"

        cmds.parent(MainEye, EyesRig)
        cmds.makeIdentity(MainUpperLid, apply=True, r=1)
        cmds.makeIdentity(MainLowerLid, apply=True, r=1)

        return MainEye
Esempio n. 2
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]])