Example #1
0
    def RMCircularControl(self, Obj, radius=1, axis="X", name=""):
        Obj = RMRigTools.validate_pymel_nodes(Obj)
        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 == 'circularControl':
            if self.NameConv.is_name_in_format(Obj):
                self.NameConv.rename_based_on_base_name(Obj, Ctrl)
            else:
                self.NameConv.rename_name_in_format(Ctrl,
                                                    name=name,
                                                    objectType='control')
        else:
            self.NameConv.rename_name_in_format(Ctrl,
                                                name=name,
                                                objectType='control')
        RMRigTools.RMAlign(Obj, Ctrl, 3)

        ResetGroup = self.rigTools.RMCreateGroupOnObj(Ctrl)

        return ResetGroup, Ctrl
Example #2
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
Example #3
0
def SpiralOfPoints(initRadius, endRadius, turns, numberOfPoints):
    loc1 = cmds.spaceLocator()
    loc2 = cmds.spaceLocator()
    cmds.parent(loc2[0], loc1[0])
    cmds.setAttr(loc2[0] + ".translateX", float(initRadius))
    groupPoints = cmds.group(empty=True)
    degreeTurns = float(turns * 360)
    degreeStep = float(degreeTurns) / (numberOfPoints - 1)
    posStep = (float(initRadius) - float(endRadius)) / (numberOfPoints - 1)

    spcLocArray = []
    startRot = 0.0
    startPos = float(initRadius)
    for point in range(0, numberOfPoints):
        NewLoc = cmds.spaceLocator()
        spcLocArray.append(NewLoc[0])
        RMRigTools.RMAlign(loc2[0], spcLocArray[point], 3)
        startPos += (-posStep)
        cmds.setAttr(loc2[0] + ".translateX", startPos)
        startRot += degreeStep
        cmds.setAttr(loc1[0] + ".rotateZ", startRot)
        cmds.parent(NewLoc, groupPoints)
    jointArray = mel.eval('''source "RMRigTools.mel";\nsource "RMRigShapeControls.mel";\n
	RMCreateBonesAtPoints( ''' + melstringArray(spcLocArray) + ''');''')
    control = mel.eval('''RMCreaControl("''' + spcLocArray[0] + '''",''' + str(float(endRadius)) + ''');''')
    cmds.addAttr(control, longName="unfold", keyable=True, hasMinValue=True, hasMaxValue=True, maxValue=10, minValue=0)

    unfoldStep = 10.0 / numberOfPoints
    currentStep = 0.0

    for joints in jointArray:
        currentrot = cmds.joint(joints, q=True, orientation=True)
        RMRigTools.connectWithLimits(control + ".unfold", joints + ".rotateZ",
                                     [[currentStep, 0], [currentStep + unfoldStep, abs(currentrot[2])]])
        currentStep = currentStep + unfoldStep
def 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)
Example #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)
Example #6
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
Example #7
0
    def RMCreateSpineJointStructure(self, SpineRef):
        rootSpine, joints = RMRigTools.RMCreateBonesAtPoints(
            SpineRef, ZAxisOrientation="z")

        SpineLength = RMRigTools.RMPointDistance(joints[0],
                                                 joints[len(joints) - 1])
        chestJoint = pm.joint(name="chest")

        self.NameConv.rename_name_in_format(chestJoint, name=chestJoint)

        RMRigTools.RMAlign(joints[len(joints) - 1], chestJoint, 3)
        #pm.parent(chestJoint, joints[len(joints)-1])
        pm.makeIdentity(chestJoint, apply=True, r=False, t=True, s=True, n=0)
        pm.xform(chestJoint, t=[SpineLength / 4, 0, 0], os=True, relative=True)
        return rootSpine, joints, chestJoint
Example #8
0
def fetAnkleRotationCorrect(side="RH"):
    # IKCorrection
    control = "Character01_%s_ankleIK00_ctr_Rig" % side
    Ball = "Character01_%s_BallIk00_jnt_Rig" % side
    # ArrayOfChildren = RMRigTools.RMRemoveChildren (control)
    ParentConst = cmds.listConnections(control, type="parentConstraint")
    IKGroup = cmds.listConnections("%s.constraintRotateX" % ParentConst[0])[0]
    cmds.delete(ParentConst)
    controlParent = cmds.listRelatives(control, parent=True)
    loc = cmds.spaceLocator(name="ReferencePoint")[0]
    loc2 = cmds.spaceLocator(name="ReferencePoint")[0]

    Balltranslation = cmds.xform(Ball, q=True, ws=True, translation=True)
    controlTranslation = cmds.xform(control, q=True, ws=True, translation=True)
    cmds.xform(loc, translation=(Balltranslation[0], controlTranslation[1], Balltranslation[2]))
    RMRigTools.RMAlign(control, loc2, 3)
    cmds.aimConstraint(loc, loc2, aimVector=[0, 1, 0], upVector=[-1, 0, 0], worldUpType='scene')
    RMRigTools.RMAlign(loc2, controlParent, 3)
    cmds.parentConstraint(control, IKGroup, mo=True)

    # FK Correction
    FKcontrol = "Character01_%s_ankleFK00_ctr_Rig" % side
    ParentConst = cmds.listConnections(FKcontrol, type="parentConstraint")
    resultingSet = set(ParentConst)
    FKparentConstrained = []
    for eachConstraint in resultingSet:
        FKparentConstrained.append(cmds.listConnections("%s.constraintRotateX" % eachConstraint)[0])
        cmds.delete(eachConstraint)

    FKcontrolParent = cmds.listRelatives(FKcontrol, parent=True)
    RMRigTools.RMAlign(control, FKcontrolParent[0], 3)

    for eachobject in FKparentConstrained:
        cmds.parentConstraint(FKcontrol, eachobject, mo=True)
    cmds.delete(loc)
    cmds.delete(loc2)
Example #9
0
def skeletonHands():
    NameConv = nameConvention.NameConvention()
    palmGroups = [
        "R_middle00_Rig_grp", "R_ring00_Rig_grp", "R_pinky00_Rig_grp",
        "R_index00_Rig_grp", "L_middle00_Rig_grp", "L_ring00_Rig_grp",
        "L_pinky00_Rig_grp", "L_index00_Rig_grp"
    ]
    for eachGroup in palmGroups:
        Group = cmds.ls(eachGroup)[0]
        NewJoint = cmds.joint(name=NameConv.get_a_short_name(Group) + "Carpos")
        NewJoint = NameConv.rename_based_on_base_name(Group, NewJoint,
                                                      {'name': str(NewJoint)})
        NewJoint = NameConv.rename_set_from_name(NewJoint, "skinjoint",
                                                 "objectType")
        RMRigTools.RMAlign(Group, NewJoint, 3)
        cmds.parent(NewJoint, Group)
Example #10
0
    def CreateHandJointStructure(self, Palm):
        referenceRoots = pm.listRelatives(Palm, children=True, type="transform")
        palmJoint = pm.joint(name=self.NameConv.get_from_name(Palm, "name"))

        RMRigTools.RMAlign(Palm, palmJoint, 3)
        self.NameConv.rename_based_on_base_name(Palm, palmJoint, system="rig")
        self.fingers = []

        for eachPoint in referenceRoots:
            fingerPoints = RMRigTools.RMCustomPickWalk(eachPoint, "transform", -1)
            FingerRoot, fingerJoints = self.rig_tools.RMCreateBonesAtPoints(fingerPoints)
            pm.parent(FingerRoot, palmJoint)
            self.fingerRoots.append(FingerRoot)
            self.fingers.append(fingerJoints)
        self.palmJoint = palmJoint
        if pm.listRelatives(self.palmJoint, parent=True):
            pm.parent(self.palmJoint, world=True)
        return palmJoint
Example #11
0
    def nurbPlaneBetweenObjects(self, Object01, Object02):
        VP1 = om.MVector(pm.xform(Object01, a=True, ws=True, q=True, rp=True))
        VP2 = om.MVector(pm.xform(Object02, a=True, ws=True, q=True, rp=True))
        longitud = VP1 - VP2
        plano = pm.nurbsPlane(ax=[0, 1, 0],
                              p=[(longitud.length()) / 2, 0, 0],
                              w=longitud.length(),
                              lr=.05,
                              d=3,
                              u=8,
                              v=1,
                              ch=0,
                              name="%sTo%sPlane" %
                              (self.name_conv.get_a_short_name(Object01),
                               self.name_conv.get_a_short_name(Object02)))
        self.name_conv.set_name_in_format(plano, useName=True)

        RMRigTools.RMAlign(Object01, plano[0], 3)
        return plano[0]
Example #12
0
    def RMCreateBonesBetweenPoints(self, InitialPoint, FinalPoint, NumberOfTB, AlignObject=None):
        DirectionVector  = FinalPoint-InitialPoint
        TotalLength = DirectionVector.length()
        Step = TotalLength / NumberOfTB
        StepVector = DirectionVector.normal() * Step
        locatorsList = []

        for count in range(0, NumberOfTB + 1):
            Locator = pm.spaceLocator()
            if AlignObject:
                if self.NameConv.is_name_in_format(AlignObject):
                    self.NameConv.rename_based_on_base_name(AlignObject, Locator,
                                                            name='TwistJoint%s' %
                                                            (self.NameConv.get_from_name(AlignObject,"name").capitalize()))#.capitalize()
            locatorsList.append(Locator)
            pm.xform(Locator, translation=list(InitialPoint+(StepVector*count)), worldSpace=True)
            RMRigTools.RMAlign(AlignObject, Locator, 2)
        self.TwistResetJoints, self.TwistJoints = RMRigTools.RMCreateBonesAtPoints(locatorsList)
        self.deleteList(locatorsList)
        return self.TwistResetJoints, self.TwistJoints
Example #13
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]])
Example #14
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
Example #15
0
def lastTwoJointsInChain(selection):
    for eachObject in selection:
        childJoints = RMRigTools.RMCustomPickWalk(eachObject, "joint", -1)
        RMRigTools.RMAlign(childJoints[len(childJoints) - 2],
                           childJoints[len(childJoints) - 1], 2)
Example #16
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()
Example #17
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
Example #18
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
Example #19
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)
Example #20
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
Example #21
0
    def RibbonCreation(self, Object01, Object02, foliculeNumber=5):
        print 'creating riboon in %s and %s' % (Object01, Object02)
        self.baseObjects.append(Object01)
        self.baseObjects.append(Object02)
        VP1 = om.MVector(pm.xform(Object01, a=True, ws=True, q=True, rp=True))
        VP2 = om.MVector(pm.xform(Object02, a=True, ws=True, q=True, rp=True))
        plano = self.nurbPlaneBetweenObjects(Object01, Object02)
        planoShape = pm.listRelatives(plano, shapes=True)[0]
        pm.select(cl=True)
        RibbonSize = VP1 - VP2

        print "plano = %s" % plano
        print "len = %s" % RibbonSize.length()

        MainSkeleton = pm.group(em=True,
                                name="%sTo%sRibbon" %
                                (self.name_conv.get_a_short_name(Object01),
                                 self.name_conv.get_a_short_name(Object02)))
        self.name_conv.rename_name_in_format(MainSkeleton, {}, useName=True)
        HairGroup = pm.group(em=True,
                             name="%sTo%sHairSystem" %
                             (self.name_conv.get_a_short_name(Object01),
                              self.name_conv.get_a_short_name(Object02)))
        self.name_conv.set_name_in_format(HairGroup, useName=True)

        nstep = 1.0 / (foliculeNumber - 1.0)
        Hys = pm.language.Mel.eval('createNode hairSystem')
        Hys = "hairSystem1"
        ArrayJoints = []
        HairSystemIndex = [0]

        folicules = []

        for n in range(foliculeNumber):
            pm.language.Mel.eval(
                'createHairCurveNode("%s", "%s" ,%s ,.5 , 1 ,0 ,0 ,0 ,0 ,"" ,1.0 ,{%s} ,"" ,"" ,2 );'
                % (Hys, planoShape, nstep * n, n))
            NewFolicule = self.name_conv.rename_name_in_format("follicle1", {})
            folicules.append(NewFolicule)
            pm.parent(NewFolicule, HairGroup)
        self.folicules = folicules
        pm.delete(pm.listRelatives(Hys, p=True))
        index = 0
        skinedJoints = pm.group(em=True,
                                name="%sTo%sskinedJoints" %
                                (self.name_conv.get_a_short_name(Object01),
                                 self.name_conv.get_a_short_name(Object02)))
        self.name_conv.rename_name_in_format(skinedJoints, useName=True)
        for eachFolicule in folicules:
            ArrayJoints.append(
                pm.joint(name="%sTo%sRibbonJoints" %
                         (self.name_conv.get_a_short_name(Object01),
                          self.name_conv.get_a_short_name(Object02))))
            self.name_conv.set_name_in_format(ArrayJoints[index], useName=True)
            RMRigTools.RMAlign(eachFolicule, ArrayJoints[index], 3)
            pm.parentConstraint(eachFolicule, ArrayJoints[index])
            index += 1
        self.jointStructure = ArrayJoints

        controles = []
        resetControles = []
        locatorControlesList = []
        locatorLookAtList = []
        jointsLookAtList = []
        groupLookAtList = []

        GroupControls = pm.group(empty=True,
                                 name="%sTo%sControls" %
                                 (self.name_conv.get_a_short_name(Object01),
                                  self.name_conv.get_a_short_name(Object02)))

        self.name_conv.rename_name_in_format(GroupControls, {}, useName=True)
        GroupJoints = pm.group(empty=True,
                               name="%sTo%sGroupJointsLookAt" %
                               (self.name_conv.get_a_short_name(Object01),
                                self.name_conv.get_a_short_name(Object02)))
        self.name_conv.rename_name_in_format(GroupJoints, {}, useName=True)

        self.allControls.append(GroupControls)
        self.joints.append(GroupJoints)

        for iloop in range(3):
            resetControlGroup, control = self.rig_controls.RMCircularControl(
                Object01,
                radius=RibbonSize.length() / 3,
                name="%sTo%sCtrl" %
                (self.name_conv.get_a_short_name(Object01),
                 self.name_conv.get_a_short_name(Object02)))
            controles.append(control)
            resetControles.append(resetControlGroup)

            locatorControl = pm.spaceLocator(
                name="%sTo%sLocatorCntrl" %
                (self.name_conv.get_a_short_name(Object01),
                 self.name_conv.get_a_short_name(Object02)))
            self.name_conv.rename_name_in_format(locatorControl, {},
                                                 useName=True)
            locatorControlesList.append(locatorControl[0])
            RMRigTools.RMAlign(Object01, locatorControl[0], 3)

            locatorLookAt = pm.spaceLocator(
                name="%sTo%sLocatorLookAt" %
                (self.name_conv.get_a_short_name(Object01),
                 self.name_conv.get_a_short_name(Object02)))
            self.name_conv.rename_name_in_format(locatorLookAt, {},
                                                 useName=True)

            locatorLookAtList.append(locatorLookAt[0])
            RMRigTools.RMAlign(Object01, locatorLookAt[0], 3)

            pm.select(clear=True)

            jointsLookAt = pm.joint(
                name="%sTo%sJointsLookAt" %
                (self.name_conv.get_a_short_name(Object01),
                 self.name_conv.get_a_short_name(Object02)))
            self.name_conv.rename_name_in_format(jointsLookAt, {},
                                                 useName=True)
            jointsLookAtList.append(jointsLookAt)
            RMRigTools.RMAlign(Object01, jointsLookAt, 3)

            groupLookAt = pm.group(empty=True,
                                   name="%sTo%sGroupLookAt" %
                                   (self.name_conv.get_a_short_name(Object01),
                                    self.name_conv.get_a_short_name(Object02)))
            self.name_conv.rename_name_in_format(groupLookAt, {}, useName=True)

            self.kinematics.append(groupLookAt)
            groupLookAtList.append(groupLookAt)
            RMRigTools.RMAlign(Object01, groupLookAt, 3)

            pm.parent(groupLookAtList, MainSkeleton)

            pm.move(RibbonSize.length() / 2 * iloop,
                    0,
                    0,
                    resetControlGroup,
                    r=True,
                    os=True,
                    moveX=True)
            pm.move(RibbonSize.length() / 2 * iloop,
                    0,
                    0,
                    locatorControl,
                    r=True,
                    os=True,
                    moveX=True)
            pm.move(RibbonSize.length() / 2 * iloop,
                    0,
                    1,
                    locatorLookAt,
                    r=True,
                    os=True,
                    moveXYZ=True)
            pm.move(RibbonSize.length() / 2 * iloop,
                    0,
                    0,
                    jointsLookAt,
                    r=True,
                    os=True,
                    moveX=True)
            pm.move(RibbonSize.length() / 2 * iloop,
                    0,
                    0,
                    groupLookAt,
                    r=True,
                    os=True,
                    moveX=True)

            pm.parent(resetControlGroup, GroupControls)
            pm.parent(locatorControl, groupLookAt)
            pm.parent(locatorLookAt, groupLookAt)
            pm.parent(jointsLookAt, GroupJoints)

            pm.makeIdentity(control, apply=True, t=1, r=0, s=1, n=0)
            pm.makeIdentity(jointsLookAt, apply=True, t=1, r=0, s=1, n=0)

            pm.parentConstraint(locatorControl, jointsLookAt)
            pm.parentConstraint(control, groupLookAt)
        self.controls = controles
        self.resetControls = resetControles
        self.resetControls = resetControles
        pm.aimConstraint(controles[1],
                         locatorControlesList[0],
                         aim=[1, 0, 0],
                         upVector=[0, 0, 1],
                         wut='object',
                         worldUpObject=locatorLookAtList[0])
        pm.aimConstraint(controles[1],
                         locatorControlesList[2],
                         aim=[1, 0, 0],
                         upVector=[0, 0, 1],
                         wut='object',
                         worldUpObject=locatorLookAtList[2])

        pm.parent(GroupJoints, MainSkeleton)

        pm.select(plano, replace=True)
        print jointsLookAtList
        for eachJoint in jointsLookAtList:
            pm.select(eachJoint, add=True)
        pm.SmoothBindSkin()
        pm.parent(plano, HairGroup)
Example #22
0
    def SetupEyes(self):

        if cmds.objExists("LEye") and cmds.objExists("REye"):
            cmds.group(em=True, name="ReyeOrientacion")
            cmds.joint(name="REyeJoint")
            cmds.group(em=True, name="ReyeBase")
            cmds.group(em=True, name="ReyeLookAt")
            cmds.group(em=True, name="ReyePointLookAt")

            cmds.group(em=True, name="LeyeOrientacion")
            cmds.joint(name="LEyeJoint")
            cmds.group(em=True, name="LeyeBase")
            cmds.group(em=True, name="LeyeLookAt")
            cmds.group(em=True, name="LeyePointLookAt")

            cmds.group(em=True, name="eyeOrientation")

            RMRigTools.RMAlign("LEye", "LeyeBase", 3)
            RMRigTools.RMAlign("LEye", "LeyeOrientacion", 3)
            RMRigTools.RMAlign("LEye", "LeyeLookAt", 3)
            RMRigTools.RMAlign("LEye", "LeyePointLookAt", 3)

            cmds.move(10, "LeyePointLookAt", moveZ=True)
            EyeParent = cmds.listRelatives("LEye", parent=True)
            cmds.parent("LeyeBase", EyeParent)
            cmds.parent("LeyeLookAt", "LeyeBase")
            cmds.parent("LeyeOrientacion", "LeyeLookAt")

            cmds.aimConstraint("LeyePointLookAt",
                               "LeyeLookAt",
                               aimVector=[0, 0, 1],
                               worldUpObject="eyeOrientation",
                               worldUpType="objectrotation")

            cmds.expression(name="LEyeExpresionX", unitConversion="none")
            script = "LeyeOrientacion.rotateY = (Character_LF_Ojo_Ctrl_fc.translateX * 4 + Character_MD_OjoRectangle_ctrl_fc.translateX * 4)/10"
            cmds.expression("LEyeExpresionX",
                            edit=True,
                            string=script,
                            unitConversion="none")
            cmds.expression(name="LEyeExpresionY", unitConversion="none")
            script = "LeyeOrientacion.rotateX = -(Character_LF_Ojo_Ctrl_fc.translateY * 4 + Character_MD_OjoRectangle_ctrl_fc.translateY * 4)/10"
            cmds.expression("LEyeExpresionY",
                            edit=True,
                            string=script,
                            unitConversion="none")

            RMRigTools.RMAlign("REye", "ReyeBase", 3)
            RMRigTools.RMAlign("REye", "ReyeOrientacion", 3)
            RMRigTools.RMAlign("REye", "ReyeLookAt", 3)
            RMRigTools.RMAlign("REye", "ReyePointLookAt", 3)

            cmds.move(10, "ReyePointLookAt", moveZ=True)
            EyeParent = cmds.listRelatives("REye", parent=True)
            cmds.parent("ReyeBase", EyeParent)
            cmds.parent("ReyeLookAt", "ReyeBase")
            cmds.parent("ReyeOrientacion", "ReyeLookAt")

            cmds.aimConstraint("ReyePointLookAt",
                               "ReyeLookAt",
                               aimVector=[0, 0, 1],
                               worldUpObject="eyeOrientation",
                               worldUpType="objectrotation")

            cmds.expression(name="REyeExpresionX", unitConversion="none")
            script = "ReyeOrientacion.rotateY = (Character_RH_Ojo_Ctrl_fc.translateX * 4 + Character_MD_OjoRectangle_ctrl_fc.translateX * 4)/10"
            cmds.expression("REyeExpresionX",
                            edit=True,
                            string=script,
                            unitConversion="none")

            cmds.expression(name="REyeExpresionY", unitConversion="none")
            script = "ReyeOrientacion.rotateX = -(Character_RH_Ojo_Ctrl_fc.translateY * 4 + Character_MD_OjoRectangle_ctrl_fc.translateY * 4)/10"
            cmds.expression("REyeExpresionY",
                            edit=True,
                            string=script,
                            unitConversion="none")

            RMRigTools.RMAlign(EyeParent, "eyeOrientation", 1)

            cmds.parent("eyeOrientation", EyeParent)

            # $LeyeBase.parent=$LEye.parent;
            # $ReyeBase.parent=$REye.parent;

            cmds.parent("LEye", "LeyeOrientacion")
            cmds.parent("REye", "ReyeOrientacion")
            '''if cmds.objExists("*REyeGeo*"):
                EyeGeo=cmds.ls("*REyeGeo*",type="transform")
                for geo in EyeGeo:
                    cmds.bindSkin(geo,"REyeJoint")

            if cmds.objExists("*LEyeGeo*"):
                EyeGeo=cmds.ls("*LEyeGeo*",type="transform")
                for geo in EyeGeo:
                    cmds.bindSkin(geo,"LEyeJoint")
            '''

            cmds.parent("OjosLookAt", EyeParent)

            cmds.parent("LeyePointLookAt", "OjosLookAt_L")
            cmds.parent("ReyePointLookAt", "OjosLookAt_R")
        else:
            print "No existen los objetos LEye y REye"