Beispiel #1
0
def orderPointsByDistance(straigtPnts, MaxDistanceDic):
    shortArray = straigtPnts
    shortArray.remove(MaxDistanceDic['points'][0])
    shortArray.remove(MaxDistanceDic['points'][1])
    distanceArray = {}
    for eachElement in shortArray:
        distanceArray[eachElement] = RMRigTools.RMPointDistance(
            MaxDistanceDic['points'][0], eachElement)
    return sorted(distanceArray, key=distanceArray.__getitem__)
Beispiel #2
0
def getExtremePoints(listOfPnts):
    MaxDistanceDic = {'points': [], 'distance': 0}
    for eachPoint in listOfPnts:
        for eachOtherPoint in listOfPnts:
            distanceValue = RMRigTools.RMPointDistance(eachPoint,
                                                       eachOtherPoint)
            if distanceValue > MaxDistanceDic['distance']:
                MaxDistanceDic['points'] = [eachPoint, eachOtherPoint]
                MaxDistanceDic['distance'] = distanceValue
    return MaxDistanceDic
Beispiel #3
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
Beispiel #4
0
    def CreateHandRig(self, PalmReferencePoint, PalmControl=None):
        self.CreateHandStructure(PalmReferencePoint)
        for fingers in self.GHS.fingers:
            self.CreateFingerSquareRig(fingers)

        self.CreatePalmRig(PalmControl=PalmControl)
        RMRigTools.RMParentArray(self.PalmControl, self.fingerControlsReset)
        palmLen = RMRigTools.RMPointDistance(self.PalmControl,
                                             self.GHS.fingerRoots[0])
        pm.parentConstraint(self.MainKinematics, self.GHS.palmJoint)
        pm.parentConstraint(self.MainKinematics, self.MainControl)

        self.NameConv.rename_set_from_name(self.GHS.palmJoint, "sknjnt",
                                           "objectType")
        for eachFinger in self.GHS.fingers:
            self.NameConv.rename_set_from_name(eachFinger, "sknjnt",
                                               "objectType")
Beispiel #5
0
    def StardardFeetFK(self, StandarFeetPointsDic, FeetControl=None):
        Side = self.NameConv.get_from_name(
            self.StandardFeetPointsDic["feet"][0], "side")
        self.rootFKJoints, StandardFeetFKJoints = self.StandardReverseFeetJointStructure(
            StandarFeetPointsDic)

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

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

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

        self.FeetControl = FeetControl

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

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

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

        self.StandardFeetFKJoints = StandardFeetFKJoints
        self.SecondLimbFeetControl = SecondLimbFeetControl
        self.SecondLimbControlResetPoint = SecondLimbfeetResetControl
Beispiel #6
0
def SpiralOfPointsStraight(initRadius, endRadius, numberOfPoints, startPoint, endPoint):
    RigTools = RMRigTools.RMRigTools()
    ShapeCntrl = RMRigShapeControls.RMRigShapeControls()
    distancia = RMRigTools.RMPointDistance(startPoint, endPoint)
    minLength = math.sin(math.pi / (numberOfPoints + 1)) * initRadius  # initRadiusdistancia/numberOfPoints/10

    print "minLength:%s" % minLength

    if minLength * numberOfPoints < distancia:
        # Locators = RigTools.RMCreateNLocatorsBetweenObjects( startPoint, endPoint, numberOfPoints )
        Locators = RigTools.RMCreateBiasedLocatorsBetweenObjects(startPoint, endPoint, numberOfPoints, minLength)
        Locators.insert(0, startPoint)
        Locators.insert(len(Locators), endPoint)
        parentJoint, jointArray = RigTools.RMCreateBonesAtPoints(Locators)
        resetPnt, control = ShapeCntrl.RMCircularControl(startPoint, radius=initRadius)
        cmds.addAttr(control, longName="unfold", keyable=True, hasMinValue=True, hasMaxValue=True, maxValue=10,
                     minValue=-10)
        unfoldStep = 10.0 / float(numberOfPoints + 1)
        currentStep = 10.0
        index = 0
        deltaRadius = (initRadius - endRadius) / numberOfPoints
        currentRadius = initRadius
        # jointArray.reverse()
        angle = 20
        for joints in jointArray[:-1]:
            # angle = 180 - SegmentAngleInCircle(currentRadius, RMRigTools.lenght_of_bone(joints) )

            if index > 0:
                angle = getAngle(currentRadius, joints, jointArray[index - 1])
            else:
                angle = getAngle(currentRadius, joints, None)

            # angle = SpiralFunction (index, numberOfPoints, initRadius, endRadius, distancia)
            # angle = SpiralFunctionBiasedPoints (index, numberOfPoints, initRadius, endRadius, distancia, minLength)
            RMRigTools.connectWithLimits(control + ".unfold", joints + ".rotateY",
                                         [[-currentStep, angle], [-(currentStep - unfoldStep), 0],
                                          [currentStep - unfoldStep, 0], [currentStep, -angle]])
            currentStep = currentStep - unfoldStep
            print currentRadius
            currentRadius = currentRadius - deltaRadius
            index += 1
Beispiel #7
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
Beispiel #8
0
    def RMCreateTwist(self, TwistJoint, LookAtObject,  NumberOfTB = 3, LookAtAxis = "Y"):
        #LookAtObject = pm.listRelatives( TwistJoint,type = "transform",children=True)[]
    
        positionA = pm.xform(TwistJoint, q=True,ws=True,rp=True)
        positionB = pm.xform(LookAtObject, q=True,ws=True,rp=True)

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

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

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

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

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

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

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

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

        #pm.connectAttr(self.TwistJoints[0]+".rotateX", TwistJointDivide + ".input1X") in this case the rotation of the lookatNode was not affecting
        pm.setAttr("%s.input2X" % TwistJointDivide, -(len(self.TwistJoints) - 1))
        pm.setAttr("%s.operation" % TwistJointDivide, 2)

        for eachJoint in self.TwistJoints[1:]:
            pm.connectAttr("%s.outputX" % TwistJointDivide, "%s.rotateX" % eachJoint)

        self.TwistControlResetPoint = resetPoint
        self.TwistControl = control
Beispiel #9
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
Beispiel #10
0
    def create_twist(self,
                     control_parent,
                     twist_joint,
                     look_at_object,
                     number_of_twist_bones=3,
                     look_at_axis="Y"):
        # LookAtObject = pm.listRelatives( TwistJoint,type = "transform",children=True)[]

        position_a = pm.xform(twist_joint, q=True, ws=True, rp=True)
        position_b = pm.xform(look_at_object, q=True, ws=True, rp=True)

        vector_a = om.MVector(position_a)
        vector_b = om.MVector(position_b)

        self.create_bones_between_points(vector_a,
                                         vector_b,
                                         number_of_twist_bones,
                                         align_object=twist_joint)

        Distance = RMRigTools.RMPointDistance(twist_joint, look_at_object)

        # pm.parentConstraint(twist_joint, self.reset_joints)
        print 'doing constraints \n'
        print self.create.constraint.constraint_type
        self.create.constraint.node_base(twist_joint,
                                         self.reset_joints,
                                         mo=True)

        # reset_point, control = RMRigShapeControls.RMCreateBoxCtrl(self.joints[0], Xratio=.1, Yratio=.1, Zratio=.1, customSize=Distance / 5, name="TwistOrigin")
        reset_point, control = self.create.controls.point_base(
            self.joints[0],
            centered=True,
            size=Distance / 5 * .1,
            name="twistOrigin")
        sign = 1
        move_distance = Distance / 5
        if "-" in look_at_axis:
            sign = -1
        if "Z" in look_at_axis or "z" in look_at_axis:
            move_list = [0, 0, move_distance * sign]
            wuv = [0, 0, sign]
        elif "Y" in look_at_axis or "y" in look_at_axis:
            move_list = [0, move_distance * sign, 0]
            wuv = [0, sign, 0]

        pm.xform(reset_point, os=True, relative=True, t=move_list)

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

        twist_joint_divide = pm.shadingNode("multiplyDivide", asUtility=True)
        self.name_convention.rename_name_in_format(twist_joint_divide,
                                                   name="TwistJoint")

        twist_addition = pm.shadingNode("plusMinusAverage", asUtility=True)
        self.name_convention.rename_name_in_format(twist_addition,
                                                   name="TwistJointAdd")
        negative_look_at_rotation = pm.shadingNode("multiplyDivide",
                                                   asUtility=True)
        self.name_convention.rename_name_in_format(
            negative_look_at_rotation, name="negativeLookAtRotation")

        pm.connectAttr(look_at_object + ".rotateX",
                       negative_look_at_rotation + ".input1X")
        pm.setAttr("%s.input2X" % negative_look_at_rotation, -1)
        pm.setAttr("%s.operation" % negative_look_at_rotation, 1)
        pm.connectAttr("%s.rotateX" % self.joints[0],
                       "%s.input1D[0]" % twist_addition)
        pm.connectAttr("%s.outputX" % negative_look_at_rotation,
                       "%s.input1D[1]" % twist_addition)
        pm.connectAttr("%s.output1D" % twist_addition,
                       "%s.input1X" % twist_joint_divide)

        # pm.connectAttr("%s.rotateX" % self.joints[0], "%s.input1X" % twist_joint_divide)
        # pm.connectAttr(self.joints[0]+".rotateX", TwistJointDivide + ".input1X")

        # in this case the rotation of the lookatNode was not affecting
        pm.setAttr("%s.input2X" % twist_joint_divide, -(len(self.joints) - 1))
        pm.setAttr("%s.operation" % twist_joint_divide, 2)

        for eachJoint in self.joints[1:]:
            pm.connectAttr("%s.outputX" % twist_joint_divide,
                           "%s.rotateX" % eachJoint)

        self.reset_controls.append(reset_point)
        pm.parent(self.reset_controls, self.rig_system.controls)
        self.controls.append(control)
        self.create.constraint.node_base(control_parent,
                                         self.reset_controls[0],
                                         mo=True)