本文整理汇总了Python中maya.cmds.spaceLocator函数的典型用法代码示例。如果您正苦于以下问题:Python spaceLocator函数的具体用法?Python spaceLocator怎么用?Python spaceLocator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spaceLocator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: MakePointOnSurfaceNd
def MakePointOnSurfaceNd(surface):
mc.select ("mesh_*MouthLip")
lx_mesh = mc.ls(sl=1)
mc.select ("snd_mouthLip*")
lx_sndJnt = mc.ls(sl=True )
lx_node ,lx_locGrp=[],[]
for lx_i in lx_sndJnt :
lx_temp=mc.xform(lx_i,q=1,ws =1,t=1)
lx_locN= "loc_"+lx_i
mc.spaceLocator(n=lx_locN,a=1,p=(lx_temp[0],lx_temp[1],lx_temp[2]))
lx_locGrp.append(lx_locN)
lx_null = 'grp_'+lx_i+'02'
mc.group(n=lx_null,em =1)
mc.toggle (lx_null,la=1)
mc.parent (lx_null ,('grp_'+lx_i+'01'))
mc.parent (('grp_'+lx_i+'03'),lx_null)
nd=mc.pointOnSurface(lx_mesh,ch=True )
#lx_node.insert(1,nd);
ndName = "pntNd_"+lx_i
mc.rename(nd,ndName )
mc.connectAttr ((ndName +".position"),('grp_'+lx_i+'02.translate'))
mc.setAttr (('grp_'+lx_i+'01.translate'),0,0,0,type ="double3")
mc.setAttr (('grp_'+lx_i+'03.translate'),0,0,0,type="double3")
mc.xform (('grp_'+lx_i+'01'),cp=True)
mc.select(cl=1)
mc.select(lx_locGrp )
mc.group (n="grp_locMouthLip01")
开发者ID:auqeyjf,项目名称:pubTool,代码行数:27,代码来源:j_MakeFacial.py
示例2: pointOnCurveLocCV
def pointOnCurveLocCV(name,curve):
if not cmds.nodeType(curve) == 'shape':
curve = cmds.listRelatives(curve, type = 'shape')[0]
mobject = GenAPI.getMObject(curve)
iterCVs = om.MItCurveCV(mobject)
while not iterCVs.isDone():
index = iterCVs.index()
nameIndex = index + 1
moPath = cmds.createNode('motionPath')
moPath = cmds.createNode('motionPath',n = '%s_0%i_MotionPath'%(name,nameIndex))
cmds.connectAttr('%s.worldSpace[0]'%curve,'%s.geometryPath'%moPath)
locator = cmds.spaceLocator(n = '%s_0%i_MP_Loc'%(name,nameIndex))
cmds.addAttr(locator[0],ln = "Offset" ,at = 'double')
cmds.setAttr('%s.Offset'%locator[0], e = True, keyable = True)
upLocator = cmds.spaceLocator(n = '%s_0%i_MP_Up_Loc'%(name,nameIndex))
cmds.connectAttr('%s.allCoordinates'%moPath,'%s.translate'%locator[0])
cmds.connectAttr('%s.rotate'%moPath,'%s.rotate'%locator[0])
cmds.connectAttr('%s.rotateOrder'%moPath, '%s.rotateOrder'%locator[0])
uValue = MeasuringTool.curveCVtoU(curve,index)
cmds.setAttr('%s.uValue'%moPath, uValue)
cmds.setAttr('%s.worldUpType'%moPath, 2)
cmds.setAttr ('%s.frontAxis'%moPath,0)
cmds.setAttr ('%s.upAxis'%moPath,2)
offsetMD = cmds.createNode('multiplyDivide', n = '%s_0%i_Offset_MD'%(locator[0],nameIndex))
cmds.connectAttr('%s.Offset'%locator[0],'%s.input1X'%offsetMD)
cmds.setAttr('%s.input2X'%offsetMD, 0.1)
offsetPMA = cmds.createNode('plusMinusAverage', n = '%s_0%i_Offset_PMA'%(locator[0],nameIndex))
cmds.connectAttr('%s.outputX'%offsetMD,'%s.input1D[0]'%offsetPMA )
cmds.setAttr('%s.input1D[1]'%offsetPMA,uValue)
cmds.connectAttr('%s.output1D'%offsetPMA, '%s.uValue'%moPath)
locPos = cmds.xform(locator[0], q = True, ws = True, translation = True)
locOrient = cmds.xform(locator[0], q = True, ws = True, rotation = True)
cmds.setAttr ('%s.worldUpVectorX'%moPath,0)
cmds.setAttr ('%s.worldUpVectorY'%moPath,0)
cmds.setAttr ('%s.worldUpVectorZ'%moPath,1)
cmds.connectAttr('%s.worldMatrix[0]'%upLocator[0], '%s.worldUpMatrix'%moPath)
nullGroup = cmds.group(empty = True, n = '%s_Group'%upLocator[0])
cmds.move(locPos[0], locPos[1],locPos[2],nullGroup)
cmds.rotate(locOrient[0],locOrient[1],locOrient[2], nullGroup)
cmds.parent(upLocator[0], nullGroup,r = True)
cmds.move(0,0,10,upLocator[0], a = True, os = True)
cmds.group(locator[0],nullGroup,n = '%s_0%i_MP_Loc_Group'%(name,nameIndex))
iterCVs.next()
开发者ID:Owacle,项目名称:maya-toolbelt,代码行数:60,代码来源:MeasuringLib.py
示例3: rotateOrderReference
def rotateOrderReference(self, rotorder, *args):
if rotorder == 0:
# 既に存在するかチェック
if cmds.objExists("locatorXYZ"):
print ("locatorXYZ exists already.")
else:
cmds.spaceLocator(p=(0, 0, 0), n="locatorXYZ")
cmds.select("locatorXYZ")
cmds.setAttr("locatorXYZ.rotateOrder", 0)
if rotorder == 2:
# 既に存在するかチェック
if cmds.objExists("locatorXYZ"):
print ("locatorZXY exists already.")
else:
cmds.spaceLocator(p=(0, 0, 0), n="locatorZXY")
cmds.select("locatorZXY")
cmds.setAttr("locatorZXY.rotateOrder", 2)
else:
print ("Info: RotateOrder Input Parameter Error <Sync Unity Transform> ")
开发者ID:Polytrash,项目名称:Unity_script,代码行数:25,代码来源:SyncUnityTransform.py
示例4: aimRig
def aimRig(self,name):
#query start location and orient
startPosition = MeasuringTool.getPointLocation(self.objectStart)
startOrient = MeasuringTool.getWorldEulerRotation(self.objectStart)
#create locators
aimLoc = cmds.spaceLocator(n = '%s_Aim_AimVector_Loc'%(name))
upLoc = cmds.spaceLocator(n = '%s_Aim_UpVector_Loc'%(name))
tgt = cmds.spaceLocator(n = '%s_Aim_Target_Loc'%(name))
#create hierarchy
posNull = cmds.group(aimLoc[0],upLoc[0],tgt[0],n = '%s_Aim_Pos_Null'%(name))
cmds.move(startPosition[0],startPosition[1],startPosition[2],posNull)
cmds.rotate(startOrient[0],startOrient[1],startOrient[2],posNull)
#find vector length
distance = self.getPointDistanceBetween()
length = MeasuringTool.getVectorLength([distance[0],distance[1],distance[2]])
#move and apply constraints to target
cmds.move(length,0,0,tgt, a = True, os = True)
cmds.move(0,0,10,upLoc[0],os = True)
cmds.parentConstraint(self.objectStart,posNull)
cmds.pointConstraint(self.objectEnd,tgt[0])
cmds.aimConstraint(tgt,aimLoc, aimVector = (1,0,0), upVector = (0,0,1), worldUpType = "object", worldUpObject = upLoc[0])
开发者ID:Owacle,项目名称:maya-toolbelt,代码行数:28,代码来源:MeasuringLib.py
示例5: setup_dof
def setup_dof(target, camera, f_stop):
cmds.setAttr(camera + ".depthOfField", 1)
# create a locator parented to the camera
cam_matrix = cmds.xform(camera, q=True, m=True, ws=True)
cam_locator = cmds.spaceLocator()
cmds.xform(cam_locator, m=cam_matrix, ws=True)
cmds.select(cam_locator, camera, r=True)
cmds.parent()
# create a locator parented to the target
target_matrix = cmds.xform(target, q=True, m=True, ws=True)
target_locator = cmds.spaceLocator()
cmds.xform(target_locator, m=target_matrix, ws=True)
cmds.select(target_locator, target, r=True)
cmds.parent()
distance_node = cmds.distanceDimension(cam_locator, target_locator)
cmds.connectAttr(distance_node + ".distance", camera + ".focusDistance")
f_stop_multiplier = 1.0
while f_stop < 1.0:
f_stop *= 2.0
f_stop_multiplier /= 2.0
cmds.setAttr(camera + ".fStop", f_stop)
cmds.setAttr(camera + ".focusRegionScale", f_stop_multiplier)
开发者ID:dictoon,项目名称:mescaline_utils,代码行数:27,代码来源:mescaline_setup.py
示例6: bdGetComMain
def bdGetComMain():
locators = cmds.ls('locator*')
if locators:
cmds.delete(locators)
mDagObject = om.MDagPath()
mSelList = om.MSelectionList()
om.MGlobal.getActiveSelectionList(mSelList)
centerMass = om.MPoint(0,0,0)
mSelList.getDagPath(0,mDagObject)
print centerMass.x, centerMass.y, centerMass.z
if mSelList.length():
if mDagObject.hasFn(om.MFn.kMesh):
mFnMesh = om.MFnMesh(mDagObject)
for i in range(mFnMesh.numVertices()):
mVertPos = om.MPoint()
mFnMesh.getPoint(i,mVertPos,om.MSpace.kWorld)
print i
print mVertPos.x, mVertPos.y,mVertPos.z
centerMass += om.MVector(mVertPos)
print centerMass.x, centerMass.y,centerMass.z
cmds.spaceLocator(p=[mVertPos.x,mVertPos.y,mVertPos.z])
print mFnMesh.numVertices()
centerMass = centerMass / (mFnMesh.numVertices())
cmds.spaceLocator(p=[centerMass.x,centerMass.y,centerMass.z])
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:33,代码来源:bdApiGetCom_v01.py
示例7: createPathLocators
def createPathLocators(*argv):
oPathLoc = cmds.spaceLocator(n='pathLocator')
oStopLoc = cmds.spaceLocator(n='stopLocator')
oPathLocGrp = cmds.group(oPathLoc,n='pathLocatorGrp')
cmds.group(oStopLoc,n='stopLocatorGrp')
cmds.pathAnimation( oPathLocGrp, stu=0, etu=1000, fa='x', ua='y', bank=True, fm = True,c='pathCurve' )
cmds.parentConstraint(oPathLoc,oStopLoc,cmds.ls('*:Master_Anim')[0])
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:7,代码来源:pathUtils_old.py
示例8: setupSw
def setupSw(self):
for joint in self._joints:
name = joint.replace(nameLib.prefixNames.jointSuffix, "") + nameLib.prefixNames.locator
# create locators
worldLocator = mc.spaceLocator(name="world_" + name)
localLocator = mc.spaceLocator(name="local_" + name)
# group for locators
rootGroup = utils.makeGroup.MakeGroup(name=name + nameLib.prefixNames.offsetGroup)
mc.parent(worldLocator, rootGroup.groupName)
mc.parent(localLocator, rootGroup.groupName)
# snap locators to posittion
mc.delete(mc.parentConstraint(joint, rootGroup.groupName))
# put them into root group
mc.parent(rootGroup.groupName, self._parent)
# orient constrain from global control
mc.orientConstraint(nameLib.prefixNames.globalControl + nameLib.prefixNames.controlSuffix, worldLocator, maintainOffset=True)
# constraint from parent
parent = mc.listRelatives(joint, parent=True)[0].replace(nameLib.prefixNames.jointSuffix, "")
parentControl = nameLib.prefixNames.fkPrefix + parent + nameLib.prefixNames.controlSuffix
mc.parentConstraint(parentControl, rootGroup.groupName, maintainOffset=True)
# create constraint for cotroller's driven group
drivenGroup = nameLib.prefixNames.fkPrefix + name.replace(nameLib.prefixNames.locator, "") + nameLib.prefixNames.controlSuffix + nameLib.prefixNames.drivenGroup
localWorldConstraint = mc.parentConstraint(worldLocator, drivenGroup)
localWorldConstraint = mc.parentConstraint(localLocator, drivenGroup)
# create connections from controller
weightList = [worldLocator[0] + "W0", localLocator[0] + "W1"]
self.connectSW(localWorldConstraint[0], parentControl, weightList)
开发者ID:robertvari,项目名称:rvRigTools,代码行数:35,代码来源:makeFKcontrol.py
示例9: set_knee_IK
def set_knee_IK():
# メッセージ
cmds.inViewMessage(amg="<hl>「指のコントローラー設置」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20)
# 座標取得
positionR = cmds.xform("Knee_R", q=True, ws=True, t=True)
locatorNameR = "Knee_R_Locator"
# ロケーター設置
cmds.spaceLocator(p=(positionR[0], positionR[1], positionR[2] + 3.8), n=locatorNameR)
knee_ik_add("Hip_R", "Ankle_R", "Knee_R_Effector", positionR, locatorNameR)
# 座標取得
positionL = cmds.xform("Knee_L", q=True, ws=True, t=True)
locatorNameL = "Knee_L_Locator"
# ロケーター設置
cmds.spaceLocator(p=(positionL[0], positionL[1], positionL[2] + 3.8), n=locatorNameL)
knee_ik_add("Hip_L", "Ankle_L", "Knee_L_Effector", positionL, locatorNameL)
# つま先のIK実行
toe_ik_add("Ankle_R", "MiddleToe2_R", "Ankle_R_Effector")
toe_ik_add("Ankle_L", "MiddleToe2_L", "Ankle_L_Effector")
# 足のコントローラー、 座標取得
toePositionR = cmds.xform("MiddleToe1_R", q=True, ws=True, t=True)
toePositionL = cmds.xform("MiddleToe1_L", q=True, ws=True, t=True)
foot_controller("foot_R_controller", toePositionR[0])
foot_controller("foot_L_controller", toePositionL[0])
# コントローラー内にエフェクター移動
cmds.parent("Ankle_L_Effector", "foot_L_controller")
cmds.parent("Knee_L_Effector", "foot_L_controller")
cmds.parent("Ankle_R_Effector", "foot_R_controller")
cmds.parent("Knee_R_Effector", "foot_R_controller")
# 親子関係移動
cmds.parent("Knee_R_Locator", "Knee_L_Locator", "foot_R_controller", "foot_L_controller", "main_controller")
开发者ID:akkey,项目名称:maya,代码行数:35,代码来源:LightSkeleton.py
示例10: setUp
def setUp(self):
cmds.file(newFile=True,f=True)
self.sphere = cmds.polySphere()
self.loc1 = cmds.spaceLocator()[0]
self.loc2 = cmds.spaceLocator()[0]
self.joint = cmds.joint()
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:7,代码来源:test_ClusterLib.py
示例11: createPoleVector
def createPoleVector(self, prefix=None, distanceScale=2, verbose=False):
print 'Building pole vector...'
if prefix is None:
prefix = self.prefix
# Create Joint Vectors
shoulderIkPos = cmds.xform(self.shoulder, q=True, ws=True, t=True)
shoulderIkVec = OpenMaya.MVector(shoulderIkPos[0], shoulderIkPos[1], shoulderIkPos[2])
elbowIkPos = cmds.xform(self.elbow, q=True, ws=True, t=True)
elbowIkVec = OpenMaya.MVector(elbowIkPos[0], elbowIkPos[1], elbowIkPos[2])
wristIkPos = cmds.xform(self.wrist, q=True, ws=True, t=True)
wristIkVec = OpenMaya.MVector(wristIkPos[0], wristIkPos[1], wristIkPos[2])
# Transpose vectors to correct pole vector translation point
bisectorVec = (shoulderIkVec * 0.5) + (wristIkVec * 0.5)
transposedVec = (elbowIkVec * distanceScale) - (bisectorVec * distanceScale)
ikChainPoleVec = bisectorVec + transposedVec
# Create a pole vector
poleVecCon = self.utils.createBoxControl('%selbowPV' % self.prefix, 0.125)
poleVecPos = [ikChainPoleVec.x, ikChainPoleVec.y, ikChainPoleVec.z]
cmds.xform(poleVecCon, t=poleVecPos)
self.utils.orientSnap(self.elbow, poleVecCon)
# Visualize Vectors and End Points
if verbose:
for vector, letter in zip([bisectorVec, transposedVec, ikChainPoleVec,
shoulderIkVec, elbowIkVec, wristIkVec],
['bisectorVec', 'transposedVec', 'ikChainPoleVec',
'shoulderIk', 'elbowIk', 'wristIk']):
cmds.spaceLocator(n='%sVecLoc' % letter, p=[vector.x, vector.y, vector.z])
cmds.curve(n='%sVecCurve' % letter, degree=1, p=[(0, 0, 0), (vector.x, vector.y, vector.z)])
return poleVecCon
开发者ID:carlkeifer3,项目名称:tbRigKit,代码行数:35,代码来源:arm.py
示例12: createDistanceNode
def createDistanceNode(**kwargs):
startTransform = kwargs.get('start')
endTransform = kwargs.get('end')
name = kwargs.get('name')
startPos = cmds.xform(startTransform,q = True,ws = True, translation = True)
endPos = cmds.xform(endTransform,q = True,ws = True, translation = True)
group = cmds.group(empty = True, name = '%s_Locator_Group'%name)
startGroup = cmds.group(empty = True, name = '%s_Start_Locator_Group'%name)
endGroup = cmds.group(empty = True, name = '%s_End_Locator_Group'%name)
cmds.parent(startGroup,group)
cmds.parent(endGroup,group)
startLocator = cmds.spaceLocator(name = '%s_Start_Locator'%name)[0]
endLocator = cmds.spaceLocator(name = '%s_End_Locator'%name)[0]
cmds.parent(startLocator,startGroup)
cmds.parent(endLocator,endGroup)
cmds.move(startPos[0],startPos[1],startPos[2],startLocator,ws = True)
cmds.move(endPos[0],endPos[1],endPos[2],endLocator,ws = True)
lengthNode = cmds.createNode('kLengthNode',name = '%s_Length'%name)
cmds.connectAttr('%s.worldMatrix[0]'%startLocator, '%s.startWorldMatrix'%lengthNode)
cmds.connectAttr('%s.parentInverseMatrix[0]'%startLocator, '%s.startParentInverseMatrix'%lengthNode)
cmds.connectAttr('%s.worldMatrix[0]'%endLocator, '%s.endWorldMatrix'%lengthNode)
cmds.connectAttr('%s.parentInverseMatrix[0]'%endLocator, '%s.endParentInverseMatrix'%lengthNode)
return lengthNode
开发者ID:Owacle,项目名称:maya-toolbelt,代码行数:34,代码来源:MayaScripts.py
示例13: _plotter_avrg
def _plotter_avrg(self):
'''plots a locator to a vertice or face per keyframe in a timeline'''
selObj=cmds.ls(sl=1, fl=1)
if len(selObj)>0:
pass
else:
print "Select 1 object"
return
getTopRange=cmds.playbackOptions(q=1, max=1)+1#get framerange of scene to set keys in iteration
getLowRange=cmds.playbackOptions(q=1, min=1)-1#get framerange of scene to set keys in iteration
edgeBucket=[]
getRange=arange(getLowRange,getTopRange, 1 )
getloc=cmds.spaceLocator(n=selObj[0]+"cnstr_lctr")
cmds.normalConstraint(selObj[0], getloc[0])
placeloc=cmds.spaceLocator(n=selObj[0]+"lctr")
for each in getRange:
cmds.currentTime(each)
transform=cmds.xform(selObj, q=1, ws=1, t=1)
posBucketx=self.array_median_find(transform[0::3])
posBuckety=self.array_median_find(transform[1::3])
posBucketz=self.array_median_find(transform[2::3])
cmds.xform(getloc[0], ws=1, t=(posBucketx, posBuckety, posBucketz))
cmds.SetKeyTranslate(getloc[0])
cmds.xform(placeloc[0], ws=1, t=(posBucketx, posBuckety, posBucketz))
cmds.SetKeyTranslate(placeloc[0])
rotate=cmds.xform(getloc[0], q=True, ws=1, ro=True)
cmds.xform(placeloc[0], ws=1, ro=rotate)
cmds.SetKeyRotate(placeloc[0])
cmds.currentTime(each)
开发者ID:edeglau,项目名称:storage,代码行数:29,代码来源:plot.py
示例14: _buildOffsetCloud
def _buildOffsetCloud(self,nodes,rootReference=None,raw=False):
'''
Build a point cloud up for each node in nodes
@param nodes: list of objects to be in the cloud
@param rootReference: the node used for the initial pibot location
@param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
'''
self.posePointCloudNodes=[]
self.posePointRoot=cmds.ls(cmds.spaceLocator(name='posePointCloud'),l=True)[0]
ppcShape=cmds.listRelatives(self.posePointRoot,type='shape')[0]
cmds.setAttr( "%s.localScaleZ" % ppcShape, 30)
cmds.setAttr( "%s.localScaleX" % ppcShape, 30)
cmds.setAttr( "%s.localScaleY" % ppcShape, 30)
if self.mayaUpAxis=='y':
cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
if rootReference:# and not mesh:
r9Anim.AnimFunctions.snap([rootReference,self.posePointRoot])
for node in nodes:
pnt=cmds.spaceLocator(name='pp_%s' % r9Core.nodeNameStrip(node))[0]
if not raw:
r9Anim.AnimFunctions.snap([node,pnt])
cmds.parent(pnt,self.posePointRoot)
self.posePointCloudNodes.append((pnt,node))
return self.posePointCloudNodes
开发者ID:miketon,项目名称:SymLink,代码行数:27,代码来源:Red9_PoseSaver.py
示例15: createCurveFromMesh
def createCurveFromMesh( meshName, centerIndices, startIndex, endIndices, numSample=20 ):
bb = om.MBoundingBox()
for i in centerIndices:
point = om.MPoint( *cmds.xform( meshName+'.vtx[%d]' % i, q=1, ws=1, t=1 ) )
bb.expand( point )
centerPoint = bb.center()
bb = om.MBoundingBox()
for i in endIndices:
point = om.MPoint( *cmds.xform( meshName+'.vtx[%d]' % i, q=1, ws=1, t=1 ) )
bb.expand( point )
endPoint = bb.center()
startPoint = om.MPoint( *cmds.xform( meshName+'.vtx[%d]' % startIndex, q=1, ws=1, t=1 ) )
aimVector = om.MVector( endPoint ) - om.MVector( startPoint )
eachPoints = []
multRate = 1.0/( numSample-1 )
for i in range( numSample ):
eachPoint = aimVector * (multRate*i) + om.MVector( centerPoint )
eachPoints.append( om.MPoint( eachPoint ) )
fnMesh = getMFnMesh( meshName )
mtx = fnMesh.dagPath().inclusiveMatrix()
mtxInv = mtx.inverse()
intersector = om.MMeshIntersector()
intersector.create( fnMesh.object() )
pointOnMesh = om.MPointOnMesh()
for point in eachPoints:
intersector.getClosestPoint( point*mtxInv, pointOnMesh )
closePoint = om.MPoint( pointOnMesh.getPoint() )*mtx
cmds.spaceLocator( p=[closePoint.x, closePoint.y, closePoint.z] )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:34,代码来源:cmdModel.py
示例16: test_setupHeirarchy
def test_setupHeirarchy(self):
#--- Setup the scene
startJnt = cmds.joint(n='startJnt',p=(3, 0, 0))
endJnt = cmds.joint(n='endJnt',p=(3, 5, -2))
locs = []
locs.append(cmds.spaceLocator(n='test_topLoc_pos', p=(0, 0, 1))[0])
locs.append(cmds.spaceLocator(n='test_midLoc_pos',p=(1, 2, 2))[0])
locs.append(cmds.spaceLocator(n='test_btmLoc_pos',p=(2, 4, 3))[0])
locGrp = cmds.group(em=True)
fGrp = cmds.group(em=True)
plane = cmds.nurbsPlane( w=1, lengthRatio=5, d=3, u=1, v=6, ax=[0, 0, 1])[0]
for each in locs:
cmds.parent(each,locGrp)
#--- Call method, get results
result = self.rig._setupHeirarchy(name='test', startObj=startJnt, endObj=endJnt,
locGrp=locGrp, plane=plane, follicleGrp=fGrp)
#--- Check Results
expectedTopNode = 'test_rbbnTopNode'
self.assertEqual(result, expectedTopNode)
self.assertTrue(cmds.objExists(expectedTopNode))
self.assertEqual(cmds.listRelatives(fGrp,parent=True)[0], expectedTopNode)
self.assertEqual(cmds.listRelatives(plane,parent=True)[0], expectedTopNode)
self.test.assertConstrained(startJnt,locs[2],type='parent')
self.test.assertConstrained(endJnt,locs[0],type='parent')
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:28,代码来源:test_RibbonRig.py
示例17: reCenterPivot
def reCenterPivot(obj):
locName = obj + "_loc"
cmds.spaceLocator(n=locName )
cmds.parent( locName, obj )
cmds.setAttr(locName + ".translateX",0)
cmds.setAttr(locName + ".translateY",0)
cmds.setAttr(locName + ".translateZ",0)
cmds.setAttr(locName + ".rotateX",0)
cmds.setAttr(locName + ".rotateY",0)
cmds.setAttr(locName + ".rotateZ",0)
cmds.Unparent(locName)
pConst = cmds.parentConstraint(obj,locName,mo=True,w=1)
cmds.bakeResults(locName,sm=True, t=(0,44),at=["tx","ty","tz","rx","ry","rz"])
cmds.delete(pConst)
newObj = cmds.duplicate(obj,n=obj+"_new")
cmds.xform(newObj[0],cp=True)
nConst = cmds.parentConstraint(locName,newObj, mo=True,w=1)
cmds.bakeResults(newObj,sm=True, t=(0,44),at=["tx","ty","tz","rx","ry","rz"])
cmds.delete(nConst)
cmds.delete(locName)
开发者ID:davidwilliamsDK,项目名称:maya,代码行数:27,代码来源:geo2Lego.py
示例18: joint
def joint(side, lowerJoint, upperJoint, useSphere=0, sharedUpper=0, sharedLower=0, show=1, heightScale=1):
name = lowerJoint + "_" + upperJoint
upperName = "SKEL_"
if sharedUpper == 0:
upperName += side + "_"
upperName += upperJoint
lowerName = "SKEL_"
if sharedLower == 0:
lowerName += side + "_"
lowerName += lowerJoint
print name
cmds.spaceLocator(name="%s_%s" % (side, name))
cmds.pointConstraint(lowerName, "%s_%s" % (side, name))
cmds.pointConstraint(upperName, "%s_%s" % (side, name))
cmds.aimConstraint(upperName, "%s_%s" % (side, name))
if useSphere:
cmds.sphere(name="%s_%s_C" % (side, name), radius=1)
else:
cmds.cylinder(name="%s_%s_C" % (side, name), radius=0.5, heightRatio=6 * heightScale)
cmds.setAttr("%s_%s_C.doubleSided" % (side, name), 0)
if show == 0:
cmds.setAttr("%s_%s_C.primaryVisibility" % (side, name), 0)
# cmds.rotate( 0, 0, 90, '%s_FOREARM_C' % (side) )
# cmds.makeIdentity( '%s_FOREARM_C' % (side), apply = 1, rotate = 1 )
cmds.select("%s_%s" % (side, name), "%s_%s_C" % (side, name))
cmds.parentConstraint()
return
开发者ID:torbensko,项目名称:Kinect-to-Maya-motion-capture,代码行数:32,代码来源:mayaKinectAutoRig.py
示例19: addOffsetRig
def addOffsetRig():
#===============================================================================
# SETUP LOCATORS FOR ALIGN AND AIM
#===============================================================================
# add offsetAimLocs to blockAimCrv
globalGrp = 'CT_teethOffset_mod_0'
mc.group(n=globalGrp, em=True)
name = 'CT_teethOffset'
targetCrv = 'CT_teethBlockAim_crv_0'
locs=[]
for locId in range(12):
loc = mc.spaceLocator(n=name+'_aim_loc_%d'%locId)[0]
mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
rt.attachToMotionPath(targetCrv, (float(locId)+0.5)/12, loc, True)
locs.append(loc)
mc.group(locs, n='CT_teethOffset_aim_loc_grp', p=globalGrp)
rt.connectVisibilityToggle(locs, globalGrp, 'aimLocs', False)
# add offsetAlignLocs to blockDrvCrv
targetCrv = 'CT_teethBlockDrv_crv_0'
locs=[]
for locId in range(12):
loc = mc.spaceLocator(n=name+'_align_loc_%d'%locId)[0]
mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
rt.alignOnMotionPath(targetCrv, (float(locId)+0.5)/12, loc, name+'_aim_loc_%d.matrix'%locId, True, ua=1, inverseUp=True)
locs.append(loc)
mc.group(locs, n='CT_teethOffset_align_loc_grp', p=globalGrp)
rt.connectVisibilityToggle(locs, globalGrp, 'alignLocs', False)
开发者ID:sayehaye3d,项目名称:ls-rigging-tools,代码行数:28,代码来源:teeth.py
示例20: build
def build(start=None, end=None, startLoc=None, endLoc=None, name=''):
'''
Creates a distance tool with locators aligned to start and end nodes
Returns a dictionary containing keys for shape, transform, startLoc and endLoc
If locators are supplied for either startLoc or endLoc, they are used in place of creating new ones
'''
if not start or not end:
return common.showDialog('Agument Error. Please supply start and end nodes')
distanceShape = cmds.createNode('distanceDimShape')
distanceTransform = cmds.listRelatives(distanceShape, parent=True, fullPath=True)
if not startLoc:
startLoc = cmds.spaceLocator(name = '%s_distance_start_loc' % name)[0]
common.align(startLoc, start)
if not endLoc:
endLoc = cmds.spaceLocator(name = '%s_distance_end_loc' % name)[0]
common.align(endLoc, end)
cmds.connectAttr('%s.worldPosition[0]' % startLoc, '%s.startPoint' % distanceShape)
cmds.connectAttr('%s.worldPosition[0]' % endLoc, '%s.endPoint' % distanceShape)
distanceTransform = cmds.rename(distanceTransform, name, ignoreShape=True)
distanceShape = cmds.rename(distanceShape, '%sShape' % distanceTransform)
returnDict = {'shape':distanceShape, 'xform':distanceTransform, 'start':startLoc, 'end':endLoc}
return returnDict
开发者ID:duncanrudd,项目名称:rooftops,代码行数:31,代码来源:measure.py
注:本文中的maya.cmds.spaceLocator函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论