本文整理汇总了Python中pymel.core.spaceLocator函数的典型用法代码示例。如果您正苦于以下问题:Python spaceLocator函数的具体用法?Python spaceLocator怎么用?Python spaceLocator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spaceLocator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDynamicChainLocators
def createDynamicChainLocators(self, prefix = ''):
#set instance prefix var
self.setPrefix(prefix)
pm.select(cl = True)
#Create Space locators and translate
self.dynamic_chain_locator_base = pm.spaceLocator(n = self.prefix + '_dynamic_chain_locator_base')
self.dynamic_chain_locator_base.translate.set(0, 0, 0)
pm.select(cl = True)
self.dynamic_chain_locator_tip = pm.spaceLocator(n = self.prefix + '_dynamic_chain_locator_tip')
self.dynamic_chain_locator_tip.translate.set(0, 10, 0)
pm.select(cl = True)
#Create Annotations and rename
self.annotation_dynamic_chain_locator_base = pm.annotate( self.dynamic_chain_locator_base, tx = self.prefix +'_dynamic_chain_base' )
pm.rename(self.annotation_dynamic_chain_locator_base.getParent().name(), self.prefix + '_dynamic_chain_base_annotation')
self.annotation_dynamic_chain_locator_tip = pm.annotate( self.dynamic_chain_locator_tip, tx = self.prefix +'_dynamic_chain_tip' )
pm.rename(self.annotation_dynamic_chain_locator_tip.getParent().name(), self.prefix + '_dynamic_chain_tip_annotation')
pm.select(cl = True)
#Parent constrain annotation transforms
pm.parentConstraint(self.dynamic_chain_locator_base, self.annotation_dynamic_chain_locator_base.getParent(), mo = False)
pm.parentConstraint(self.dynamic_chain_locator_tip, self.annotation_dynamic_chain_locator_tip.getParent(), mo = False)
示例2: create_planar_locators
def create_planar_locators(nLocators, length=10.0, name='test', size=1):
root = pm.spaceLocator(name='%s_root' %name)
root.add_shape(shape='double_cross', axis='+z', size=size)
locators=[root]
for i in range(nLocators):
spacing = length / (nLocators - 1)
tx = i * spacing
locator = pm.spaceLocator(name='%s_locator_%d' %(name, i+1))
locator.getShape().localScale.set([size,size,size])
#locator.add_parent_group()
pm.parent(locator, root)
locator.translateX.set(tx)
locators.append(locator)
for i in range(2, len(locators)):
pm.aimConstraint(locators[i], locators[i-1], mo=False, aimVector=[1,0,0], upVector=[0,0,1], worldUpType='objectrotation', worldUpVector = [0,0,1], worldUpObject=root)
for locator in locators[1:]:
locator.tz.lock()
locator.rotate.lock()
for locator in locators[1:-1]:
locator.add_rotate_arrows(size=size)
return locators
示例3: createNoiseControl
def createNoiseControl(self):
# Create locator
control = '%s%s'%(self.camera, self._CONTROL_SUFIX)
pc.spaceLocator(n=control)
# Create attribute for turning noise on/off
pc.addAttr(ln='NOISE_SWITCH', k=False, at='enum', en='-:')
pc.setAttr('%s.NOISE_SWITCH'%control, lock=True, cb=True)
pc.addAttr(ln='Noise', k=False, at='enum', en='Off:On:')
pc.setAttr('%s.Noise'%control, 1, cb=True)
# Create translation noise attributes: frequency, amplitude (x, y, z), jitter and seed
for noise_type in ['T', 'R']:
nname = 'TRANSLATION' if noise_type == 'T' else 'ROTATION'
pc.addAttr(ln='%s_NOISE'%nname, k=False, at='enum', en='-:')
pc.setAttr('%s.%s_NOISE'%(control, nname), lock=True, cb=True)
for axis in ['X', 'Y', 'Z']:
pc.addAttr(ln='Frequency_%s%s'%(noise_type, axis), k=True, at='double', min=0)
pc.addAttr(ln='Amplitude_%s%s'%(noise_type, axis), k=True, at='double', min=0)
pc.addAttr(ln='Jitter_%s'%noise_type, k=True, at='double', min=0)
pc.addAttr(ln='Seed_%s'%noise_type, k=False, at='short', dv=random.randint(0, 9999))
pc.setAttr('%s.Seed_%s'%(control, noise_type), cb=True)
# Create extra attributes for camera position offset
pc.addAttr(ln='CAM_OFFSET', k=False, at='enum', en='-:')
pc.setAttr('%s.CAM_OFFSET'%control, lock=True, cb=True)
for axis in ['X', 'Y', 'Z']:
pc.addAttr(ln='Offset_%s'%axis, k=True, at='double')
return control
示例4: makeNull
def makeNull():
#pm.melGlobals.initVar( 'string[]', 'KinectSkelNames' )
i=0
for i in range(0,24):
pm.spaceLocator(p=(0, 0, 0),n=KinectSkelNames[i])
pm.spaceLocator(p=(0, 0, 0),n="KINECT_HAND")
for i in range(0,15):
point[i] = [0.0,0.0,0.0]
makeSkel()
for i in range(0,15):
pm.rename('joint'+str(i+1), KinectSkelJoints[i]+'_jt')
for i in range(0,15):
pm.pointConstraint( KinectSkelJoints[i], KinectSkelJoints[i]+'_jt' )
pm.orientConstraint( KinectSkelJoints[i], KinectSkelJoints[i]+'_jt' )
#Create Camera
cam = pm.camera()[1]
#print pm.camera(cam, query=True, aspectRatio=True)
cam.setAspectRatio(3)
print cam.getAspectRatio()
示例5: createHighlight
def createHighlight(mesh, lightType=mayaLights["Spot"], offset=6):
""" Create Light based on curve drawn on object """
# Get the currently selected curve
curveA = getSelection()
# Get the start and end points of the curve as Vectors
crv_posA = dt.Vector(pm.pointOnCurve(curveA, pr=0))
crv_posB = dt.Vector(pm.pointOnCurve(curveA, pr=curveA.maxValue.get()))
# Calculate the mid point
midPoint = (crv_posA + crv_posB) / 2
# Get closest point & normal on mesh
pointOnMesh_set = mesh.getClosestPointAndNormal(midPoint, space="world")
pointOnMesh = pointOnMesh_set[0]
pointOnMesh_normal = pointOnMesh_set[1]
pm.spaceLocator(p=pointOnMesh) # For debug/vis
# Create dummy camera
cam = pm.camera()
camera = cam[0]
camera.setTranslation(pointOnMesh + pointOnMesh_normal * offset)
pm.viewLookAt(camera, pos=pointOnMesh)
# Create light
createLight(lightType, camera.getTranslation(), camera.getRotation())
# Delete dummy camera
pm.delete(camera)
示例6: connectJacketLoc
def connectJacketLoc(twistCrv, untwistCrv, param, name='', addCrvs=[]):
'''
'''
mp = pm.createNode('motionPath', n=twistCrv+name+'_mp')
untwistCrv.worldSpace >> mp.geometryPath
mp.u.set(param)
npc = pm.createNode('nearestPointOnCurve', n=twistCrv+name+'_npc')
mp.allCoordinates >> npc.inPosition
twistCrv.worldSpace >> npc.inputCurve
allLocs = []
loc = pm.spaceLocator(n=twistCrv+name+'_loc')
npc.position >> loc.translate
allLocs.append(loc)
for crv in addCrvs:
pci = pm.createNode('pointOnCurveInfo', n=crv+name+'_pci')
npc.parameter >> pci.parameter
crv.worldSpace >> pci.inputCurve
loc = pm.spaceLocator(n=crv+name+'_loc')
pci.position >> loc.translate
allLocs.append(loc)
pm.select(allLocs)
示例7: setNodeAxisVectors
def setNodeAxisVectors(node, oldA1="posY", oldA2="posX", newA1="posY", newA2="posX", orient=True):
node = pm.PyNode(node)
#these are world space vectors
oldV1 = getNodeAxisVector(node, oldA1)
oldV2 = getNodeAxisVector(node, oldA2)
_logger.debug("%s vector: %s; %s vector: %s" % (oldA1, str(oldV1), oldA2, str(oldV2)))
newV1 = g_vectorMap[newA1]
newV2 = g_vectorMap[newA2]
posL = pm.spaceLocator()
aimL = pm.spaceLocator()
upL = pm.spaceLocator()
aimL.setParent(posL)
upL.setParent(posL)
pm.delete(pm.pointConstraint(node, posL, mo=False))
aimL.translate.set(oldV1)
upL.translate.set(oldV2)
pm.delete(pm.aimConstraint(aimL, node, aimVector=newV1, upVector=newV2, worldUpType='object', worldUpObject=upL))
pm.delete(posL)
if orient:
node.jox.set(node.jox.get() + node.rotateX.get())
node.joy.set(node.joy.get() + node.rotateY.get())
node.joz.set(node.joz.get() + node.rotateZ.get())
node.rotate.set([0, 0, 0])
示例8: build
def build(self):
"""builds it self
"""
self.curve = curve(d=1, p=[(1, 0, 0), (-1, 0, 0)], k=(0, 1))
self.corner1_locator = spaceLocator()
self.corner2_locator = spaceLocator()
select(self.curve)
ClusterCurve()
# try to find the clusterHandles
curve_shape = curve.getShape()
clusters = []
handles = []
for node in curve_shape.listHistroy():
if isinstance(node, ClusterHandle):
handles.append(node)
elif isinstance(node, Cluster):
clusters.append(node)
self.cluster1 = clusters[0]
self.cluster2 = clusters[0]
self.cluster_handle1 = handles[0]
self.cluster_handle2 = handles[1]
# set clusters to absolute
self.cluster1.setAttr('relative', 0)
self.cluster2.setAttr('relative', 0)
示例9: makeNodeSet
def makeNodeSet(pointValueList, transNodeType):
for x in pointValueList:
if transNodeType == 'locator':
pm.spaceLocator().t.set(x)
else:
pm.createNode(transNodeType).t.set(x)
示例10: 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
示例11: _ctrlDBL
def _ctrlDBL(self, controls):
pmc.undoInfo(openChunk=True)
if controls == []:
controls = pmc.ls(sl=True)
for control in controls:
control_roo = pmc.xform(control, q=True, roo=True)
control_mtx = pmc.xform(control, q=True, m=True, ws=True)
control_parent = pmc.listRelatives(control, p=True)
pmc.select(cl=True)
locdbl_parent = pmc.spaceLocator(n='locDBL_parent_' + control)
locdbl_offset = pmc.spaceLocator(n='locDBL_offset_' + control)
pmc.xform(locdbl_parent, ws=True, m=control_mtx)
pmc.xform(locdbl_offset, ws=True, m=control_mtx)
pmc.parent(locdbl_offset, locdbl_parent)
pmc.parent(locdbl_parent, control_parent)
pmc.parent(control, locdbl_offset)
if control_roo == 'xyz':
pmc.xform(locdbl_offset, roo='zyx')
if control_roo == 'yzx':
pmc.xform(locdbl_offset, roo='xzy')
if control_roo == 'zxy':
pmc.xform(locdbl_offset, roo='yxz')
if control_roo == 'xzy':
pmc.xform(locdbl_offset, roo='yzx')
if control_roo == 'yxz':
pmc.xform(locdbl_offset, roo='zxy')
if control_roo == 'zyx':
pmc.xform(locdbl_offset, roo='xyz')
md_trns = pmc.createNode('multiplyDivide', n='mdTRNS_locDBL_' + control)
md_rot = pmc.createNode('multiplyDivide', n='mdROT_locDBL_' + control)
md_scl = pmc.createNode('multiplyDivide', n='mdSCL_locDBL_' + control)
pmc.setAttr(md_trns + '.input1', [-1,-1,-1])
pmc.setAttr(md_rot.input1, [-1,-1,-1])
pmc.setAttr(md_scl.input1, [ 1, 1, 1])
pmc.setAttr(md_scl.operation, 2)
pmc.connectAttr(control + '.translate', md_trns + '.input2')
pmc.connectAttr(control + '.rotate', md_rot + '.input2')
pmc.connectAttr(control + '.scale', md_scl + '.input2')
pmc.connectAttr(md_trns + '.output', locdbl_offset + '.translate')
pmc.connectAttr(md_rot + '.output', locdbl_offset + '.rotate')
pmc.connectAttr(md_scl + '.output', locdbl_offset + '.scale')
pmc.setAttr(locdbl_parent + 'Shape.visibility', 0)
pmc.setAttr(locdbl_offset + 'Shape.visibility', 0)
pmc.undoInfo(closeChunk=True)
示例12: 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' )
示例13: bdSwitchParent
def bdSwitchParent():
selection = pm.ls(sl=1,type='transform')
if selection:
ctrl = selection[0]
try:
currentParent = ctrl.attr('Parent').get()
except:
pm.warning('Current selection has no Parent attribute, aborting!')
return
print currentParent
switchFrame = pm.currentTime(q=1)
pm.currentTime(switchFrame-1,e=1)
pm.setKeyframe(ctrl)
pm.currentTime(switchFrame,e=1)
#World Parent
if currentParent == 1:
print 'Frow World to hand'
tempLoc = pm.spaceLocator(n='temp')
tempCnstr = pm.parentConstraint(ctrl,tempLoc)
pm.delete(tempCnstr)
ctrl.attr('Parent').set(0)
worldPos = tempLoc.getTranslation(space='world')
worldRot = tempLoc.getRotation(space='world')
ctrl.setTranslation(worldPos,space='world')
ctrl.setRotation(worldRot,space='world')
pm.delete(tempLoc)
pm.setKeyframe(ctrl )
else :
print 'From hand to world'
tempLoc = pm.spaceLocator(n='temp')
tempCnstr = pm.parentConstraint(ctrl,tempLoc)
pm.delete(tempCnstr)
ctrl.attr('Parent').set(1)
worldPos = tempLoc.getTranslation(space='world')
worldRot = tempLoc.getRotation(space='world')
ctrl.setTranslation(worldPos,space='world')
ctrl.setRotation(worldRot,space='world')
pm.delete(tempLoc)
pm.setKeyframe(ctrl )
else:
pm.warning('Select a ticket ctrl or the pound bill ctrl')
示例14: curve_drive
def curve_drive(curve):
grp_crv = 'curveDrive_GRP'
sel = pm.ls(sl=True)
for obj in sel:
if curve.getShape().type() == 'nurbsCurve':
CPOC = curve.closestPoint(obj.t.get())
if not pm.objExists(grp_crv):
grp = pm.group(em=True,n=grp_crv)
grp.visibility.set(0)
print curve, CPOC
pm.spaceLocator(p=CPOC)
示例15: create_radian_trigger
def create_radian_trigger(prefix):
prefix = ("%s_radianTrigger") %prefix
display = pm.group(empty=True, name="%s_display" %prefix)
display.overrideEnabled.set(1)
display.overrideDisplayType.set(2)
grp = pm.group(empty=True, name="%s_grp" %prefix)
loc = pm.spaceLocator(name = "%s_target" %prefix)
pm.addAttr(loc, at='double', ln="radical", k=True)
pm.addAttr(loc, at='double', ln="angle", k=True)
pos = pm.spaceLocator(name = "%s_pos" %prefix)
loc.ty.set(1)
loc.tz.set(1)
pos.tz.set(1)
radical_exp = '%s.radical = rad_to_deg( atan2( %s.translateY , %s.translateX ) )' %(loc.name(), loc.name(), loc.name())
angle_exp = "%s.angle = rad_to_deg( acos( %s.translateZ / (sqrt( pow(%s.translateX, 2) + pow(%s.translateY, 2) + pow(%s.translateZ, 2) ) ) ) )" %(loc.name(), loc.name(), loc.name(), loc.name(), loc.name())
pm.expression( o=loc, s= radical_exp, name="%s_radical_exp" %prefix)
pm.expression( o=loc, s= angle_exp, name="%s_angle_exp" %prefix)
planer_curve = "curve -d 1 -p 0 0 0 -p -1 0 0 -p -0.965926 0.258819 0 -p -0.765926 0.258819 0 -p -0.865926 0.258819 0 -p -0.865926 0.358819 0 -p -0.865926 0.158819 0 -p -0.865926 0.258819 0 -p -0.965926 0.258819 0 -p -0.866025 0.5 0 -p -0.707107 0.707107 0 -p -0.353553 0.353553 0 -p -0.707107 0.707107 0 -p -0.5 0.866025 0 -p -0.258819 0.965926 0 -p 0 1 0 -p 0 0.5 0 -p 0 1 0 -p 0.258819 0.965926 0 -p 0.5 0.866025 0 -p 0.707107 0.707107 0 -p 0.353553 0.353553 0 -p 0.707107 0.707107 0 -p 0.866025 0.5 0 -p 0.965926 0.258819 0 -p 1 0 0 -p 0.5 0 0 -p 1 0 0 -p 0.965926 -0.258819 0 -p 0.866025 -0.5 0 -p 0.707107 -0.707107 0 -p 0.353553 -0.353553 0 -p 0.707107 -0.707107 0 -p 0.5 -0.866025 0 -p 0.258819 -0.965926 0 -p 0 -1 0 -p 0 -0.5 0 -p 0 -1 0 -p -0.258819 -0.965926 0 -p -0.5 -0.866025 0 -p -0.707107 -0.707107 0 -p -0.353553 -0.353553 0 -p -0.707107 -0.707107 0 -p -0.866025 -0.5 0 -p -0.965926 -0.258819 0 -p -0.765926 -0.258819 0 -p -0.965926 -0.258819 0 -p -1 0 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 -k 40 -k 41 -k 42 -k 43 -k 44 -k 45 -k 46 -k 47"
planer = pm.PyNode(pm.mel.eval(planer_curve))
planer.rename("%s_planer" %prefix)
arrow_curve = 'curve -d 1 -p 0 0 0 -p 0 0.377909 0 -p -0.0449662 0.378085 0 -p 0 0.460303 0 -p 0.0449662 0.378085 0 -p 0 0.377909 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 ;'
arrow = pm.PyNode(pm.mel.eval(arrow_curve))
pm.makeIdentity(arrow, apply=True, t=True, r=True, s=True)
arrow.rename("%s_arrow" %prefix)
angle_curves = pm.circle(name="%s_angleCurve" %prefix, r=0.5)
pm.aimConstraint(pos, angle_curves[0], mo=False, aimVector=[0,1,0], upVector=[-1,0,0], worldUpType='object', worldUpObject=loc)
pm.parent(arrow, angle_curves)
loc.angle >> angle_curves[-1].sweep
posPointer = pm.curve(name='%s_posPointer'%prefix, d = 1, p = [(0,0,0), (0,0,1)])
pointer = pm.curve(name='%s_targetPointer'%prefix, d = 1, p = [(0,0,0), (0,0,0)])
pointer.inheritsTransform.set(0)
cls1 = pm.cluster(pointer.cv[0], name='%s_pointerClusterStart' %prefix)
cls2 = pm.cluster(pointer.cv[1], name='%s_pointerClusterEnd' %prefix)
pm.parent(pos, planer, angle_curves[0], cls1, pointer, posPointer, display)
pm.parent(display, loc, grp)
pm.parent(cls2, loc, r=True)
cls1[1].v.set(0)
cls2[1].v.set(0)
pos.v.set(0)