本文整理汇总了Python中pymel.core.joint函数的典型用法代码示例。如果您正苦于以下问题:Python joint函数的具体用法?Python joint怎么用?Python joint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了joint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createJntChain
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
示例2: create_jnts_on_points
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("")
示例3: wiggleJointChain
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
示例4: createIKSpline
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: test_create_heirarchy
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))
示例6: autoPoleVector
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) )
示例7: install_subMetaRig_proxy
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
示例8: build_flexi_jnts
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 )
示例9: GuideCrv
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
示例10: createBoundJointChain
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: buildChains
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))
示例12: fromList
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: createCurveBoundJoints
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)
示例14: jointChainOrient
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' )
示例15: splineIK_controls
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)