def makeChainFromObj(nodeRoot, nodeEnd, baseName):
    rootName = '{}_root'.format(baseName)
    endName = '{}_end'.format(baseName)
    rootPos = mc.xform(nodeRoot, q=True, ws=True, t=True)
    endPos = mc.xform(nodeEnd, q=True, ws=True, t=True)
    # create joint chain
    mc.select(cl=True)
    rootJoint = mc.joint(n=rootName)
    mc.setAttr('{}.radius'.format(rootJoint), 0.02)
    mc.xform(rootJoint, ws=True, t=rootPos)
    mc.select(cl=True)
    endJoint = mc.joint(n=endName)
    mc.setAttr('{}.radius'.format(endJoint), 0.02)
    mc.xform(endJoint, ws=True, t=endPos)
    mc.parent(endJoint, rootJoint)
    mc.joint(rootJoint,
             e=True,
             oj='zxy',
             secondaryAxisOrient='yup',
             ch=True,
             zso=True)
    chainOrig = orig.orig(objlist=[rootJoint],
                          suffix=['_orig'],
                          origtype='joint',
                          fromsel=False,
                          viz=False,
                          get_ssc=False,
                          rtyp='auto')[0]

    return (rootJoint, endJoint, chainOrig, rootPos, endPos)
Exemple #2
0
def createTeethCtrl(guide, visTransform, stack):
    visAttr = 'teethTweakVis'
    baseSkinSet = 'teeth_skin_set'
    skinSet = '%s_teeth_skin_set' % stack
    animSet = 'teeth_anim_set'
    if not mc.ls('%s.%s' % (visTransform, visAttr)):
        mc.addAttr(visTransform, ln=visAttr, at='bool', dv=0)
        mc.setAttr('%s.%s' % (visTransform, visAttr), edit=True, k=True)
    if not mc.objExists('skin_set'):
        mc.select(cl=True)
        mc.sets(n='skin_set')
    if not mc.objExists(baseSkinSet):
        mc.select(cl=True)
        mc.sets(n=baseSkinSet)
        mc.sets(baseSkinSet, add='skin_set')
    if not mc.objExists(skinSet):
        mc.select(cl=True)
        mc.sets(n=skinSet)
        mc.sets(skinSet, add=baseSkinSet)

    if not mc.objExists('anim_set'):
        mc.select(cl=True)
        mc.sets(n='anim_set')
    if not mc.objExists(animSet):
        mc.select(cl=True)
        mc.sets(n=animSet)
        mc.sets(animSet, add='anim_set')

    mc.select(cl=True)
    newCtrl = mc.joint(n=guide.replace('GUIDE', 'ctrl'))
    mc.setAttr('%s.drawStyle' % newCtrl, 2)
    mc.parent(newCtrl, guide, r=True)
    mc.parent(newCtrl, w=True)
    mc.sets(newCtrl, add=skinSet)
    mc.sets(newCtrl, add=animSet)
    guideShapes = mc.listRelatives(guide, s=True)
    if guideShapes:
        for i, shape in enumerate(guideShapes):
            mc.parent(shape, newCtrl, s=True, r=True)
            newShapeName = mc.rename(shape,
                                     guide.replace('GUIDE', 'ctrlShape%d' % i))
            #connectShapesvis
            mc.connectAttr('%s.%s' % (visTransform, visAttr),
                           '%s.visibility' % newShapeName)
    newCtrl = mc.rename(newCtrl, guide.replace('GUIDE', 'ctrl'))
    newOrig = orig.orig(objlist=[newCtrl],
                        suffix=['_orig'],
                        origtype='joint',
                        fromsel=False,
                        viz=False,
                        get_ssc=False,
                        rtyp='auto')[0]
    mc.disconnectAttr('%s.scale' % newOrig, '%s.inverseScale' % newCtrl)
    return (newCtrl, newOrig)
def makeAutoNode(nodeRoot):
    legRootOrig = mc.listRelatives(nodeRoot, p=True)[0]
    rootParent = mc.listRelatives(legRootOrig, p=True)[0]
    # create Auto node
    legRootAuto = '{}_auto'.format(nodeRoot)
    mc.group(n=legRootAuto, em=True)
    legRootAutoOrig = orig.orig(objlist=[legRootAuto],
                                suffix=['_orig'],
                                origtype='transform',
                                fromsel=False,
                                viz=False,
                                get_ssc=False,
                                rtyp='auto')[0]
    # reparent hierarchy
    mc.parent(legRootAutoOrig, legRootOrig)
    mc.setAttr('{}.translate'.format(legRootAutoOrig), 0, 0, 0)
    mc.parent(legRootAutoOrig, rootParent)
    mc.parent(legRootOrig, legRootAuto)
    return (legRootAuto, legRootAutoOrig)
Exemple #4
0
def scaleOpositCtrl(name):
    objOrig = mc.listRelatives(name, p=True)[0]
    origParent = mc.listRelatives(objOrig, p=True)[0]
    childs = mc.listRelatives(name, c=True)
    unparentedChilds = []
    if childs:
        for child in childs:
            if not mc.objectType(child) == 'nurbsCurve':
                mc.parent(child, w=True)
                unparentedChilds.append(child)
    mc.parent(objOrig, w=True)
    mc.setAttr('{}.rotate'.format(objOrig), 0, 0, 0)
    mc.setAttr('{}.scaleX'.format(objOrig), -1)
    mc.parent(objOrig, origParent)
    if unparentedChilds:
        for child in unparentedChilds:
            scaleTampon = orig.orig(objlist=[child],
                                    suffix=['_scale'],
                                    origtype='transform',
                                    fromsel=False,
                                    viz=False,
                                    get_ssc=False,
                                    rtyp='auto')
            mc.parent(scaleTampon, name)
def doLayeredFkTongue():
    sides = ['L', 'R']
    facialFGrp = 'facial_fGrp'
    facialDriversGrp = 'facialDrivers'
    tongueRoot = 'tongue_jnt_1_orig'
    storeGroup = 'tongue_noXformGrp'
    headSKN = 'head_SKN'

    bcsNode = mc.ls(type='DPK_bcs')[0]
    headMeshShape = mel.eval('DPK_bcs -q -g %s' % bcsNode)[0]
    '''
    #get edges Manually
    getEdges = mc.ls(sl=True,fl=True)
    Edges = []
    for edge in getEdges:
        asciiName = edge.encode('ascii','ignore')
        Edges.append(asciiName)
    print Edges
    '''

    # get list of edges to generate base tongue surf
    lVertices = [
        u'head_hi_bcsObj.vtx[5677]', u'head_hi_bcsObj.vtx[5678]',
        u'head_hi_bcsObj.vtx[5683]', u'head_hi_bcsObj.vtx[5686]',
        u'head_hi_bcsObj.vtx[5689]', u'head_hi_bcsObj.vtx[5692]',
        u'head_hi_bcsObj.vtx[5693]', u'head_hi_bcsObj.vtx[5697]',
        u'head_hi_bcsObj.vtx[5699]', u'head_hi_bcsObj.vtx[5700]',
        u'head_hi_bcsObj.vtx[5710]', u'head_hi_bcsObj.vtx[5714]',
        u'head_hi_bcsObj.vtx[5715]', u'head_hi_bcsObj.vtx[5775]',
        u'head_hi_bcsObj.vtx[7369]', u'head_hi_bcsObj.vtx[7558]',
        u'head_hi_bcsObj.vtx[7561]', u'head_hi_bcsObj.vtx[7564]',
        u'head_hi_bcsObj.vtx[7567]', u'head_hi_bcsObj.vtx[7570]',
        u'head_hi_bcsObj.vtx[7572]', u'head_hi_bcsObj.vtx[7574]',
        u'head_hi_bcsObj.vtx[7576]', u'head_hi_bcsObj.vtx[7582]',
        u'head_hi_bcsObj.vtx[7586]', u'head_hi_bcsObj.vtx[7590]',
        u'head_hi_bcsObj.vtx[7600]', u'head_hi_bcsObj.vtx[8259]',
        u'head_hi_bcsObj.vtx[8291]', u'head_hi_bcsObj.vtx[8303]'
    ]
    rVertices = [
        u'head_hi_bcsObj.vtx[1274]', u'head_hi_bcsObj.vtx[1275]',
        u'head_hi_bcsObj.vtx[1280]', u'head_hi_bcsObj.vtx[1283]',
        u'head_hi_bcsObj.vtx[1286]', u'head_hi_bcsObj.vtx[1289]',
        u'head_hi_bcsObj.vtx[1290]', u'head_hi_bcsObj.vtx[1294]',
        u'head_hi_bcsObj.vtx[1296]', u'head_hi_bcsObj.vtx[1297]',
        u'head_hi_bcsObj.vtx[1307]', u'head_hi_bcsObj.vtx[1311]',
        u'head_hi_bcsObj.vtx[1312]', u'head_hi_bcsObj.vtx[1372]',
        u'head_hi_bcsObj.vtx[2966]', u'head_hi_bcsObj.vtx[3155]',
        u'head_hi_bcsObj.vtx[3158]', u'head_hi_bcsObj.vtx[3161]',
        u'head_hi_bcsObj.vtx[3164]', u'head_hi_bcsObj.vtx[3167]',
        u'head_hi_bcsObj.vtx[3169]', u'head_hi_bcsObj.vtx[3171]',
        u'head_hi_bcsObj.vtx[3173]', u'head_hi_bcsObj.vtx[3179]',
        u'head_hi_bcsObj.vtx[3183]', u'head_hi_bcsObj.vtx[3187]',
        u'head_hi_bcsObj.vtx[3197]', u'head_hi_bcsObj.vtx[3856]',
        u'head_hi_bcsObj.vtx[3888]', u'head_hi_bcsObj.vtx[3900]'
    ]
    lEdges = mc.polyListComponentConversion(lVertices,
                                            fv=True,
                                            te=True,
                                            internal=True)
    rEdges = mc.polyListComponentConversion(rVertices,
                                            fv=True,
                                            te=True,
                                            internal=True)
    edgesLists = [lEdges, rEdges]

    #creates store group for futur cleanup
    mc.group(n=storeGroup, em=True)
    mc.setAttr('%s.inheritsTransform' % storeGroup, False)
    mc.hide(storeGroup)
    mc.parent(storeGroup, facialFGrp)
    #create head_SKN decomposeMatrix for later use
    headSKMDM = mc.createNode('decomposeMatrix', n='%s_dm' % headSKN)
    mc.connectAttr('%s.worldMatrix[0]' % headSKN, '%s.inputMatrix' % headSKMDM)

    #creates nodeBased surf from edges selection
    baseTongueLoft = mc.createNode('loft', n='tongueBase_loft')
    mc.setAttr('%s.autoReverse' % baseTongueLoft, False)
    tongueBaseSurf = mc.createNode('nurbsSurface', n='tongueBase_surfShape')
    mc.connectAttr('%s.outputSurface' % baseTongueLoft,
                   '%s.create' % tongueBaseSurf)
    mc.parent(mc.listRelatives(tongueBaseSurf, p=True)[0], facialDriversGrp)

    petcList = []
    for i, list in enumerate(edgesLists):
        mc.select(list)
        baseTongueCrv = mc.polyToCurve(ch=True,
                                       degree=3,
                                       form=0,
                                       n='%s_tongueBase_crv' % sides[i])
        baseTonguePetc = mc.rename(baseTongueCrv[1],
                                   '%s_tongueBase_petc' % sides[i])
        petcList.append(baseTonguePetc)
        curveShape = mc.listRelatives(baseTongueCrv[0], s=True)[0]
        mc.connectAttr('%s.outputcurve' % baseTonguePetc,
                       '%s.inputCurve[%d]' % (baseTongueLoft, i))
        mc.delete(baseTongueCrv[0])

    #Generate FK proxy hierarchy from template tongue
    ## get all tongue Pose nodes
    allTongueObj = mc.listRelatives(tongueRoot, ad=True, type='transform')
    tonguePose = []
    for obj in allTongueObj:
        splitName = obj.rsplit('_', 2)
        if splitName[1] == 'pose':
            tonguePose.append(obj)
    ## create FK proxy  hyerarchy
    ###creates proxy Nodes
    tonguePoseProxy = []
    for pose in tonguePose:
        mc.select(cl=True)
        newPose = mc.joint(n='%s_proxy' % pose)
        tonguePoseProxy.append(newPose)
        mc.setAttr('%s.radius' % newPose, 0.02)
        newSkin = mc.duplicate(newPose, n=newPose.replace('pose', 'SKN'))
        mc.parent(newSkin, newPose)
        mewOrig = orig.orig(objlist=[newPose],
                            suffix=['_orig'],
                            origtype='joint',
                            fromsel=False,
                            viz=False,
                            get_ssc=False,
                            rtyp='auto')[0]
        mc.rename(mewOrig, mewOrig.replace('pose', 'jnt'))

    ### recreates parenting
    firstProxyNode = ''
    for pose in tonguePose:
        poseOrig = mc.listRelatives(pose, p=True)[0]
        poseProxy = '%s_proxy' % pose
        poseOrigProxy = mc.listRelatives(poseProxy, p=True)[0]

        poseOrigParent = mc.listRelatives(poseOrig, p=True)[0]
        poseOrigProxyParent = '%s_proxy' % poseOrigParent

        if not poseOrigParent == 'jaw_SKN':
            mc.parent(poseOrigProxy, poseOrigProxyParent)
        elif poseOrigParent == 'jaw_SKN':
            firstProxyNode = poseOrigProxy

    ### match proxy nodes on local nodes
    mc.parent(firstProxyNode, 'jaw_SKN')
    firstNode = firstProxyNode.replace('_proxy', '')
    patchLib.smartcopyAttr(firstNode, firstProxyNode)

    allProxyNodes = mc.listRelatives(firstProxyNode, ad=True)
    for node in allProxyNodes:
        rigNode = node.replace('_proxy', '')
        patchLib.smartcopyAttr(rigNode, node)

    # create cns nodes
    tongueCns = []
    for pose in tonguePoseProxy:
        ### create cns and hooks hierarchy
        poseTest = int(pose.rsplit('_', 2)[1])
        cnsNode = mc.group(n=pose.replace('proxy', 'cns'), em=True)
        mc.parent(cnsNode, pose, r=True)
        mc.parent(cnsNode, w=True)
        cnsHookNode = mc.duplicate(cnsNode, n=cnsNode.replace('cns', 'hook'))
        tongueCns.append(cnsNode)

        ### connect cns nodes to surface with Xrivet, then constraint proxy nodes to cns nodes
        surf = mc.listRelatives(tongueBaseSurf, p=True)[0]

        if poseTest <= (len(tonguePoseProxy) - 3):
            xRivet = xrivetTrOnNurbs(cnsNode,
                                     surf,
                                     mainDirection=1,
                                     out='worldSpace[0]',
                                     u=None,
                                     v=None,
                                     offsetOrient=[0, 0, 0],
                                     min=False)
            mc.parentConstraint(cnsHookNode, pose, mo=True)
            massConnect(pose, pose.replace('_proxy', ''))
            mc.connectAttr('%s.outputScale' % headSKMDM, '%s.scale' % cnsNode)
        else:
            mc.parentConstraint('jaw_SKN', cnsNode, mo=True)
            mc.parentConstraint(cnsHookNode, pose, mo=True)
            massConnect(pose, pose.replace('_proxy', ''))
        mc.parent(cnsHookNode, cnsNode)

        ### connect local poseNodes rotate ORders to proxy rotate ORders
        source = pose.replace('_proxy', '')
        mc.connectAttr('%s.rotateOrder' % source, '%s.rotateOrder' % pose)

        #### cleanup
        mc.parent(cnsNode, storeGroup)
Exemple #6
0
def patch():

    #vars#########################################################################################
    sides = ['L', 'R']
    intFixes = ['front', 'back']
    fullLegDuplicate = ['leg_01', 'leg_02', 'foot_01', 'foot_02']
    headGimbal = 'head_gimbal'
    chestAdjust = 'chest_adjust_ctrl'
    autoSourceBaseName = 'leg_foot_ball_01_ctrl_orig'
    ##############################################################################################

    # --- reorient legs offsets for better symmetrical behavior
    for side in sides[1]:
        baseName = 'leg_root_offset_ctrl'
        for fix in intFixes:
            name = '{}_{}_{}'.format(side, fix, baseName)
            scaleOpositCtrl(name)
    for side in sides[1]:
        baseNameList = ['scapula_ctrl', 'hip_ctrl']
        for baseName in baseNameList:
            name = '{}_{}'.format(side, baseName)
            scaleOpositCtrl(name)

    # --- fix right fuckedUp tumbles
    bankSource = mc.listConnections('L_front_leg_rvfoot_heel_ctrl.rotateAxisX',
                                    p=True,
                                    s=True)[0]
    mc.keyframe((bankSource.split('.', 1)[0]),
                index=(0, 0),
                absolute=True,
                valueChange=1)
    bankSource = mc.listConnections('L_front_leg_rvfoot_tip_ctrl.rotateAxisX',
                                    p=True,
                                    s=True)[0]
    mc.keyframe((bankSource.split('.', 1)[0]),
                index=(1, 1),
                absolute=True,
                valueChange=-1)
    bankSource = mc.listConnections('R_front_leg_rvfoot_heel_ctrl.rotateAxisX',
                                    p=True,
                                    s=True)[0]
    mc.keyframe((bankSource.split('.', 1)[0]),
                index=(0, 0),
                absolute=True,
                valueChange=1)
    bankSource = mc.listConnections('R_front_leg_rvfoot_tip_ctrl.rotateAxisX',
                                    p=True,
                                    s=True)[0]
    mc.keyframe((bankSource.split('.', 1)[0]),
                index=(1, 1),
                absolute=True,
                valueChange=-1)

    Rbank01Source = mc.listConnections(
        'R_front_leg_rvfoot_bank_01_ctrl.rotateAxisZ', p=True, s=True)[0]
    Rbank02Source = mc.listConnections(
        'R_front_leg_rvfoot_bank_02_ctrl.rotateAxisZ', p=True, s=True)[0]
    mc.connectAttr(Rbank02Source,
                   'R_front_leg_rvfoot_bank_01_ctrl.rotateAxisZ',
                   f=True)
    mc.connectAttr(Rbank01Source,
                   'R_front_leg_rvfoot_bank_02_ctrl.rotateAxisZ',
                   f=True)
    mc.keyframe((Rbank01Source.split('.', 1)[0]),
                index=(1, 1),
                absolute=True,
                valueChange=-1)
    mc.keyframe((Rbank02Source.split('.', 1)[0]),
                index=(0, 0),
                absolute=True,
                valueChange=1)

    Rbank01Source = mc.listConnections(
        'R_back_leg_rvfoot_bank_01_ctrl.rotateAxisZ', p=True, s=True)[0]
    Rbank02Source = mc.listConnections(
        'R_back_leg_rvfoot_bank_02_ctrl.rotateAxisZ', p=True, s=True)[0]
    mc.connectAttr(Rbank02Source,
                   'R_back_leg_rvfoot_bank_01_ctrl.rotateAxisZ',
                   f=True)
    mc.connectAttr(Rbank01Source,
                   'R_back_leg_rvfoot_bank_02_ctrl.rotateAxisZ',
                   f=True)
    mc.keyframe((Rbank01Source.split('.', 1)[0]),
                index=(1, 1),
                absolute=True,
                valueChange=-1)
    mc.keyframe((Rbank02Source.split('.', 1)[0]),
                index=(0, 0),
                absolute=True,
                valueChange=1)

    # --- change parenting of scapulas and leg_root_offsets to avoid unwanted scale and reconstraint to maintain behavior
    bodyGimball = 'body_gimbal_ctrl'
    hips = 'hips_ctrl'
    chest = 'chest_ctrl'
    chestOffset = 'chest_offset_ctrl'
    pelvisOrig = 'pelvis_ctrl_orig'
    chestTangentOrig = 'chest_tan_ik_ctrl_ik_pivot_ctrl_orig'
    neckBaseIk = 'neck_base_ik_ctrl'
    legRootOffset = 'back_leg_root_offset_ctrl'

    scapulasJointsOrig = ['L_scapula_ctrl_orig', 'R_scapula_ctrl_orig']
    legOffsetsOrig = [
        'L_back_leg_root_offset_ctrl_orig', 'R_back_leg_root_offset_ctrl_orig'
    ]

    scapulasOrig = 'scapulas_orig'
    legsOffsetsOrig = 'back_legs_offsets_orig'
    mc.group(n=scapulasOrig, em=True)
    mc.group(n=legsOffsetsOrig, em=True)
    mc.parent(scapulasOrig, chest, r=True)
    mc.parent(legsOffsetsOrig, hips, r=True)
    mc.parent(scapulasOrig, legsOffsetsOrig, bodyGimball)
    mc.parentConstraint(chest, scapulasOrig, mo=True)
    mc.parentConstraint(hips, legsOffsetsOrig, mo=True)
    mc.parent(scapulasJointsOrig, scapulasOrig)
    mc.parent(legOffsetsOrig, legsOffsetsOrig)

    # --- reparent all leg joints in lag back offsets
    for side in sides:
        mc.parent('{}_back_leg_01_fullLeg_orig'.format(side),
                  '{}_{}'.format(side, legRootOffset))

    # --- disconnect inversScale from perlvis orig
    mc.disconnectAttr('{}.scale'.format(hips),
                      '{}.inverseScale'.format(pelvisOrig))

    # --- create Auto locators for source of legs automation
    for side in sides:
        for fix in intFixes:

            autoSourceName = '{}_{}_{}'.format(side, fix, autoSourceBaseName)
            sourcePos = mc.xform(autoSourceName, q=True, ws=True, t=True)
            autoLoc = mc.spaceLocator(
                n=autoSourceName.replace('orig', 'autoLoc'))[0]
            mc.xform(autoLoc, ws=True, t=sourcePos)
            mc.parent(autoLoc, autoSourceName)
            mc.hide(autoLoc)

    # --- build top legs iks and leg automation Rigs
    dogLegsTopIKs.buildLegsTopIks(sides, intFixes, chestAdjust)
    dogLegsTopIKs.buildLegsAutomation(sides, intFixes)

    # --- build toes additional rigs
    baseNameToes = 'toes'
    branchesToes = ['pinkyToe', 'ringToe', 'middleToe', 'bigToe']

    dogToes.buildToes(sides, intFixes, baseNameToes, branchesToes)

    # --- build volumeSpine
    volumeSpine.makeSpine(chest, hips, bodyGimball)

    # --- build ears
    smartParentTarget = 'head_gimbal_ctrl'
    smartDupTargets = ['L_ear_fk_ctrl_01_orig', 'R_ear_fk_ctrl_01_orig']

    volumeEars.makeVolumeEars(smartParentTarget, smartDupTargets, side, sides)

    # --- reparent toes in toesBase
    for side in sides:
        for fix in intFixes:
            toesBase = '{}_{}_toes_base_ctrl'.format(side, fix)
            toesJnt = '{}_{}_toes'.format(side, fix)
            toesChilds = mc.listRelatives(toesJnt, c=True, type='joint')
            mc.parent(toesBase, toesJnt)
            for child in toesChilds:
                mc.parent(child, toesBase)
                mc.disconnectAttr('{}.scale'.format(toesBase),
                                  '{}.inverseScale'.format(child))

    # --- patch spine to add chest_offset_ctrl
    ## reparent chest tangent control
    mc.parent(chestTangentOrig, chestOffset)
    mc.disconnectAttr(
        '{}.scale'.format(chest),
        '{}.inverseScale'.format(mc.listRelatives(chestOffset, p=True)[0]))
    ## add chestOffset transforms to chest smart joint
    chestSmartJoint = '{}_surfNurbs_ikMiddleSmart'.format(chest)
    ### create pma nodes and connest transforms from chest and chest offset to it
    chestSmartSumTra = mc.createNode(
        'plusMinusAverage', n='{}_tra_sum_pma'.format(chestSmartJoint))
    chestSmartSumRot = mc.createNode(
        'plusMinusAverage', n='{}_rot_sum_pma'.format(chestSmartJoint))
    chestSmartSumSca = mc.createNode(
        'plusMinusAverage', n='{}_sca_sum_pma'.format(chestSmartJoint))
    chestSmartNormSca = mc.createNode(
        'multiplyDivide', n='{}_sca)norm_md'.format(chestSmartJoint))

    mc.connectAttr('{}.translate'.format(chest),
                   '{}.input3D[0]'.format(chestSmartSumTra))
    mc.connectAttr('{}.translate'.format(chestOffset),
                   '{}.input3D[1]'.format(chestSmartSumTra))
    mc.connectAttr('{}.rotate'.format(chest),
                   '{}.input3D[0]'.format(chestSmartSumRot))
    mc.connectAttr('{}.rotate'.format(chestOffset),
                   '{}.input3D[1]'.format(chestSmartSumRot))
    mc.connectAttr('{}.scale'.format(chest),
                   '{}.input3D[0]'.format(chestSmartSumSca))
    mc.connectAttr('{}.scale'.format(chestOffset),
                   '{}.input3D[1]'.format(chestSmartSumSca))
    mc.connectAttr('{}.output3D'.format(chestSmartSumSca),
                   '{}.input1'.format(chestSmartNormSca))
    mc.setAttr('{}.input2'.format(chestSmartNormSca), 0.5, 0.5, 0.5)

    ### for connection of pmas to chest smart
    mc.connectAttr('{}.output3D'.format(chestSmartSumTra),
                   '{}.translate'.format(chestSmartJoint),
                   f=True)
    mc.connectAttr('{}.output3D'.format(chestSmartSumRot),
                   '{}.rotate'.format(chestSmartJoint),
                   f=True)
    mc.connectAttr('{}.output'.format(chestSmartNormSca),
                   '{}.scale'.format(chestSmartJoint),
                   f=True)

    # --- patch neck rig to add autoOffset on neck_base_ik_ctrl and its smart ctrls
    addParentList = [
        neckBaseIk, '{}_necksurfNurbsSmart'.format(neckBaseIk),
        '{}_necksurfNurbs_ikMiddleSmart'.format(neckBaseIk)
    ]
    newParents = orig.orig(objlist=addParentList,
                           suffix=['_auto'],
                           origtype='joint',
                           fromsel=False,
                           viz=False,
                           get_ssc=False,
                           rtyp='auto')
    patchLib.smartConnect(newParents[0], newParents[1])
    patchLib.smartConnect(newParents[0], newParents[2])
    # --- make new nodes and connections to connect chestOffset to neckRig
    ## create matrixOffset node, place it and constrain it to chestOffset
    neckBaseIkMatrixOffset = mc.group(n='{}_matrixOffset'.format(neckBaseIk),
                                      em=True)
    mc.parent(neckBaseIkMatrixOffset,
              mc.listRelatives(mc.listRelatives(neckBaseIk, p=True), p=True),
              r=True)
    chestOffsetPos = mc.xform(chestOffset, q=True, ws=True, t=True)
    mc.xform(neckBaseIkMatrixOffset, ws=True, t=chestOffsetPos)
    mc.parentConstraint(chestOffset, neckBaseIkMatrixOffset, mo=True)
    ## create matrix nodes and do connections to chestOffset
    chestOffsetMM = mc.createNode('multMatrix',
                                  n='{}_toNeck_mm'.format(chestOffset))
    chestOffsetDM = mc.createNode('decomposeMatrix',
                                  n='{}_toNeck_dm'.format(chestOffset))
    mc.connectAttr('{}.matrixSum'.format(chestOffsetMM),
                   '{}.inputMatrix'.format(chestOffsetDM))

    mc.connectAttr('{}.inverseMatrix'.format(neckBaseIkMatrixOffset),
                   '{}.matrixIn[0]'.format(chestOffsetMM))
    mc.connectAttr('{}.matrix'.format(chestOffset),
                   '{}.matrixIn[1]'.format(chestOffsetMM))
    mc.connectAttr('{}.matrix'.format(neckBaseIkMatrixOffset),
                   '{}.matrixIn[2]'.format(chestOffsetMM))
    mc.connectAttr('{}.outputTranslate'.format(chestOffsetDM),
                   '{}.translate'.format(newParents[0]))

    # --- reparent roots of Neck compressors into neckMid ctrl
    neckCompressorList = [
        'C_bottomNeck_base_orig', 'L_bottomNeck_base_orig',
        'R_bottomNeck_base_orig', 'C_topNeck_base_orig', 'L_topNeck_base_orig',
        'R_topNeck_base_orig'
    ]
    neckMidIk = 'neck_mid_ik_ctrl'
    mc.parent(neckCompressorList, neckMidIk)
    # --- reparent tip of top neck compressors
    tipTopNeckCompBaseName = 'topNeck_tip'
    tipTopNeckTargetBaseName = 'reverse_scapula_root'
    for side in sides:
        mc.parent('{}_{}'.format(side, tipTopNeckCompBaseName),
                  '{}_{}'.format(side, tipTopNeckTargetBaseName))
    # --- flip neck compressors ctrl_origs to fix ctrl orientation
    for each in neckCompressorList:
        splitName = each.split('_', 1)[0]
        if not splitName == 'R':
            origName = each.replace('base', 'ctrl')
            mc.setAttr('{}.jointOrientX'.format(origName), 180)

    # --- unlock translate on leg_mid_ctrls
    for side in sides:
        for fix in intFixes:
            node = '{}_{}_leg_mid_orig'.format(side, fix)
            newNodeName = mc.rename(node, node.replace('orig', 'ctrl_orig'))
            patchLib.locksSwitch(newNodeName,
                                 T=True,
                                 R=True,
                                 S=False,
                                 V=False,
                                 lockdo='unlock',
                                 keydo=False)

    # --- expose and tweak missing rotate Orders ---

    xyzRoList = []
    yzxRoList = []
    zxyRoList = []
    xzyRoList = [
        'head_ctrl', 'head_gimbal_ctrl', 'body_ctrl', 'body_gimbal_ctrl',
        'chest_ctrl', 'chest_offset_ctrl', 'hips_ctrl', 'pelvis_ctrl',
        'R_front_leg_IK_ctrl', 'R_front_leg_rvfoot_tip_ctrl',
        'R_front_leg_rvfoot_heel_ctrl', 'L_front_leg_IK_ctrl',
        'L_front_leg_rvfoot_tip_ctrl', 'L_front_leg_rvfoot_heel_ctrl',
        'R_back_leg_IK_ctrl', 'R_back_leg_rvfoot_heel_ctrl',
        'R_back_leg_rvfoot_tip_ctrl', 'L_back_leg_IK_ctrl',
        'L_back_leg_rvfoot_tip_ctrl', 'L_back_leg_rvfoot_heel_ctrl',
        'neck_mid_ik_ctrl', 'neck_base_ik_ctrl', 'neck_end', 'neck_02',
        'neck_ik_root', 'chest_tan_ik_ctrl',
        'chest_tan_ik_ctrl_center_ik_ctrl', 'spine_mid_ik_ctrl',
        'spine_mid_ik_ctrl_center_ik_ctrl', 'hips_tan_ik_ctrl',
        'hips_tan_ik_ctrl_center_ik_ctrl'
    ]
    yxzRoList = []
    zyxRoList = [
        'tail_root_fk_ctrl_01', 'tail_root_fk_ctrl_02', 'tail_fk_ctrl_01',
        'tail_fk_ctrl_02', 'tail_fk_ctrl_03', 'Tail_offset_ctrl',
        'tail_tip_ctrl'
    ]

    roLib.updateRotateOrder(xyz=xyzRoList,
                            yzx=yzxRoList,
                            zxy=zxyRoList,
                            xzy=xzyRoList,
                            yxz=yxzRoList,
                            zyx=zyxRoList)

    # ---  add head_hook for later facial parenting
    headHook = 'head_hook'
    mc.group(n=headHook, em=True)
    mc.parent(headHook, '%s_ctrl' % headGimbal, r=True)
Exemple #7
0
def patch():

    sides = ['L','R']
    pelvisCtrl = 'pelvis_ctrl'
    hipIkAdjustCtrl = 'hips_adjust_ik_ctrl_orig'
    chestAddjustCtrl = 'chest_adjust_ctrl'
    chestAdjustIKCtrlOrig = 'chest_adjust_ik_ctrl_orig'
    neckIkbase = 'neck_base_ik_ctrl'
    neckFk = 'neck_01'
    neckTipAdjust = 'neck_tip_adjust_ik_ctrl'
    neckTip = 'neck_tip_ik_ctrl'
    headCtrl = 'head_ctrl'
    headGimbalCtrl = 'head_gimbal_ctrl'

    #constraints neck_tip_adjust_ik_ctrl rotZ to headGimbalCtrl rot Z and adds blend
    AttrName = 'neckFollow'
    neckFollowRev = '%s_Rev' % AttrName
    holdGrp ='neck_tip_adjust_ik_ctrl_hold' 
    holdGrpOrig ='neck_tip_adjust_ik_ctrl_hold_orig' 

    mc.group( n = holdGrp , em = True )
    holdGrpOrig = orig.orig(objlist=[holdGrp], suffix=['_orig'], origtype='transform', fromsel=False, viz=False, get_ssc=False, rtyp='auto')[0]
    mc.parent(holdGrpOrig,(mc.listRelatives(neckTipAdjust , p= True )) , r = True )

    mc.addAttr( headCtrl , ln = AttrName , at = 'double' , min = 0 , max = 1 , dv = 0  )
    mc.setAttr('%s.%s' %(headCtrl,AttrName) , edit = True , k = True )
    headToNeckOrientCns = mc.orientConstraint(headGimbalCtrl,holdGrp,neckTipAdjust , mo = True , sk = ['x','z'] )[0]
    mc.createNode('reverse' , n = neckFollowRev )

    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.target[0].targetWeight' % headToNeckOrientCns , f = True )
    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.input.inputX' %  neckFollowRev , f = True )
    mc.connectAttr('%s.outputX' %  neckFollowRev, '%s.target[1].targetWeight' % headToNeckOrientCns , f = True )

    ######################################################################################################################################################################################
    ######################################################################################################################################################################################
    #TEASER DIRTY WORK START##############################################################################################################################################################
    ######################################################################################################################################################################################
    ######################################################################################################################################################################################

    # --- anchor pelvisPosition to last centerSpine anchor position

    mainHips = 'hips_ctrl'
    pelvisCtrl = 'pelvis_ctrl'
    maxLengthAttr = 'maxLengthBlend'

    hipsSmart = 'hips_body_gimbal_ctrl_surfNurbs_SmartJointsGrp'
    lastAnchor = 'spine_anchor_06_jnt'
    pelvisAnchorGrpSmart = 'pelvis_spineAnchor_grp_smart'
    pelvisAnchorGrp = 'pelvis_spineAnchor_grp'
    
    pelvisAnchorJnt = 'pelvis_spineAnchor_jnt_smart'

    mc.group(n=pelvisAnchorGrpSmart,em=True)
    mc.parent(pelvisAnchorGrpSmart,hipsSmart)
    mc.parentConstraint(lastAnchor,pelvisAnchorGrpSmart)

    mc.group(n=pelvisAnchorGrp,em=True)
    mc.parent(pelvisAnchorGrp,pelvisAnchorGrpSmart,r=True)
    mc.parent(pelvisAnchorGrp,mainHips)
    orig.orig(objlist=[pelvisAnchorGrp,pelvisAnchorGrpSmart], suffix=['_orig'], origtype='transform', fromsel=False, viz=False, get_ssc=False, rtyp='auto')
    mc.select(clear=True)
    
    pelvisAnchorPB = mc.createNode('pairBlend' , n='%s_pb' %pelvisAnchorGrp )
    mc.setAttr('%s.rotInterpolation' %pelvisAnchorPB , 1 )
    mc.connectAttr('%s.translate' %pelvisAnchorGrpSmart , '%s.inTranslate2' %pelvisAnchorPB)
    mc.connectAttr('%s.rotate' %pelvisAnchorGrpSmart , '%s.inRotate2' %pelvisAnchorPB)
    mc.connectAttr('%s.%s' %(mainHips,maxLengthAttr) , '%s.weight' %pelvisAnchorPB )
    mc.connectAttr('%s.outTranslate' %pelvisAnchorPB , '%s.translate' %pelvisAnchorGrp)
    mc.connectAttr('%s.outRotate' %pelvisAnchorPB , '%s.rotate' %pelvisAnchorGrp)

    mc.parent(mc.listRelatives(pelvisCtrl,p=True)[0],pelvisAnchorGrp)

    # --- add smart pelvisJoint parented into maxLenghts stuff
    mc.joint(n=pelvisAnchorJnt)
    mc.parent(pelvisAnchorJnt,pelvisAnchorGrpSmart,r=True)
    mc.setAttr('%s.radius' %pelvisAnchorJnt , 0.5 )
    mc.hide(pelvisAnchorJnt)

    # --- constraint sides helpers
    HelpFrontTrgt = ['spine_deform_U10_V02_ctrl','spine_deform_U04_V02_ctrl']   
    HelpBackTrgt = ['spine_deform_U10_V04_ctrl','spine_deform_U04_V04_ctrl']  

    frontHelperName = 'HELPER_frontLeg_sides_SKN_tip'
    backHelperName = 'HELPER_backLeg_flap_SKN_tip'

    for s , side in enumerate(sides):
        mc.pointConstraint( HelpFrontTrgt[s], '%s_%s' %(side,frontHelperName) )
        mc.pointConstraint( HelpBackTrgt[s], '%s_%s' %(side,backHelperName) )



    ################################################################################################################################################
    # adds missing ctrl to animSet,rempve unwanted ones, temp Hardcoded
    adCtrlList = ['mouthSquash_ctrl','lipsUp_ctrl']

    mc.sets([u'R_front_leg_rvfoot_toes_end_ctrl'] , rm = 'R_front_leg_ik_set' )
    mc.sets([u'R_front_leg_rvfoot_toes_end_ctrl'] , rm = 'R_front_leg_ZS_set' )

    mc.sets([u'R_back_leg_rvfoot_ik_ball_02_jnt', u'R_back_leg_ik_rvfoot_ball_01_joint', u'R_back_leg_rvfoot_toes_end_ctrl'] , rm = 'R_back_leg_ik_set' )
    mc.sets([u'R_back_leg_rvfoot_ik_ball_02_jnt', u'R_back_leg_ik_rvfoot_ball_01_joint', u'R_back_leg_rvfoot_toes_end_ctrl'] , rm = 'R_back_leg_ZS_set' )

    mc.sets([u'R_back_fullLeg_01', u'R_back_fullLeg_02', u'R_back_fullLeg_03', u'R_back_fullLeg_04'] , rm = 'R_back_leg_fk_set' )
    mc.sets([u'R_back_fullLeg_01', u'R_back_fullLeg_02', u'R_back_fullLeg_03', u'R_back_fullLeg_04'] , rm = 'R_back_leg_ZS_set' )

    mc.sets([u'L_front_leg_rvfoot_toes_end_ctrl'] , rm = 'L_front_leg_ik_set' )
    mc.sets([u'L_front_leg_rvfoot_toes_end_ctrl'] , rm = 'L_front_leg_ZS_set' )

    mc.sets([u'L_back_leg_rvfoot_toes_end_ctrl', u'L_back_leg_ik_rvfoot_ball_01_joint', u'L_back_leg_rvfoot_ik_ball_02_jnt'] , rm = 'L_back_leg_ik_set' )
    mc.sets([u'L_back_leg_rvfoot_toes_end_ctrl', u'L_back_leg_ik_rvfoot_ball_01_joint', u'L_back_leg_rvfoot_ik_ball_02_jnt'] , rm = 'L_back_leg_ZS_set' )

    mc.sets([u'L_back_fullLeg_01', u'L_back_fullLeg_02', u'L_back_fullLeg_03', u'L_back_fullLeg_04'] , rm = 'L_back_leg_fk_set' )
    mc.sets([u'L_back_fullLeg_01', u'L_back_fullLeg_02', u'L_back_fullLeg_03', u'L_back_fullLeg_04'] , rm = 'L_back_leg_ZS_set' )

    ################################################################################################################################################
    #previz cleanup ################################################################################################################################
    
    ##############################################################################################     
    remSetList = ['L_scapula_ik_jnt_01','L_scapula_root_ik_jnt_01','R_hip_ik_jnt_01','R_scapula_ik_jnt_01','R_scapula_root_ik_jnt_01','L_hip_ik_jnt_01','head_gimbal_ctrl_smart',]

    for obj in remSetList:
        getSets = mc.listSets(object = obj)
        if getSets:
            for set in getSets:
                mc.sets(obj , rm = set)   
    ##############################################################################################  

    # temp previz cleanup
    neckIkRoot = 'neck_ik_root'

    # temp Attributes set
    mc.setAttr('%s.stretch' % neckIkRoot , 0 )
    mc.setAttr('%s.squash' % neckIkRoot , 0 )
    mc.setAttr('%s.tweakVis' % neckIkRoot , 0 )

    # hide ctrls and shapes - temp Hardcoded
    hideList = ['neck_tip_ik_ctrlShape','neck_base_ik_ctrlShape']
    for each in hideList : mc.hide(each)
Exemple #8
0
def createFKSection(baseName, ctrlName, offsetName, num, suff, doOffset,
                    makeShape, color):
    #baseName:string
    #ctrlName:string
    #offsetName:string
    #num:int
    #suffix:string
    #doOffset:bool
    #makeShape:bool
    #color: None or List [#,#,#]

    ctrlNodeName = '%s_%s_%02d%s' % (baseName, ctrlName, num, suff)
    offsetNodeName = '%s_%s_%s_%02d%s' % (baseName, offsetName, ctrlName, num,
                                          suff)
    mc.select(cl=True)
    newCtrl = mc.joint(n=ctrlNodeName)
    mc.setAttr('%s.radius' % newCtrl, 0.1)
    if makeShape == True:
        mc.setAttr('%s.drawStyle' % newCtrl, 2)
        shapes.create(newCtrl,
                      shape='circle',
                      size=.5,
                      scale=[1, 1, 1],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 0],
                      color=color,
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
    newCtrlOrig = orig.orig(objlist=[newCtrl],
                            suffix=['_orig'],
                            origtype='joint',
                            fromsel=False,
                            viz=False,
                            get_ssc=False,
                            rtyp='auto')[0]
    newCtrlOrig = mc.rename(newCtrlOrig,
                            newCtrlOrig.replace('smart_orig', 'orig_smart'))
    if doOffset == True:
        mc.select(cl=True)
        newOffset = mc.joint(n=offsetNodeName)
        mc.setAttr('%s.radius' % newOffset, 0.1)
        if makeShape == True:
            mc.setAttr('%s.drawStyle' % newOffset, 2)
            shapes.create(newOffset,
                          shape='circle',
                          size=.25,
                          scale=[1, 1, 1],
                          axis='y',
                          twist=0,
                          offset=[0, 0, 0],
                          color=color,
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
        newOffsetOrig = orig.orig(objlist=[newOffset],
                                  suffix=['_orig'],
                                  origtype='joint',
                                  fromsel=False,
                                  viz=False,
                                  get_ssc=False,
                                  rtyp='auto')[0]
        newOffsetOrig = mc.rename(
            newOffsetOrig, newOffsetOrig.replace('smart_orig', 'orig_smart'))
        mc.parent(newOffsetOrig, newCtrl)
        return ([newCtrl, newCtrlOrig], [newOffset, newOffsetOrig])
    return ([newCtrl, newCtrlOrig])
Exemple #9
0
def makeVolumeEars(smartParentTarget, smartDupTargets, side, sides):

    ###############################################################################################################################################
    # --- ears smart Rig
    #smartParentTarget = 'head_gimbal_ctrl'
    #smartDupTargets = ['L_ear_fk_ctrl_01_orig','R_ear_fk_ctrl_01_orig']
    earsNoXformGrp = 'ears_ctrl_noXformGrp'
    WORLDGrp = 'WORLD'
    ## --- create noXform Grp for ears
    mc.group(n=earsNoXformGrp, em=True)
    mc.parent(earsNoXformGrp, WORLDGrp)
    mc.hide(earsNoXformGrp)

    # --- duplicate the base of the fkHierarchy, will be use as base of smart hierarchy
    smartParent = mc.duplicate(smartParentTarget,
                               po=True,
                               n='%s_smart' % smartParentTarget)[0]
    mc.parent(smartParent, earsNoXformGrp)
    # --- duplicate all of the fks in one go to create fk_smarts
    smartsList = mc.duplicate(smartDupTargets)
    for i, each in enumerate(smartDupTargets):
        mc.parent(smartsList[i], w=True)

    # --- goes into the hierarchy of duplicated Fks and counts the depth of the hierarchy. stops when arrived at end of hierarchy
    hierarchyDepthList = []
    for i, each in enumerate(smartDupTargets):
        hierarchyDepth = 0
        nexChild = ''
        stopLoop = False
        for j in range(0, 20):
            if j == 0:
                nexChild = each
            getChild = mc.listRelatives(nexChild, c=True, f=True)
            if getChild:
                for child in getChild:
                    if not mc.objectType(child) == 'nurbsCurve':
                        if mc.objectType(child) == 'joint':
                            splittedName1 = child.rsplit('|')[-1]
                            splittedName2 = splittedName1.split('offset')

                            checkEnd = splittedName1.rsplit('_', 1)[-1]

                            if not len(splittedName2) > 1:
                                if not checkEnd == 'end':
                                    nexChild = child
                                else:
                                    stopLoop = True
                                    hierarchyDepthList.append(j)
                                    break
            if stopLoop == True:
                break
        mc.delete(smartsList[i])
    # --- derives controls loop from hierarchy depth
    smartLoopLenthList = []
    for each in hierarchyDepthList:
        loopLength = (each / 2) + 2
        smartLoopLenthList.append(loopLength)

    # --- recreates hierarchy as smart nodes

    for i, each in enumerate(smartDupTargets):
        loop = smartLoopLenthList[i]
        baseName = each.split('_ctrl_', 1)[0]
        ctrlName = 'ctrl'
        offsetName = 'offset'
        suff = '_smart'
        makeShape = False
        color = None

        parentNext = smartParent
        for j in range(0, loop):
            num = j + 1

            if j < loop - 1:
                if j == 0:
                    doOffset = False
                    newCtrls = createFKSection(baseName, ctrlName, offsetName,
                                               num, suff, doOffset, makeShape,
                                               color)
                    mc.parent(newCtrls[1], parentNext)

                    trgt = newCtrls[0].rsplit('_', 1)[0]
                    origTrgt = newCtrls[1].rsplit('_', 1)[0]
                    smartConnect(trgt, newCtrls[0])
                    smartConnect(origTrgt, newCtrls[1])
                    parentNext = newCtrls[0]

                else:
                    doOffset = True
                    newCtrls = createFKSection(baseName, ctrlName, offsetName,
                                               num, suff, doOffset, makeShape,
                                               color)
                    mc.parent(newCtrls[0][1], parentNext)

                    trgt = newCtrls[0][0].rsplit('_', 1)[0]
                    origTrgt = newCtrls[0][1].rsplit('_', 1)[0]
                    offsetTrgt = newCtrls[1][0].rsplit('_', 1)[0]
                    origOffsetTrgt = newCtrls[1][1].rsplit('_', 1)[0]
                    smartConnect(trgt, newCtrls[0][0])
                    smartConnect(origTrgt, newCtrls[0][1])
                    smartConnect(offsetTrgt, newCtrls[1][0])
                    smartConnect(origOffsetTrgt, newCtrls[1][1])
                    parentNext = newCtrls[0][0]

            if j == loop - 1:
                mc.select(cl=True)
                endJoint = mc.joint(n='%s_%s_end_smart' % (baseName, ctrlName))
                endOffsetOrig = mc.joint(
                    n='%s_%s_%s_%02d_orig_smart' %
                    (baseName, offsetName, ctrlName, loop))
                endOffset = mc.joint(n='%s_%s_%s_%02d_smart' %
                                     (baseName, offsetName, ctrlName, loop))

                mc.setAttr('%s.radius' % endJoint, 0.1)
                mc.setAttr('%s.radius' % endOffsetOrig, 0.1)
                mc.setAttr('%s.drawStyle' % endOffsetOrig, 2)
                mc.setAttr('%s.radius' % endOffset, 0.1)

                mc.parent(endJoint, parentNext)
                smartConnect('%s_%s_end' % (baseName, ctrlName), endJoint)
                smartConnect(
                    '%s_%s_%s_%02d_orig' %
                    (baseName, offsetName, ctrlName, loop), endOffsetOrig)
                smartConnect(
                    '%s_%s_%s_%02d' % (baseName, offsetName, ctrlName, loop),
                    endOffset)

    # --- creates volumeSurf and deforms for ears //temporary use of firstSurf
    rigPart = 'ear'
    deformGrp = 'ctrl_DeformGrp'
    endSurfDeformGrp = 'ears_endSurf_%s' % deformGrp

    # --- assign values for columeSurf characteristics
    volspansV = 16
    volspansU = 8
    volDeg = 3
    ## ---creates ears volSurfaces
    earCurveGUIDEList = [
        'L_topEar_curve_GUIDE', 'L_topMidtEar_curve_GUIDE',
        'L_midtEar_curve_GUIDE', 'L_botMidEar_curve_GUIDE',
        'L_BotEar_curve_GUIDE'
    ]
    earVolSurfList = []
    # --- create left volume surface
    duplicatedCurves = mc.duplicate(earCurveGUIDEList)
    loftCurves = []
    mc.parent(duplicatedCurves, w=True)
    for u, curve in enumerate(duplicatedCurves):
        curveName = str(curve)
        strippedName = curveName.rsplit('_', 1)[0]
        loftCurves.append(mc.rename(curve, '%s_loftCurve' % strippedName))
    loftCurves = loftCurves[::-1]
    volSurf = mc.loft(loftCurves,
                      ch=False,
                      ar=False,
                      d=3,
                      u=True,
                      n='L_%s_volume_surfNurbs' % rigPart)[0]
    mc.rebuildSurface(volSurf,
                      rt=0,
                      su=volspansU,
                      sv=volspansV,
                      kc=True,
                      ch=False)
    mc.delete(loftCurves)
    mc.parent(volSurf, earsNoXformGrp)
    earVolSurfList.append(volSurf)
    # --- creates right ear surf from scale
    rVolsurf = mc.duplicate(volSurf, n='R_%s_volume_surfNurbs' % rigPart)[0]
    rVolsurfUSpans = mc.getAttr('%s.spansU' % rVolsurf)
    rVolsurfVSpans = mc.getAttr('%s.spansV' % rVolsurf)
    rVolsurfUDeg = mc.getAttr('%s.degreeU' % rVolsurf)
    rVolsurfVDeg = mc.getAttr('%s.degreeV' % rVolsurf)
    rVolsurfUCount = rVolsurfUSpans + rVolsurfUDeg
    rVolsurfVCount = rVolsurfVSpans
    for u in range(0, rVolsurfUCount):
        for v in range(0, rVolsurfVCount):
            pointPos = mc.pointPosition('%s.cv[%d][%d]' % (rVolsurf, u, v))
            mc.move(-pointPos[0],
                    pointPos[1],
                    pointPos[2],
                    '%s.cv[%d][%d]' % (rVolsurf, u, v),
                    a=True,
                    ws=True)
    mc.reverseSurface(rVolsurf, d=1, ch=False)
    earVolSurfList.append(rVolsurf)

    mc.group(n=endSurfDeformGrp, em=True)
    mc.parent(endSurfDeformGrp, smartParentTarget)
    volumeEarsDeformSKNList = []
    for s, surf in enumerate(earVolSurfList):
        ## --- creates and attaches jointsCloud
        side = sides[s]
        sideEndSurfDeformGrp = '%s_%s' % (side, endSurfDeformGrp)
        mc.group(n=sideEndSurfDeformGrp, em=True)
        mc.parent(sideEndSurfDeformGrp, endSurfDeformGrp)

        UDeformsCount = 9
        VDeformCount = 10
        endSurf = surf
        tempPOSI = tempPOSI = mc.createNode('pointOnSurfaceInfo',
                                            n='volumeSpine_temp_posi')
        mc.setAttr('%s.turnOnPercentage' % tempPOSI, True)
        mc.connectAttr('%s.worldSpace[0]' % endSurf,
                       '%s.inputSurface' % tempPOSI)
        for i in range(0, UDeformsCount - 1):
            for j in range(0, VDeformCount - 1):
                ## --- creates deform ctrl/skin hierarchy
                mc.select(cl=True)
                deformSkn = mc.joint(n='%s_%s_deform_U%02d_V%02d_SKN' %
                                     (side, rigPart, i, j))
                mc.setAttr('%s.radius' % deformSkn, 0.01)
                mc.select(cl=True)
                deformCtrl = mc.joint(n='%s_%s_deform_U%02d_V%02d_ctrl' %
                                      (side, rigPart, i, j))
                mc.setAttr('%s.radius' % deformCtrl, 0.01)
                mc.setAttr('%s.drawStyle' % deformCtrl, 2)
                smartConnect(deformCtrl, deformSkn)
                shapes.create(deformCtrl,
                              shape='pyramidDouble',
                              size=0.05,
                              scale=[1, 1, 1],
                              axis='y',
                              twist=0,
                              offset=[0, 0, 0],
                              color=[0.5, 0, 0.5],
                              colorDegradeTo=None,
                              replace=True,
                              middle=False)
                deformOrig = orig.orig(objlist=[deformCtrl],
                                       suffix=['_orig'],
                                       origtype='joint',
                                       fromsel=False,
                                       viz=False,
                                       get_ssc=False,
                                       rtyp='auto')[0]
                deformAuto = orig.orig(objlist=[deformCtrl],
                                       suffix=['_auto'],
                                       origtype='joint',
                                       fromsel=False,
                                       viz=False,
                                       get_ssc=False,
                                       rtyp='auto')[0]
                mc.parent(deformSkn, deformAuto)
                volumeEarsDeformSKNList.append(deformSkn)
                ## --- getWorld Position placement for deform orig from UV
                UValue = ((1.000 / (UDeformsCount - 1)) * i)
                VValue = ((1.000 / (VDeformCount - 1)) * j)
                mc.setAttr('%s.parameterU' % tempPOSI, UValue)
                mc.setAttr('%s.parameterV' % tempPOSI, VValue)
                ctrlPos = mc.getAttr('%s.position' % tempPOSI)[0]
                mc.setAttr('%s.translate' % deformOrig, ctrlPos[0], ctrlPos[1],
                           ctrlPos[2])
                ## --- attach deformer ctrl/joints to endSurface
                xrivetTrOnNurbs(deformOrig,
                                endSurf,
                                mainDirection=1,
                                out='worldSpace[0]',
                                u=None,
                                v=None,
                                offsetOrient=[0, 0, 0],
                                min=False)
                ## --- reparent deform origs into rig
                mc.parent(deformOrig, sideEndSurfDeformGrp)
        mc.select(cl=True)
        mc.delete(tempPOSI)

    ## --- TempCleanup of ears sets
    volumeEarsSkinSet = 'volume_ears_skin_set'
    mc.sets(volumeEarsDeformSKNList, n=volumeEarsSkinSet)
    mc.sets(volumeEarsSkinSet, add='skin_set')
    ### --- disconnect inverseScale on ears to allow headScale
    fkEarsOrigs = ['L_ear_fk_ctrl_01_orig', 'R_ear_fk_ctrl_01_orig']
    for earOrig in fkEarsOrigs:
        mc.disconnectAttr('head_gimbal_ctrl.scale',
                          '%s.inverseScale' % earOrig)
def buildLegsTopIks(sides, intFixes, chestAdjust):

    #sides = ['L','R']
    #intFixes = ['front','back']
    #chestAdjust = 'chest_adjust_ctrl'
    baseRgb = [[0, 0, 1], [1, 0, 0]]
    darkRgb = [[0, 0, .8], [.8, 0, 0]]
    lightRgb = [[.5, .5, 1], [1, .5, .5]]

    for s, side in enumerate(sides):
        fix = intFixes[0]
        #### front leg
        # add of Auto node + orig on top of leg root offset orig
        nodeRoot = '{}_{}_leg_root_offset_ctrl'.format(side, fix)

        makeAutoNode(nodeRoot)

        # --- recreate reverse scapula joint with Ik and scaleBlend
        nodeEnd = '{}_scapula_ctrl'.format(side)
        baseName = nodeEnd.replace('scapula_ctrl', 'reverse_scapula')
        attrNode = '{}_{}_leg_SW_ctrl'.format(side, fix)
        attrName = '{}ScapulaStretch'.format(side)

        revIK = makeRevIk(nodeRoot, nodeEnd, baseName, attrNode, attrName)

        # --- add auto group on reverse ikh orig
        revIkAuto = makeAutoNode(revIK[2])
        print 'ikAuto Target = %s' % revIK[3]
        print revIkAuto

        # --- recrate base scapula chain and pointConstraint scapula_orig to it
        baseScapRoot = chestAdjust
        baseScapName = nodeEnd.replace('scapula_ctrl', 'scapula_base_jnt')

        scapulaBaseChain = makeChainFromObj(baseScapRoot, nodeEnd,
                                            baseScapName)
        mc.parent(scapulaBaseChain[2], chestAdjust)
        mc.pointConstraint(scapulaBaseChain[1],
                           mc.listRelatives(nodeEnd, p=True),
                           mo=False)

        # --- recreate base scapula  secondary chain + ik  fullScale
        baseScapSecName = nodeEnd.replace('scapula_ctrl',
                                          'scapula_base_sec_jnt')
        baseScapAttrName = 'baseScapeScale'
        baseScapSecEnd = mc.listRelatives(nodeEnd, p=True)
        basScapSecChain = makeRevIk(scapulaBaseChain[0], baseScapSecEnd,
                                    baseScapSecName, scapulaBaseChain[0],
                                    baseScapAttrName)
        mc.setAttr('{}.{}'.format(scapulaBaseChain[0], baseScapAttrName), 1)
        mc.setAttr('{}.{}'.format(scapulaBaseChain[0], baseScapAttrName),
                   l=True)

        # --- make scapula base ctrl
        mc.select(cl=True)
        scapulaBaseCtrl = mc.joint(
            n=nodeEnd.replace('scapula', 'scapula_base'))
        mc.setAttr('{}.drawStyle'.format(scapulaBaseCtrl), 2)
        mc.setAttr('{}.radius'.format(scapulaBaseCtrl), k=False)
        mc.parent(scapulaBaseCtrl, nodeEnd, r=True)

        shapes.create(scapulaBaseCtrl,
                      shape='root',
                      size=.6,
                      scale=[1, 1, 1],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 0],
                      color=lightRgb[s],
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
        scapulaBaseCtrlOrig = orig.orig(objlist=[scapulaBaseCtrl],
                                        suffix=['_orig'],
                                        origtype='joint',
                                        fromsel=False,
                                        viz=False,
                                        get_ssc=False,
                                        rtyp='auto')[0]
        scapulaBaseCtrlAuto = orig.orig(objlist=[scapulaBaseCtrlOrig],
                                        suffix=['_auto'],
                                        origtype='joint',
                                        fromsel=False,
                                        viz=False,
                                        get_ssc=False,
                                        rtyp='auto')[0]
        patchLib.locksSwitch(scapulaBaseCtrl,
                             T=False,
                             R=True,
                             S=True,
                             V=True,
                             lockdo='lock',
                             keydo=False)

        mc.pointConstraint(revIK[1], scapulaBaseCtrlAuto, mo=True)

        # --- make reverse scapula secondary chain and full ik stretch
        baseSecName = nodeEnd.replace('scapula_ctrl', 'reverse_scapula_sec')
        revSecIK = makeRevIk(revIK[0], scapulaBaseCtrl, baseSecName, revIK[0],
                             baseScapAttrName)
        mc.setAttr('{}.{}'.format(revIK[0], baseScapAttrName), 1)
        mc.setAttr('{}.{}'.format(revIK[0], baseScapAttrName), l=True)

        mc.pointConstraint(revSecIK[1], basScapSecChain[3], mo=True)

        # constraint reverse chain Orig to base leg ctrl
        revChainOrig = mc.listRelatives(revIK[0], p=True)
        legBaseCtrl = '{}_{}_leg_01_base_ctrl'.format(side, fix)

        mc.pointConstraint(legBaseCtrl, revChainOrig, mo=True)

        # connect base scapula ctrl to advance attr
        mc.connectAttr('{}.advanced'.format(attrNode),
                       '{}.visibility'.format(scapulaBaseCtrlOrig))

        #### back leg ####
        fix = intFixes[1]

        sideHipRoot = '{}_hip_ctrl'.format(side)
        sideHipEnd = '{}_{}_leg_root_offset_ctrl'.format(side, fix)

        # --- make side hip auto
        sideHipAuto = makeAutoNode(sideHipEnd)

        # --- add end joint on side hips control
        sideHipBaseName = sideHipRoot.replace('ctrl', 'chain')

        siddeHipChain = makeChainFromObj(sideHipRoot, sideHipEnd,
                                         sideHipBaseName)
        mc.parent(siddeHipChain[2], sideHipRoot)

        # --- re PointConstraint
        mc.pointConstraint(siddeHipChain[1], sideHipAuto[1])

        # --- double side hip chain in IK fullStretch controlled by back leg offset
        sideHipSecRoot = mc.listRelatives(sideHipEnd, p=True)
        sideHipSecBaseName = sideHipBaseName.replace('chain', 'sec')
        sideHipSecattrName = 'sideHipScale'

        sideHipSecChain = makeRevIk(siddeHipChain[0], sideHipSecRoot,
                                    sideHipSecBaseName, siddeHipChain[0],
                                    sideHipSecattrName)
        mc.setAttr('{}.{}'.format(siddeHipChain[0], sideHipSecattrName), 1)
        mc.setAttr('{}.{}'.format(siddeHipChain[0], sideHipSecattrName),
                   l=True)

        # --- constraint side hip ik to back leg base Ctrl
        backLegBaseCtrl = '{}_{}_leg_01_base_ctrl'.format(side, fix)
        mc.pointConstraint(backLegBaseCtrl, sideHipSecChain[3], mo=True)
Exemple #11
0
def buildToes(sides, intFixes, baseName, branches):

    #sides = ['L','R']
    #intFixes = ['front','back']
    #baseName = 'toes'
    #branches = ['pinkyToe','ringToe','middleToe','bigToe']
    baseRgb = [[0, 0, 1], [1, 0, 0]]
    darkRgb = [[0, 0, .8], [.8, 0, 0]]
    lightRgb = [[.5, .5, 1], [1, .5, .5]]

    for fix in intFixes:
        for s, side in enumerate(sides):
            # toes All control
            ## get average toes world pos
            worldPosList = []
            for branch in branches:
                tipPos = mc.xform('{}_{}_{}_IK_ctrl'.format(side, fix, branch),
                                  q=True,
                                  ws=True,
                                  t=True)
                worldPosList.append(tipPos)
            worldPosListLen = len(worldPosList)
            worldPosSum = [0, 0, 0]
            for i in range(0, worldPosListLen):
                worldPosSum[0] += worldPosList[i][0]
                worldPosSum[1] += worldPosList[i][1]
                worldPosSum[2] += worldPosList[i][2]
            worldPosAverage = [
                worldPosSum[0] / worldPosListLen,
                worldPosSum[1] / worldPosListLen,
                worldPosSum[2] / worldPosListLen
            ]
            ## create toes All Ctrl
            toesAllCtrl = mc.group(n='{}_{}_toes_all_IK_ctrl'.format(
                side, fix),
                                   em=True)
            mc.setAttr('{}.translate'.format(toesAllCtrl), worldPosAverage[0],
                       worldPosAverage[1], worldPosAverage[2])
            mc.parent(toesAllCtrl, '{}_{}_foot_03_SKN'.format(side, fix))
            mc.setAttr('{}.translateX'.format(toesAllCtrl), 0)
            shapes.create(toesAllCtrl,
                          shape='square',
                          size=1,
                          scale=[.55, .2, .4],
                          axis='y',
                          twist=0,
                          offset=[0, 0, 0],
                          color=lightRgb[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
            orig.orig(objlist=[toesAllCtrl],
                      suffix=['_orig'],
                      origtype='transform',
                      fromsel=False,
                      viz=False,
                      get_ssc=False,
                      rtyp='auto')

            # reparent and constraint main toes grp
            mc.parent('{}_{}_toes'.format(side, fix),
                      '{}_{}_leg_scl'.format(side, fix))
            mc.parentConstraint('{}_{}_foot_02_SKN'.format(side, fix),
                                '{}_{}_toes'.format(side, fix),
                                mo=True)

            # reparent cushion joint
            mc.parent('{}_{}_cushion_ctrl_orig'.format(side, fix),
                      '{}_{}_leg_scl'.format(side, fix))
            mc.disconnectAttr(
                '{}_{}_leg_scl.scale'.format(side, fix),
                '{}_{}_cushion_ctrl_orig.inverseScale'.format(side, fix))

            for branch in branches:
                # reparent toes hierarchy
                mc.parent('{}_{}_{}_IK_ctrl_orig'.format(side, fix, branch),
                          toesAllCtrl)

                # reparent toes tips in toes end joints
                mc.parent('{}_{}_{}_tip_ctrl_orig'.format(side, fix, branch),
                          '{}_{}_{}_end'.format(side, fix, branch))

                # reparent ik poleVectors in ik ctrl origs
                mc.parent('{}_{}_{}_PV_ctrl_orig'.format(side, fix, branch),
                          '{}_{}_{}_IK_ctrl_orig'.format(side, fix, branch))

                # add upVectors visSwitch
                attrNode = '{}_{}_{}_IK_ctrl'.format(side, fix, branch)
                AttrName = 'showUpV'
                mc.addAttr(attrNode, ln=AttrName, at='bool', dv=0)
                mc.setAttr('{}.{}'.format(attrNode, AttrName),
                           edit=True,
                           k=True)
                mc.connectAttr('{}.{}'.format(attrNode, AttrName),
                               '{}_{}_{}_PV_ctrl_orig.visibility'.format(
                                   side, fix, branch),
                               f=True)

                # make blens orient rig for toes tips
                tipOrigParent = mc.listRelatives(
                    '{}_{}_{}_tip_ctrl_orig'.format(side, fix,
                                                    branch), p=True)[0]
                ## create hold grp
                holdGrp = mc.group(n='{}_{}_{}_tip_hold'.format(
                    side, fix, branch),
                                   em=True)
                mc.parent(holdGrp,
                          '{}_{}_{}_tip_ctrl_orig'.format(side, fix, branch),
                          r=True)
                mc.parent(holdGrp, tipOrigParent)
                ## create orient constraint and blend
                ### create orient Attr
                attrNode = '{}_{}_{}_IK_ctrl'.format(side, fix, branch)
                AttrName = 'toeTipOrient'
                mc.addAttr(attrNode,
                           ln=AttrName,
                           at='double',
                           min=0,
                           max=1,
                           dv=0)
                mc.setAttr('{}.{}'.format(attrNode, AttrName),
                           edit=True,
                           k=True)
                ### multipliy Attr and ikFK blend
                toeTipOrientMDL = mc.createNode(
                    'multDoubleLinear',
                    n='{}_{}_{}_tipOrient_mdl'.format(side, fix, branch))
                mc.connectAttr('{}.{}'.format(attrNode, AttrName),
                               '{}.input1'.format(toeTipOrientMDL))
                mc.connectAttr(
                    '{}_{}_{}_SW_ctrl.fkIk'.format(side, fix, branch),
                    '{}.input2'.format(toeTipOrientMDL))
                ### orientConstraint toes tip orig
                tipOrientCns = mc.orientConstraint(
                    '{}_{}_{}_IK_ctrl'.format(side, fix, branch),
                    holdGrp,
                    '{}_{}_{}_tip_ctrl_orig'.format(side, fix, branch),
                    mo=True)[0]
                ### add reverse node and connect blend on orient constraint
                toeTipOrientRv = mc.createNode(
                    'reverse',
                    n='{}_{}_{}_tipOrient_rv'.format(side, fix, branch))
                mc.connectAttr('{}.output'.format(toeTipOrientMDL),
                               '{}.inputX'.format(toeTipOrientRv))
                mc.connectAttr(
                    '{}.output'.format(toeTipOrientMDL),
                    '{}.target[0].targetWeight'.format(tipOrientCns),
                    f=True)
                mc.connectAttr(
                    '{}.outputX'.format(toeTipOrientRv),
                    '{}.target[1].targetWeight'.format(tipOrientCns),
                    f=True)

                # change shapes

                shapes.create('{}_{}_{}_nail_ctrl'.format(side, fix, branch),
                              shape='cube',
                              size=.1,
                              scale=[.5, 1, .5],
                              axis='z',
                              twist=0,
                              offset=[0, 0, 0],
                              color=lightRgb[s],
                              colorDegradeTo=None,
                              replace=True,
                              middle=False)
                shapes.create('{}_{}_{}_tip_ctrl'.format(side, fix, branch),
                              shape='square',
                              size=.25,
                              scale=[.4, .5, .75],
                              axis='y',
                              twist=0,
                              offset=[0, 0, 0],
                              color=darkRgb[s],
                              colorDegradeTo=None,
                              replace=True,
                              middle=False)
                shapes.create('{}_{}_{}_squash_ctrl'.format(side, fix, branch),
                              shape='cube',
                              size=.15,
                              scale=[.6, .1, 1],
                              axis='y',
                              twist=0,
                              offset=[0, 0, 0],
                              color=lightRgb[s],
                              colorDegradeTo=None,
                              replace=True,
                              middle=False)
                shapes.create('{}_{}_{}_IK_ctrl'.format(side, fix, branch),
                              shape='square',
                              size=.25,
                              scale=[.5, .5, 1],
                              axis='y',
                              twist=0,
                              offset=[0, 0, 0],
                              color=baseRgb[s],
                              colorDegradeTo=None,
                              replace=True,
                              middle=False)

            shapes.create('{}_{}_cushion_ctrl'.format(side, fix),
                          shape='square',
                          size=.3,
                          scale=[1, 1, 1],
                          axis='y',
                          twist=0,
                          offset=[0, 0, 0],
                          color=baseRgb[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
            shapes.create('{}_{}_leg_scl_ctrl'.format(side, fix),
                          shape='cube',
                          size=.22,
                          scale=[1, .3, 1],
                          axis='y',
                          twist=0,
                          offset=[0, 0, 0],
                          color=lightRgb[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
Exemple #12
0
def patch():

    sides = ['L','R']
    intFixes = ['front','back']
    pelvisCtrl = 'pelvis_ctrl'
    hipIkAdjustCtrl = 'hips_adjust_ik_ctrl_orig'
    chestAddjustCtrl = 'chest_adjust_ctrl'
    chestAdjustIKCtrlOrig = 'chest_adjust_ik_ctrl_orig'
    neckIkbase = 'neck_base_ik_ctrl'
    neckFk = 'neck_01'
    neckTipAdjust = 'neck_tip_adjust_ik_ctrl'
    neckTip = 'neck_tip_ik_ctrl'
    headCtrl = 'head_ctrl'
    headGimbalCtrl = 'head_gimbal_ctrl'

    #constraints neck_tip_adjust_ik_ctrl rotZ to headGimbalCtrl rot Z and adds blend
    AttrName = 'neckFollow'
    neckFollowRev = '%s_Rev' % AttrName
    holdGrp ='neck_tip_adjust_ik_ctrl_hold' 
    holdGrpOrig ='neck_tip_adjust_ik_ctrl_hold_orig' 

    mc.group( n = holdGrp , em = True )
    holdGrpOrig = orig.orig(objlist=[holdGrp], suffix=['_orig'], origtype='transform', fromsel=False, viz=False, get_ssc=False, rtyp='auto')[0]
    mc.parent(holdGrpOrig,(mc.listRelatives(neckTipAdjust , p= True )) , r = True )

    mc.addAttr( headCtrl , ln = AttrName , at = 'double' , min = 0 , max = 1 , dv = 0  )
    mc.setAttr('%s.%s' %(headCtrl,AttrName) , edit = True , k = True )
    headToNeckOrientCns = mc.orientConstraint(headGimbalCtrl,holdGrp,neckTipAdjust , mo = True , sk = ['x','y'] )[0]
    mc.createNode('reverse' , n = neckFollowRev )

    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.target[0].targetWeight' % headToNeckOrientCns , f = True )
    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.input.inputX' %  neckFollowRev , f = True )
    mc.connectAttr('%s.outputX' %  neckFollowRev, '%s.target[1].targetWeight' % headToNeckOrientCns , f = True )


    # --- anchor pelvisPosition to last centerSpine anchor position

    mainHips = 'hips_ctrl'
    pelvisCtrl = 'pelvis_ctrl'
    maxLengthAttr = 'maxLengthBlend'

    hipsSmart = 'hips_body_gimbal_ctrl_surfNurbs_SmartJointsGrp'
    lastAnchor = 'spine_anchor_06_jnt'
    pelvisAnchorGrpSmart = 'pelvis_spineAnchor_grp_smart'
    pelvisAnchorGrp = 'pelvis_spineAnchor_grp'
    
    pelvisAnchorJnt = 'pelvis_spineAnchor_jnt_smart'

    mc.group(n=pelvisAnchorGrpSmart,em=True)
    mc.parent(pelvisAnchorGrpSmart,hipsSmart)
    mc.parentConstraint(lastAnchor,pelvisAnchorGrpSmart)

    mc.group(n=pelvisAnchorGrp,em=True)
    mc.parent(pelvisAnchorGrp,pelvisAnchorGrpSmart,r=True)
    mc.parent(pelvisAnchorGrp,mainHips)
    orig.orig(objlist=[pelvisAnchorGrp,pelvisAnchorGrpSmart], suffix=['_orig'], origtype='transform', fromsel=False, viz=False, get_ssc=False, rtyp='auto')
    mc.select(clear=True)
    
    pelvisAnchorPB = mc.createNode('pairBlend' , n='%s_pb' %pelvisAnchorGrp )
    mc.setAttr('%s.rotInterpolation' %pelvisAnchorPB , 1 )
    mc.connectAttr('%s.translate' %pelvisAnchorGrpSmart , '%s.inTranslate2' %pelvisAnchorPB)
    mc.connectAttr('%s.rotate' %pelvisAnchorGrpSmart , '%s.inRotate2' %pelvisAnchorPB)
    mc.connectAttr('%s.%s' %(mainHips,maxLengthAttr) , '%s.weight' %pelvisAnchorPB )
    mc.connectAttr('%s.outTranslate' %pelvisAnchorPB , '%s.translate' %pelvisAnchorGrp)
    mc.connectAttr('%s.outRotate' %pelvisAnchorPB , '%s.rotate' %pelvisAnchorGrp)

    mc.parent(mc.listRelatives(pelvisCtrl,p=True)[0],pelvisAnchorGrp)

    # --- add smart pelvisJoint parented into maxLenghts stuff
    mc.joint(n=pelvisAnchorJnt)
    mc.parent(pelvisAnchorJnt,pelvisAnchorGrpSmart,r=True)
    mc.setAttr('%s.radius' %pelvisAnchorJnt , 0.5 )
    mc.hide(pelvisAnchorJnt)

    # --- constraint sides helpers
    HelpFrontTrgt = ['spine_deform_U10_V02_ctrl','spine_deform_U04_V02_ctrl']   
    HelpBackTrgt = ['spine_deform_U10_V04_ctrl','spine_deform_U04_V04_ctrl']  

    frontHelperName = 'HELPER_frontLeg_sides_SKN_tip'
    backHelperName = 'HELPER_backLeg_flap_SKN_tip'

    for s , side in enumerate(sides):
        mc.pointConstraint( HelpFrontTrgt[s], '%s_%s' %(side,frontHelperName) )
        mc.pointConstraint( HelpBackTrgt[s], '%s_%s' %(side,backHelperName) )


    ################################################################################################################################################
    #cleanup ################################################################################################################################
    
    # --- remove unwanted nodes from sets  
    remSetList = ['head_gimbal_ctrl_smart','neck_01','neck_tip_adjust_ik_ctrl','neck_tip_ik_ctrl','neck_end','L_back_leg_rvfoot_spin_ctrl','L_front_leg_rvfoot_spin_ctrl',
                  'R_back_leg_rvfoot_spin_ctrl','R_front_leg_rvfoot_spin_ctrl','L_reverse_scapula_root']

    for obj in remSetList:
        if mc.objExists(obj) == True:
            getSets = mc.listSets(object = obj)
            if getSets:
                for set in getSets:
                    mc.sets(obj , rm = set)   

    # --- make main toes sets for a less messy main set
    for side in sides:
        for fix in intFixes:
            tips = mc.ls('{}_{}_*Toe_tip_ctrl'.format(side,fix), type = 'joint' )
            squashs = mc.ls('{}_{}_*Toe_squash_ctrl'.format(side,fix), type = 'joint' )
            nails = mc.ls('{}_{}_*Toe_nail_ctrl'.format(side,fix), type = 'joint' )
            cushion = '{}_{}_cushion_ctrl'.format(side,fix)
            
            mc.sets(cushion , add = '{}_{}_toes_anim_set'.format(side,fix) )
            mc.sets(cushion , add = '{}_{}_toes_ZS_set'.format(side,fix) )
            mc.sets(cushion , add = '{}_{}_toes_skin_set'.format(side,fix) )
            for each in tips:
                mc.sets(each , add = '{}_{}_toes_anim_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_ZS_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_skin_set'.format(side,fix) )
            for each in squashs:
                mc.sets(each , add = '{}_{}_toes_anim_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_ZS_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_skin_set'.format(side,fix) )
            for each in nails:
                mc.sets(each , add = '{}_{}_toes_anim_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_ZS_set'.format(side,fix) )
                mc.sets(each , add = '{}_{}_toes_skin_set'.format(side,fix) ) 
        scapBase = '{}_scapula_base_sec_jnt_root'.format(side)
        revScap = '{}_reverse_scapula_sec_root'.format(side)
        sideHip = '{}_hip_sec_root'.format(side)
        mc.sets(scapBase , add = '{}_front_leg_skin_set'.format(side) )
        mc.sets(revScap , add = '{}_front_leg_skin_set'.format(side) )
        mc.sets(sideHip , add = '{}_back_leg_skin_set'.format(side) )

            
    
    neckIkRoot = 'neck_ik_root'
    # Attributes set
    mc.setAttr('%s.stretch' % neckIkRoot , 0 )
    mc.setAttr('%s.squash' % neckIkRoot , 0 )
    mc.setAttr('%s.tweakVis' % neckIkRoot , 0 )

    # hide ctrls and shapes - temp Hardcoded
    hideList = ['neck_tip_ik_ctrlShape','neck_tip_adjust_ik_ctrlShape','neck_01Shape']
    for each in hideList : mc.hide(each)
    
    ## --- set animation default values on legs automation
    
    '''
def patch():

    pelvisCtrl = 'pelvis_ctrl'
    hipIkAdjustCtrl = 'hips_adjust_ik_ctrl_orig'
    chestAddjustCtrl = 'chest_adjust_ctrl'
    chestAdjustIKCtrlOrig = 'chest_adjust_ik_ctrl_orig'
    neckIkbase = 'neck_base_ik_ctrl'
    neckFk = 'neck_01'
    neckTipAdjust = 'neck_tip_adjust_ik_ctrl'
    neckTip = 'neck_tip_ik_ctrl'
    headCtrl = 'head_ctrl'
    headGimbalCtrl = 'head_gimbal_ctrl'

    #fix jaw skinSet Temp
    mc.sets( ['jaw_SKN','lipsUp_SKN'] , add = 'jaw_root_jnt_skin_set' )

    #constraints neck_tip_adjust_ik_ctrl rotZ to headGimbalCtrl rot Z and adds blend
    AttrName = 'neckFollow'
    neckFollowRev = '%s_Rev' % AttrName
    holdGrp ='neck_tip_adjust_ik_ctrl_hold' 
    holdGrpOrig ='neck_tip_adjust_ik_ctrl_hold_orig' 

    mc.group( n = holdGrp , em = True )
    holdGrpOrig = orig.orig(objlist=[holdGrp], suffix=['_orig'], origtype='transform', fromsel=False, viz=False, get_ssc=False, rtyp='auto')[0]
    mc.parent(holdGrpOrig,(mc.listRelatives(neckTipAdjust , p= True )) , r = True )

    mc.addAttr( headCtrl , ln = AttrName , at = 'double' , min = 0 , max = 1 , dv = 0  )
    mc.setAttr('%s.%s' %(headCtrl,AttrName) , edit = True , k = True )
    headToNeckOrientCns = mc.orientConstraint(headGimbalCtrl,holdGrp,neckTipAdjust , mo = True , sk = ['x','z'] )[0]
    mc.createNode('reverse' , n = neckFollowRev )

    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.target[0].targetWeight' % headToNeckOrientCns , f = True )
    mc.connectAttr('%s.%s' %(headCtrl,AttrName), '%s.input.inputX' %  neckFollowRev , f = True )
    mc.connectAttr('%s.outputX' %  neckFollowRev, '%s.target[1].targetWeight' % headToNeckOrientCns , f = True )


    #connects pelvis_ctrl translate to hips_adjust_ik_ctrl_orig
    mc.connectAttr('%s.translate' % pelvisCtrl , '%s.translate' % hipIkAdjustCtrl , f = True )
    #connects  and blend pelvis_ctrl rotate to hips_adjust_ik_ctrl_orig
    AttrName = 'hipAdjustRotateFollow'
    hipFollowMD = '%s_MD' % AttrName

    mc.addAttr( pelvisCtrl , ln = AttrName , at = 'double' , min = 0 , max = 1 , dv = 0  )
    mc.setAttr('%s.%s' %(pelvisCtrl,AttrName) , edit = True , k = True )

    mc.createNode('multiplyDivide' , n = hipFollowMD )
    mc.connectAttr( '%s.rotateX' % pelvisCtrl , '%s.input1X' % hipFollowMD , f = True )
    mc.connectAttr( '%s.rotateY' % pelvisCtrl , '%s.input1Y' % hipFollowMD , f = True )
    mc.connectAttr( '%s.rotateZ' % pelvisCtrl , '%s.input1Z' % hipFollowMD , f = True )
    mc.connectAttr('%s.%s' %(pelvisCtrl,AttrName) , '%s.input2X' % hipFollowMD , f = True )
    mc.connectAttr('%s.%s' %(pelvisCtrl,AttrName) , '%s.input2Y' % hipFollowMD , f = True )
    mc.connectAttr('%s.%s' %(pelvisCtrl,AttrName) , '%s.input2Z' % hipFollowMD , f = True )
    mc.connectAttr( '%s.outputX' % hipFollowMD , '%s.rotateX' % hipIkAdjustCtrl , f = True )
    mc.connectAttr( '%s.outputY' % hipFollowMD , '%s.rotateY' % hipIkAdjustCtrl , f = True )
    mc.connectAttr( '%s.outputZ' % hipFollowMD , '%s.rotateZ' % hipIkAdjustCtrl , f = True )

    #constraints chest_adjust_ctrl to 'neck_ik_root' while ommiting rotation first then add rotation blend
    mc.parentConstraint( chestAddjustCtrl , neckIkbase , mo = True , sr = ['x','y','z'] )
    #constraints chest_adjust_ctrl to chest_adjust_ik_ctrl while ommiting rotation first then add rotation blend
    mc.parentConstraint( chestAddjustCtrl , chestAdjustIKCtrlOrig , mo = True , sr = ['x','y','z'] )

    chestAdjustOrigHold = '%s_hold' % chestAdjustIKCtrlOrig
    chestAdjustFollowREV = '%s_follow_REV' % chestAdjustIKCtrlOrig
    chestAdjustOrigParent = mc.listRelatives( chestAdjustIKCtrlOrig , p=True)[0]

    mc.group(n = chestAdjustOrigHold , em = True )
    mc.parent( chestAdjustOrigHold , chestAdjustOrigParent , r =True )
    chestAdjustOrigOrientCns = mc.orientConstraint( chestAddjustCtrl , chestAdjustOrigHold , chestAdjustIKCtrlOrig , mo = True )[0]

    AttrName = '%sFollow' % chestAddjustCtrl
    mc.addAttr( chestAddjustCtrl , ln = AttrName , at = 'double' , min = 0 , max = 1 , dv = 1  )
    mc.setAttr('%s.%s' %(chestAddjustCtrl,AttrName) , edit = True , k = True )

    mc.createNode('reverse' , n = chestAdjustFollowREV )
    mc.connectAttr( '%s.%s' %(chestAddjustCtrl,AttrName), '%s.inputX' % chestAdjustFollowREV , f = True )
    mc.connectAttr('%s.%s' %(chestAddjustCtrl,AttrName) ,  '%s.target[0].targetWeight' % chestAdjustOrigOrientCns , f = True )
    mc.connectAttr('%s.outputX' % chestAdjustFollowREV ,  '%s.target[1].targetWeight' % chestAdjustOrigOrientCns , f = True )

    #####TEMP fix spine deform ORientation -- HARDCODED
    adRotList = ['spine_ctrl_deform_01_origAdditiveRotation','spine_ctrl_deform_02_origAdditiveRotation','spine_ctrl_deform_03_origAdditiveRotation']
    for adRot in adRotList :
        mc.setAttr('%s.inputBZ' % adRot , -90 )

    ################################################################################################################################################
    # adds missing ctrl to animSet,rempve unwanted ones, temp Hardcoded
    adCtrlList = ['jaw_ctrl','mouthSquash_ctrl','lipsUp_ctrl']

    mc.sets(adCtrlList , add = 'jaw_root_jnt_fk_set' )
    mc.sets(adCtrlList , add = 'jaw_root_jnt_ZS_set' )

    mc.sets([u'R_front_leg_rvfoot_toes_end_ctrl'] , rm = 'R_front_leg_ik_set' )
    mc.sets([u'R_front_leg_rvfoot_toes_end_ctrl'] , rm = 'R_front_leg_ZS_set' )

    mc.sets([u'R_back_leg_rvfoot_ik_ball_02_jnt', u'R_back_leg_ik_rvfoot_ball_01_joint', u'R_back_leg_rvfoot_toes_end_ctrl'] , rm = 'R_back_leg_ik_set' )
    mc.sets([u'R_back_leg_rvfoot_ik_ball_02_jnt', u'R_back_leg_ik_rvfoot_ball_01_joint', u'R_back_leg_rvfoot_toes_end_ctrl'] , rm = 'R_back_leg_ZS_set' )

    mc.sets([u'R_back_fullLeg_01', u'R_back_fullLeg_02', u'R_back_fullLeg_03', u'R_back_fullLeg_04'] , rm = 'R_back_leg_fk_set' )
    mc.sets([u'R_back_fullLeg_01', u'R_back_fullLeg_02', u'R_back_fullLeg_03', u'R_back_fullLeg_04'] , rm = 'R_back_leg_ZS_set' )

    mc.sets([u'L_front_leg_rvfoot_toes_end_ctrl'] , rm = 'L_front_leg_ik_set' )
    mc.sets([u'L_front_leg_rvfoot_toes_end_ctrl'] , rm = 'L_front_leg_ZS_set' )

    mc.sets([u'L_back_leg_rvfoot_toes_end_ctrl', u'L_back_leg_ik_rvfoot_ball_01_joint', u'L_back_leg_rvfoot_ik_ball_02_jnt'] , rm = 'L_back_leg_ik_set' )
    mc.sets([u'L_back_leg_rvfoot_toes_end_ctrl', u'L_back_leg_ik_rvfoot_ball_01_joint', u'L_back_leg_rvfoot_ik_ball_02_jnt'] , rm = 'L_back_leg_ZS_set' )

    mc.sets([u'L_back_fullLeg_01', u'L_back_fullLeg_02', u'L_back_fullLeg_03', u'L_back_fullLeg_04'] , rm = 'L_back_leg_fk_set' )
    mc.sets([u'L_back_fullLeg_01', u'L_back_fullLeg_02', u'L_back_fullLeg_03', u'L_back_fullLeg_04'] , rm = 'L_back_leg_ZS_set' )

    ################################################################################################################################################
    #previz cleanup ################################################################################################################################

    # temp previz cleanup
    neckIkRoot = 'neck_ik_root'
    chestRootCtrl = 'chest_root_ctrl'
    neckTipAdjustCtrl = 'neck_tip_adjust_ik_ctrl'

    # temp Attributes set
    mc.setAttr('%s.stretch' % neckIkRoot , 0 )
    mc.setAttr('%s.squash' % neckIkRoot , 0 )
    mc.setAttr('%s.tweakVis' % neckIkRoot , 0 )
    mc.setAttr('%s.stretch' % chestRootCtrl , 0 )
    mc.setAttr('%s.squash' % chestRootCtrl , 0 )
    mc.setAttr('%s.tweakVis' % chestRootCtrl , 0 )

    # hide ctrls and shapes - temp Hardcoded
    hideList = ['neck_tip_ik_ctrlShape','jaw_root_ctrlShape','neck_base_ik_ctrlShape','chest_adjust_ik_ctrlShape',
                'chest_root_ctrlShape','hips_adjust_ik_ctrlShape','spine_ctrl_01Shape','spine_ctrl_02Shape','spine_ctrl_03Shape']
    for each in hideList : mc.hide(each)

    # lock/hide channels
    mc.setAttr( '%s.rotateY' % neckTipAdjustCtrl , l = True , k = False )
Exemple #14
0
def patch():

    facialDrv = 'facialDrivers'

    eyeMaskOrig = 'eyeMask_ctrl_orig'

    JawClenchLOrig = 'Jaw_Clench_l_ctrl_orig'
    JawClenchROrig = 'Jaw_Clench_r_ctrl_orig'
    jawChinOrig = 'jawChin_ctrl_orig'

    UpHeadGuide = 'UpHead_ctrl_GUIDE_01'
    UpHeadOrig = 'UpHead_ctrl_01_orig'
    UpHeadCtrl = 'UpHead_ctrl_01'
    LowerHeadGuide = 'LowerHead_ctrl_GUIDE_01'
    LowerHeadOrig = 'LowerHead_ctrl_01_orig'
    LowerHeadCtrl = 'LowerHead_ctrl_01'
    mouthSquashOrig = 'mouthSquash_jnt_orig'
    mouthSquashSKN = 'mouthSquash_SKN'
    mouthGlobal = 'mouthGlobal_ctrl_orig'
    foreheadGrp = 'forehead_grp'
    headSKN = 'head_SKN'
    jawctrl = 'jaw_ctrl'
    jawJntOrig = 'jaw_jnt_orig'
    jawShapeGrp = 'jaw_SHAPE_grp'
    jawMidSkin = 'jaw_02_SKN'
    noseGrp = 'nose_grp'
    noseUp = 'nose_up_ctrl'
    noseUpOrig = 'nose_up_ctr_orig'
    neckTrash = 'neck_grpTRASH'
    earGrp = 'ear_grp'
    eyeGrp = 'eye_grp'
    eyeMaskGrp = 'eyeMask_ctrl_orig'

    sides = ['L', 'R', 'C']
    lipFlapOrig = 'lipFlap_ctrl_01_orig'
    lipflapAll = 'lipFlap_all_ctrl'
    lipflapTip = 'lipFlap_tip_ctrl'
    lipflapCup = 'lipFlap_cup_ctrl'
    lipFlapList = [lipflapAll, lipflapTip, lipflapCup]

    #try :

    #reparent halfSkulls
    mc.parent(eyeMaskOrig, UpHeadOrig, LowerHeadOrig, headSKN)
    #reparent jawClenches
    mc.parent(JawClenchLOrig, JawClenchROrig, jawctrl)
    #reparent foreHead into topSKull
    mc.parent(foreheadGrp, UpHeadCtrl)
    #reparent mouthSquash et nose into lowerSkull
    mc.parent(noseGrp, mouthSquashOrig, LowerHeadCtrl)
    #deparent halfSkulls guides
    mc.parent(UpHeadGuide, LowerHeadGuide, facialDrv)
    # reparent jawChin in MidHJaw
    mc.parent(jawChinOrig, jawMidSkin)

    #change midSkulls ctrlShapes
    shapes.create(UpHeadCtrl,
                  shape='circleHalf',
                  size=2,
                  scale=[1.25, 1, 1.75],
                  axis='y',
                  twist=-90,
                  offset=[0, 0, 0.5],
                  color=[255, 255, 0],
                  colorDegradeTo=None,
                  replace=True,
                  middle=False)
    shapes.create(LowerHeadCtrl,
                  shape='circleHalf',
                  size=2,
                  scale=[1.25, 1, 1.75],
                  axis='y',
                  twist=90,
                  offset=[0, 0, -0.5],
                  color=[255, 255, 0],
                  colorDegradeTo=False,
                  replace=True,
                  middle=False)

    # --- add upjaw ctrl
    ## create jawUp and jawUp proxies
    mc.select(cl=True)
    upJaw = mc.joint(n='upJaw_ctrl')
    mc.setAttr('{}.radius'.format(upJaw), 0.01)
    mc.select(cl=True)
    upJawLoHeadProxy = mc.joint(n='upJaw_loHead_proxy')
    mc.setAttr('{}.radius'.format(upJawLoHeadProxy), 0.01)
    mc.select(cl=True)
    upJawMSquashProxy = mc.joint(n='upJaw_mSquash_proxy')
    mc.setAttr('{}.radius'.format(upJawMSquashProxy), 0.01)

    jawpPos = mc.xform(jawctrl, q=True, ws=True, t=True)
    mc.xform(upJaw, ws=True, t=jawpPos)
    mc.xform(upJawLoHeadProxy, ws=True, t=jawpPos)
    mc.xform(upJawMSquashProxy, ws=True, t=jawpPos)
    jawPosOrigs = orig.orig(
        objlist=[upJaw, upJawLoHeadProxy, upJawMSquashProxy],
        suffix=['_orig'],
        origtype='joint',
        fromsel=False,
        viz=False,
        get_ssc=False,
        rtyp='auto')

    ## reparent nodes in jawUp nodes
    mc.parent(eyeGrp, eyeMaskGrp, UpHeadOrig, upJaw)
    mc.parent(noseGrp, upJawLoHeadProxy)
    mSquashSKNChilds = mc.listRelatives(mouthSquashSKN, c=True)
    for child in mSquashSKNChilds:
        if not (child == jawJntOrig or child == jawShapeGrp):
            print child
            mc.parent(child, upJawMSquashProxy)
    ## reparent jawUp nodes
    mc.parent(jawPosOrigs[0], headSKN)
    mc.parent(jawPosOrigs[1], LowerHeadCtrl)
    mc.parent(jawPosOrigs[2], mouthSquashSKN)
    ## connectJawUps
    smartConnect(upJaw, upJawLoHeadProxy)
    smartConnect(upJaw, upJawMSquashProxy)
    # --- add shape to UpJaw
    shapes.create(upJaw,
                  shape='pinSphere',
                  size=0.75,
                  scale=[1, 1, 1],
                  axis='y',
                  twist=0,
                  offset=[0, .75, 0],
                  color=[1, 1, 0],
                  colorDegradeTo=None,
                  replace=True,
                  middle=False)
    # --- change mouthGlobal parentConstraint targets
    mouthGlobalCns = mc.listConnections('{}.translateX'.format(mouthGlobal),
                                        s=True)[0]
    mc.delete(mouthGlobalCns)
    mc.parentConstraint(upJaw, jawctrl, mouthGlobal, mo=True)
    # --- add upJaw to skinSet
    mc.sets(upJaw, add='head_jnt_skin_set')

    # --- reparent and adjust Shapes for flaps ctrls
    mainColList = [[0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0]]
    secColList = [[0.5, 0.5, 1.0], [1.0, 0.5, 0.5], [1.0, 1.0, 0.65]]
    sizeList = [0.07, 0.07, 0.04]

    for s, side in enumerate(sides):
        ## --- reparent dKey ctrls to world
        allCtrl = '%s_%s' % (side, lipflapAll)
        tipCtrl = '%s_%s' % (side, lipflapTip)

        allCtrlOrig = mc.listRelatives('%s_%s' % (side, lipflapAll), p=True)[0]
        mc.parent(allCtrlOrig, w=True)

        if side == 'L':
            shapes.create(allCtrl,
                          shape='pyramid',
                          size=sizeList[s],
                          scale=[1.5, -1.5, 1.5],
                          axis='y',
                          twist=0,
                          offset=[0, -0.5, 0],
                          color=mainColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
            shapes.create(tipCtrl,
                          shape='arrowFourCurve',
                          size=sizeList[s],
                          scale=[0.8, -0.8, 0.8],
                          axis='y',
                          twist=0,
                          offset=[0, -0.28, 0],
                          color=secColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)

        elif side == 'R':
            shapes.create(allCtrl,
                          shape='pyramid',
                          size=sizeList[s],
                          scale=[1.5, 1.5, 1.5],
                          axis='y',
                          twist=0,
                          offset=[0, 0.5, 0],
                          color=mainColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
            shapes.create(tipCtrl,
                          shape='arrowFourCurve',
                          size=sizeList[s],
                          scale=[0.8, 0.8, 0.8],
                          axis='y',
                          twist=0,
                          offset=[0, 0.28, 0],
                          color=secColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)

        elif side == 'C':
            shapes.create(allCtrl,
                          shape='pyramid',
                          size=sizeList[s],
                          scale=[1.5, -1.5, 1.5],
                          axis='y',
                          twist=0,
                          offset=[0, -0.2, 0],
                          color=mainColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)
            shapes.create(tipCtrl,
                          shape='arrowFourCurve',
                          size=sizeList[s],
                          scale=[0.8, -0.8, 0.8],
                          axis='y',
                          twist=0,
                          offset=[0, -0.12, 0],
                          color=secColList[s],
                          colorDegradeTo=None,
                          replace=True,
                          middle=False)

    # add hierarchy for drivenKeys on lipFlaps fk joints
    dKeyAllNodesList = []
    dKeyTipNodesList = []
    for side in sides:
        sideDKeyNodesList = []
        firstOrig = '%s_%s' % (side, lipFlapOrig)
        flapRoot = orig.orig(objlist=[firstOrig],
                             suffix=['_root'],
                             origtype='joint',
                             fromsel=False,
                             viz=False,
                             get_ssc=False,
                             rtyp='auto')[0]
        allChilds = mc.listRelatives(flapRoot,
                                     c=True,
                                     typ='transform',
                                     ad=True)
        allChilds.reverse()
        for child in allChilds:
            stripName = child.rsplit('_', 1)[-1]
            if not stripName == 'orig' and not stripName == 'end':
                dkeyNode = orig.orig(objlist=[child],
                                     suffix=['_dKeyAll'],
                                     origtype='joint',
                                     fromsel=False,
                                     viz=False,
                                     get_ssc=False,
                                     rtyp='auto')[0]
                sideDKeyNodesList.append(dkeyNode)
        dKeyAllNodesList.append(sideDKeyNodesList)

    for list in dKeyAllNodesList:
        sideDKeyNodesList = []
        listLen = len(list)
        for i in range((listLen / 2), listLen):
            ctrl = mc.listRelatives(list[i], c=True, typ='transform')[0]
            dkeyNode = orig.orig(objlist=[ctrl],
                                 suffix=['_dKeyTip'],
                                 origtype='joint',
                                 fromsel=False,
                                 viz=False,
                                 get_ssc=False,
                                 rtyp='auto')[0]
            sideDKeyNodesList.append(dkeyNode)
        dKeyTipNodesList.append(sideDKeyNodesList)
    # change controls shapes on lipFlaps FKs
    attrName = 'showLipFlapsFK'
    for s, side in enumerate(sides):
        mainFlapCtrl = '%s_%s' % (side, lipflapAll)
        mc.addAttr(mainFlapCtrl, ln=attrName, at='bool')
        mc.setAttr('%s.%s' % (mainFlapCtrl, attrName), edit=True, k=True)

        flapRoot = '%s_%s_root' % (side, lipFlapOrig)
        allChilds = mc.listRelatives(flapRoot,
                                     c=True,
                                     typ='transform',
                                     ad=True)
        allChilds.reverse()
        for child in allChilds:
            stripName = child.rsplit('_', 1)[-1]
            if not stripName == 'orig' and not stripName == 'end' and not stripName == 'dKeyAll' and not stripName == 'dKeyTip':
                if not side == 'R':
                    shapes.create(child,
                                  shape='pinPyramid',
                                  size=sizeList[s],
                                  scale=[4, 5, 5],
                                  axis='-X',
                                  twist=0,
                                  offset=[0, 0, 0],
                                  color=mainColList[s],
                                  colorDegradeTo=None,
                                  replace=True,
                                  middle=False)
                else:
                    shapes.create(child,
                                  shape='pinPyramid',
                                  size=sizeList[s],
                                  scale=[-4, 5, 5],
                                  axis='-X',
                                  twist=0,
                                  offset=[0, 0, 0],
                                  color=mainColList[s],
                                  colorDegradeTo=None,
                                  replace=True,
                                  middle=False)

            childShapes = mc.listRelatives(child, s=True)
            if childShapes:
                for childShape in childShapes:
                    mc.connectAttr('%s.%s' % (mainFlapCtrl, attrName),
                                   '%s.visibility' % childShape)

    # scale R side -1 to get propper symmetrical behavior
    for each in (lipFlapList[0], lipFlapList[1]):
        if each == 'lipFlap_cup_ctrl':
            mc.setAttr('%s_%s.jointOrientY' % (sides[1], each), 180)
        else:
            mc.setAttr('%s_%s_orig.scale' % (sides[1], each), -1, -1, -1)

    for side in sides[1]:
        root = '%s_%s_root' % (side, lipFlapOrig)
        allChilds = mc.listRelatives(root, c=True, typ='transform', ad=True)
        allChilds.reverse()
        for child in allChilds:
            stripName = child.rsplit('_', 1)[-1]
            if stripName == 'orig' or stripName == 'dKeyAll' or stripName == 'dKeyTip':
                mc.setAttr('%s.scale' % child, -1, -1, -1)

    #reparent all flaps inside mouthSquash
    for side in sides:
        mc.parent('%s_%s_root' % (side, lipFlapOrig),
                  '%s_%s_orig' % (side, lipflapAll), mouthSquashSKN)
        mc.parent('%s_%s_orig' % (side, lipflapCup), mouthSquashSKN)

    # --- create smart_flaps joints
    smartFlapsGrp = mc.group(n='flaps_smart_grp', em=True)
    mc.parent(smartFlapsGrp, 'facial_fGrp')
    mc.setAttr('%s.inheritsTransform' % smartFlapsGrp, False)
    mc.select(cl=True)
    smartFlapsHoldJnt = mc.joint(n='flaps_smart_hold_jnt')
    mc.parent(smartFlapsHoldJnt, smartFlapsGrp)

    smartTrgt = [
        '%s_%s_root' % (sides[0], lipFlapOrig),
        '%s_%s_root' % (sides[1], lipFlapOrig),
        '%s_%s_root' % (sides[2], lipFlapOrig)
    ]
    smartDupTargets = []
    for each in smartTrgt:
        newTrgt = mc.duplicate(each, n='%s_smart' % each)[0]
        smartDupTargets.append(newTrgt)
    mc.parent(smartDupTargets, smartFlapsGrp)

    # --- add dkNode on top of nose_upCtrl
    noseUpDkey = mc.group(n='{}_dKey'.format(noseUp), em=True)
    mc.parent(noseUpDkey, mouthSquashSKN)
    mc.setAttr('{}.translate'.format(noseUpDkey), 0, 0, 0)
    mc.parent(noseUpDkey, noseGrp)
    mc.parent(noseUpOrig, noseUpDkey)

    # --- goes into the hierarchy of duplicated Fks and counts the depth of the hierarchy. stops when arrived at end of hierarchy
    for i, each in enumerate(smartDupTargets):
        nexChild = ''
        stopLoop = False
        for j in range(0, 30):
            if j == 0:
                nexChild = each
            getChild = mc.listRelatives(nexChild, c=True, f=True)
            if getChild:
                for child in getChild:
                    if mc.objectType(child) == 'nurbsCurve':
                        mc.delete(child)

                    else:
                        if mc.objectType(child) == 'joint':
                            splittedName1 = child.rsplit('|')[-1]
                            checkEnd = splittedName1.rsplit('_', 1)[-1]

                            newName = mc.rename(child,
                                                '%s_smart' % splittedName1)
                            smartConnect(splittedName1, newName)

                            if not checkEnd == 'end':
                                nexChild = newName
                            else:
                                stopLoop = True
            if stopLoop == True:
                break

    # --- add dkNode on top of C_lipFlap_dKey
    CNoseSideDKeyAll = orig.orig(objlist=['C_lipFlap_ctrl_01_dKeyAll'],
                                 suffix=['_side'],
                                 origtype='transform',
                                 fromsel=False,
                                 viz=False,
                                 get_ssc=False,
                                 rtyp='auto')[0]
    CNoseSideDKeyAllSmart = orig.orig(
        objlist=['C_lipFlap_ctrl_01_dKeyAll_smart'],
        suffix=['_side'],
        origtype='transform',
        fromsel=False,
        viz=False,
        get_ssc=False,
        rtyp='auto')[0]
    smartConnect(CNoseSideDKeyAll, CNoseSideDKeyAllSmart)

    #save lists in tempNode
    tempSaveGrp = mc.group(n='tempSaveGrp', em=True)
    mc.hide(tempSaveGrp)
    mc.addAttr(tempSaveGrp, ln='dKeyAllNodesList', dt='string')
    mc.addAttr(tempSaveGrp, ln='dKeyTipNodesList', dt='string')
    mc.setAttr('%s.dKeyAllNodesList' % tempSaveGrp,
               dKeyAllNodesList,
               type='string')
    mc.setAttr('%s.dKeyTipNodesList' % tempSaveGrp,
               dKeyTipNodesList,
               type='string')

    # --- do teeth generate
    teethGen.generateTeeth()
Exemple #15
0
def patch():

    pelvName = 'pelvis'
    clavName = 'clavicle'
    armRootOff = 'arm_root_offset'
    legRootOffName = 'leg_root_offset'
    armIK = 'arm_IK'
    legIK = 'leg_IK'
    armFK = 'arm'
    legFK = 'leg'
    footFK = 'foot'
    wristFK = 'wrist'
    root = 'root'
    rootGimbal = 'root_gimbal'
    head = 'head'
    headGimbal = 'head_gimbal'
    ikFKSwitchTgt = 'arm_ik_tgt'
    neckIKTipAdjust = 'neck_ik_tip_adjust'
    headRotProxyOrig = 'headRotProxy_orig'
    headProxyRot = 'headRotProxy'
    ribCage2 = 'ribCage_bend_ctrl_02'

    palmCtrlName = 'hand_palm_ctrl'
    middleCtrlName = 'middle_01'

    sides = ['L', 'R']

    ###Fix Axises and rotate Orders############################################################

    #reorient translate R clavicle
    rClavRelatives = patchLib.getRelatives(sides[1], clavName, 1)
    mc.parent(rClavRelatives[3], w=True)
    mc.setAttr('%s.scale' % rClavRelatives[1], -1, -1, -1)
    mc.parent(rClavRelatives[3], rClavRelatives[2])
    #reorient R arm root offset
    rArmRootOfftRelatives = patchLib.getRelatives(sides[1], armRootOff, '')
    mc.parent(rArmRootOfftRelatives[3], w=True)
    mc.setAttr('%s.scale' % rArmRootOfftRelatives[1], -1, -1, -1)
    mc.setAttr('%s.jointOrientX' % rArmRootOfftRelatives[1], 0)
    mc.parent(rArmRootOfftRelatives[3], rArmRootOfftRelatives[2])
    #reorient R ik Hand
    rArmIKRelatives = patchLib.getRelatives(sides[1], armIK, '')
    for rel in rArmIKRelatives[3]:
        patchLib.locksSwitch(rel,
                             T=True,
                             R=True,
                             S=True,
                             V=False,
                             lockdo='unlock',
                             keydo=False)
    mc.parent(rArmIKRelatives[3], w=True)
    mc.setAttr('%s.jointOrientX' % rArmIKRelatives[0], 90)
    mc.setAttr('%s.jointOrientY' % rArmIKRelatives[0], -90)
    mc.parent(rArmIKRelatives[3], rArmIKRelatives[2])
    for rel in rArmIKRelatives[3]:
        patchLib.locksSwitch(rel,
                             T=True,
                             R=True,
                             S=True,
                             V=False,
                             lockdo='lock',
                             keydo=False)
    ##reorient IKFK switch target
    mc.setAttr('%s_%s.rotate' % (sides[1], ikFKSwitchTgt), l=False)
    mc.setAttr('%s_%s.rotateY' % (sides[1], ikFKSwitchTgt), -180)
    mc.setAttr('%s_%s.rotate' % (sides[1], ikFKSwitchTgt), l=True)

    #reorient et hide Attr legs root offset
    llegRootOffRelatives = patchLib.getRelatives(sides[0], legRootOffName, '')
    mc.parent(llegRootOffRelatives[3], w=True)
    mc.setAttr('%s.rotateX' % llegRootOffRelatives[1], 0)
    mc.parent(llegRootOffRelatives[3], llegRootOffRelatives[2])

    rlegRootOffRelatives = patchLib.getRelatives(sides[1], legRootOffName, '')
    RLegProxyScaleGrp = '%s_%s_scaleProxy' % (sides[1], legRootOffName)
    mc.group(n=RLegProxyScaleGrp, em=True)
    mc.parent(RLegProxyScaleGrp, rlegRootOffRelatives[0], r=True)
    mc.parent(rlegRootOffRelatives[3], RLegProxyScaleGrp)
    mc.parent(RLegProxyScaleGrp, w=True)
    mc.setAttr('%s.scale' % rlegRootOffRelatives[1], -1, -1, -1)
    mc.parent(RLegProxyScaleGrp, rlegRootOffRelatives[2])

    mc.setAttr('L_leg_root_offset_ctrl.scaleX', k=False, l=True)
    mc.setAttr('L_leg_root_offset_ctrl.scaleY', k=False, l=True)
    mc.setAttr('L_leg_root_offset_ctrl.scaleZ', k=False, l=True)
    mc.setAttr('R_leg_root_offset_ctrl.scaleX', k=False, l=True)
    mc.setAttr('R_leg_root_offset_ctrl.scaleY', k=False, l=True)
    mc.setAttr('R_leg_root_offset_ctrl.scaleZ', k=False, l=True)

    #connects feets rotateOrder to feets_SKN rotateORders
    for side in sides:
        for i in range(1, 3):
            mc.connectAttr('%s_%s_%02d.rotateOrder' % (side, footFK, i),
                           '%s_%s_%02d_SKN.rotateOrder' % (side, footFK, i),
                           f=True)
    #################################################################################################
    # --- add leg ground IK ctrls on top of actual leg Iks
    for side in sides:

        if side == 'L':
            ctrlcolor = 6
        elif side == 'R':
            ctrlcolor = 13
        mc.select(cl=True)
        newCtrl = mc.joint(n='%s_%s_ground_ctrl' % (side, legIK))
        mc.setAttr('%s.drawStyle' % newCtrl, 2)
        shapes.create(newCtrl,
                      shape='square',
                      size=2,
                      scale=[1, 1, 2],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 1],
                      color=ctrlcolor,
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
        newCtrlOrig = orig.orig(objlist=[newCtrl],
                                suffix=['_orig'],
                                origtype='joint',
                                fromsel=False,
                                viz=False,
                                get_ssc=False,
                                rtyp='auto')[0]
        mc.parent(newCtrlOrig, '%s_%s_rvfoot_heel_ctrl' % (side, legFK))
        mc.setAttr('%s.translate' % newCtrlOrig, 0, 0, 0)
        mc.parent(newCtrlOrig, 'traj')
        mc.parent('%s_%s_ctrl_orig' % (side, legIK), newCtrl)
        mc.sets(newCtrl, add='%s_%s_anim_set' % (side, legFK))
        mc.sets(newCtrl, add='%s_%s_ZS_set' % (side, legFK))
        mc.connectAttr('%s_leg_SW_ctrl.fkIk' % side, '%s.visibility' % newCtrl)

    # --- fix right fuckedUp bank
    Rbank01Source = mc.listConnections(
        '%s_%s_rvfoot_bank_01_ctrl.rotateAxisZ' % (sides[1], legFK),
        p=True,
        s=True)[0]
    Rbank02Source = mc.listConnections(
        '%s_%s_rvfoot_bank_02_ctrl.rotateAxisZ' % (sides[1], legFK),
        p=True,
        s=True)[0]
    mc.connectAttr(Rbank02Source,
                   '%s_%s_rvfoot_bank_01_ctrl.rotateAxisZ' % (sides[1], legFK),
                   f=True)
    mc.connectAttr(Rbank01Source,
                   '%s_%s_rvfoot_bank_02_ctrl.rotateAxisZ' % (sides[1], legFK),
                   f=True)
    mc.keyframe((Rbank01Source.split('.', 1)[0]),
                index=(1, 1),
                absolute=True,
                valueChange=-1)
    mc.keyframe((Rbank02Source.split('.', 1)[0]),
                index=(0, 0),
                absolute=True,
                valueChange=1)

    #################################################################################################

    #reparent armTwist reader rig to avoid flips when FKarm currentSpace not in restPose
    twistTrgtList = ['twist', 'twist_aimdir']
    for side in sides:
        parentTrgt = mc.listRelatives('%s_%s_01_orig' % (side, armFK), p=True)
        for twist in twistTrgtList:
            twistname = '%s_%s_01_%s' % (side, armFK, twist)
            patchLib.locksSwitch(twistname,
                                 T=True,
                                 R=True,
                                 S=True,
                                 V=True,
                                 lockdo='unlock',
                                 keydo=False)
            mc.parent(twistname, parentTrgt)
            patchLib.locksSwitch(twistname,
                                 T=True,
                                 R=False,
                                 S=True,
                                 V=True,
                                 lockdo='lock',
                                 keydo=False)
    ##################################################################################################

    # --- readjust Palm Controls
    JOSettings = [(-180, 0, 90), (0, 0, -90)]

    for side in sides:
        palmCtrl = '%s_%s' % (side, palmCtrlName)
        palmOrig = mc.listRelatives(palmCtrl, p=True)[0]

        # get constraints from palmCtrl, its targets and the blend settings, then remove constraints
        outCns = mc.listConnections('%s.parentMatrix[0]' % palmCtrl)
        cnsTargets = []
        for cns in outCns:
            target = mc.listConnections('%s.constraintTranslateX' % cns)[0]
            blend0 = mc.getAttr('%s.target[0].targetWeight' % cns)
            blend1 = mc.getAttr('%s.target[1].targetWeight' % cns)
            cnsTargets.append((target, (blend0, blend1)))
            mc.delete(cns)

        # realigns the palm ctrl orig
        palmOrigParent = mc.listRelatives(palmOrig, p=True)[0]
        mc.parent(palmOrig, w=True)
        mc.setAttr('%s.jointOrient' % palmOrig, JOSettings[0][0],
                   JOSettings[0][1], JOSettings[0][2])

        alignPos = mc.xform('%s_%s' % (side, middleCtrlName),
                            q=True,
                            t=True,
                            ws=True)
        mc.setAttr('%s.translateY' % palmOrig, alignPos[1])
        mc.setAttr('%s.translateZ' % palmOrig, alignPos[2])
        mc.parent(palmOrig, palmOrigParent)

        #reconstraint Targets to palmCtrl
        for each in cnsTargets:
            target = each[0]
            blends = each[1]
            newCns = mc.parentConstraint(palmOrig, palmCtrl, target,
                                         mo=True)[0]

            blend0 = mc.listConnections('%s.target[0].targetWeight' % newCns,
                                        p=True)[0]
            blend1 = mc.listConnections('%s.target[1].targetWeight' % newCns,
                                        p=True)[0]
            mc.setAttr(blend0, blends[0])
            mc.setAttr(blend1, blends[1])

    #neckTwist#######################################
    attrName = 'neckTwistFollow'
    neckFollowMdl = '%s_mdl' % attrName

    mc.group(n=headRotProxyOrig, em=True)
    mc.group(n=headProxyRot, em=True)
    mc.parent(headProxyRot, headRotProxyOrig)
    mc.parent(headRotProxyOrig, '%s_orig' % neckIKTipAdjust, r=True)
    getRO = mc.getAttr('%s.jointOrient' % neckIKTipAdjust)[0]
    mc.setAttr('%s.rotateAxis' % headRotProxyOrig, getRO[0], getRO[1],
               getRO[2])
    mc.setAttr('%s.rotateOrder' % neckIKTipAdjust, 2)
    mc.setAttr('%s.rotateOrder' % headProxyRot, 2)
    mc.orientConstraint('head_gimbal_ctrl', headProxyRot, mo=True)
    # --- adds blendattribute for neckTwist on head
    mc.addAttr('%s_ctrl' % head, ln=attrName, at='double', min=0, max=1, dv=1)
    mc.setAttr('%s_ctrl.%s' % (head, attrName), edit=True, k=True)
    mc.createNode('multDoubleLinear', n=neckFollowMdl)
    mc.connectAttr('%s.rotateY' % headProxyRot,
                   '%s.input1' % neckFollowMdl,
                   f=True)
    mc.connectAttr('%s_ctrl.%s' % (head, attrName),
                   '%s.input2' % neckFollowMdl,
                   f=True)

    mc.connectAttr('%s.output' % neckFollowMdl, '%s.rotateY' % neckIKTipAdjust)
    #neckTwist#######################################

    #reparent last neck deform#######################
    lastNeckDeform = mc.ls('neck_ctrl_deform_*_orig')[-1]
    mc.parent(lastNeckDeform, neckIKTipAdjust)

    # ---  add head_hook for later facial parenting
    headHook = 'head_hook'
    mc.group(n=headHook, em=True)
    mc.parent(headHook, '%s_ctrl' % headGimbal, r=True)

    # --- add breathCtrl
    breathingCtrl = 'breathing_ctrl'
    mc.select(cl=True)
    mc.joint(n=breathingCtrl)
    shapes.create(breathingCtrl,
                  shape='arrowTwo',
                  size=0.5,
                  scale=[1, 1, 1],
                  axis='z',
                  twist=0,
                  offset=[0, 0, 0],
                  color=[1, 0.5, 0.3],
                  colorDegradeTo=None,
                  replace=True,
                  middle=False)
    mc.setAttr('%s.drawStyle' % breathingCtrl, 2)
    breathingOrig = orig.orig(objlist=[breathingCtrl],
                              suffix=['_orig'],
                              origtype='joint',
                              fromsel=False,
                              viz=False,
                              get_ssc=False,
                              rtyp='auto')[0]
    mc.parent(breathingOrig, ribCage2, r=True)
    mc.setAttr('%s.jointOrient' % breathingOrig, 0, 0, 0)
    mc.setAttr('%s.translate' % breathingOrig, 0, 0, 1)
    mc.sets(breathingCtrl, add='spine_ctrl_anim_set')
    mc.sets(breathingCtrl, add='spine_ctrl_ZS_set')
    ## set locks and limits
    mc.setAttr('%s.translateX' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.translateY' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.rotateX' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.rotateY' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.rotateZ' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.scaleX' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.scaleY' % breathingCtrl, l=True, k=False)
    mc.setAttr('%s.scaleZ' % breathingCtrl, l=True, k=False)
    mc.transformLimits(breathingCtrl, etz=(True, True), tz=(-1.5, 1.5))

    # --- expose and tweak missing rotate Orders ---
    ctrlList = mc.listConnections('?_hand_fk_set.dagSetMembers')
    ctrlList.append(mc.listConnections('L_hand_anim_set.dagSetMembers')[0])
    ctrlList.append(mc.listConnections('R_hand_anim_set.dagSetMembers')[0])
    ctrlList.append('L_leg_01')
    ctrlList.append('R_leg_01')

    xyzRoList = []
    yzxRoList = []
    zxyRoList = ctrlList
    xzyRoList = [
        'head_ctrl', 'head_gimbal_ctrl', 'root_ctrl', 'root_gimbal_ctrl',
        'pelvis_ctrl', 'spine_mid_ctrl', 'spine_tip_ctrl',
        'spine_tip_adjust_ctrl', 'L_arm_IK_ctrl', 'R_arm_IK_ctrl', 'L_wrist',
        'R_wrist', 'L_wrist_offset', 'R_wrist_offset', 'L_leg_IK_ctrl',
        'R_leg_IK_ctrl', 'L_leg_IK_ground_ctrl', 'R_leg_IK_ground_ctrl',
        'L_leg_root_offset_ctrl', 'R_leg_root_offset_ctrl'
    ]
    yxzRoList = ['L_leg_02', 'R_leg_02', 'L_arm_02', 'R_arm_02']
    zyxRoList = [
        'L_foot_01', 'R_foot_01', 'L_foot_02', 'R_foot_02', 'L_arm_01',
        'R_arm_01'
    ]

    roLib.updateRotateOrder(xyz=xyzRoList,
                            yzx=yzxRoList,
                            zxy=zxyRoList,
                            xzy=xzyRoList,
                            yxz=yxzRoList,
                            zyx=zyxRoList)
Exemple #16
0
def patch():

    #vars#########################################################################################
    sides = ['L', 'R']
    intFixes = ['front', 'back']
    fullLegDuplicate = ['leg_01', 'leg_02', 'foot_01', 'foot_02']
    ##############################################################################################

    for side in sides:
        if side == 'L':
            ctrlcolor = 6
        elif side == 'R':
            ctrlcolor = 13
        #duplicates legs joints to create new fullLeg chain######################################################
        newChain = []
        for i, joint in enumerate(fullLegDuplicate):
            target = '%s_%s_%s' % (side, intFixes[1], joint)
            if mc.objExists(target):
                newjoint = mc.duplicate(target, po=True)[0]
                patchLib.locksSwitch(newjoint,
                                     T=True,
                                     R=True,
                                     S=True,
                                     V=True,
                                     lockdo='unlock',
                                     keydo=True)
                mc.parent(newjoint, w=True)
                newName = '%s_%s_fullLeg_%02d' % (side, intFixes[1], (i + 1))
                mc.rename(newjoint, newName)
                newChain.append(newName)
        if newChain:
            mc.parent(newChain[3], newChain[2])
            mc.parent(newChain[2], newChain[1])
            mc.parent(newChain[1], newChain[0])
        ##parents new fullLeg at the same place as base legs########################################################
        newParent = mc.listRelatives('%s_%s_leg_01_orig' % (side, intFixes[1]),
                                     p=True)[0]
        mc.parent(newChain[0], newParent)
        ############################################################################################################
        #creates new upvector and ik for fullLeg####################################################################
        duplicatedUpVector = mc.duplicate('%s_%s_leg_PV_ctrl' %
                                          (side, intFixes[1]))[0]
        fullLegUpV = mc.rename(duplicatedUpVector,
                               '%s_%s_fullLeg_PV_ctrl' % (side, intFixes[1]))
        shapes.create(fullLegUpV,
                      shape='pyramid',
                      size=1,
                      scale=[1, 1, 1],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 0],
                      color=ctrlcolor,
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
        fullLegUpVOrig = orig.orig(objlist=[fullLegUpV],
                                   suffix=['_orig'],
                                   origtype='transform',
                                   fromsel=False,
                                   viz=False,
                                   get_ssc=False,
                                   rtyp='auto')[0]
        mc.parent(fullLegUpVOrig, 'traj')
        ###scales newUpvector shape up ##########################################################
        scalePoints = mc.ls('%s.cv[*]' % fullLegUpV, fl=True)
        mc.scale(1.25, 1.25, 1.25, scalePoints, r=True, ocp=True)
        ##creates ik for fullLeg###################################################################################
        fullLegIkName = '%s_%s_fullLeg_ikh' % (side, intFixes[1])
        fullLegIk = mc.ikHandle(sj=newChain[0],
                                ee=newChain[3],
                                n=fullLegIkName,
                                sol='ikRPsolver')
        mc.poleVectorConstraint(fullLegUpV, fullLegIk[0])
        ##reparent log upV in FullLeg upV and replace constraint
        upVCnsName = '%s_%s_leg_PV_ctrl_orig_parentConstraint1' % (side,
                                                                   intFixes[1])
        upVCnsTarget = mc.parentConstraint(upVCnsName, q=True, tl=True)[0]
        mc.delete(upVCnsName)
        legUpVOrig = '%s_%s_leg_PV_ctrl_orig' % (side, intFixes[1])
        mc.parent(legUpVOrig, fullLegUpV)
        mc.parentConstraint(upVCnsTarget, fullLegUpVOrig, mo=True)

        ############################################################################################################

        #updating original ball 01 and 02 rigs######################################################################
        ball01 = '%s_%s_leg_rvfoot_ball_01_ctrl' % (side, intFixes[1])
        ball02Orig = '%s_%s_leg_rvfoot_ball_02_ctrl_orig' % (side, intFixes[1])
        ball02 = '%s_%s_leg_rvfoot_ball_02_ctrl' % (side, intFixes[1])
        #updating original ball_01 rig##############################################################################
        ##ads ik offset on ball01###################################################################################
        patchLib.locksSwitch(ball01,
                             T=True,
                             R=True,
                             S=True,
                             V=True,
                             lockdo='unlock',
                             keydo=True)
        ball01ik = mc.duplicate(ball01, po=True)
        ball01ikend = mc.duplicate(ball02Orig, po=True)
        ball01ikName = '%s_%s_leg_ik_rvfoot_ball_01_joint' % (side,
                                                              intFixes[1])
        ball01ikEndName = '%s_%s_leg_ik_rvfoot_ball_01_end' % (side,
                                                               intFixes[1])
        ball01ik = mc.rename(ball01ik, ball01ikName)
        ball01ikend = mc.rename(ball01ikend, ball01ikEndName)
        mc.parent(ball01ikend, ball01ik)
        mc.parent(ball01, ball01ik)
        ###creates ctrl for ball01  ik offset###########################################################################
        ballIKCtrlname = '%s_%s_leg_rvfoot_ik_ball_01_ctrl' % (side,
                                                               intFixes[1])
        mc.select(cl=True)
        ballIKCtrl = mc.joint(n=ballIKCtrlname)
        mc.setAttr('%s.drawStyle' % ballIKCtrl, 2)
        ballIKCtrlOrig = orig.orig(objlist=[ballIKCtrl],
                                   suffix=['_orig'],
                                   origtype='joint',
                                   fromsel=False,
                                   viz=False,
                                   get_ssc=False,
                                   rtyp='auto')[0]
        shapes.create(ballIKCtrl,
                      shape='cube',
                      size=.25,
                      scale=[1, .5, 1],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 0],
                      color=ctrlcolor,
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
        mc.parent(ballIKCtrlOrig, ball01ikend)
        mc.setAttr('%s.translate' % ballIKCtrlOrig, 0, 0, 0)
        mc.parent(ballIKCtrlOrig, (mc.listRelatives(ball01ik, p=True)))
        ###creates ikSCsolver for ball 01 ik #####################################################################
        ball01ikhName = '%s_%s_leg_rvfoot_ik_ball_01_ikh' % (side, intFixes[1])
        ball01ikh = mc.ikHandle(sj=ball01ik,
                                ee=ball01ikend,
                                n=ball01ikhName,
                                sol='ikSCsolver')
        mc.parent(ball01ikh[0], ballIKCtrl)

        patchLib.locksSwitch(ball01,
                             T=True,
                             R=False,
                             S=True,
                             V=True,
                             lockdo='lock',
                             keydo=False)
        #updating original ball_02 rig##############################################################################
        ##remove original aim constraint############################################################################
        ball02AimCns = mc.listConnections('%s.rotateX' % ball02Orig)[0]
        mc.delete(ball02AimCns)
        ##ads ik offset on ball02###################################################################################
        ballDublicate = [
            ball02Orig,
            '%s_%s_leg_rvfoot_ball_02_ctrl' % (side, intFixes[1]),
            '%s_%s_leg_rvfoot_ankle_ctrl' % (side, intFixes[1])
        ]
        newBall = []
        for j, ballJnt in enumerate(ballDublicate):
            newJnt = mc.duplicate(ballJnt, po=True)
            newJntName = ballDublicate[j].replace('rvfoot', 'rvfoot_ik')
            newJntName = newJntName.replace('ctrl', 'jnt')
            mc.rename(newJnt, newJntName)
            newBall.append(newJntName)
        mc.parent(newBall[2], newBall[1])
        mc.parent(newBall[1], newBall[0])
        mc.parent(newBall[0], ball02Orig)
        mc.parent(ball02, newBall[1])
        ###creates ikSCsolver for ball ik offset#####################################################################
        ball02ikhName = '%s_%s_leg_rvfoot_ik_ball_02_ikh' % (side, intFixes[1])
        ball02ikh = mc.ikHandle(sj=newBall[1],
                                ee=newBall[2],
                                n=ball02ikhName,
                                sol='ikSCsolver')
        ###creates ctrl for ball ik offset###########################################################################
        ballIKCtrlname = '%s_%s_leg_rvfoot_ik_ball_02_ctrl' % (side,
                                                               intFixes[1])
        mc.select(cl=True)
        ballIKCtrl = mc.joint(n=ballIKCtrlname)
        mc.setAttr('%s.drawStyle' % ballIKCtrl, 2)
        ballIKCtrlOrig = orig.orig(objlist=[ballIKCtrl],
                                   suffix=['_orig'],
                                   origtype='joint',
                                   fromsel=False,
                                   viz=False,
                                   get_ssc=False,
                                   rtyp='auto')[0]
        if side == 'L':
            ctrlcolor = 6
        elif side == 'R':
            ctrlcolor = 13
        shapes.create(ballIKCtrl,
                      shape='locator',
                      size=1,
                      scale=[1, 1, 1],
                      axis='y',
                      twist=0,
                      offset=[0, 0, 0],
                      color=ctrlcolor,
                      colorDegradeTo=None,
                      replace=True,
                      middle=False)
        mc.parent(ballIKCtrlOrig, newBall[2], r=True)
        mc.parent(ballIKCtrlOrig, newBall[0])
        ####adjusts ctrl position####################################################################################
        mc.setAttr('%s.translateY' % ballIKCtrlOrig,
                   (mc.getAttr('%s.translateY' % ballIKCtrlOrig)) * 2)
        mc.xform(ballIKCtrlOrig, ws=True, r=True, a=True, ro=(0, 0, 0))
        if side == 'L':
            mc.setAttr('%s.jointOrientX' % ballIKCtrl,
                       180 - (mc.getAttr('%s.rotateX' % ballIKCtrlOrig)))
        if side == 'R':
            mc.setAttr('%s.jointOrientX' % ballIKCtrl,
                       -(mc.getAttr('%s.rotateX' % ballIKCtrlOrig)))
        ##parents ball 02 ikh into ctrl##############################################################################
        mc.parent(ball02ikh[0], ballIKCtrl)
        mc.setAttr('%s.translate' % ball02ikh[0], 0, 0, 0)
        ##constraints updated ball02 to fullLeg######################################################################
        mc.parentConstraint(newChain[3],
                            newBall[0],
                            st=["x", "y", "z"],
                            mo=True)
        ##connects translate of fullLegs first joint to base legs first joint#######################################
        mc.connectAttr('%s.translate' % newChain[0],
                       '%s_%s_leg_01_orig.translate' % (side, intFixes[1]),
                       f=True)
        ##parent new ikh############################################################################################
        fullLegParent = '%s_%s_leg_rvfoot_ball_01_ctrl' % (side, intFixes[1])
        mc.parent(fullLegIk[0], fullLegParent)

        ##############################################################################################################
        #temp remove front aim cns on ball_02
        mc.delete('%s_%s_leg_rvfoot_ball_02_ctrl_orig_aimConstraint1' %
                  (side, intFixes[0]))
        ##############################################################################################################
        # rough cleanup
        hideList = [
            'leg_rvfoot_ik_ball_02_ikh', 'fullLeg_ikh',
            'leg_rvfoot_ik_ball_01_ikh', 'fullLeg_01'
        ]
        for toHide in hideList:
            mc.hide('%s_%s_%s' % (side, intFixes[1], toHide))