예제 #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
예제 #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
예제 #3
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
예제 #4
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