Exemplo n.º 1
0
 def homeNull(self):
     sel = cmds.ls(sl=True)
     for i in sel:
         if 'CON' in i:
             homeNul(i)
         else:
             homeNul(i, i + '_NUL')
Exemplo n.º 2
0
def fkAddNeckOP():
    
    fkSpineJointList = [ 'C_FK_neck1_NUL', 'C_FK_neck2_NUL', 'C_FK_neck3_NUL', 'C_FK_head_NUL' ]
    
    fkControllerMaker( 'circle', 'yellow', fkSpineJointList[1:3] )
    
    homeNul( 'C_IK_head_CON', 'C_IK_head_extra_NUL' )
    
    cmds.parentConstraint( 'C_IK_neck1Sub_CON', fkSpineJointList[0], mo=True )
    
    attachNode( 'C_FK_head_NUL', 'C_IK_head_extra_NUL', 'translate', 'rotate', 'scale', 'shear' )
    
    attachPart( 'C_IK_neck1_CON', 'C_FK_neck2_NUL', 'translate', 'rotate', 'scale', 'shear' )
    
    cmds.parent ( 'C_FK_neck1_NUL', w=1 )
Exemplo n.º 3
0
def fkAddSpineOP():

    fkSpineJointList = [
        'C_FKsub_spine1_NUL', 'C_FKsub_spine2_NUL', 'C_FKsub_spine3_NUL',
        'C_FKsub_chest_NUL'
    ]

    fkControllerMaker('circle', 'yellow', fkSpineJointList[1:3])

    homeNul('C_IK_upBody_CON', 'C_IK_upBody_fkSubAttach_NUL')

    cmds.parentConstraint('C_IK_lowBodySub_CON', fkSpineJointList[0], mo=True)

    attachNode('C_FKsub_chest_NUL', 'C_IK_upBody_fkSubAttach_NUL', 'translate',
               'rotate', 'scale', 'shear')

    attachPart('C_IK_root_CON', 'C_FKsub_spine2_NUL_NUL', 'translate',
               'rotate', 'scale', 'shear')
Exemplo n.º 4
0
    def spaceBlend(self):
        self.spaceNul = homeNul(
            self.target,
            self.target.replace(self.target.split('_')[-1], 'SPC'))
        #print self.spaceNul

        FAN = attachNode(self.firstSpaceLOC[0], self.spaceNul)
        SAN = attachNode(self.secondSpaceLOC[0], self.spaceNul)

        self.namePBD = createPairBlendNode(
            FAN[1], SAN[1], self.spaceNul,
            self.spaceNul.replace(self.spaceNul.split('_')[-1], 'PBD'),
            'rotate')
Exemplo n.º 5
0
def pivotToControllerOP(mySide):
    myColor = 'blue'
    if mySide == 'R':
        myColor = 'red'
    else:
        pass

    anklePivotName =  '%s_ankleRoll_main_PIVOT' % mySide
    pivotList = [ '%s_hindLeg_inSideRoll_PIVOT'% mySide, '%s_hindLeg_outSideRoll_PIVOT'% mySide, '%s_hindLeg_heelRoll_PIVOT'% mySide, '%s_hindLeg_toeRoll_PIVOT'% mySide, '%s_hindLeg_footTwist_PIVOT'% mySide, '%s_hindLeg_ballRoll_PIVOT'% mySide, '%s_hindLeg_toeTab_PIVOT'% mySide ]
    pivotNulList = [ '%s_inSideRoll_hindLeg_NUL'% mySide ]
    # create foot controller
    ankleRollCONT = controllerShape( anklePivotName.replace( 'PIVOT', 'CON' ), 'cube', myColor )
    cvNum = cmds.getAttr( '%s.spans' % ankleRollCONT ) + cmds.getAttr( '%s.degree' % ankleRollCONT )
    cmds.select( '%s.cv[0:%s]' % ( ankleRollCONT, cvNum-1 ) )
    cmds.scale( 0.5, 0.5, 0.5 )
    cmds.select( cl=True )
    cmds.parent( '%sShape' % ankleRollCONT, anklePivotName, r=True, s=True )
    cmds.delete( ankleRollCONT )
    ankleRollCON = cmds.rename( anklePivotName, anklePivotName.replace( 'PIVOT', 'CON' ) )

    for x in range( len( pivotList ) ):
        CONT = controllerShape( pivotList[x].replace( 'PIVOT', 'CON' ), 'cube', myColor )
        cvNum = cmds.getAttr( '%s.spans' % CONT ) + cmds.getAttr( '%s.degree' % CONT )
        cmds.select( '%s.cv[0:%s]' % ( CONT, cvNum-1 ) )
        cmds.scale( 0.5, 0.5, 0.5 )
        cmds.select( cl=True )
        cmds.parent( '%sShape' % CONT, pivotList[x], r=True, s=True )
        cmds.delete( CONT )
        ankleRollCON = cmds.rename( pivotList[x], pivotList[x].replace( 'PIVOT', 'CON' ) )

    # make ankle controller by main ankle controller
    myParent = '%s_rig_ball_JNT' % mySide
    myMainCon = '%s_ankleRoll_main_CON' % mySide
    myMainNul = '%s_ankleRoll_main_NUL' % mySide
    
    myAimParnt = '%s_template_ankle_JNT' % mySide
    myAimUp = '%s_template_knee_JNT' % mySide
    
    myCon = controllerShape( myMainCon.replace( 'main_CON', 'CON' ), 'cube', myColor )
    myNul = homeNul( myCon )
    
    cmds.delete ( cmds.parentConstraint( myParent, myNul, mo=0 ) )
    cmds.delete ( cmds.aimConstraint ( myAimParnt, myNul, aim=( 1, 0, 0 ), u=( 0, 1, 0 ), wut='object', wuo=myAimUp ) )
    
    cmds.parentConstraint( myParent, myNul, mo=1 )
    cmds.parentConstraint( myCon, myMainNul, mo=1 )
	
    cmds.parent ( '%s_IK_ankle_SC_HDL' % mySide, myCon )
Exemplo n.º 6
0
def R_ikHindLegOP():

    DR = cmds.duplicate( 'L_hindFootLocatorTemplate_GRP', renameChildren=True )
    cmds.scale( -1, 1, 1, DR[0] )
    for x in range(len(DR)):
        uniqueName = cmds.rename( DR[x], DR[x].replace( 'L_', 'R_' )[0:-1] )

    hindLegIkJointList = [ 'R_IK_hip_JNT', 'R_IK_knee_JNT', 'R_IK_ankle_JNT', 'R_IK_ball_JNT', 'R_IK_toe_JNT', 'R_IK_toeTip_JNT' ]
    
    footTemplateLocLict = [ 'R_hindLeg_inSideRollTemple', 'R_hindLeg_outSideRollTemple', 'R_hindLeg_heelRollTemple', 'R_hindLeg_toeRollTemple', 'R_hindLeg_footTwistTemple', 'R_hindLeg_ballRollTemple', 'R_hindLeg_toeTabTemple' ]
    
    # separate duplicate for ikSpringSolver
    sSJointList = []
    dList = cmds.duplicate( hindLegIkJointList[0], renameChildren=True )
    for x in range( len( dList ) ):
        rN = cmds.rename( dList[x], dList[x].replace( 'IK', 'rig' )[0:-1] )
        sSJointList.append(rN)
    cmds.delete( sSJointList[4] )
    del sSJointList[4:]
        
    # create IK
    RPs = ikHandleMaker( hindLegIkJointList[0], hindLegIkJointList[2], 'ikRPsolver' )
    RPsName = cmds.rename( RPs[0], hindLegIkJointList[0].replace( 'JNT', 'RP_HDL' ) )
    RPsEffectorName = cmds.rename( RPs[1], hindLegIkJointList[0].replace( 'JNT', 'RP_IKEFFECTOR' ) )
    
    SCs1 = ikHandleMaker( hindLegIkJointList[2], hindLegIkJointList[3], 'ikSCsolver' )
    SCs1Name = cmds.rename( RPs[0], hindLegIkJointList[2].replace( 'JNT', 'SC_HDL' ) )
    SCs1EffectorName = cmds.rename( RPs[1], hindLegIkJointList[2].replace( 'JNT', 'SC_IKEFFECTOR' ) )
    
    SCs2 = ikHandleMaker( hindLegIkJointList[3], hindLegIkJointList[4], 'ikSCsolver' )
    SCs2Name = cmds.rename( RPs[0], hindLegIkJointList[3].replace( 'JNT', 'SC_HDL' ) )
    SCs2EffectorName = cmds.rename( RPs[1], hindLegIkJointList[3].replace( 'JNT', 'SC_IKEFFECTOR' ) )
    
    SCs3 = ikHandleMaker( hindLegIkJointList[4], hindLegIkJointList[5], 'ikSCsolver' )
    SCs3Name = cmds.rename( RPs[0], hindLegIkJointList[4].replace( 'JNT', 'SC_HDL' ) )
    SCs3EffectorName = cmds.rename( RPs[1], hindLegIkJointList[4].replace( 'JNT', 'SC_IKEFFECTOR' ) )
    
    mel.eval( 'ikSpringSolver;' )
    Ss = cmds.ikHandle ( sj=sSJointList[0], ee=sSJointList[3], sol='ikSpringSolver' )
    SsName = cmds.rename( RPs[0], sSJointList[0].replace( 'JNT', 'SS_HDL' ) )
    SsEffectorName = cmds.rename( RPs[1], sSJointList[0].replace( 'JNT', 'SS_IKEFFECTOR' ) )
    
    ####################################################################################################################################
    
    IST = footTemplateLocLict[0]
    OST = footTemplateLocLict[1]
    HRT = footTemplateLocLict[2]
    TRT = footTemplateLocLict[3]

    FTT = footTemplateLocLict[4]

    BRT = footTemplateLocLict[5]

    TTT = cmds.spaceLocator( n=footTemplateLocLict[6] )
    pSnap( TTT[0], hindLegIkJointList[-2] )

    ####################################################################################################################################
    
    # create pivot positon
    pivotList = []
    pivotNulList = []
    
    for x in range( len( footTemplateLocLict ) ):
        PL = cmds.group( em=True, n=footTemplateLocLict[x].replace( 'Temple', '_PIVOT' ) )
        pSnap( PL, footTemplateLocLict[x] )
        
        pivotList.append(PL)
        
    for x in range( len( pivotList ) - 1 ):
        cmds.parent( pivotList[x+1], pivotList[x] )
        
    for x in range( len( pivotList ) ):
        PH = homeNul( pivotList[x] )
        pivotNulList.append(PH)
        

    
    cmds.parent( SCs2Name, pivotList[5] )
    cmds.parent( SCs3Name, pivotList[-1] )
    
    anklePivotName = cmds.group( em=True, n='R_ankleRoll_main_PIVOT' )
    anklePos = cmds.xform( hindLegIkJointList[3], t=True, ws=True, q=True )
    cmds.move( anklePos[0], anklePos[1], anklePos[2], anklePivotName )
    cmds.parent( anklePivotName, sSJointList[2] )
    
    homeNul( anklePivotName )
    
    # create controller
    haindLegControllerName = controllerShape( hindLegIkJointList[3].replace( 'ball_JNT', 'hindLeg_CON' ), 'cube', 'blue' )
    cmds.move( anklePos[0], anklePos[1], anklePos[2], haindLegControllerName )
    
    hipContollerName = controllerShape( hindLegIkJointList[0].replace( 'JNT', 'CON' ), 'cube', 'blue' )
    hipPos = cmds.xform( hindLegIkJointList[0], t=True, ws=True, q=True )
    cmds.move( hipPos[0], hipPos[1], hipPos[2], hipContollerName )
    
    kneePVContollerName = controllerShape( hindLegIkJointList[1].replace( 'JNT', 'CON' ), 'sphere', 'blue' )
    kneePVPos = cmds.xform( hindLegIkJointList[1], t=True, ws=True, q=True )
    cmds.move( kneePVPos[0], kneePVPos[1], kneePVPos[2], kneePVContollerName )
    
    # controller homeNull
    homeNul( haindLegControllerName )
    homeNul( hipContollerName )
    homeNul( kneePVContollerName )
    
    # constraints & grouping
    cmds.parent( pivotNulList[0], haindLegControllerName )
    
    cmds.pointConstraint( hipContollerName, hindLegIkJointList[0] )
    cmds.pointConstraint( hipContollerName, sSJointList[0] )
    
    cmds.poleVectorConstraint( kneePVContollerName, SsName )
    cmds.poleVectorConstraint( sSJointList[1], RPsName )
    
    cmds.parent( SsName, pivotList[5] )
    
    cmds.parent( RPsName, anklePivotName )

    # add Attr 
    cmds.addAttr( haindLegControllerName, longName='foot', at='enum', en='Controls', keyable=True )
    cmds.setAttr( '%s.foot' % haindLegControllerName, lock=True )
    
    cmds.addAttr( haindLegControllerName, longName='leg', at='enum', en='Angle', keyable=True )
    cmds.setAttr( '%s.leg' % haindLegControllerName, lock=True )
    cmds.addAttr( haindLegControllerName, longName='angle', at='double', keyable=True, attributeType='float', min=-10, max=10, dv=0 )
    
    SAB0 = cmds.createNode( 'setRange', n=haindLegControllerName.replace( '_CON', 'SAB0_RNG' ) )
    SAB1 = cmds.createNode( 'setRange', n=haindLegControllerName.replace( '_CON', 'SAB1_RNG' ) )
    
    cmds.setAttr( '%s.minX' % SAB0, 0 )
    cmds.setAttr( '%s.maxX' % SAB0, 1 )
    cmds.setAttr( '%s.oldMinX' % SAB0, -10 )
    cmds.setAttr( '%s.oldMaxX' % SAB0, 10 )
    
    cmds.setAttr( '%s.minX' % SAB1, 1 )
    cmds.setAttr( '%s.maxX' % SAB1, 0 )
    cmds.setAttr( '%s.oldMinX' % SAB1, -10 )
    cmds.setAttr( '%s.oldMaxX' % SAB1, 10 )
    
    cmds.connectAttr( '%s.angle' % haindLegControllerName, '%s.valueX' % SAB0 )
    cmds.connectAttr( '%s.outValue.outValueX' % SAB0, '%s.springAngleBias[0].springAngleBias_FloatValue' % SsName )
    
    cmds.connectAttr( '%s.angle' % haindLegControllerName, '%s.valueX' % SAB1 )
    cmds.connectAttr( '%s.outValue.outValueX' % SAB1, '%s.springAngleBias[1].springAngleBias_FloatValue' % SsName )     
Exemplo n.º 7
0
    def createIkSpineController(self):
        #rootCon = fkControllerMaker( 'cross', 'yellow', [self.spineJointList[0]] )
        neck1Con = fkControllerMaker('cube', 'yellow',
                                     [self.spineJointList[0]])
        headCon = fkControllerMaker('cube', 'yellow',
                                    [self.spineJointList[-2]])

        #self.spineControllerList = rootCon[0][0], neck1Con[0][0], headCon[0][0]
        self.spineControllerNulList = neck1Con[1][0], headCon[1][0]
        self.spineConstraintList = neck1Con[2][0], headCon[2][0]

        cmds.delete(self.spineConstraintList)
        """
        for each in range( len(self.spineControllerNulList)-1 ):
            cmds.delete( cmds.aimConstraint( self.spineJointList[each+1], self.spineControllerNulList[each], aimVector=[0,1,0], upVector=[0,0,-1], worldUpType='vector', worldUpVector=[0,1,0]  ) )
        cmds.delete( cmds.aimConstraint( self.spineJointList[-2], self.spineControllerNulList[-1], aimVector=[0,-1,0], upVector=[0,0,-1], worldUpType='vector', worldUpVector=[0,1,0]  ) )
        """
        #self.hipCon = controllerShape( 'C_IK_hip_CON', 'cube', 'yellow' )

        #POsnap( self.hipCon, self.spineJointList[0] )
        #hipConNul = homeNul( self.hipCon )
        """
        cmds.delete( cmds.aimConstraint( self.spineJointList[2], hipConNul, aimVector=[0,1,0], upVector=[0,0,-1], worldUpType='vector', worldUpVector=[0,1,0]  ) )
        """

        # 'C_IK_hip_CON' pivot moving~~
        """
        lowBodyPos = cmds.xform( neck1Con[0], ws=True, t=True, q=True )
        cmds.move( lowBodyPos[0], lowBodyPos[1], lowBodyPos[2], '%s.rotatePivot' % self.hipCon )
        cmds.move( lowBodyPos[0], lowBodyPos[1], lowBodyPos[2], '%s.rotatePivot' % hipConNul )
        
        hipConCvN = cmds.getAttr( '%s.spans' % self.hipCon )
        cmds.select( '%s.cv[0:%s]' % ( self.hipCon, hipConCvN ) )
        cmds.scale( 0.8, 0.8, 0.8, ocp=True )
        cmds.select( cl=True )
        """
        # Add Sub Controller
        print self.spineControllerNulList
        self.lowBodySubCon = controllerShape('C_IK_neck1Sub_CON', 'cube',
                                             'yellow')
        self.upBodySubCon = controllerShape('C_IK_headSub_CON', 'cube',
                                            'yellow')

        lowBodySubConCvN = cmds.getAttr('%s.spans' % self.lowBodySubCon)
        cmds.select('%s.cv[0:%s]' % (self.lowBodySubCon, lowBodySubConCvN))
        cmds.scale(0.8, 0.8, 0.8, ocp=True)
        cmds.select(cl=True)
        upBodySubConCvN = cmds.getAttr('%s.spans' % self.upBodySubCon)
        cmds.select('%s.cv[0:%s]' % (self.upBodySubCon, upBodySubConCvN))
        cmds.scale(0.8, 0.8, 0.8, ocp=True)
        cmds.select(cl=True)

        self.lowBodySubConNul = homeNul(self.lowBodySubCon)
        self.upBodySubConNul = homeNul(self.upBodySubCon)

        POsnap(self.lowBodySubConNul, neck1Con[0][0])
        POsnap(self.upBodySubConNul, headCon[0][0])

        cmds.parent(self.lowBodySubConNul, neck1Con[0][0])
        cmds.parent(self.upBodySubConNul, headCon[0][0])

        #cmds.parent( hipConNul, self.lowBodySubCon )

        #........................................................................................
        #print self.spineControllerList#(u'C_IK_root_CON', u'C_IK_spine1_CON', u'C_IK_chest_CON')
        self.lowBody = 'C_IK_neck1_CON'
        self.upBody = 'C_IK_head_CON'

        self.lowBodyNul = 'C_IK_neck1_NUL'
        self.upBodyNul = 'C_IK_head_NUL'
Exemplo n.º 8
0
    def createIkSpineSet(self):
        IKH = ikHandleMaker(self.spineJointList[0], self.spineJointList[-2],
                            'ikSplineSolver')
        print IKH
        IKH = [u'ikHandle1', u'effector1', u'curve1']
        handleName = cmds.rename(IKH[0], 'C_IK_neck_HDL')
        effectorName = cmds.rename(IKH[1], 'C_IK_neck_EFFECTOR')
        curveName = cmds.rename(IKH[2], 'C_IK_neck_CRV')

        cmds.rebuildCurve(curveName, s=2, d=3)

        locatorName = curveToLocatorFix(curveName)
        print locatorName
        #cmds.parent( curveName, w=True )

        for x in range(len(locatorName)):
            NUL = homeNul(locatorName[x])
            self.locatorNulList.append(NUL)

        # Advanced Twist Controls Set
        upLoc = cmds.spaceLocator(n=self.upBody.replace('CON', 'aTwist_LOC'))
        cmds.delete(cmds.parentConstraint(self.spineJointList[-2], upLoc))
        cmds.parent(upLoc, self.upBodySubCon)
        #[u'C_IK_root_JNT', u'C_IK_spine1_JNT', u'C_IK_spine2_JNT', u'C_IK_spine3_JNT', u'C_IK_chest_JNT']
        lowLoc = cmds.spaceLocator(n=self.lowBody.replace('CON', 'aTwist_LOC'))
        cmds.delete(cmds.parentConstraint(self.spineJointList[0], lowLoc))
        cmds.parent(lowLoc, self.lowBodySubCon)

        cmds.setAttr('%s.dTwistControlEnable' % handleName, 1)
        cmds.setAttr('%s.dWorldUpType' % handleName, 4)
        cmds.setAttr('%s.dWorldUpAxis' % handleName, 0)

        cmds.setAttr('%s.dWorldUpVectorX' % handleName, 0)
        cmds.setAttr('%s.dWorldUpVectorY' % handleName, 1)
        cmds.setAttr('%s.dWorldUpVectorZ' % handleName, 0)
        cmds.setAttr('%s.dWorldUpVectorEndX' % handleName, 0)
        cmds.setAttr('%s.dWorldUpVectorEndY' % handleName, 1)
        cmds.setAttr('%s.dWorldUpVectorEndZ' % handleName, 0)

        cmds.connectAttr('%s.worldMatrix' % lowLoc[0],
                         '%s.dWorldUpMatrix' % handleName)
        cmds.connectAttr('%s.worldMatrix' % upLoc[0],
                         '%s.dWorldUpMatrixEnd' % handleName)

        #
        cmds.orientConstraint(self.upBodySubCon,
                              self.spineJointList[-1],
                              mo=True)

        #print self.locatorNulList[u'C_IK_spine1_NUL', u'C_IK_spine2_NUL', u'C_IK_spine3_NUL', u'C_IK_spine4_NUL']
        AP_low0 = attachPart(self.lowBodySubCon, self.locatorNulList[0],
                             'translate', 'rotate', 'scale', 'shear')
        AP_low1 = attachPart(self.lowBodySubCon, self.locatorNulList[1],
                             'translate', 'rotate', 'scale', 'shear')

        AP_up4 = attachPart(self.upBodySubCon, self.locatorNulList[3],
                            'translate', 'rotate', 'scale', 'shear')
        AP_up5 = attachPart(self.upBodySubCon, self.locatorNulList[4],
                            'translate', 'rotate', 'scale', 'shear')

        #cmds.parentConstraint( self.hipCon, self.spineJointList[0], mo=True )
        """
        #......
        AP_lowBoy = attachPart( self.spineControllerList[0], self.lowBodyNul, 'translate', 'rotate', 'scale', 'shear' )
        AP_upBoy = attachPart( self.spineControllerList[0], self.upBodyNul, 'translate', 'rotate', 'scale', 'shear' )
        """
        #...
        #noneScaleSpineGroup = cmds.group( handleName, curveName, self.locatorNulList[0], self.locatorNulList[1], self.locatorNulList[2], self.locatorNulList[3],
        #                                                         self.locatorNulList[4], self.locatorNulList[5], name='noneScaleSpine_GRP' )
        """ 
        cmds.parent( noneScaleSpineGroup, 'noneScale_GRP' )
        
        cmds.parent( self.spineJointList[0], 'C_IK_spineJoint_GRP' )
        
        cmds.parent( self.spineControllerNulList[0], 'C_move_CON' )
        
        cmds.parent( self.lowBodyNul, 'C_IK_spineController_GRP' )
        cmds.parent( self.upBodyNul, 'C_IK_spineController_GRP' )
        
        cmds.parent( AP_low0, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_low1, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_low2, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_up3, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_up4, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_up5, 'C_IK_spineAttach_GRP' )
        
        cmds.parent( AP_lowBoy, 'C_IK_spineAttach_GRP' )
        cmds.parent( AP_upBoy, 'C_IK_spineAttach_GRP' )
        """
        spineMiddleCon = controllerShape('C_IK_neckMiddle_CON', 'hexagon',
                                         'yellow')
        print spineMiddleCon
        #Psnap( spineMiddleCon, self.locatorNulList[2] )
        cmds.delete(
            cmds.parentConstraint(self.upBody, self.lowBody, spineMiddleCon))
        cmds.delete(cmds.orientConstraint(self.lowBody, spineMiddleCon))

        spineMiddleConNul = homeNul(spineMiddleCon)

        cmds.parentConstraint(self.upBodySubCon,
                              self.lowBodySubCon,
                              spineMiddleConNul,
                              mo=True)
        attachPart(spineMiddleCon, self.locatorNulList[2], 'translate',
                   'rotate', 'scale', 'shear')

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

        cmds.delete(cmds.parentConstraint('C_IK_head_JNT', 'C_FK_head_NUL'))
        cmds.delete(cmds.parentConstraint('C_IK_neck1_JNT', 'C_FK_neck1_NUL'))
        cmds.delete(cmds.parentConstraint('C_IK_neck3_JNT', 'C_FK_neck2_NUL'))
        cmds.delete(cmds.parentConstraint('C_IK_neck5_JNT', 'C_FK_neck3_NUL'))

        # hierarchy of neck nul
        cmds.parent('C_FK_head_NUL', 'C_FK_neck3_NUL')
        cmds.parent('C_FK_neck3_NUL', 'C_FK_neck2_NUL')
        cmds.parent('C_FK_neck2_NUL', 'C_FK_neck1_NUL')
Exemplo n.º 9
0
conNulNameList = []
fkConNameList = []
fkConNulNameList = []
for i in range(cvNum):
    pos = cmds.pointPosition('%s.cv[%s]' % (selectCurve, i))
    #print pos
    #cvPosition.append( pos )
    conName = controllerShape(side + '_IK_' + surfix + '_%s_CON' % i, 'rombus',
                              'red')
    cmds.move(pos[0], pos[1], pos[2], conName)

    nurbsBindJoint = cmds.joint(n=conName.replace('CON', 'JNT'))
    nurbsBindJointList.append(nurbsBindJoint)
    cmds.select(cl=True)

    conNulName = homeNul(conName)
    conNulNameList.append(conNulName)

    # create FK node
    fkConName = controllerShape(side + '_FK_' + surfix + '_%s_CON' % i,
                                'dubleOctagon', 'blue')

    if side == 'R':
        cmds.rotate(0, 0, 180, fkConName)

    fkConNameList.append(fkConName)
    cmds.move(pos[0], pos[1], pos[2], fkConName)

    fkConNulName = homeNul(fkConName)
    fkConNulNameList.append(fkConNulName)
# create FK node
Exemplo n.º 10
0
    def createController(self):
        # create controller
        foreLegControllerName = controllerShape(
            self.IkForeLegJointList[4].replace('foot1_JNT', 'foreLeg_CON'),
            'cube', 'blue')
        cmds.move(self.wristPos[0], self.wristPos[1], self.wristPos[2],
                  foreLegControllerName)

        clavicleControllerName = controllerShape(
            self.IkForeLegJointList[0].replace('JNT', 'CON'), 'cube', 'blue')
        shoulderPos = cmds.xform(self.IkForeLegJointList[0],
                                 t=True,
                                 ws=True,
                                 q=True)
        shoulderRot = cmds.xform(self.IkForeLegJointList[0],
                                 ro=True,
                                 ws=True,
                                 q=True)
        cmds.move(shoulderPos[0], shoulderPos[1], shoulderPos[2],
                  clavicleControllerName)
        cmds.rotate(shoulderRot[0], shoulderRot[1], shoulderRot[2],
                    clavicleControllerName)

        clavicleWorldControllerName = controllerShape(
            self.IkForeLegJointList[0].replace('JNT', 'world_CON'), 'cube',
            'blue')
        cmds.move(shoulderPos[0], shoulderPos[1], shoulderPos[2],
                  clavicleWorldControllerName)

        elbowPVContollerName = controllerShape(
            self.IkForeLegJointList[2].replace('JNT', 'CON'), 'sphere', 'blue')
        elbowPVPos = cmds.xform(self.IkForeLegJointList[2],
                                t=True,
                                ws=True,
                                q=True)
        cmds.move(elbowPVPos[0], elbowPVPos[1], elbowPVPos[2],
                  elbowPVContollerName)

        # controller homeNull
        homeNul(foreLegControllerName)
        shoulderContollerNul = homeNul(clavicleControllerName)
        elbowPVContollerNameNul = homeNul(elbowPVContollerName)
        cmds.select(elbowPVContollerNameNul)
        cmds.move(-1, r=True, z=True)

        clavicleWorldControllerNul = homeNul(clavicleWorldControllerName)

        # constraints & grouping
        cmds.parent(self.pivotNulList[0], foreLegControllerName)
        cmds.parent(shoulderContollerNul, clavicleWorldControllerName)

        # add attr
        cmds.addAttr(foreLegControllerName,
                     longName='foot',
                     at='enum',
                     en='Controls',
                     keyable=True)
        cmds.setAttr('%s.foot' % foreLegControllerName, lock=True)

        #########################################################################################################################
        # create clavicleControllerRotZNul
        clavicleControllerRotZNul = homeNul(
            clavicleControllerName,
            clavicleControllerName.replace('_CON', 'RotZ_NUL'))

        # create clavicle
        cmds.aimConstraint(foreLegControllerName,
                           clavicleControllerRotZNul,
                           mo=True,
                           aimVector=[-1, 0, 0],
                           upVector=[0, 1, 0],
                           worldUpType='none',
                           skip=['x', 'y'])  #-aimVector -1 0 0 -upVector 0 1 0

        cmds.setKeyframe('%s.rz' % clavicleControllerRotZNul)
        cmds.disconnectAttr('pairBlend1_inRotateZ1.output',
                            'pairBlend1.inRotateZ1')
        cmds.delete('pairBlend1_inRotateZ1')

        cmds.rename('pairBlend1', 'L_clvicleRotZ_PBD')

        # add attr autoClavicle
        cmds.addAttr(foreLegControllerName,
                     longName='auto',
                     at='enum',
                     en='Shoulder',
                     keyable=True)
        cmds.setAttr('%s.auto' % foreLegControllerName, lock=True)
        cmds.addAttr(foreLegControllerName,
                     longName='front',
                     at='double',
                     keyable=True,
                     attributeType='float',
                     min=0,
                     max=1,
                     dv=0.5)

        # connection
        cmds.connectAttr('%s.front' % foreLegControllerName,
                         '%s.blendAim1' % clavicleControllerRotZNul)

        # parentConstraint
        cmds.parentConstraint(clavicleControllerName,
                              self.IkForeLegJointList[0],
                              mo=True)
        cmds.parentConstraint(clavicleControllerName,
                              self.subIkJointList[0],
                              mo=True)

        # create foot controller
        wristRollCONT = controllerShape(
            self.wristPivotName.replace('PIVOT', 'CON'), 'cube', 'blue')
        cvNum = cmds.getAttr('%s.spans' % wristRollCONT) + cmds.getAttr(
            '%s.degree' % wristRollCONT)
        cmds.select('%s.cv[0:%s]' % (wristRollCONT, cvNum - 1))
        cmds.select(cl=True)
        cmds.parent('%sShape' % wristRollCONT,
                    self.wristPivotName,
                    r=True,
                    s=True)
        cmds.delete(wristRollCONT)
        wristRollCON = cmds.rename(self.wristPivotName,
                                   self.wristPivotName.replace('PIVOT', 'CON'))

        for x in range(len(self.pivotList)):
            CONT = controllerShape(self.pivotList[x].replace('PIVOT', 'CON'),
                                   'cube', 'yellow')
            cvNum = cmds.getAttr('%s.spans' % CONT) + cmds.getAttr(
                '%s.degree' % CONT)
            cmds.select('%s.cv[0:%s]' % (CONT, cvNum - 1))
            cmds.scale(0.5, 0.5, 0.5)
            cmds.select(cl=True)
            cmds.parent('%sShape' % CONT, self.pivotList[x], r=True, s=True)
            cmds.delete(CONT)
            wristRollCON = cmds.rename(
                self.pivotList[x], self.pivotList[x].replace('PIVOT', 'CON'))

        # create spaceLocator
        shoulderLOC = cmds.spaceLocator(
            n=self.subIkJointList[1].replace('JNT', 'PV_LOC'))
        shoulderLocatorNUL = homeNul(shoulderLOC[0])
        Psnap(shoulderLocatorNUL, self.subIkJointList[1])
        cmds.setAttr('%s.translateZ' % shoulderLOC[0], -7)

        wristRollLOC = cmds.spaceLocator(
            n=wristRollCONT.replace('CON', 'PV_LOC'))
        wristRollLocatorNUL = homeNul(wristRollLOC[0])
        cmds.parent(wristRollLocatorNUL, wristRollCONT)
        Psnap(wristRollLocatorNUL, wristRollCONT)
        cmds.setAttr('%s.translateZ' % wristRollLOC[0], -1)

        # pole Vector Constrain
        cmds.poleVectorConstraint(shoulderLOC, self.G_RPName)
        cmds.poleVectorConstraint(elbowPVContollerName, self.RPsName)
        cmds.poleVectorConstraint(wristRollLOC, self.RP1Name)

        #
        cmds.parentConstraint(self.subIkJointList[-2],
                              self.wristPivotNameNul,
                              mo=True)

        cmds.setKeyframe('%s.rx' % self.wristPivotNameNul)
        cmds.setKeyframe('%s.ry' % self.wristPivotNameNul)
        cmds.setKeyframe('%s.rz' % self.wristPivotNameNul)

        cmds.disconnectAttr('pairBlend1_inRotateX1.output',
                            'pairBlend1.inRotateX1')
        cmds.disconnectAttr('pairBlend1_inRotateY1.output',
                            'pairBlend1.inRotateY1')
        cmds.disconnectAttr('pairBlend1_inRotateZ1.output',
                            'pairBlend1.inRotateZ1')

        cmds.delete('pairBlend1_inRotateX1', 'pairBlend1_inRotateY1',
                    'pairBlend1_inRotateZ1')

        cmds.rename('pairBlend1', 'L_clvicleRotZ_PBD')

        #
        cmds.addAttr(wristRollCONT,
                     longName='wristRoll',
                     at='enum',
                     en='Lock',
                     keyable=True)
        cmds.setAttr('%s.wristRoll' % wristRollCONT, lock=True)
        cmds.addAttr(wristRollCONT,
                     longName='fallowRotate',
                     at='double',
                     keyable=True,
                     attributeType='float',
                     min=0,
                     max=1,
                     dv=1)

        cmds.connectAttr('%s.fallowRotate' % wristRollCONT,
                         '%s.blendParent1' % self.wristPivotNameNul)

        #cmds.connectAttr( '%s.vis' % haindLegControllerName, '%s.visibility' % self.pivotNulList[0] )

        cmds.select(cl=True)
Exemplo n.º 11
0
    def createReverseFoot(self):
        # create foot temple
        pivotPos = cmds.xform(self.IkForeLegJointList[-2],
                              t=True,
                              ws=True,
                              q=True)

        FTT = self.footTemplateLocList[4]

        BRT = cmds.spaceLocator(n=self.footTemplateLocList[5])
        POsnap(BRT[0], self.IkForeLegJointList[-2])

        TTT = cmds.spaceLocator(n=self.footTemplateLocList[6])
        POsnap(TTT[0], self.IkForeLegJointList[-2])

        # create pivot positon
        for x in range(len(self.footTemplateLocList)):
            PL = cmds.group(em=True,
                            n=self.footTemplateLocList[x].replace(
                                'Temple', '_PIVOT'))
            POsnap(PL, self.footTemplateLocList[x])

            self.pivotList.append(PL)

        for x in range(len(self.pivotList) - 1):
            cmds.parent(self.pivotList[x + 1], self.pivotList[x])

        for x in range(len(self.pivotList)):
            PH = homeNul(self.pivotList[x])

            self.pivotNulList.append(PH)

        cmds.parent(self.pivotNulList[-1], self.pivotList[4])

        cmds.delete(self.footTemplateLocList[4:7])

        # parenting handle
        cmds.parent(self.G_RPName, self.pivotList[5])

        cmds.parent(self.RP1Name, self.pivotList[5])
        cmds.parent(self.SCs2Name, self.pivotList[5])
        cmds.parent(self.SCs3Name, self.pivotList[-1])

        self.wristPivotName = cmds.group(em=True, n='R_wistRoll_PIVOT')
        self.wristPos = cmds.xform(self.IkForeLegJointList[4],
                                   t=True,
                                   ws=True,
                                   q=True)
        cmds.move(self.wristPos[0], self.wristPos[1], self.wristPos[2],
                  self.wristPivotName)
        cmds.delete(
            cmds.aimConstraint(self.subIkJointList[3],
                               self.wristPivotName,
                               aimVector=[0, 1, 0],
                               upVector=[0, 0, 1],
                               worldUpType='vector',
                               worldUpVector=[0, 1, 0]))
        #cmds.parent( self.wristPivotName, self.subIkJointList[2] )

        cmds.parent(self.RPsName, self.wristPivotName)

        self.wristPivotNameNul = homeNul(self.wristPivotName)
        print self.wristPivotNameNul