예제 #1
0
    def setFK(self,*jnt):
        copied=[]

        for e in jnt:
            name=e.split('_')[0]+'_FK_'+e.split('_')[2]

            dup= cmds.duplicate (e,n=name,rr=True,rc=True)
            tmp=setUniqueName(dup[0],'JNT')
            par= cmds.listRelatives (tmp,p=True,typ='joint')
            chi= cmds.listRelatives (tmp,c=True,typ='joint')

            if par is not None:
                if len(copied) is not 0:
                    cmds.parent (tmp,copied[-1])
                    if cmds.connectionInfo (tmp+'.inverseScale',id=True) is False:
                        cmds.connectAttr (copied[-1]+'.scale',tmp+'.inverseScale',f=True)
            if chi is not None:
                cmds.delete (chi)

            copied.append(tmp)

        cmds.parent(copied[0],'FKJoint_GRP')
        self.FkCon=fkControllerMaker( 'octagon', 'yellow', copied )

        for s in self.FkCon[0]:
            sha= cmds.listRelatives (s,s=True,typ='nurbsCurve')
            cmds.rotate (0,0,90,sha[0]+'.cv[*]',os=1)

        nul= cmds.listRelatives (self.FkCon[0][0],p=True)
        cmds.parent (nul,'FKControl_GRP')

        return self.FkCon[0]
예제 #2
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')
예제 #3
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)
예제 #4
0
    def setIK(self,*jnt):
        buffer=[]
        copied=[]

        tmp=cmds.listRelatives (jnt[0],c=1,ad=1)
        c=jnt[0]
        buffer.append(c)

        for i in range(len(tmp)):

            if jnt[-1] in c:
                break
            else:
                c=cmds.listRelatives (c,c=True)
                buffer.append(c[0])

        #조인트 복사 및 중복된 네임 정리
        for e in buffer:
            name=e.split('_')[0]+'_IK_'+e.split('_')[2]
            dup= cmds.duplicate (e,n=name,rr=True,rc=True)

            tmp= setUniqueName(dup[0],'JNT')
            par= cmds.listRelatives (tmp,p=True,typ='joint')
            chi= cmds.listRelatives (tmp,c=True,typ='joint')

            if par is not None:
                if len(copied) is not 0:
                    cmds.parent (tmp,copied[-1])
                    if cmds.connectionInfo (tmp+'.inverseScale',id=True) is False:
                        cmds.connectAttr (copied[-1]+'.scale',tmp+'.inverseScale',f=True)
            if chi is not None:
                cmds.delete (chi)
            copied.append(tmp)

        cmds.parent(copied[0],'IKJoint_GRP')
        tmp= ikHandleMaker( copied[0], copied[-2], 'ikRPsolver' )
        hdl= cmds.rename (tmp[0],copied[-2].replace('JNT','HDL'))
        cmds.setAttr (hdl+'.v',0)
        cmds.parent (hdl,'auxillary_GRP')


        self.IkCon=ikControllerMaker( copied[-2] ,hdl)

        otherCon= fkControllerMaker( 'circle', 'yellow', [copied[-1]] )

        cmds.delete(otherCon[2])
        cmds.orientConstraint (otherCon[0],copied[-1],w=True)

        ballUp= controllerShape(otherCon[0][0].replace('_CON','RollUp_CON'),'hexagon', 'yellow' )
        ballUp_Nul= homeNul (ballUp)
        cmds.delete(cmds.pointConstraint (copied[-1],ballUp_Nul,w=True))
        cmds.rotate (90,0,0,ballUp+'.cv[*]',os=1)

        heelUp= controllerShape(self.IkCon[0][1].replace('_CON','RollUp_CON'),'hexagon', 'yellow' )
        heelUp_Nul= homeNul (heelUp)
        cmds.delete(cmds.pointConstraint (copied[-2],heelUp_Nul,offset=(0,-1,-1),w=True))
        cmds.rotate (90,0,0,heelUp+'.cv[*]',os=1)

        self.IkCon[0].append(str(otherCon[0][0]))
        self.IkCon[1].append(str(otherCon[1][0]))

        cmds.parent (self.IkCon[1][3],ballUp_Nul,heelUp_Nul,self.IkCon[0][0])

        #rolling up
        roll=addRollingUp()
        tmp=roll.rollUp(self.IkCon[0][1].replace('_CON','_LOC'),ballUp,heelUp)
        cmds.parent (tmp,'roll_GRP')

        #attach shoulder
        tmp=attachPart2(heelUp ,self.IkCon[1][3] , 'translate','rotate','scale','shear')
        cmds.parent(tmp,'attach_GRP')

        #connect stretchy
        st=stretchyLock()
        if cmds.objExists (self.IkCon[0][1].replace('_CON','_LOC')) is True:
            st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2])
        else:
            tempString= cmds.spaceLocator (n=self.IkCon[0][1].replace('_CON','_LOC'))
            cmds.parent (tempString,self.IkCon[0][1].replace('_CON','Sub_CON'))
            st.setStretchyLock(self.IkCon[0][1],self.IkCon[0][2],self.IkCon[0][1].replace('_CON','_LOC'),copied[0],copied[1],copied[2])

        n=noneFlip()
        n.setup(self.IkCon[0][1].replace('_CON','_LOC'),copied[0],self.IkCon[0][2])
        cmds.rotate (90,0,0,self.IkCon[0][3]+'.cv[*]',os=1)

        return self.IkCon[0]
예제 #5
0
파일: fkAddSpine.py 프로젝트: mappp7/tools
from baseRig.util.fkControllerMaker import *
from baseRig.util.snap import *
from baseRig.util.homeNul import *
from baseRig.util.attach import *

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')
예제 #6
0
    def createIkSpineController(self):
        rootCon = fkControllerMaker('cross', 'yellow',
                                    [self.spineJointList[0]])
        spine1Con = fkControllerMaker('cube', 'yellow',
                                      [self.spineJointList[1]])
        chestCon = fkControllerMaker('cube', 'yellow',
                                     [self.spineJointList[-1]])

        self.spineControllerList = rootCon[0][0], spine1Con[0][0], chestCon[0][
            0]
        self.spineControllerNulList = rootCon[1][0], spine1Con[1][0], chestCon[
            1][0]
        self.spineConstraintList = rootCon[2][0], spine1Con[2][0], chestCon[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')
        #print self.spineJointList[1]
        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]  ) )
        """
        #cmds.parent( hipConNul, self.spineControllerList[1] )

        # 'C_IK_hip_CON' pivot moving~~
        lowBodyPos = cmds.xform(spine1Con[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_lowBodySub_CON', 'cube',
                                             'yellow')
        self.upBodySubCon = controllerShape('C_IK_upBodySub_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, spine1Con[0][0])
        POsnap(self.upBodySubConNul, chestCon[0][0])

        cmds.parent(self.lowBodySubConNul, spine1Con[0][0])
        cmds.parent(self.upBodySubConNul, chestCon[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 = cmds.rename(self.spineControllerList[1],
                                   'C_IK_lowBody_CON')
        self.upBody = cmds.rename(self.spineControllerList[2],
                                  'C_IK_upBody_CON')

        self.lowBodyNul = cmds.rename(self.spineControllerNulList[1],
                                      'C_IK_lowBody_NUL')
        self.upBodyNul = cmds.rename(self.spineControllerNulList[2],
                                     'C_IK_upBody_NUL')