예제 #1
0
def build_mirror_dict():
    face_jnt = [attr.node() for attr in pm.ls('*.face_joint')]
    no_mid_face_jnt = []
    for jnt in face_jnt:
        pos = om.MVector(pm.joint(jnt, q=1, p=1, a=1))
        if pos.x > 0.2 or pos.x < -0.2:
            no_mid_face_jnt.append(jnt)

    face_jnt = no_mid_face_jnt

    mirror_dict = {}
    pairs = 0
    for i in range(len(face_jnt)):
        start_jnt = face_jnt[i]
        start_pos = om.MVector(pm.joint(start_jnt, q=1, p=1, a=1))
        for j in range(i + 1, len(face_jnt)):
            jnt = face_jnt[j]
            jnt_pos = om.MVector(pm.joint(jnt, q=1, p=1, a=1))
            mid = (start_pos + jnt_pos) * 0.5
            if -0.001 <= mid.x <= 0.001:
                if jnt_pos.x > 0:
                    mirror_dict[pairs] = [jnt, start_jnt]
                elif jnt_pos.x < 0:
                    mirror_dict[pairs] = [start_jnt, jnt]
                pairs += 1
                # face_jnt.remove(jnt)
                # face_jnt.remove(start_jnt)
                break

    return mirror_dict
예제 #2
0
    def test_create_heirarchy(self):
        # Test on object with parent
        jnts = []
        jnts.append(pm.joint(p=(1, 1, 1)))
        jnts.append(pm.joint(p=(2, 2, 2)))
        crv = pm.circle()[0]
        pm.delete(pm.parentConstraint(jnts[-1], crv, mo=0))
        pm.parent(crv, jnts[-1])

        grps = control.create_heirarchy('temp', crv, 5)

        count = 0
        for g in grps:
            self.assertTrue(
                transforms.assertLocationsMatch(g, crv))
            self.assertTrue(
                transforms.assertDefaultScale(g))
            if count > 0:
                self.assertTrue(
                    transforms.assertAllZero(g))
                self.assertTrue(
                    transforms.assertParentIs(g, grps[count-1]))
            count += 1

        self.assertEqual(grps[0].name(), 'temp_top_node')
        self.assertEqual(grps[-1].name(), 'temp_btm_node')
        self.assertTrue(transforms.assertParentIs(crv,
                                                  grps[-1]))
        self.assertTrue(transforms.assertParentIs(grps[0],
                                                  jnts[-1]))
        self.assertTrue(transforms.assertAllZero(crv))
        self.assertTrue(transforms.assertDefaultScale(crv))
예제 #3
0
	def cerateFeatherJoint(self , rootPoint = None , endPoint = None , name = None , num = 1 , numRoot = 1):
		'''
		@rootPoint : list , This is the rootPoint of the root joint point
		@endPoint : list , This is the endPoint of the end joint point 
		@name : str , This is the name is joint name 
		@num : int , This is the num is number
		@numRoot : int , This is the numRoot is root joint number 
		'''
		number = self.getTwoNnmber(num)
		if not len(rootPoint) is len(endPoint):
			OpenMaya.MGlobal.displayError('@rootPoint and @endPoint not even : len(rootPoint) = %s len(endPoint) = %s'%(len(rootPoint),len(endPoint)))
			return 
		frontJointName = name+'_front'+number+'_'
		backJointName = name+'_back'+number+'_'
		tupleRootPoint = [(t1[0] , t1[1] , t1[2]) for t1 in rootPoint]
		tupleEndPoint = [(t2[0] , t2[1] , t2[2]) for t2 in endPoint]
		OpenMaya.MGlobal_clearSelectionList()
		frontJoint = [pm.joint(n = frontJointName + str(i1+numRoot) , p = point1 ) for i1 , point1 in enumerate(tupleRootPoint)]
		pm.joint(frontJoint[0] , e = True , zso = 1 , oj = "xyz" , sao = "yup" , ch = True)
		pm.joint(frontJoint[-1] , e = True , zso = 1 , oj = "none" , ch = True)
		OpenMaya.MGlobal_clearSelectionList()
		backJoint = [pm.joint(n = backJointName + str(i2+numRoot) , p = point2 ) for i2 , point2 in enumerate(tupleEndPoint)]
		pm.joint(backJoint[0] , e = True , zso = 1 , oj = "xyz" , sao = "yup" , ch = True)
		pm.joint(backJoint[-1] , e = True , zso = 1 , oj = "none" , ch = True)
		OpenMaya.MGlobal_clearSelectionList()
		
		frontBackList = [frontJoint,backJoint] 
		return frontBackList			
예제 #4
0
def createIKSpline( jntList ):
    pymelLogger.debug('Starting: createIKSpline()...') 
    # Make IK Spline
    ikHandleTorso = pm.ikHandle( startJoint=jntList[0], endEffector=jntList[-1], solver = 'ikSplineSolver', numSpans = 4, name = jntList[-1]+'_'+Names.suffixes['ikhandle'])
    # we should probably rename the object created to know names ......    
    # CAREFULL // inherits Transform OFF, to avoid double transformation when grouped later on
    pm.setAttr(ikHandleTorso[2] + '.inheritsTransform', 0)
    
    # Duplicate last and first joint to use as Drivers of the spine Ik curve
    print jntList
    drvStart = pm.duplicate(jntList[0], parentOnly=True, name = Names.prefixes['driver']+'_'+ jntList[0] +'_'+Names.suffixes['start'])
    drvEnd = pm.duplicate(jntList[-1], parentOnly=True, name = Names.prefixes['driver']+'_'+ jntList[-1] +'_'+Names.suffixes['end'])
    pm.parent(drvEnd, w=1)
    
    # Make radius bigger
    pm.joint(drvStart, edit = True, radius = 1)
    pm.joint(drvEnd, edit = True, radius = 1)
    
    # Skin hip/shldr jnt's to back curve
    pm.skinCluster(drvStart,drvEnd,ikHandleTorso[2],dr=4)
    
    # return nedded elements
    rList = [ikHandleTorso, drvStart, drvEnd ]
    
    pymelLogger.debug('End: createIKSpline()...') 
    return rList
예제 #5
0
 def createJntChain(self):
     print 'creating joint chain'
     jntList = []
     crv = pm.ls(self.crv)[0]
     crv = pm.rebuildCurve(crv,rpo=1,rt=0,end=1, kr=0,kcp=0,kep=1,kt=0, s=0,d=3,tol=0)[0]
     numCvs = crv.getShape().numCVs()
     
     #jnt pos is calculated by sampling a closest point on crv in order to same length segments no matter the cv num and position
     pociNode = pm.shadingNode('pointOnCurveInfo',asUtility = 1)
     pociNode.turnOnPercentage.set(1)
     crv.getShape().worldSpace[0] >> pociNode.inputCurve
     tempLoc = pm.spaceLocator()
     pociNode.position >> tempLoc.translate
     segmentLength = 1.0 /( self.numJnt - 1)
     pm.select(cl=1)
     for i in range(self.numJnt):
         pociNode.parameter.set(i*segmentLength)
         jntPos = tempLoc.getTranslation(space='world')
         
         jnt = pm.joint(p=jntPos,name = self.name + '_vfk_jnt_' + (str(i)).zfill(2) )
         jntList.append(jnt)
 
     pm.joint(jntList[0],e=True, oj='xyz',secondaryAxisOrient='yup',ch= True,zso=True)
     jntList[-1].jointOrient.set([0,0,0])
 
     pm.delete([tempLoc,pociNode])
     
     self.jntList = jntList
예제 #6
0
 def createJntChain(self):
     print 'creating joint chain'
     jntList = []
     crv = pm.ls(self.crv)[0]
     crv = pm.rebuildCurve(crv,rpo=1,rt=0,end=1, kr=0,kcp=0,kep=1,kt=0, s=0,d=3,tol=0)[0]
     numCvs = crv.getShape().numCVs()
     
     #jnt pos is calculated by sampling a closest point on crv in order to same length segments no matter the cv num and position
     pociNode = pm.shadingNode('pointOnCurveInfo',asUtility = 1)
     pociNode.turnOnPercentage.set(1)
     crv.getShape().worldSpace[0] >> pociNode.inputCurve
     tempLoc = pm.spaceLocator()
     pociNode.position >> tempLoc.translate
     segmentLength = 1.0 /( self.numJnt - 1)
     pm.select(cl=1)
     for i in range(self.numJnt):
         pociNode.parameter.set(i*segmentLength)
         jntPos = tempLoc.getTranslation(space='world')
         
         jnt = pm.joint(p=jntPos,name = self.name + '_ik_jnt_' + (str(i)).zfill(2) )
         jntList.append(jnt)
 
     pm.joint(jntList[0],e=True, oj='xyz',secondaryAxisOrient='yup',ch= True,zso=True)
     jntList[-1].jointOrient.set([0,0,0])
 
     pm.delete([tempLoc,pociNode])
     
     self.jntList = jntList
예제 #7
0
    def buildChains(self, *args):
        """
        Build joint chains based on locator positions.
        """
        self.jointChain = []
        self.ikChain = []
        self.fkChain = []

        loc1Pos = pm.xform(self.loc1, q=True, ws=True, t=True)
        loc2Pos = pm.xform(self.loc2, q=True, ws=True, t=True)
        loc3Pos = pm.xform(self.loc3, q=True, ws=True, t=True)

        jnt1='%s_shldrJnt'%self.prefix
        jnt2='%s_elbow1Jnt'%self.prefix
        jnt3='%s_wristJnt'%self.prefix

        self.jointChain.append(pm.PyNode(pm.joint(p=loc1Pos, n=jnt1))) 
        self.jointChain.append(pm.PyNode(pm.joint(p=loc2Pos, n=jnt2)))
        self.jointChain.append(pm.PyNode(pm.joint(p=loc3Pos, n=jnt3)))

        #--- Orient the chain
        self.orientChain()

        #--- Creating duplicate ik/fk joint chains
        for each in pm.duplicate(self.jointChain, rc=True):
            # Slice off number maya adds during duplication
            each.rename('%s_ik' % each[:-1])
            self.ikChain.append(pm.PyNode(each))

        for each in pm.duplicate(self.jointChain, rc=True):
            each.rename('%s_fk' % each[:-1])
            self.fkChain.append(pm.PyNode(each))
예제 #8
0
def autoPoleVector( baseJnt=None, endJnt=None, side='L' ):

	baseJntPos = pm.xform( baseJnt, q=True, t=True, ws=True )
	endJntPos = pm.xform( endJnt, q=True, t=True, ws=True )

	pm.select(clear=True)
	poleVectorJnt_one = pm.joint( p=baseJntPos )
	poleVectorJnt_two = pm.joint( p=endJntPos )
	poleVectorIKstuff = pm.ikHandle(  sj = poleVectorJnt_one, ee = poleVectorJnt_two, solver = "ikSCsolver"  )

	pv = pm.spaceLocator()
	pv.setParent( poleVectorJnt_two )
	pv.translate.set( 0,0,0 )
	pvZeros = ZeroGrp( pv )

	pm.pointConstraint( poleVectorIKstuff[0], pvZeros[0] )

	if side=='L':
		pv.translateX.set( 1 )
	elif side=='R':
		pv.translateX.set( -1 )


	pvZeros[0].setParent( poleVectorJnt_two )

	return ( pv, poleVectorIKstuff, (poleVectorJnt_one, poleVectorJnt_two) ) 
예제 #9
0
    def buildChains(self, *args):
        """
        Build joint chains based on locator positions.
        """
        self.jointChain = []
        self.ikChain = []
        self.fkChain = []

        loc1Pos = pm.xform(self.loc1, q=True, ws=True, t=True)
        loc2Pos = pm.xform(self.loc2, q=True, ws=True, t=True)
        loc3Pos = pm.xform(self.loc3, q=True, ws=True, t=True)

        jnt1 = '%s_shldrJnt' % self.prefix
        jnt2 = '%s_elbow1Jnt' % self.prefix
        jnt3 = '%s_wristJnt' % self.prefix

        self.jointChain.append(pm.PyNode(pm.joint(p=loc1Pos, n=jnt1)))
        self.jointChain.append(pm.PyNode(pm.joint(p=loc2Pos, n=jnt2)))
        self.jointChain.append(pm.PyNode(pm.joint(p=loc3Pos, n=jnt3)))

        #--- Orient the chain
        self.orientChain()

        #--- Creating duplicate ik/fk joint chains
        for each in pm.duplicate(self.jointChain, rc=True):
            # Slice off number maya adds during duplication
            each.rename('%s_ik' % each[:-1])
            self.ikChain.append(pm.PyNode(each))

        for each in pm.duplicate(self.jointChain, rc=True):
            each.rename('%s_fk' % each[:-1])
            self.fkChain.append(pm.PyNode(each))
	def createBoundJointChain(self):
		pm.select(cl = True)
		
		
		#Iterate highResCurveCoordList and append to boundJointsList joint at each position
		self.boundJointsList = []
		
		for index in range(0, len(self.highResCurveCoordList)):
			#create Joint
			
			#decide jointNames
			jointName = self.prefix + '_bound_j_' + str(index + 1)
			if( index == 0 ): jointName = self.prefix + '_bound_j_' + 'base'
			if( index + 1 == len(self.highResCurveCoordList) ): jointName = self.prefix + '_bound_j_' + 'tip'
			
			joint = pm.joint(a = True, p= self.highResCurveCoordList[index] , co = True, n = jointName)
			self.boundJointsList.append(joint)
			
			
		pm.select(cl = True)
		
		
		#Orient boundJoints
		pm.joint(self.boundJointsList[0], e = True, sao = 'yup', oj='xyz', zso = True, ch = True)
		pm.select(cl = True)
		
		
		#Create boundJointsGrp and parent first bound joint
		self.boundJointsGrp = pm.group(n = self.prefix + '_bound_joints_grp')
		pm.select(cl = True)
		pm.parent(self.boundJointsList[0] , self.boundJointsGrp)
		pm.select(cl = True)
예제 #11
0
 def create_jnts_on_points(self, points, prefix, chain=True):
     """ Create joints over a series of points
     Args:
         points (tuple): tuple of size 3, 3d position
         prefix (str): joint name prefix
         chain (bool): whether or not to create a joint chain or free floating
     Returns [pm.nt.Joint]: list of joints created
     """
     print 'create_jnts_on_points'
     self.joints = []
     
     for index, point in enumerate(points):
         jnt_name = self.format_string.format(PREFIX = prefix,
                                              INDEX = '%03d' % (index+1),
                                              SUFFIX = 'JNT')
         jnt = pm.joint(p=point, n=jnt_name)
         self.joints.append(jnt)
         
         if len(self.joints) > 1 and chain:
             jnt.setParent(self.joints[index-1])
             pm.select(self.joints[0], r=True)
             pm.joint(e = True, ch = True, oj = 'yxz', secondaryAxisOrient = 'zup', zso = True)
             pm.select(clear = True)
         if not chain:
             jnt.setParent("")
예제 #12
0
 def fromList(self,posList = [],orientList = [],autoOrient = 1):
     
     for i in range(len(posList)):
         
         tempName = nameUtils.getUniqueName(self.side,self.baseName,self.type)
         if i == len(posList) - 1:
             tempName = nameUtils.getUniqueName(self.side,self.baseName,self.type)
             
         pm.select(cl = 1)
         
         if autoOrient == 1:
             
             tempJnt = pm.joint(n = tempName,position = posList[i])
             
         else :
             tempJnt = pm.joint(n = tempName,position = posList[i],orientation = orientList[i])
         
         self.chain.append(tempJnt)
     self.__parentJoints()
      
     if autoOrient == 1:
         #pm.joint(self.chain[0].name(),e = 1,oj = 'yzx',secondaryAxisOrient = 'zup',ch = 1)
          
         pm.joint(self.chain[0].name(),e = 1,oj = 'xyz',secondaryAxisOrient = 'zdown',ch = 1)
         #xzy -secondaryAxisOrient ydown -ch -zso;
          
     self.__zeroOrientJoint(self.chain[-1])
예제 #13
0
def autoPoleVector(baseJnt=None, endJnt=None, side='L'):

    baseJntPos = pm.xform(baseJnt, q=True, t=True, ws=True)
    endJntPos = pm.xform(endJnt, q=True, t=True, ws=True)

    pm.select(clear=True)
    poleVectorJnt_one = pm.joint(p=baseJntPos)
    poleVectorJnt_two = pm.joint(p=endJntPos)
    poleVectorIKstuff = pm.ikHandle(sj=poleVectorJnt_one,
                                    ee=poleVectorJnt_two,
                                    solver="ikSCsolver")

    pv = pm.spaceLocator()
    pv.setParent(poleVectorJnt_two)
    pv.translate.set(0, 0, 0)
    pvZeros = ZeroGrp(pv)

    pm.pointConstraint(poleVectorIKstuff[0], pvZeros[0])

    if side == 'L':
        pv.translateX.set(1)
    elif side == 'R':
        pv.translateX.set(-1)

    pvZeros[0].setParent(poleVectorJnt_two)

    return (pv, poleVectorIKstuff, (poleVectorJnt_one, poleVectorJnt_two))
예제 #14
0
    def createIkChain(self):
        print 'creating joint chains'
        ikJntList = []

        startJntVec = om.MVector(self.start[0], self.start[1], self.start[2])
        endJntVec = om.MVector(self.end[0], self.end[1], self.end[2])
        diffVec = endJntVec - startJntVec

        # calculate the witdth of the surface as a fraction of the total joint chain length
        jntChainLength = diffVec.length()
        self.width = jntChainLength * self.widthMult

        crvPoints = []

        for i in range(self.numJnt + 1):
            vec = startJntVec + diffVec * (i * 1.0 / self.numJnt)
            jntPos = [vec.x, vec.y, vec.z]

            ikJnt = pm.joint(p=jntPos, name=self.name + '_' + (str(i)).zfill(2) + '_IK')
            ikJntList.append(ikJnt)

        pm.joint(ikJntList[0], e=True, oj='xyz', secondaryAxisOrient='yup', ch=True, zso=True)
        ikJntList[-1].jointOrient.set([0, 0, 0])

        self.ikJntList = ikJntList
        pm.parent(self.ikJntList[0], self.jntGrp)
        pm.select(cl=1)
예제 #15
0
def insertJoints(childJnt, count=1):
    """
    Insert one or more joints as parents of a joint.

    Args:
        childJnt: A Joint node, the inserted joint will be a parent to this joint
    """
    result = []
    pm.select(cl=True)
    parentJnt = childJnt.getParent()
    if parentJnt is None:
        pm.warning('Cannot insert joints for a joint without a parent')
        return result
    startPosition = parentJnt.getTranslation(space='world')
    endPosition = childJnt.getTranslation(space='world')
    print(startPosition, endPosition)
    joints = [parentJnt]
    rad = parentJnt.radius.get()
    for i in range(count):
        jointPos = (endPosition - startPosition) * \
                   (float(i + 1) / float(count + 1)) + startPosition
        j = pm.joint(p=jointPos)
        setJointParent(j, joints[-1])
        j.radius.set(rad)
        pm.joint(j, e=True, oj='xyz', secondaryAxisOrient='yup', zso=True)
        result.append(j)
        joints.append(j)
    setJointParent(childJnt, joints[-1])
    return result
예제 #16
0
def curve2Joints(cv, jntSize=10):
    '''create joints along a curve on every control point
    '''

    cvDup = pm.PyNode(mc.duplicate(cv)[0])
    #clean up the cvDup and setup the curve ready
    pm.delete(cvDup, ch=True)
    pm.makeIdentity(cvDup, apply=True, t=1, r=1, s=1, n=0)
    cvShape = cvDup.getShape()
    #get the position of all the CVs
    cvPosList = cvShape.getCVs()
    #get the position of one CV by index
    cv1 = cvShape.getCV(0)
    #get the number of CVs
    numCV = cvShape.numCVs()
    pm.select(d=True)
    jntList = []
    for pos in cvPosList:
        newJnt = pm.joint(p=pos, radius=jntSize)
        jntList.append(str(newJnt))

    for jnt in jntList:
        pm.joint(jnt, sao='yup', zso=1, e=1, oj='xyz')

    pm.delete(cvDup)

    return jntList
예제 #17
0
def GuideCrv(startGuider=None, endGuider=None):

    if startGuider == None or endGuider == None:
        startGuider, endGuider = pm.ls(sl=True)

    pm.select(clear=True)

    startJnt = pm.joint(n=startGuider.name() + "_guideCrvJnt")
    pm.parent(startJnt, startGuider)
    startJnt.translate.set(0, 0, 0)
    startJnt.visibility.set(0)
    pm.setAttr(startJnt.visibility, lock=True)

    endJnt = pm.joint(n=endGuider.name() + "_guideCrvJnt")
    pm.parent(endJnt, endGuider)
    endJnt.translate.set(0, 0, 0)
    endJnt.visibility.set(0)
    pm.setAttr(endJnt.visibility, lock=True)

    startJntPos = pm.xform(startJnt, q=True, ws=True, t=True)
    endJntPos = pm.xform(endJnt, q=True, ws=True, t=True)

    guideCrv = pm.curve(degree=1, p=(startJntPos, endJntPos), k=(1, 2))

    pm.rename(guideCrv, startGuider.name() + "_guideCrv")

    pm.skinCluster(guideCrv, startJnt, endJnt)

    guideCrv.inheritsTransform.set(0)
    guideCrv.template.set(1)

    pm.select(clear=True)

    return guideCrv
예제 #18
0
 def install_subMetaRig_proxy(self):
     logger.debug("Function Called ( %s )"%inspect.stack()[0][3])
     
     #retrieve components   
     prefix = self.prefix.get()
     if self.side.get():
         prefix = "%s_%s"%(self.prefix.get(), self.side.get())
     
     #build components
     proxy_gr = pm.group(empty=True, name='%s_proxy_gr' %prefix)
     proxy_1 = pm.spaceLocator(name='%s_proxy_1' %prefix)
     proxy_2 = pm.spaceLocator(name='%s_proxy_2' %prefix)
     
     joint_1 = pm.joint(name='%s_joint_1' %prefix)
     joint_2 = pm.joint(name='%s_joint_2' %prefix)
     
     pm.parent( proxy_1, proxy_2, joint_1, joint_2, proxy_gr)
     
     #store components
     joint_1.message >> self.joint_1
     joint_2.message >> self.joint_2
     proxy_1.message >> self.proxy_1
     proxy_2.message >> self.proxy_2
     proxy_gr.message >> self.proxy_gr
     
     pass
예제 #19
0
def rig_curveBetweenTwoPoints(start,end, name='curveBetween' , degree=1, colour='white', parent='allModel_GRP'):

    startPos = pm.xform( start, translation=True, query=True, ws=True)
    endPos = pm.xform( end, translation=True, query=True, ws=True)

    pm.select(cl=True)
    startJnt = pm.joint(name=name+'Start_JNT')
    pm.pointConstraint( start, startJnt )
    pm.select(cl=True)
    endJnt = pm.joint(name=name+'End_JNT')
    pm.pointConstraint( end, endJnt )

    curve = pm.curve( n=name+'_CRV', d=degree, p=(startPos, endPos), k=(0,1) )

    sc = pm.skinCluster( (startJnt, endJnt),curve , tsb=True, dr=1)

    pm.skinPercent( sc, curve.cv[0],tv=(startJnt, 1)  )
    pm.skinPercent( sc, curve.cv[1],tv=(endJnt, 1)  )

    col = name_to_rgb(colour)
    curve.overrideColorRGB.set(col[0], col[1], col[2])

    topGrp = 'puppetLinearCurves_GRP'
    if not pm.objExists(topGrp):
        topGrp = rig_transform(0, name='puppetLinearCurves', type='group',
                                    parent=parent).object

    pm.parent(curve,startJnt,endJnt, topGrp)
    pm.setAttr(curve+".inheritsTransform", 0)
    pm.setAttr(curve+".template", 1)

    pm.hide( startJnt, endJnt )

    return curve
예제 #20
0
def CreateTwistJnt(prefix, jntList, jntName, prntJnt, nxtJnt, jntRadius,
                   moveConst, Reparent):

    twistJnt = cmds.duplicate(str(prntJnt),
                              n=str(prefix) + str(jntName),
                              parentOnly=True)[0]
    pm.joint(twistJnt, e=True, rad=jntRadius)

    # move jnt between 2 jnts
    if moveConst is True:
        pm.parent(twistJnt, world=True)
        constr = pm.parentConstraint(prntJnt,
                                     nxtJnt,
                                     twistJnt,
                                     sr=["x", "y", "z"],
                                     mo=False,
                                     w=1)
        pm.delete(constr)

    # reparent jnts
    if Reparent is True:
        pm.parent(twistJnt, prntJnt)

    # add new jnt to list
    #ind = jntList.index(prntJnt)
    #jntList.insert(ind + 1, twistJnt)

    # add jnts to list
    jntList.append(twistJnt)
예제 #21
0
    def buildSkeleton(self):
        pm.undoInfo(openChunk=True)
        parentChildPairs = {}
        for blueprint in self.character.chBlueprintsList:
            pm.select(cl=1)
            jntList = []
            i = 1
            prevJnt = None
            for guide in blueprint.guides_list:
                guidePos = guide.getTranslation(space='world')
                jnt = pm.joint(n=blueprint.side + guide.name().replace(MRIGLOBALS.BPGUIDE, MRIGLOBALS.BNDJNT),
                               p=guidePos)
                if i > 1:
                    pm.joint(prevJnt, e=True, oj='xyz', secondaryAxisOrient='yup', zso=True)
                prevJnt = jnt
                jntList.append(jnt)
                i += 1

            jntList[-1].jointOrientX.set(0)
            jntList[-1].jointOrientY.set(0)
            jntList[-1].jointOrientZ.set(0)
            parentName = blueprint.parent.replace(MRIGLOBALS.BPGUIDE, MRIGLOBALS.BNDJNT)
            parentChildPairs[parentName] = jntList[0]

        for parent, child in parentChildPairs.iteritems():
            if 'trs' in parent:
                pm.parent(child, self.character.chSkeletonGrp)
            else:
                pm.parent(child, parent)
        pm.undoInfo(closeChunk=True)
예제 #22
0
def createFxJoints():
    root = None
    chest = None
    search = pm.ls('Skeleton_Root')
    if search:
        root = search[0]
    search = pm.ls('Chest')
    if search:
        chest = search[0]

    if not root or not chest:
        return "No Skeleton_Root or Chest joint in scene"

    pm.select(cl=1)
    fxroot = pm.joint(name='fx_root')
    rootPos = root.getTranslation(space='world')
    fxroot.setTranslation([rootPos[0], rootPos[1], rootPos[2] + 4])
    pm.parent(fxroot, root)

    pm.select(cl=1)
    fxchest = pm.joint(name='fx_chest')
    chestPos = chest.getTranslation(space='world')
    fxchest.setTranslation([chestPos[0], chestPos[1], chestPos[2] + 4])
    pm.parent(fxchest, chest)
    return 'Fx Joints Created'
예제 #23
0
    def create_baseJnts(self, scale, flex):
        '''create the weighting joints for the system'''
        # rename the startJoint

        if self.positionNode:
            pm.select(self.positionNode)

        self.startJnt = pm.joint()
        self.startJnt.renameNode(name=self.TipName)
        self.startJnt.addCon()
        self.twistJnt = pm.joint()
        self.twistJnt.renameNode(name=self.TipName, base='%sTwist')
        self.startJnt.getParent().setParent(world=True)

        if self.endNode:
            pm.select(self.endNode)
        else:
            pm.select(self.startJnt)
        self.endJnt = pm.joint()
        self.endJnt.renameNode(name=self.TipName, index='end')
        self.endJnt.setParent(self.startJnt)

        if not self.endNode:
            self.endJnt.translateX.set(20)

        if scale:
            pm.select(self.startJnt)
            self.scale = pm.joint()
            self.scale.renameNode(name=self.TipName, base='%sScale')

        if flex:
            pm.select(self.startJnt)
            self.flex = pm.joint()
            self.flex.renameNode(name=self.TipName, base='%sFlex')
예제 #24
0
def GuideCrv ( startGuider=None , endGuider=None ):

	if startGuider==None or endGuider==None:
		startGuider,endGuider = pm.ls(sl=True)
	
	pm.select(clear=True)
	
	startJnt = pm.joint ( n = startGuider.name()+"_guideCrvJnt")
	pm.parent (startJnt , startGuider)
	startJnt.translate.set (0,0,0)
	startJnt.visibility.set (0)
	pm.setAttr ( startJnt.visibility , lock=True  )
	
	
	endJnt = pm.joint (  n = endGuider.name()+"_guideCrvJnt" )
	pm.parent (endJnt , endGuider)
	endJnt.translate.set (0,0,0)
	endJnt.visibility.set (0)
	pm.setAttr ( endJnt.visibility , lock=True  )
	
	startJntPos = pm.xform ( startJnt , q=True , ws=True , t=True)
	endJntPos = pm.xform ( endJnt , q=True , ws=True , t=True)
	
	guideCrv = pm.curve ( degree=1 , p = (startJntPos ,endJntPos) , k=(1,2)  )
	
	pm.rename ( guideCrv , startGuider.name()+"_guideCrv")
	
	pm.skinCluster ( guideCrv , startJnt , endJnt  )
	
	guideCrv.inheritsTransform.set(0)
	guideCrv.template.set(1)
	
	pm.select(clear=True)
	
	return guideCrv
예제 #25
0
def wiggleJointChain(strPnt, endPnt, side='FL', chainPos='Upper'):
    '''
    create joint chain between two points (strPnt & endPnt). require name string of strPnt & endPnt
    '''
    strPos = pm.xform( strPnt, q=True, ws=True, translation=True )
    endPos = pm.xform( endPnt, q=True, ws=True, translation=True )
    
    if side.endswith('L'):
        sideLabel = 1
    elif side.endswith('R'):
        sideLabel = 2
        
    ikSpCrv = pm.curve( degree=2, editPoint=( strPos, endPos) )
    ikSpCrv.rename( 'wiggle_%s_%s_CRV'%(side, chainPos) )
    ikSpCrvShp = ikSpCrv.listRelatives(shapes=True)[0]
    pm.select(clear=True)
    
    jnt2pos = pm.pointOnCurve( ikSpCrv, pr=0.3333, turnOnPercentage=True)
    jnt3pos = pm.pointOnCurve( ikSpCrv, pr=0.6667, turnOnPercentage=True )
    
    jntPos = ( strPos, jnt2pos, jnt3pos, endPos )
    jntList = []
    for pnt in jntPos:
        jName = 'Wiggle_%s_%s_%02d'%(side, chainPos, jntPos.index(pnt)+1)
        newJoint = pm.joint(name=jName, p=pnt)
        newJoint.side.set(sideLabel)
        newJoint.__getattr__('type').set(18)
        newJoint.otherType.set(jName)
        jntList.append(newJoint)
        
    pm.joint( jntList[0], edit=True, orientJoint='xyz', secondaryAxisOrient='xup', children=True, zeroScaleOrient=True )
    
    ikHandle = pm.ikHandle( name='Wiggle_%s_%s_ikHandle'%(side, chainPos),
                            solver='ikSplineSolver', 
                            createCurve=False, 
                            curve=ikSpCrvShp, 
                            startJoint=jntList[0].name(), 
                            endEffector=jntList[-1].name(), 
                            rootOnCurve=False, 
                            createRootAxis=True, 
                            parentCurve=False )
    
    jntGrp = jntList[0].listRelatives(parent=True)[0]
    jntGrp.rename('Wiggle_%s_%s'%(side, chainPos))
    crvInfo = pm.createNode('curveInfo', name='crvInf_wiggle_%s_%s'%(side, chainPos))
    multDiv1 = pm.createNode('multiplyDivide', name='md_wiggle_%s_%s_01'%(side, chainPos))
    multDiv2 = pm.createNode('multiplyDivide', name='md_wiggle_%s_%s_02'%(side, chainPos))
    ikSpCrvShp.worldSpace >> crvInfo.inputCurve
    arcLgt = crvInfo.arcLength.get()
    multDiv1.input2X.set(arcLgt)
    multDiv1.operation.set(2)
    spacing = jntList[1].tx.get()
    multDiv2.input2X.set(spacing)
    multDiv1.outputX >> multDiv2.input1X
    crvInfo.arcLength >> multDiv1.input1X
    
    for jnt in jntList[1:]:
        multDiv2.outputX >> jnt.tx
    
    return ikSpCrvShp, ikSpCrv, ikHandle[0], jntGrp
예제 #26
0
	def createCurveBoundJoints(self):
		
		pm.select(cl = True)
		
		
		#curve_bound_j_base
		pm.select(cl = True)
		self.curve_bound_j_base = pm.joint(a = True, p= (0,0,0),  co = True, n = self.prefix +'_curve_bound_j_base')
		pm.select(cl = True)
		
		#group
		self.curve_bound_j_base_grp = pm.group(self.curve_bound_j_base, n = self.prefix + '_curve_bound_j_base_grp')
		pm.select(cl = True)
		
		#translate
		self.curve_bound_j_base_grp.translate.set(self.leg_locator_tip_worldCoords)
		pm.select(cl = True)
		
		
		
		#curve_bound_j_tip
		pm.select(cl = True)
		self.curve_bound_j_tip = pm.joint(a = True, p= (0,0,0),  co = True, n = self.prefix +'_curve_bound_j_tip')
		pm.select(cl = True)
		
		#group
		self.curve_bound_j_tip_grp = pm.group(self.curve_bound_j_tip, n = self.prefix + '_curve_bound_j_tip_grp')
		pm.select(cl = True)
		
		#translate
		self.curve_bound_j_tip_grp.translate.set(self.foot_locator_worldCoords)
		pm.select(cl = True)
예제 #27
0
    def build_flexi_jnts(self, follicles):
        """ 
        Args:
            None
        Returns (None)
        """
        follicle_prefix = '%s_flexiPlane_' % self.flexiPlaneNameField.getText()
        jntGRP_name = self.flexiPlaneNameField.getText() + '_flexiPlane_JNT_GRP'
        
        pm.group( em = True, name = jntGRP_name )
        
        for index,follicle in enumerate(follicles):
            jnt_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
                                                 INDEX = 'flexiPlane_jnt%03d' % (index+1),
                                                 SUFFIX = 'JNT')
            jnt_offset_name = jnt_name.replace('_JNT','Offset_GRP')
            tweek_ctrlCon_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
                                                 INDEX = 'flexiPlane_tweak%03d' % (index+1),
                                                 SUFFIX = 'CTRLCon_GRP')

            pm.joint( p = ( follicle.translateX.get(), 0, 0 ), n = jnt_name )
            pm.select(jnt_name, r=True)
            offSetGRP.add_offset_grps()
            
            pm.parent( jnt_offset_name, jntGRP_name )
            pm.select( clear = True )
            
            tweak_ctrl_con = pm.PyNode(tweek_ctrlCon_name)
            joint_offset = pm.PyNode(jnt_offset_name)
            
            pm.parentConstraint( tweek_ctrlCon_name, jnt_offset_name )
            
            pm.setAttr(jnt_name + '.rotateZ', -90)
            pm.makeIdentity( jnt_name, apply=True, translate=True, rotate=True )
예제 #28
0
def createJointsAlongCurve(crv,
                           amount=4,
                           name='C_spine##_fkJnt',
                           jointRadius=1):
    joints = []
    crv_info = '%s_pointinfo' % crv
    pm.delete(pm.ls(crv_info))
    crv_info = pm.shadingNode('pointOnCurveInfo',
                              name=crv_info,
                              asUtility=True)
    pm.setAttr('%s.turnOnPercentage' % crv_info, 1)

    pm.connectAttr('%s.worldSpace[0]' % crv, '%s.inputCurve' % crv_info, f=1)
    amount = amount - 1
    for i in range(0, amount):
        pm.setAttr('%s.parameter' % crv_info, (1.00 / amount * float(i)))
        # log_debug(pm.getAttr('%s.parameter' % crv_info))
        position_on_curve = pm.getAttr('%s.position' % crv_info)

        # create joint at position
        j = pm.joint(n=name.replace('##', '%02d' % (i + 1)),
                     p=position_on_curve,
                     radius=jointRadius)
        joints.append(j)

    pm.setAttr('%s.parameter' % crv_info, 1)
    position_on_curve = pm.getAttr('%s.position' % crv_info)
    j = pm.joint(n=name.replace('##', '%02d' % (amount + 1)) + 'End',
                 p=position_on_curve,
                 radius=jointRadius)
    joints.append(j)

    pm.delete(pm.ls(crv_info))

    return joints
예제 #29
0
    def createHeadJoints(self):
        jointList = []

        # check number of spine joints to locate the helper head helpers
        self.spineHelpersList = pm.ls('M_spine*rigHelper', type='transform')

        # get head rigHelpers positions
        self.headRoot = pm.PyNode(
            self.spineHelpersList[(len(self.spineHelpersList) - 2)])
        self.headEnd = pm.PyNode(
            self.spineHelpersList[(len(self.spineHelpersList) - 1)])

        self.headRootPos = self.headRoot.getTranslation('world')
        self.headEndPos = self.headEnd.getTranslation('world')

        jointList.append(
            pm.joint(name='M_headRoot_jnt',
                     p=(self.headRootPos[0], self.headRootPos[1],
                        self.headRootPos[2])))
        jointList.append(
            pm.joint(name='M_headEnd_jnt',
                     p=(self.headEndPos[0], self.headEndPos[1],
                        self.headEndPos[2])))

        # orient Joints
        for i in range(len(jointList)):
            pm.select(jointList[i])
            pm.joint(e=True,
                     oj='yxz',
                     secondaryAxisOrient='zup',
                     ch=True,
                     zso=True)
예제 #30
0
    def selection_base(cls, *args, **kwargs):
        """
        @param *point_array : (list) Each element of the list need to be a vector value (x,y,z)
                                     and it will be unpack

        @param name        : (String)
        @param padding      : (Bool) If the joints will have padding number

        # example
        points =[[0.0, 0.0, 0.0], [-2.54, 4.68, -0.96], [2.66, 4.66, -6.16], [0.66, 8.22, -6.83]]
        test = adbJnt.Joint.selection_base()
        """

        name = kwargs.pop('name', 'joint1')
        padding = kwargs.pop('padding', False)

        jnts_array = []
        for index, sel in enumerate(pm.selected()):
            # create variable for the position of the locators
            pos = sel.getRotatePivot(space='world')
            # unparent the joints
            pm.select(cl=True)
            # create joints and position them on top of locators
            if padding:
                _joint = pm.joint(p=pos, n='{}_{}'.format(name, index + 1))
            else:
                _joint = pm.joint(p=pos, n=name)
            jnts_array.append(_joint)

        return cls(jnts_array)
 def generateFinger(self,
                    _rootLoc,
                    _endLoc,
                    _fingerName,
                    _handedness,
                    _numMidJoints=2):
     fingerChain = []
     delta = _rootLoc.t.get()
     local = _rootLoc.localPosition.get()
     root = pm.joint(p=delta + local,
                     n='bind_' + _handedness + '_' + _fingerName + '_root')
     pm.parent(root, w=1)
     fingerChain.append(root)
     delta = _endLoc.t.get()
     local = _endLoc.localPosition.get()
     end = pm.joint(p=delta + local,
                    n='bind_' + _handedness + '_' + _fingerName + '_end')
     pm.parent(end, w=1)
     fingerAim = pm.datatypes.Vector(end.getTranslation() -
                                     root.getTranslation())
     fingerAim.normalize()
     fingerLength = self.distanceBetween(root.getTranslation(),
                                         end.getTranslation())
     positions = []
     p1 = fingerLength * 0.5
     positions.append(p1)
     p2 = fingerLength * 0.75
     positions.append(p2)
     names = ['mid', 'tip']
     i = 0
     while i < _numMidJoints:
         trans = root.getTranslation() + (fingerAim * (positions[i]))
         newJt = pm.joint(p=trans,
                          n='bind_' + _handedness + '_' + _fingerName +
                          '_' + names[i])
         pm.parent(newJt, w=1)
         fingerChain.append(newJt)
         i += 1
     fingerChain.append(end)
     i = 0
     while i < len(fingerChain):
         if i < len(fingerChain) - 1:
             # TODO: work out why the reorienting shit doesn't work in the
             # aimAt method
             fingerChain[i].jointOrient.set([0, 0, 0])
             self.aimAt(fingerChain[i], fingerChain[i + 1])
             rotVal = fingerChain[i].rotate.get()
             fingerChain[i].jointOrient.set(rotVal)
             fingerChain[i].r.set([0, 0, 0])
         else:
             fingerChain[i].jointOrient.set([0, 0, 0])
         i = i + 1
     j = 0
     while j < len(fingerChain):
         if j < len(fingerChain) - 1:
             pm.parent(fingerChain[j + 1], fingerChain[j])
         j = j + 1
     fingerChain[-1].jointOrient.set([0, 0, 0])
     return fingerChain
예제 #32
0
    def FKIK_create_joints_from_guides(self, *args):
        '''
        Using guides generated from the FKIK_create_guides (stored in self.guide_list),
        create base joint chains which form the FK/IK joint system.
            @Attribute(s):
                self.slave_JNT_list
                self.FK_JNT_list
                self.IK_JNT_list
        '''
        
        # Get relevent transformation information
        guide_trans = self.query_translation(self.guide_list)
        guide_orient = self.FKIK_query_orient(self.guide_list)

        # Create joints in place absolute to the world
        pm.select(clear=True)
        slave_shoulder = pm.joint(position=guide_trans[0], absolute=True)
        pm.select(clear=True)
        slave_elbow = pm.joint(position=guide_trans[1], absolute=True)
        pm.select(clear=True)
        slave_wrist = pm.joint(position=guide_trans[2], absolute=True)
        
        # Set individual orientation to avoid issues with joint orientation later.
        slave_shoulder.setOrientation(guide_orient[0].asQuaternion())
        slave_elbow.setOrientation(guide_orient[1].asQuaternion())
        slave_wrist.setOrientation(guide_orient[2].asQuaternion())
        
        # Establish parentage
        slave_wrist.setParent(slave_elbow)
        slave_elbow.setParent(slave_shoulder)
        
        # Duplicate for the driver chains
        FK_shoulder = pm.duplicate(slave_shoulder)[0]
        FK_elbow = FK_shoulder.getChildren()[0]
        FK_wrist = FK_elbow.getChildren()[0]
        
        IK_shoulder= pm.duplicate(slave_shoulder)[0]
        IK_elbow = IK_shoulder.getChildren()[0]
        IK_wrist = IK_elbow.getChildren()[0]
        
        # Rename everything
        slave_shoulder.rename(self.JNT_prefix_dict['slave']+self.JNT_name_list[0])
        slave_elbow.rename(self.JNT_prefix_dict['slave']+self.JNT_name_list[1])
        slave_wrist.rename(self.JNT_prefix_dict['slave']+self.JNT_name_list[2])
        
        FK_shoulder.rename(self.JNT_prefix_dict['FK']+self.JNT_name_list[0])
        FK_elbow.rename(self.JNT_prefix_dict['FK']+self.JNT_name_list[1])
        FK_wrist.rename(self.JNT_prefix_dict['FK']+self.JNT_name_list[2])
        
        IK_shoulder.rename(self.JNT_prefix_dict['IK']+self.JNT_name_list[0])
        IK_elbow.rename(self.JNT_prefix_dict['IK']+self.JNT_name_list[1])
        IK_wrist.rename(self.JNT_prefix_dict['IK']+self.JNT_name_list[2])
    
        self.slave_JNT_list = [slave_shoulder, slave_elbow, slave_wrist]
        self.FK_JNT_list = [FK_shoulder, FK_elbow, FK_wrist]
        self.IK_JNT_list = [IK_shoulder, IK_elbow, IK_wrist]
        
        # Run internal functions
        self.FKIK_connect_arms()
예제 #33
0
    def genereateAnim(self, reopen=True):
        # export_path,_ = self.getFilename()
        Scene = self.preExport()
        FBXAnim = os.path.join(Scene.dirname(), "FBXAnim")
        os.mkdir(FBXAnim) if not os.path.exists(FBXAnim) else None
        export_path = os.path.join(FBXAnim, "%s.FBX" % Scene.namebase)
        export_path = export_path.replace('\\', '/')

        # NOTE 导入所有的 reference
        [ref.importContents(True) for ref in pm.listReferences()]

        mesh_list = pm.ls("MODEL", ni=1, dag=1, type="mesh")
        # # NOTE 删除非变形器历史
        # pm.bakePartialHistory( mesh_list,prePostDeformers=True )
        jnt_list = self.getJntList(mesh_list)

        pm.select(cl=1)
        root = pm.joint(n="root")

        jnt_parent = self.getRelParent(jnt_list, root)

        anim_parent = {}
        for jnt in jnt_list:
            pm.select(cl=1)
            anim_jnt = pm.joint(n="%s_bind" % jnt)
            pm.parentConstraint(jnt, anim_jnt, mo=0)
            pm.scaleConstraint(jnt, anim_jnt, mo=0)
            parent = jnt_parent[jnt]
            anim_parent[
                anim_jnt] = "%s_bind" % parent if parent != root else root

        jnt_transform = {}
        for anim_jnt, parent in anim_parent.items():
            anim_jnt.setParent(parent)
            # NOTE 删除骨骼缩放修正组
            transform = anim_jnt.getParent()
            if transform != parent:
                pm.ungroup(transform)

        # NOTE bake 关键帧
        start_time = pm.playbackOptions(q=1, min=1)
        end_time = pm.playbackOptions(q=1, max=1)
        pm.bakeResults(anim_parent.keys(),
                       simulation=1,
                       t=(start_time, end_time))

        # NOTE 删除 root 骨骼下的所有约束
        pm.delete(pm.ls(root, dag=1, ni=1, type="constraint"))

        pm.select(root)

        # NOTE 导出文件
        mel.eval('FBXExport -f "' + export_path + '" -s')
        os.startfile(os.path.dirname(export_path))

        # NOTE 重新打开当前文件
        if reopen:
            pm.openFile(pm.sceneName(), f=1)
예제 #34
0
def jointChainOrient( objs=[] ): # wip
    '''
    update : 2015-04-29
    '''
    if objs:
        pm.selec(objs)
    objs = pm.ls(sl=True, o=True)
    if not objs:
        raise

    joints = pm.ls(sl=True, type='joint')
    if not joints:
        raise

    upMeshs = []
    if pm.filterExpand(sm=12):    
        upMeshs = [pm.PyNode(c) for c in pm.filterExpand(sm=12) ] # 업축으로 사용할 메쉬

    # 조인트 오리엔트 조정: 메쉬의 가장 가까운 점의 노말을 조인트의 up으로 설정
    if upMeshs:
        for jnt in joints:
            parentJnt = jnt.getParent()
            if parentJnt:
                # point에서 가장 가까운 Vertex의 Normal을 up으로 설정
                pos   = parentJnt.getTranslation( ws=True)
                vtx   = getClosestVertexOnMesh( upMeshs[0], pos )
                pos   = vtx.getPosition()
                norm  = vtx.getNormal()
                upPos = pos + norm * 1000000 # 노말 위치가 가까우면 방향이 틀어져 버림.. 그래서 큰 수를 곱함.

                upLoc = pm.spaceLocator(n='parentJnt_upLoc#')
                upLoc.t.set( upPos )

                jntOrient( [parentJnt, jnt, upLoc] )
                #pm.joint( parentJnt, edit=True, zso=True, oj='xyz', sao='yup' )
                pm.delete( upLoc )

    else:
        for jnt in joints:
            parentJnt = jnt.getParent()
            if parentJnt and parentJnt.type()=='joint':
                print jnt
                up = pm.spaceLocator()

                grandParent = parentJnt.getParent()
                if grandParent and grandParent.type()=='joint':
                    pm.delete( pm.parentConstraint( grandParent, up ) )                    
                else:
                    pm.delete( pm.parentConstraint( parentJnt, up ) )

                jntOrient( [parentJnt, jnt, up], worldUpType='objectrotation' )
                pm.refresh()
                pm.select(jnt)
                pm.delete(up)

    # 끝 조인트 오리엔트 조정
    if len(joints)>1:    
        pm.joint( joints[-1], edit=True, oj='none' )
예제 #35
0
    def splineIK_controls(self, *args):
        """ Build splineIK Controls
        Args:
            None
        Returns (None)
        """
        jnt_prefix = self.jntNameFeild.getText()
        midJnt = self.model.numCVs / 2
        
        #Create and place joints
        baseJoint = pm.joint( p = self.model.crvCVs[0].getPosition(), n = self.jntNameFeild.getText() + '_base_JNT')
        pm.select(clear = True)
        midJoint = pm.joint( p = self.model.crvCVs[midJnt].getPosition(), n = self.jntNameFeild.getText() + '_mid_JNT')
        pm.select(clear = True)
        endJoint = pm.joint( p = self.model.crvCVs[-1].getPosition(), n = self.jntNameFeild.getText() + '_end_JNT')
        pm.select(clear = True)                                              

        #Create CTRL curves
        pm.circle(c = (0, 0, 0), nr = (0, 1, 0), sw = 360, r = 1, d = 3, ut = False, tol = 3.80125e-10, s = 8, ch = False, n = self.jntNameFeild.getText() + '_base_CTRL')
        pm.select(self.jntNameFeild.getText() + '_base_CTRL', r=True)
        pm.select(self.jntNameFeild.getText() + '_base_JNT', add=True)
        nPos.set_newPosition()
        pm.select(self.jntNameFeild.getText() + '_base_CTRL', r=True)
        offSetGRP.add_offset_grps()
        conGRP.add_con_grps()
        pm.select(clear = True)
        
        pm.circle(c = (0, 0, 0), nr = (0, 1, 0), sw = 360, r = 1, d = 3, ut = False, tol = 3.80125e-10, s = 8, ch = False, n = self.jntNameFeild.getText() + '_mid_CTRL')
        pm.select(self.jntNameFeild.getText() + '_mid_CTRL', r=True)
        pm.select(self.jntNameFeild.getText() + '_mid_JNT', add=True)
        nPos.set_newPosition()
        pm.select(self.jntNameFeild.getText() + '_mid_CTRL', r=True)
        offSetGRP.add_offset_grps()
        conGRP.add_con_grps()
        pm.select(clear = True)
        
        pm.circle(c = (0, 0, 0), nr = (0, 1, 0), sw = 360, r = 1, d = 3, ut = False, tol = 3.80125e-10, s = 8, ch = False, n = self.jntNameFeild.getText() + '_end_CTRL')
        pm.select(self.jntNameFeild.getText() + '_end_CTRL', r=True)
        pm.select(self.jntNameFeild.getText() + '_end_JNT', add=True)
        nPos.set_newPosition()
        pm.select(self.jntNameFeild.getText() + '_end_CTRL', r=True)
        offSetGRP.add_offset_grps()
        conGRP.add_con_grps()
        pm.select(clear = True)
        
        #Skin jnt's to crv
        pm.select(self.jntNameFeild.getText() + '_base_JNT', r=True)
        pm.select(self.jntNameFeild.getText() + '_mid_JNT', add=True) 
        pm.select(self.jntNameFeild.getText() + '_end_JNT', add=True)       
        pm.select(self.jntNameFeild.getText() + '_CRV', add=True) 
        pm.skinCluster(n=self.jntNameFeild.getText() + '_smoothSkin', mi=3, sm=0, nw=2)

        #Constrain joints to ctrl grps
        pm.parentConstraint( self.jntNameFeild.getText() + '_base_CTRLCon_GRP', self.jntNameFeild.getText() + '_base_JNT')
        pm.parentConstraint( self.jntNameFeild.getText() + '_mid_CTRLCon_GRP', self.jntNameFeild.getText() + '_mid_JNT')
        pm.parentConstraint( self.jntNameFeild.getText() + '_end_CTRLCon_GRP', self.jntNameFeild.getText() + '_end_JNT')
        pm.select(clear = True)
예제 #36
0
def build_skinJnts_spine(startknob, endknob, amount):
    pm.select(clear=1)

    start_jnt, end_jnt = pm.joint(n='C_spine01_skinJnt'), pm.joint(n='C_spine%02d_skinJnt' % amount)

    pm.xform(start_jnt, t=pm.xform(startknob, q=1, t=1, ws=1), ws=1)
    pm.xform(end_jnt, t=pm.xform(endknob, q=1, t=1, ws=1), ws=1)

    riggUtils.splitJnt(amount, joints=[start_jnt, end_jnt])
예제 #37
0
    def transfer_deformer_weights(self, geo_source, geo_target=None, deformer_source=None, deformer_target=None,
                                  surface_association="closestPoint"):
        """
        Copies the weight map of a deformer of an object to the deformer of another object.
        :param geo_source: Source Shape
        :param geo_target: Target Shape
        :param deformer_source: Source Deformer
        :param deformer_target: Target Deformer
        :param surface_association: Surface Association. Valid values: closestPoint, rayCast, or closestComponent.
        """
        assert geo_source and deformer_source and deformer_target, \
            "select a source and target geometry and then the source and target deformers"

        previous_selection = pm.selected()

        if not geo_target:
            geo_target = geo_source

        self.progress_bar_init()
        self.progress_bar_next()

        deformer_source_weights = deformer_source.weightList[0].weights.get()

        self.progress_bar_next()
        tmp_source = pm.duplicate(geo_source)[0]
        tmp_target = pm.duplicate(geo_target)[0]
        tmp_source.v.set(True)
        tmp_target.v.set(True)

        self.progress_bar_next()
        pm.select(clear=True)
        l_jnt = list()
        l_jnt.append(pm.joint(n="jnt_tmpA_01", p=[0, 0, 0]))
        l_jnt.append(pm.joint(n="jnt_tmpA_02", p=[0, 1, 0]))
        skin_source = pm.skinCluster(l_jnt, tmp_source, nw=1)
        skin_target = pm.skinCluster(l_jnt, tmp_target, nw=1)

        self.progress_bar_next()
        skin_source.setNormalizeWeights(0)
        pm.skinPercent(skin_source, tmp_source, nrm=False, prw=100)
        skin_source.setNormalizeWeights(True)
        [pm.setAttr('{}.wl[{}].w[{}]'.format(skin_source, i, 0), value) for i, value in enumerate(deformer_source_weights)]
        [pm.setAttr('{}.wl[{}].w[{}]'.format(skin_source, i, 1), 1.0 - value) for i, value in enumerate(deformer_source_weights)]

        self.progress_bar_next()
        pm.copySkinWeights(ss=skin_source, ds=skin_target, nm=True, sa=surface_association)

        self.progress_bar_next()
        deformer_target_weights = [v for v in skin_target.getWeights(tmp_target, 0)]
        [deformer_target.weightList[0].weights[i].set(val) for i, val in enumerate(deformer_target_weights)]

        self.progress_bar_next()
        pm.delete([tmp_source, tmp_target, l_jnt])
        pm.select(previous_selection)

        self.progress_bar_next()
        self.progress_bar_ends(message="Finished successfully!")
예제 #38
0
파일: proxyskel.py 프로젝트: Mikfr83/fossil
def pointer(parent, child):
    '''
    Makes proxy joints for two TempJoints so the hierarchical relationship can be drawn.
    
    ..  todo:: I think the actual connection logic might move to BPJoint.setParent
    '''

    assert type(parent).__name__ == type(
        child).__name__ == 'BPJoint', 'Both must be TempJoints'

    if not parent.attr('children').isConnectedTo(child.attr('parent')):
        parent.attr('children') >> child.attr('parent')

    proxyRadius = _DEFAULT_PROXY_RADIUS
    try:
        proxyRadius = parent.parent.proxy.radius.get()
    except:
        pass
    grp = getProxyGroup()

    if not child.proxy:
        makeProxy(child, grp, child.radius.get() * _DEFAULT_PROXY_RADIUS)

    if not parent.proxy:
        makeProxy(parent, grp, parent.radius.get() * _DEFAULT_PROXY_RADIUS)

    # If card parentage is established, manage vis
    if parent.cardCon.node() != child.cardCon.node():
        parentCardName = simpleName(parent.cardCon.node())
        childCardName = simpleName(child.cardCon.node())

        child.proxy.setParent(grp)

        linkStart = joint(grp)
        linkStart.radius.set(parent.radius.get() * proxyRadius)
        linkEnd = joint(linkStart)
        linkEnd.radius.set(child.radius.get() * proxyRadius)

        pointConstraint(parent, linkStart)
        pointConstraint(child, linkEnd)

        pdil.math.multiply(parent.cardCon.node().v,
                           child.cardCon.node().v) >> linkStart.v

        if not child.cardCon.node().v.isConnectedTo(child.v):
            child.cardCon.node().v >> child.v

        child.v >> child.proxy.v

        _clearLink(child.proxy)
        _recordLink(child.proxy, linkStart)

        child.proxy.rename(childCardName + '_proxy')
        linkStart.rename(parentCardName + '_' + childCardName + '_link')

    else:
        child.proxy.setParent(parent.proxy)
예제 #39
0
def orient_processJoints(*args):
    jointBeingManipulated = txt_orientJointBase.getText()
    freezeTransform(jointBeingManipulated)
    pm.joint(jointBeingManipulated,
             zso=1,
             ch=1,
             e=1,
             oj='xyz',
             secondaryAxisOrient='yup')
예제 #40
0
def create_jointChain( IdName = 'joint', inputCurve = pm.selected(), orientation = 'xyz' ):
    
    # get number of CVs on InputCurve
    numberOfCvs = pm.getAttr( inputCurve[0] + '.cp',s=1 )
    
    # create joints on world space cv locations
    Jnts = []
    for i in range(0, numberOfCvs):
        pm.select( clear = True )
        currentCvPos = pm.pointPosition( inputCurve[0].cv[i], w=1 )
        Jnt = pm.joint( name = '_'.join( ['bn', IdName, str( i+1 )] ) )
        pm.xform( Jnt, t = currentCvPos )
        Jnts.append( Jnt )
        
    # create end joint
    pm.select( clear = True )
    endJntPos = 0.1 * ( pm.getAttr( Jnts[len(Jnts)-1].translate ) - pm.getAttr( Jnts[len(Jnts)-2].translate ) ) + pm.getAttr( Jnts[len(Jnts)-1].translate )
    endJnt = pm.joint( name = 'be_' + IdName, position = endJntPos, a = True )
    Jnts.append( endJnt )
    
    # set aim and orientation vectors, always yup
    aimDict = {}
    aimDict[orientation[0]] = 1
    aimDict[orientation[1]] = 0
    aimDict[orientation[2]] = 0
    aimVec = ( aimDict['x'], aimDict['y'], aimDict['z'] )

    orientDict = {}
    orientDict[orientation[0]] = 0
    orientDict[orientation[1]] = 0
    orientDict[orientation[2]] = 1
    orientVec = ( orientDict['x'], orientDict['y'], orientDict['z'] )
    
    # orient first joint
    JntAimConstrain = pm.aimConstraint( Jnts[1], Jnts[0], aimVector = aimVec, upVector = (0,1,0), worldUpType = "scene" )
    pm.delete( JntAimConstrain )
    Jnts[0].jointOrient.set( Jnts[0].rotate.get() )
    Jnts[0].rotate.set( 0,0,0 )
    
    # orient middle joints
    for i in range( 1, len( Jnts ) - 1 ):
        JntAimConstrain = pm.aimConstraint( Jnts[i+1], Jnts[i], aimVector = aimVec, upVector = orientVec, worldUpType = "objectrotation", worldUpVector = orientVec, worldUpObject = Jnts[i-1] )
        pm.delete( JntAimConstrain )
        Jnts[i].jointOrient.set( Jnts[i].rotate.get() )
        Jnts[i].rotate.set( 0,0,0 )
    
    # orient last joint
    Jnts[len( Jnts ) -1 ].jointOrient.set( Jnts[len( Jnts ) -2 ].jointOrient.get() )
    
    # parent joints
    for i in range( 1, len( Jnts ) ):
        pm.parent( Jnts[i], Jnts[i-1], absolute = True)

    pm.select( Jnts[0] )
    print('Successfully created and oriented joint-chain. Continuing...')
    return Jnts
예제 #41
0
 def testPreserveSelection(self):
     j1 = pmc.joint()
     j2 = pmc.joint()
     @preserve_selection
     def spam():
         pmc.select(j2)
         self.assertEqual(pmc.selected(), [j2])
     pmc.select(j1)
     spam()
     self.assertEqual(pmc.selected(), [j1])
예제 #42
0
 def create_joints(self, key):
     py.select(cl=True)
     if 'mouth_center' in key:
         self.joint[key] = [py.joint(n='cn_'+key+'_jnt', position=(py.xform('cn_'+key+'_L', q=True, t=True, a=True, ws=True)))]
     elif 'head' in key:
         self.joint[key] = [py.joint(n='cn_'+key+'_jnt', position=(py.xform('cn_'+key+'_L', q=True, t=True, a=True, ws=True)))]
     else:
         self.joint[key] = [py.joint(n='rt_'+key+'_jnt', position=(py.xform('rt_'+key+'_L', q=True, t=True, a=True, ws=True))),
                       py.joint(n='lf_'+key+'_jnt', position=(py.xform('lf_'+key+'_L', q=True, t=True, a=True, ws=True)))]
     py.select(cl=True)
예제 #43
0
    def build(self, *args):
        """
        Builds the joints on the curve.
        """
        # naming convention
        asset = self.asset
        side = self.side
        part = self.part
        joints = self.joints
        security = joints + 1

        if self.gui:
            asset = self.asset_name.text()
            side = self.side.currentText()
            part = self.part_name.text()
            joints = self.joints_box.value()
            print joints
            security = joints + 1
        try:
            self.curve = pm.ls(sl=True)[0]
            curve_name = NameUtils.get_unique_name(asset, side, part, "crv")
            pm.rename(self.curve, curve_name)
        except IndexError:
            pm.warning("Please select a curve")
            return

        length_of_curve = pm.arclen(self.curve)
        equal_spacing = length_of_curve / float(joints)

        # clear the selection
        pm.select(cl=True)

        # # create the joints
        for x in xrange(int(joints) + 1):
            name = NameUtils.get_unique_name(asset, side, part, "jnt", security)
            pm.joint(n=name)

            joint_position = (x * equal_spacing)
            pm.move(0, joint_position, 0)

        root_joint = pm.selected()[0].root()
        end_joint = pm.ls(sl=True)[0]
        solver = 'ikSplineSolver'

        # attach joints to curve
        ik_name = NameUtils.get_unique_name(asset, side, part, "ikHandle")
        self.ikHandle = pm.ikHandle(sj=root_joint, ee=end_joint, sol=solver,
                        c=self.curve, pcv=True, roc=True, ccv=False, n=ik_name)
        joint_chain = pm.ls(root_joint, dag=True)

        # delete history
        pm.makeIdentity(root_joint, apply=True)

        # cleanup
        self.cleanup()
예제 #44
0
def create_skeleton():
    root_ori = pm.ls('Adjustment_layer')[0]
    pm.select(cl=1)
    root_jnt = pm.joint(name='root')
    children = pm.listRelatives(root_ori)
    for child in children:
        pm.select(cl=1)
        if child.getChildren():
            jnt = pm.joint(name=child.getChildren()[0].name())
            pm.parent(jnt, root_jnt)
            pm.parentConstraint(child.getChildren()[0], jnt, mo=0)
예제 #45
0
 def create(cls, numb=1, name='joint1', rad=1.0, padding=False):
     pm.select(None)
     jnt_created = []
     for number in range(numb):
         if padding:
             jnt = pm.joint(n='{}_{:02d}'.format(name, number + 1), rad=rad)
         else:
             jnt = pm.joint(n='{}'.format(name), rad=rad)
         pm.parent(jnt, w=1)
         jnt_created.append(jnt)
     return cls(jnt_created)
예제 #46
0
def assignWeight(geo, wdata, skinc=None, jnt=None, pos=None):

    comp = "vtx"
    if geo.type() == "nurbsCurve":
        comp = "cv"
    mesh = None
    if pm.PyNode(geo).type() != "transform":
        mesh = geo
        geo = geo.getParent()

    #TODO: find center of wlist
    if not pos:
        pos = [0, 0, 0]

    if not jnt:
        print " Z"
        pm.select(cl=1)
        jnt = pm.joint(p=pos)
        jnt_grp = pm.group(jnt, em=1, n=str(jnt) + "_grp")
        jnt_grp.setTranslation(pos)
        jnt.setParent(jnt_grp)
    if not skinc:
        print " Y"

        skinc = getSkinc(geo)
    if not skinc:
        print " X"

        # insert base jnt
        pm.select(cl=1)
        basejnt = pm.joint(n=(str(geo) + "_baseJnt"))
        # check cons TODO: reconnect all constraint types
        ls_constrs = pm.parentConstraint(geo, q=1, n=1)
        if ls_constrs:
            transfer_constraint(geo, basejnt)
        skinc = pm.skinCluster(geo, basejnt)
        print "  New skincluster: {0}".format(skinc)

    print "_:", geo, skinc
    # add infl
    pm.skinCluster(skinc, e=1, ai=jnt, lw=1, wt=0)
    print "_:", jnt
    #########
    """
    for v, w in vtxs_data1.items():
        print "__:", v, w
        pm.skinPercent(snc, v, tv=[str(jnt), w])
    """
    for i, w in wdata.items():
        #print "__:", i, w
        print i, w
        pm.skinPercent(skinc, geo.__getattr__(comp)[i], tv=[str(jnt), w])

    return jnt
예제 #47
0
    def test_angleX(self):
        joint = pm.joint(angleX=31.5)
        self.assertEqual(pm.joint(joint, q=1, angleX=1), 31.5)
        pm.joint(joint, e=1, angleX=20.2)
        self.assertEqual(pm.joint(joint, q=1, angleX=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(ax=31.5)
        self.assertEqual(pm.joint(joint, q=1, ax=1), 31.5)
        pm.joint(joint, e=1, ax=20.2)
        self.assertEqual(pm.joint(joint, q=1, ax=1), 20.2)
        pm.delete(joint)
예제 #48
0
    def test_angleY(self):
        joint = pm.joint(angleY=31.5)
        self.assertEqual(pm.joint(joint, q=1, angleY=1), 31.5)
        pm.joint(joint, e=1, angleY=20.2)
        self.assertEqual(pm.joint(joint, q=1, angleY=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(ay=31.5)
        self.assertEqual(pm.joint(joint, q=1, ay=1), 31.5)
        pm.joint(joint, e=1, ay=20.2)
        self.assertEqual(pm.joint(joint, q=1, ay=1), 20.2)
        pm.delete(joint)
예제 #49
0
    def test_angleZ(self):
        joint = pm.joint(angleZ=31.5)
        self.assertEqual(pm.joint(joint, q=1, angleZ=1), 31.5)
        pm.joint(joint, e=1, angleZ=20.2)
        self.assertEqual(pm.joint(joint, q=1, angleZ=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(az=31.5)
        self.assertEqual(pm.joint(joint, q=1, az=1), 31.5)
        pm.joint(joint, e=1, az=20.2)
        self.assertEqual(pm.joint(joint, q=1, az=1), 20.2)
        pm.delete(joint)
예제 #50
0
    def test_radius(self):
        joint = pm.joint(radius=31.5)
        self.assertEqual(pm.joint(joint, q=1, radius=1), 31.5)
        pm.joint(joint, e=1, radius=20.2)
        self.assertEqual(pm.joint(joint, q=1, radius=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(rad=31.5)
        self.assertEqual(pm.joint(joint, q=1, rad=1), 31.5)
        pm.joint(joint, e=1, rad=20.2)
        self.assertEqual(pm.joint(joint, q=1, rad=1), 20.2)
        pm.delete(joint)
예제 #51
0
def orientMirorredJoint(jnt, jntChild):
    jntChildPos = pm.duplicate(jntChild, name = (jntChild.nodeName() + "_positive_stretch_foot"), parentOnly = True)[0]
    bakPos = jntChild.translate.get()
#     print(bakPos)
    newPos = [bakPos[0]*-1,bakPos[1]*-1, bakPos[2]*-1 ]
#     print(newPos)
    jntChildPos.translate.set(newPos)
    jntChild.setParent(world = True)
    pm.joint(jnt, edit = True, orientJoint = "xzy", secondaryAxisOrient = "zup", zso = True )
    pm.delete(jntChildPos)
    jntChild.setParent(jnt)
    return om.MGlobal_displayInfo("orient done")
예제 #52
0
    def test_stiffnessX(self):
        joint = pm.joint(stiffnessX=31.5)
        self.assertEqual(pm.joint(joint, q=1, stiffnessX=1), 31.5)
        pm.joint(joint, e=1, stiffnessX=20.2)
        self.assertEqual(pm.joint(joint, q=1, stiffnessX=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(stx=31.5)
        self.assertEqual(pm.joint(joint, q=1, stx=1), 31.5)
        pm.joint(joint, e=1, stx=20.2)
        self.assertEqual(pm.joint(joint, q=1, stx=1), 20.2)
        pm.delete(joint)
예제 #53
0
    def test_stiffnessY(self):
        joint = pm.joint(stiffnessY=31.5)
        self.assertEqual(pm.joint(joint, q=1, stiffnessY=1), 31.5)
        pm.joint(joint, e=1, stiffnessY=20.2)
        self.assertEqual(pm.joint(joint, q=1, stiffnessY=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(sty=31.5)
        self.assertEqual(pm.joint(joint, q=1, sty=1), 31.5)
        pm.joint(joint, e=1, sty=20.2)
        self.assertEqual(pm.joint(joint, q=1, sty=1), 20.2)
        pm.delete(joint)
예제 #54
0
    def test_stiffnessZ(self):
        joint = pm.joint(stiffnessZ=31.5)
        self.assertEqual(pm.joint(joint, q=1, stiffnessZ=1), 31.5)
        pm.joint(joint, e=1, stiffnessZ=20.2)
        self.assertEqual(pm.joint(joint, q=1, stiffnessZ=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(stz=31.5)
        self.assertEqual(pm.joint(joint, q=1, stz=1), 31.5)
        pm.joint(joint, e=1, stz=20.2)
        self.assertEqual(pm.joint(joint, q=1, stz=1), 20.2)
        pm.delete(joint)
예제 #55
0
    def create( self ):

        #
        # Create Kinect2 Joints
        #
        aimer = []
        for kjot in self.k2map:
            tag = self.k2map[kjot][0]
            aimid = self.k2map[kjot][2]
            aim = None if aimid is None else self.k2map[aimid][0]
            aimv = (1,0,0)

            t = pm.xform( tag, q=True, ws=True, t=True )
            pm.select( cl=True )
            pm.joint( p=t, n=kjot )

            if not aim is None:
                aimv = (-1,0,0) if pm.getAttr(aim+'.tx') < 0 else aimv
                aimer.append(pm.aimConstraint( aim, kjot, aim=aimv, wut='objectrotation', u=(0,1,0), wu=(0,1,0), wuo=tag ))
        pm.delete( aimer )

        #
        # Make Joints Hierarchy
        #
        for kjot in self.k2map:
            parent = self.k2map[kjot][1]
            aimid = self.k2map[kjot][2]
            if not parent is None:
                pm.parent( kjot, self.k2map[kjot][1] )
                if aimid is None:
                    pm.setAttr( kjot+'.jointOrient', (0,0,0) )

            # Freeze Transformations
            pm.makeIdentity( kjot, a=True, jo=False, t=False, r=True, s=False, n=0, pn=True )

        #
        # Make Constraint
        #
        for kjot in self.k2map:
            tag = self.k2map[kjot][0]
            aimid = self.k2map[kjot][2]
            aim = None if aimid is None else self.k2map[aimid][0]
            aimv = (1,0,0)

            # Aim Constraint
            pm.pointConstraint( tag, kjot )

            # Aim Constraint
            if not aim is None:
                aimv = (-1,0,0) if pm.getAttr(aim+'.tx') < 0 else aimv
                pm.aimConstraint( aim, kjot, aim=aimv, wut='objectrotation', u=(0,1,0), wu=(0,1,0), wuo=tag )

        return
예제 #56
0
    def test_stiffnessZ(self):
        joint = pm.joint(stiffnessZ=31.5)
        self.assertEqual(pm.joint(joint, q=1, stiffnessZ=1), 31.5)
        pm.joint(joint, e=1, stiffnessZ=20.2)
        self.assertEqual(pm.joint(joint, q=1, stiffnessZ=1), 20.2)
        pm.delete(joint)

        joint = pm.joint(stz=31.5)
        self.assertEqual(pm.joint(joint, q=1, stz=1), 31.5)
        pm.joint(joint, e=1, stz=20.2)
        self.assertEqual(pm.joint(joint, q=1, stz=1), 20.2)
        pm.delete(joint)
예제 #57
0
def bdJointOnCurveFromEdge():
    edgeCurveAll = pm.polyToCurve (form = 2,degree=1)
    pm.select(cl=1)
    meshName = pm.listConnections('%s.inputPolymesh'%edgeCurveAll[1])[0]

    edgeCurve = pm.ls(edgeCurveAll[0])
    numCv = edgeCurve[0].getShape().numCVs()
    baseJoints = []
    for i in range(numCv):
        pos = edgeCurve[0].getShape().getCV(i, space='world')
        baseJoints.append(pm.joint(n=meshName + '_jnt_' + str(i),p=pos))
    pm.joint(baseJoints[0],e=True, oj='xzy',secondaryAxisOrient='zdown',ch= True,zso=True)        
예제 #58
0
def jointOnCurveCVs(size=1, crv=None, prefix="lid"):
	jnts = []
	for i,cv in enumerate(crv.cv):
		pm.select( clear=1 )
		cvPose = pm.xform( cv, q=1, t=1, ws=1 )
		jnts.append( pm.joint(p=cvPose, name="%s_%s_jnt"%(prefix,i)) )
		jnts[i].radius.set( size )	
		pm.joint( jnts[i], e=True, oj="xyz", sao="yup", zso=1, ch=1 )
	pm.delete( (jnts[1],jnts[-2]) )
	jnts.remove( jnts[1] )
	jnts.remove( jnts[-2] )
	return jnts