本文整理汇总了Python中Control.create方法的典型用法代码示例。如果您正苦于以下问题:Python Control.create方法的具体用法?Python Control.create怎么用?Python Control.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control.create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeFkControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def _makeFkControls(fkControls=None, side=None):
pymelLogger.debug('Starting: _makeControls()...')
topNodeList = []
for ctrl in fkControls:
parent = ctrl.replace('_'+Names.suffixes['fk']+'_'+Names.suffixes['control'],'')
topNode = Control.create( name=ctrl, offsets=3, shape='circle_01',
size=1.5, color=_getSideColor(side),
pos=None, parent=parent, typ='body' )
pm.parent(topNode, world=1)
topNodeList.append(topNode)
# getting ctrl and contrainting it directly to the jnt
childs = topNode.listRelatives(ad=1)
if 'Shape' in str(childs[0]):
cc = childs[1]
else: cc = childs[0]
pm.parentConstraint(cc,parent, mo=1)
# parent each offset to the previous ctrl
topNodeList.reverse()
last = ''
for element in topNodeList:
if last:
last.setParent(element.listRelatives(ad=1)[1]) # getting transform node not shape
last = element
topOffsetNode = last
return topOffsetNode
pymelLogger.debug('End: _makeControls()...')
示例2: createHipShoudersControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def createHipShoudersControls( drvStart, drvEnd, jntList ):
pymelLogger.debug('Starting: createHipShoudersControls()...')
# Get drvStart Position
drvS_pos = pm.xform(drvStart[0], query = True, translation = True)
# Get drvEnd Position
drvE_pos = pm.xform(drvEnd[0], query = True, translation = True)
# Create Hip Control
ctrl = jntList[0] + '_' + Names.suffixes['control']
rot = pm.xform(drvStart[0],q=1,ws=1,ro=1)
rot = [-90,0,90]
hips_cnt = Control.create( name= ctrl , offsets=2, shape='cube',
size=[1,1,1], color='cyan',
pos=drvS_pos, rot=rot, parent=None, typ='body' )
# Create Shoulder Ctrl
#shoulder_cnt = Control.create()
######## fix this !!! top spine ctrl shoud b called SpineX_ctrl
ctrl = jntList[-1]+ '_' + Names.suffixes['control']
rot = pm.xform(jntList[-1],ws=1,q=1,ro=1)
shoulder_cnt = Control.create( name=ctrl, offsets=2, shape='circle_01',
size=2, color='red',
pos=drvE_pos,rot=rot, parent=None, typ='body' )
# Connect CC to Drv Jnts
pm.parentConstraint(hips_cnt.listRelatives(ad=1)[0].getParent(), drvStart, maintainOffset = True)
pm.parentConstraint(shoulder_cnt.listRelatives(ad=1)[0].getParent(), drvEnd, maintainOffset = True)
# Clean Ctrls Attributes (Lock and Hide Scale and Visibility)
hideLockAttr(hips_cnt, lockHideSV)
hideLockAttr(shoulder_cnt, lockHideSV)
hideLockAttr(drvStart[0], lockHideS)
hideLockAttr(drvEnd[0], lockHideS)
rList = [hips_cnt, shoulder_cnt]
pymelLogger.debug('End: createHipShoudersControls()...')
return rList
示例3: _makeControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def _makeControls():
pymelLogger.debug('Starting: _makeControls()...')
# Neck
parent = 'head_controls'
ctrl= Names.controls_neck[0]
pos = pm.xform('Neck',ws=1,q=1,rp=1)
rot = pm.xform('Neck',ws=1,q=1,ro=1)
s = [['head_body_attach_space','head_world_space'],['local','world'],'orient']
Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, rot=rot, color=None, switch=s,
pos=pos, parent=parent, typ='head' )
# Neck1
parent = Names.controls_neck[0]
ctrl= Names.controls_neck[1]
pos = pm.xform('Neck1',ws=1,q=1,rp=1)
rot = pm.xform('Neck1',ws=1,q=1,ro=1)
Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, rot=rot, color=None,
pos=pos, parent=parent, typ='head' )
pymelLogger.debug('End: _makeControls()...')
示例4: _makeIkControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def _makeIkControls(ikControls=None):
pymelLogger.debug('Starting: _makeIkControls()...')
for ctrl in ikControls:
if 'IK' in ctrl:
if Names.prefixes['left'] in ctrl:
parent = '%s%s'%(Names.prefixes['left'],Names.joints_arm[-1])
if Names.prefixes['right'] in ctrl:
parent = '%s%s'%(Names.prefixes['right'],Names.joints_arm[-1])
topNode = Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, color=None,
pos=None, parent=parent, typ='body' )
pm.parent(topNode, 'controls')
if 'PV' in ctrl:
pass
pymelLogger.debug('End: _makeIkControls()...')
示例5: bodyCtrlSetUp
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def bodyCtrlSetUp( fkJnts, hips_cnt, shoulder_cnt, drvStart ):
pymelLogger.debug('Starting: bodyCtrlSetUp()...')
# Body control
pos = pm.xform(hips_cnt, q=1, ws=1,rp=1)
body_cnt_offset = Control.create( name= Names.controls_torso_cog , offsets=1, shape='circle_2_arrow',
size=[1,1,1], color='darkBlue',
pos=pos, parent=None, typ='body' )
body_cnt = body_cnt_offset.listRelatives(ad=1)[0].getParent()
# position and freeze
#rootPos = pm.xform(drvStart[0], query = True, translation = True)
#body_cnt.setTranslation(rootPos)
#pm.makeIdentity(body_cnt, apply=True)
# Change rotation order cc_body
#setRotateOrder(body_cnt, 2)
# Lock and Hide Scale - Vis
hideLockAttr(body_cnt, lockHideSV)
# Parent torso_baseJnt to cc_body (CAREFUL!!! If no FKControls created this will not work now!!!!)
pm.parent(fkJnts[0], body_cnt)
# Group cc_jc_hip and parent it to torso_baseJnt (We group it first to keep de cc zeroed out)
grp_cc_hip = pm.group(hips_cnt, name= Names.torso_hips_grp )
pm.parent(grp_cc_hip, fkJnts[0])
# Group cc_jc_shoulder and parent it to torso_endJnt (We group it first to keep de cc zeroed out)
grp_cc_shoulder = pm.group(shoulder_cnt, name=Names.torso_shoulders_grp )
pm.parent(grp_cc_shoulder, fkJnts[-1])
# Lock and Hide Attr groups created
hideLockAttr(grp_cc_hip, lockHideTRSV)
hideLockAttr(grp_cc_shoulder, lockHideTRSV)
pymelLogger.debug('End: bodyCtrlSetUp()...')
return body_cnt_offset
示例6: build_body
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def build_body():
pymelLogger.debug('Starting: build_body()...')
Torso.build()
# legs
CanidaeLeg.build(side = Names.prefixes['left'])
CanidaeLeg.build(side = Names.prefixes['right'])
# arms
Arm.build(side = Names.prefixes['left'])
Arm.build(side = Names.prefixes['right'])
# Hands and fingers
Hand.build( side = Names.prefixes['left'] )
Hand.build( side = Names.prefixes['right'] )
# main ctrl
main_cnt_name = Names.joints_torso[0] + '_' + Names.suffixes['control']
main_cnt = Control.create( name=main_cnt_name, offsets=0, shape='circle_4_arrow',
size=1, color='yellow',
pos=None, parent=None, typ='body' )
pm.parent(main_cnt, 'controls')
######################
######################
# hard coded! fix!
consGrp = [Names.torso_module, Names.legs_module]
for grp in consGrp:
try: pm.parentConstraint( main_cnt, grp, mo=1 )
except: print 'Could not constraint: ' + main_cnt + ' to ' + grp
# constraint main to reference_jnt
pm.parentConstraint(main_cnt, Names.joints_torso[0], mo=1)
######################
######################
pymelLogger.debug('End: build_body()...')
示例7: build
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def build( side=None ):
pymelLogger.debug('Starting: build()...')
if side == None: raise Exception('Make sure side: %s is valid '%side)
if side != Names.prefixes['left'] and side != Names.prefixes['right']:
raise Exception('Make sure side: %s is valid '%side)
# create hand jnt
handJntList = _createHandJnt( side ) # [handJnt, handJntName]
handJnt = handJntList[0]
handJntSH = handJntList[1]
# create hand switch
ctrl = handJntSH + '_' + Names.suffixes['switch']
hand_switch_offset = Control.create( name= ctrl , offsets=1, shape='cube',
size=[1,1,1], color=_getSideColor(side),
pos=None, parent=handJnt, typ='body' )
hand_switch_offset.setParent( world=1 )
hand_switch = hand_switch_offset.getChildren()[0] # it will work only with one offset
hideLockAttr(hand_switch, lockHideTRSV)
# add switch attr
pm.addAttr( hand_switch, longName= Names.switchIkFk, k=True, min=0, max=1 )
# parentConstraint switch offset to sh handJnt !!!! Make sure it will work
pm.parentConstraint(handJntSH, hand_switch_offset, mo=True)
# build fingers
Finger.build( side=side, label='Fingers', control=hand_switch, parentJnt = handJnt,
curl='Z',twist='X',spread='Y', fkNormal=(1.0, 0.0, 0.0), radius=0.3 )
# group switch and hand
hand_grp = pm.group(hand_switch_offset,handJnt,name = handJntSH + '_' + Names.suffixes['group'])
_cleanUp( hand_grp )
pymelLogger.debug('End: build()...')
示例8: _makeControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def _makeControls():
''' Make Head and Face controls, parented to Neck '''
pymelLogger.debug('Starting: _makeControls()...')
# Head
parent = Names.controls_neck[1]
ctrl= Names.controls_head[0]
pos = pm.xform('Head',ws=1,q=1,rp=1)
rot = pm.xform('Head',ws=1,q=1,ro=1)
s = [['head_head_ctrl_space','head_world_space'],['local','world'],'orient']
Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, color=None, switch=s,
pos=pos, rot=rot, parent=parent, typ='head' )
# Face controls
parent = 'head_controls'
ctrl= Names.controls_face[0]
pos = pm.xform('Head',ws=1,q=1,rp=1)
pos[0] += 3
Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, color=None,
pos=pos, parent=parent, typ='head' )
pos[0] += 1
for ctrl in Names.controls_face:
if ctrl == Names.controls_face[0]:
continue
pos[1] += 1
parent = Names.controls_face[0]
ctrl= ctrl
Control.create( name=ctrl, offsets=3, shape='circle_01',
size=None, color=None,
pos=pos, parent=parent, typ='head' )
pymelLogger.debug('End: _makeControls()...')
示例9: createFKControls
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def createFKControls( jntList ):
pymelLogger.debug('Starting: createFKControls()...')
# for now creating based on current spline and same number
# will not be oriented to the joint but world (analyze this!!)
listJnts = []
for jnt in jntList:
pm.select(clear=1)
newJnt = pm.duplicate(jnt,rr=True,po=True, name=jnt+'_'+Names.suffixes['fk'])[0]
try:
newJnt.setParent(world=1)
except: pass
listJnts.append(newJnt)
listJnts.reverse()
index = 0
for jnt in listJnts:
if index+1 == len(listJnts): break
jnt.setParent(listJnts[index+1])
index = index + 1
listJnts.reverse()
# Create controls for the fk spines
fkSpines = listJnts[1:-1]
# parent shape to joint
#cc_torso01 = jcControl.circleControl('cc_'+torso01)
offsetList = []
for fkJnt in fkSpines:
jPos = pm.xform(fkJnt, query = True, translation = True, ws=1)
rot = pm.xform(fkJnt, query = True, ro = True, ws=1)
cName = fkJnt.split('_')[0] + '_' + Names.suffixes['control']
#rot = pm.xform(fkJnt.replace( '_' + Names.suffixes['fk'], '' ),ws=1,q=1,ro=1)
offsetGrp = Control.create( name=cName, offsets=2, shape='circle_01',
size=1.8, color='yellow',
pos=jPos, parent=None,rot=rot, typ='body' )
offsetList.append(offsetGrp)
# parent constraint
print offsetGrp.listRelatives(ad=1)[0].getParent()
pm.parentConstraint( offsetGrp.listRelatives(ad=1)[0].getParent(), fkJnt, mo=1 )
# parent offset grps
topGrp = offsetList[0]
if not len(offsetList) == 0:
# parent groups
offsetList.reverse()
last = ''
for offsetgrp in offsetList:
if last:
last.setParent(offsetgrp.listRelatives(ad=1)[0].getParent())
last = offsetgrp
# parent top to hips_fk jnt
topGrp.setParent(listJnts[0])
# hide chain
"""
for fkjnt in fkJntList:
pm.hide(fkjnt)
"""
pymelLogger.debug('End: createFKControls()...')
return listJnts
示例10: createIKLeg
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def createIKLeg( listJnts, side ):
toeBaseJnt = listJnts[-3]
# create ik handle
ikh = pm.ikHandle( sj=listJnts[0], ee=toeBaseJnt, sol='ikRPsolver', name=toeBaseJnt + '_' +Names.suffixes['ikhandle'] )
ikh[0].hide()
# create ik sc solvers for foot and toe
ikhfoot = pm.ikHandle( sj=toeBaseJnt, ee=listJnts[-2], sol='ikSCsolver', name=listJnts[-2] + '_' +Names.suffixes['ikhandle'] )
ikhfoot[0].hide()
ikhtoe = pm.ikHandle( sj=listJnts[-2], ee=listJnts[-1], sol='ikSCsolver', name=listJnts[-1] + '_' +Names.suffixes['ikhandle'] )
ikhtoe[0].hide()
# parent ik handles to inverse foot
inverseFoot = str(toeBaseJnt.name())
inverseFoot = pm.ls( inverseFoot.replace('_'+Names.suffixes['ik'], '_inversefoot'),r=1 )[0]
inverseToe = pm.ls(str(inverseFoot.name())+'1',r=1)[0]
inverseToeEnd = pm.ls(str(inverseFoot.name()+'2'),r=1)[0]
# create offset for toe roll
offsetGrp = pm.group(em=1,name=str(inverseToeEnd.name()) + '_offsetGrpA')
offsetGrpB = pm.group(em=1,name=str(inverseToeEnd.name()) + '_offsetGrpB')
offsetGrp.setParent( inverseToe )
offsetGrp.setTranslation([0,0,0])
offsetGrp.setRotation([0,0,0])
offsetGrp.setParent(w=1)
offsetGrpB.setParent(offsetGrp)
offsetGrpB.setTranslation([0,0,0])
offsetGrpB.setRotation([0,0,0])
ikh[0].setParent(inverseFoot)
ikhfoot[0].setParent(inverseToe)
ikhtoe[0].setParent(offsetGrpB)
offsetGrp.setParent(inverseToeEnd)
# create curve for ik foot
if side == Names.prefixes['left']: ctrl = Names.controls_leftLegIK
elif side ==Names.prefixes['right']: ctrl = Names.controls_rightLegIK
else: raise Exception('Make sure side: %s is valid '%side)
posjnt = pm.xform(toeBaseJnt, query = True, translation = True, ws=1)
rotjnt = pm.xform(toeBaseJnt, query = True, ro = True, ws=1)
foot_cnt = Control.create( name=ctrl, offsets=1, shape='circle_01',
size=1.5, color=getSideColor(side),
pos=posjnt,rot=rotjnt, parent=None, typ='body' )
############ fix this! need to rotate 180 to make sure that ctrl behaves properly
if side == Names.prefixes['right']:
pm.rotate(foot_cnt,0,0,180,os=1, r=1)
ankleFloorJnt = pm.ls('%s%s' %(side,'AnkleFloor_if'),r=1 )[0]
foot_ctrl = foot_cnt.listRelatives(ad=1)[0].getParent()
ankleFloorJnt.setParent( foot_ctrl )
ankleFloorJnt.hide()
# add attr to foot control
pm.addAttr(foot_ctrl, longName='heel_roll',k=True)
pm.addAttr(foot_ctrl, longName='toe_roll',k=True)
pm.addAttr(foot_ctrl, longName='toeEnd_roll',k=True)
pm.addAttr(foot_ctrl, longName='toe_up_down',k=True)
# connect attrs
pm.connectAttr( foot_ctrl + '.' + 'heel_roll', ankleFloorJnt + '.' + 'rotateZ' )
pm.connectAttr( foot_ctrl + '.' + 'toe_roll', inverseToe + '.' + 'rotateZ' )
pm.connectAttr( foot_ctrl + '.' + 'toeEnd_roll', inverseToeEnd + '.' + 'rotateZ' )
pm.connectAttr( foot_ctrl + '.' + 'toe_up_down', offsetGrpB + '.' + 'rotateZ' )
#####################
# create pole vector
if side == Names.prefixes['left']: ctrl = Names.controls_leftLegIKPV
elif side ==Names.prefixes['right']: ctrl = Names.controls_rightLegIKPV
else: raise Exception('Make sure side: %s is valid '%side)
pv_cnt = Control.create( name=ctrl, offsets=1, shape='cube',
size=0.4, color=getSideColor(side),
pos=None, parent=None, typ='body' )
# parent constraint w/o offsets to UpLeg, Leg
cons = pm.parentConstraint( listJnts[0], listJnts[1],listJnts[2], pv_cnt, mo=0 )
pm.delete(cons)
# aim contraint to leg
cons = pm.aimConstraint( listJnts[1], pv_cnt,mo=0 )
pm.move( pv_cnt, 10,0,0, os=1,r=1)
pm.delete(cons)
# connect pole vector
pm.poleVectorConstraint( pv_cnt.getChildren()[0], ikh[0] )
####################
#.........这里部分代码省略.........
示例11: build
# 需要导入模块: import Control [as 别名]
# 或者: from Control import create [as 别名]
def build( side=None, label='Fingers',control=None, parentJnt=None,
curl='Z',twist='X',spread='Y',
fkNormal=(1.0, 0.0, 0.0), radius=0.3):
pymelLogger.debug('Starting: build()...')
if side == None: raise Exception('Make sure side: %s is valid '%side)
if side == Names.prefixes['left']: fingerJnts = Names.joints_leftFingers_list
elif side == Names.prefixes['right']: fingerJnts = Names.joints_rightFingers_list
else: raise Exception('Make sure side: %s is valid '%side)
# Is the last joint of the chain going to be skinned ? hasEndJnt = 0
# or last joint should not be considered ? hasEndJnt = 1
hasEndJnt = 1 # hard coding it, by default last joint will not be considered
rList = createJnts( side, fingerJnts, hasEndJnt ) # [ startJnts, endJnts, attNames, newJnts, originalJnts ]
startJnts = rList[0]
endJnts = rList[1]
attNames = rList[2]
newJnts = rList[3]
originalJnts = rList[4]
# Create main attributes on control
pm.select(control,r=True)
attList = pm.attributeInfo(control,all=True)
if(label not in attList):
try:
pm.addAttr(longName=label,k=True)
pm.setAttr(control + '.' + label, lock=True)
except:
pass #Attribute already exists @ todo - Catch specific exemption
# Create controller vis switch
pm.addAttr(longName='Control_Vis',k=True, min=0, max=1,dv=1)
# Create spread all
pm.addAttr(longName='spread_all',k=True, min=-10.0, max=10.0)
# Create tenson all
pm.addAttr(longName='tension_all',k=True, min=0.0, max=10.0)
# Create tenson all
pm.addAttr(longName='curl_all',k=True)
chainParent = ''
offsetGrpsLists = []
########################################################
########################################################
########################################################
# spread hard coded calculation #
jntLen = len(startJnts)
startValue=-50
endValue=50
range = -(startValue) + endValue
increment = range / jntLen
startV = startValue
endV = endValue
spreadList=[]
if jntLen%2==0:
centerIndex = jntLen/2
index=1
while index < jntLen+1:
if index < centerIndex:
spreadList.append( [startV,endV] )
startV = startV + increment
endV = endV - increment
if index > centerIndex:
spreadList.append( [startV,endV] )
startV = startV + increment
endV = endV - increment
index = index + 1
else:
centerIndex = (jntLen+1)/2
index=1
while index < jntLen+1:
if index < centerIndex:
spreadList.append( [startV,endV] )
startV = startV + increment
endV = endV - increment
if index == centerIndex:
spreadList.append([0,0])
startV = 0 + increment
endV = 0 - increment
if index > centerIndex:
spreadList.append( [startV,endV] )
startV = startV + increment
endV = endV - increment
index = index + 1
########################################################
########################################################
########################################################
print 'spread list ', spreadList
#.........这里部分代码省略.........