本文整理汇总了Python中maya.cmds.cluster函数的典型用法代码示例。如果您正苦于以下问题:Python cluster函数的具体用法?Python cluster怎么用?Python cluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cluster函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: RMCreateLineBetwenPoints
def RMCreateLineBetwenPoints (self, Point1, Point2):
Curve = cmds.curve (degree=1, p=[[0,0,0],[1,0,0]], name = "curveLineBetweenPnts")
Curve = self.NameConv.RMRenameBasedOnBaseName(Point1, Curve, NewName = Curve)
NumCVs = cmds.getAttr (Curve + ".controlPoints" , size = True)
Cluster1, Cluster1Handle = cmds.cluster (Curve+".cv[0]", relative=True, name = "clusterLineBetweenPnts")
Cluster1 = self.NameConv.RMRenameBasedOnBaseName(Point1 , Cluster1, NewName = Cluster1)
Cluster1Handle = self.NameConv.RMRenameBasedOnBaseName(Point1 , Cluster1Handle, NewName = Cluster1Handle)
Cluster2, Cluster2Handle = cmds.cluster (Curve+".cv[1]", relative=True, name = "clusterLineBetweenPnts")
Cluster2 = self.NameConv.RMRenameBasedOnBaseName(Point2 , Cluster2, NewName = Cluster2)
Cluster2Handle = self.NameConv.RMRenameBasedOnBaseName(Point2 , Cluster2Handle, NewName = Cluster2Handle)
cmds.setAttr(Curve+".overrideEnabled",1)
cmds.setAttr(Curve+".overrideDisplayType",1)
RMAlign (Point1, Cluster1Handle, 1)
RMAlign (Point2, Cluster1Handle, 1)
PointConstraint1 = cmds.pointConstraint (Point1, Cluster1Handle, name = "PointConstraintLineBetweenPnts")[0]
PointConstraint1 = self.NameConv.RMRenameBasedOnBaseName(Point1 , PointConstraint1, NewName = PointConstraint1)
PointConstraint2 = cmds.pointConstraint (Point2, Cluster2Handle, name = "PointConstraintLineBetweenPnts")[0]
PointConstraint2 = self.NameConv.RMRenameBasedOnBaseName(Point2 , PointConstraint2, NewName = PointConstraint2)
DataGroup = cmds.group (em = True,name = "DataLineBetweenPnts")
DataGroup = self.NameConv.RMRenameBasedOnBaseName(Point1 , DataGroup, NewName = DataGroup)
cmds.parent (Cluster1Handle, DataGroup)
cmds.parent (Cluster2Handle, DataGroup)
cmds.parent (Curve, DataGroup)
return DataGroup , Curve
开发者ID:rendermotion,项目名称:RMMel,代码行数:32,代码来源:RMRigTools.py
示例2: __init__
def __init__(self, objs = [], vertices = []):
self.objs = objs
self.vertices = vertices
#lattice -divisions 2 3 2 -objectCentered true -ol 1;
#mc.select( self.objs, self.vertices )
#CREATION
grp = mn.Node( mc.group( n = "head_toon_GRP", em = True ) )
deGrp = mn.Node( mc.group( n = "head_toon_deformer_GRP", em = True ) )
deGrp.parent = grp
deGrp.a.v.v = False
deGrp.a.v.locked = True
latNods = mc.lattice( self.objs, self.vertices, divisions = [ 2,3,2], objectCentered = True, ol = 1, n = 'head_toon_LAT' )
latBase = mn.Node( latNods[2] )
latBase.parent = deGrp
lat = mn.Node( latNods[1] )
lat.parent = deGrp
#mc.select( lat + ".pt[0:1][2][0]", lat + ".pt[0:1][2][1]" )
topClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][2][0]", lat.shape.name + ".pt[0:1][2][1]", n = 'top_face_toon_CLU' )[1] )
topClus.a.v.v = False
topClus.a.v.locked = True
#mc.select( lat + ".pt[0:1][1][0]", lat + ".pt[0:1][1][1]" )
midClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][1][0]", lat.shape.name + ".pt[0:1][1][1]", n = 'mid_face_toon_CLU' )[1] )
#mc.select( lat + ".pt[0:1][0][0]", lat + ".pt[0:1][0][1]" )
lowClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][0][0]", lat.shape.name + ".pt[0:1][0][1]", n = 'low_face_toon_CLU' )[1] )
ctl = crv.Curve( "head_toon_CTL" )
ctl = ctl.create( "sphere" )
ctl.a.t.v = topClus.worldPosition
mc.makeIdentity( ctl.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
topClus.parent = ctl
midClus.parent = deGrp
lowClus.parent = deGrp
ctl.parent = grp
#CONSTRAINS
midClus.a.r >> topClus.a.r
mc.pointConstraint( topClus.name, lowClus.name, midClus.name, mo = True )
#SCALE FOR MID CLUSTER
dist = mn.createNode( 'distanceBetween', n = 'head_toon_DIS' )
ctl.a.worldMatrix >> dist.a.inMatrix1
ctl.a.rp >> dist.a.point1
lowClus.a.worldMatrix >> dist.a.inMatrix2
lowClus.a.rp >> dist.a.point2
mul = mn.createNode( 'multiplyDivide', n = 'head_toon_scale_MUL' )
mul.a.input1.v = [dist.a.distance.v]*3
mul.a.operation.v = 2
dist.a.distance >> mul.a.input2X
dist.a.distance >> mul.a.input2Y
dist.a.distance >> mul.a.input2Z
mul.a.output >> midClus.a.s
#AIM CONSTRAINT
upLocGrp = mn.Node( mc.group( n = "head_upVector_GRP", em = True ) )
upLocGrp.a.t.v = midClus.worldPosition
mc.makeIdentity( upLocGrp.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
upLocGrp.parent = deGrp
mc.orientConstraint( ctl.name, lowClus.name, upLocGrp.name, mo = True )
upLoc = mn.Node( mc.spaceLocator( n = 'head_upVector_LOC' )[0] )
upLoc.a.t.v = midClus.worldPosition
upLoc.a.tz.v = upLoc.a.tz.v + 5
mc.aimConstraint( topClus.name, midClus.name, mo = True, weight = 1, aimVector = [1, 0, 0], upVector = [0, 1, 0], worldUpType = "object", worldUpObject = upLoc.name )
upLoc.parent = upLocGrp
mc.pointConstraint( topClus.name, lowClus.name, upLoc.name, mo = True )
开发者ID:skarone,项目名称:PipeL,代码行数:60,代码来源:head.py
示例3: autoEyebrowGuidePosition
def autoEyebrowGuidePosition(side = None, guideName = None):
objectName = side + "_" + guideName
sel = cmds.ls(os = 1, flatten = 1)
pos = []
cluster = []
# check which type of component is selected and store the position
for t in sel:
i = t
selType = t.split(".")[1][0]
if selType == "e":
vtx = cmds.polyListComponentConversion(i, fe = 1, tv = 1)
cmds.select(vtx)
cls = cmds.cluster()
clsPos = cmds.xform(cls, query = 1, rotatePivot = 1, worldSpace = 1)
pos.append(clsPos)
cluster.append(cls)
elif selType == "f":
vtx = cmds.polyListComponentConversion(i, ff = 1, tv = 1)
cmds.select(vtx)
cls = cmds.cluster()
clsPos = cmds.xform(cls, query = 1, rotatePivot = 1, worldSpace = 1)
pos.append(clsPos)
cluster.append(cls)
elif selType == "v":
cmds.warning("Select in another component mode! We are out of verts dude!!!")
else:
cmds.warning("No components selected dude!!!")
# check if guide group exists
if cluster:
if cmds.objExists(objectName + "_TRN"):
cmds.delete(objectName + "_TRN")
# create the guides
guides = defGuideCmds.defGuideCrv()
guides.__init__(nSpans = len(cluster)-1, curveDegree = 1, offset =.2, offsetVector = [1,0,0], side = side, name = guideName, startPosition = [0,0,0], ctlSize = 10)
cmds.delete("C_curve_TRN")
# delete the cluster
for c in cluster:
cmds.delete(c)
# list all the guides inside the guideName group except the curve
loc = cmds.listRelatives(objectName + "_TRN", allDescendents = 1, type = "transform")[:-1]
# reposition the guides at the vertices place
for i, p in zip(loc, pos):
cmds.xform(i, translation = p, worldSpace = 1)
# mirror the guides
cmds.select(loc)
guides.createMirror()
开发者ID:jonntd,项目名称:Public,代码行数:60,代码来源:tools_list.py
示例4: RMCreateClustersOnCurve
def RMCreateClustersOnCurve(self , curve = None):
if curve.__class__ in [str,unicode]:
masterCurve = curve
mode = "single"
#print ("degree:%s",degree)
#print ("spans:%s",spans)
#print ("form:%s",form)
elif curve.__class__ == list:
masterCurve = curve[0]
mode = "multi"
degree = cmds.getAttr (masterCurve + ".degree")
spans = cmds.getAttr (masterCurve + ".spans")
form = cmds.getAttr (masterCurve + ".form")
# Form (open = 0, closed = 1, periodic = 2)
clusterList=[]
if form == 0 or form ==1:
#print "Open Line"
for i in range(0 , (degree + spans)):
cluster = cmds.cluster(masterCurve + ".cv["+str(i)+"]",name=self.NameConv.RMUniqueName ("Character_MD_ClusterOnCurve_cls_rig"))
if mode == "multi":
self.RMAddToCluster(i , curve[1:],cluster)
clusterList.append(cluster[1])
cmds.setAttr(cluster[1]+".visibility",0)
##cmds.cluster(cluster,edit=True,geometry = curve + ".["+str(i)+"]")
if form == 2:
#print "periodic Line"
for i in range(0,spans):
cluster = cmds.cluster(masterCurve+".cv["+str(i)+"]" ,name = self.NameConv.RMUniqueName ("Character_MD_ClusterOnCurve_cls_rig"))
if mode == "multi":
self.RMAddToCluster(i , curve[1:], cluster)
clusterList.append(cluster[1])
cmds.setAttr(cluster[1]+".visibility",0)
#cmds.cluster(cluster,edit=True,geometry = curve + ".["+str(i)+"]")
return clusterList
开发者ID:rendermotion,项目名称:RMMel,代码行数:34,代码来源:RMLaces.py
示例5: rebuild
def rebuild(self):
'''
Rebuild the cluster deformer from the recorded deformerData
'''
# Check target geometry
for obj in self.deformerData.iterkeys():
if not mc.objExists(obj): raise UserInputError('Object '+obj+' does not exist!')
# Check deformer
if mc.objExists(self.deformerName):
raise UserInputError('Cluster '+self.deformerName+' already exists!')
# Rebuild deformer
cluster = None
if mc.objExists(self.handle):
cluster = mc.cluster(self.getMemberList(),n=self.deformerName,wn=(self.handle,self.handle))
else:
cluster = mc.cluster(self.getMemberList(),n=self.deformerName)
if cluster[1] != self.handle: mc.rename(cluster[1],self.handle)
deformer = cluster[0]
# Connect bindPreMatrix
if self.bindPreMatrix:
if mc.objExists(self.bindPreMatrix[0]):
mc.connectAttr(self.bindPreMatrix[0],cluster+'.bindPreMatrix')
# Connect geomMatrix
for conn in self.geomMatrix.iterkeys():
if mc.objExists(conn):
mc.connectAttr(conn+'.'+self.geomMatrix[conn][0],cluster+'.geomMatrix['+str(self.geomMatrix[conn][1])+']')
# Set cluster weights
self.loadWeights()
# Return result
return deformer
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:35,代码来源:clusterData.py
示例6: cameraFrustum_build
def cameraFrustum_build(cam_shape):
#make sure a camera is loaded
if cam_shape==0:
cmds.error('no camera loaded...select a camera and load')
else:
#create frustum only if one doesnt already exist
selCamXform = cmds.listRelatives(cam_shape[0], p=1)
prefix = 'frust_'
frustumGrpName = prefix + 'camera_frustum_all_grp'
if cmds.objExists(frustumGrpName)==0:
#create main grp
frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)
#create frustum geo
frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
cmds.delete(frustumGeo[0], constructionHistory=True)
cmds.parent(frustumGeo[0], frustumMainGrp)
#load plugin "nearestPointOnMesh.mll" if needed and connect
plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
if plugin==0:
cmds.loadPlugin('nearestPointOnMesh.mll')
nearNodeName = prefix + 'npomNode'
npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')
#create clusters
cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')
#create near/far/camera locs
cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
cmds.parent(cameraLoc[0], frustumMainGrp)
nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
cmds.move(0, 0, -1)
farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
cmds.move(0, 0, 1)
#parent clusters under loc -- parent locs under camera loc
cmds.parent(nearCluster[1], nearLoc[0])
cmds.parent(farCluster[1], farLoc[0])
cmds.parent(nearLoc[0], cameraLoc[0])
cmds.parent(farLoc[0], cameraLoc[0])
#constrain camera loc to camera
cmds.parentConstraint(selCamXform, cameraLoc, weight=1)
return frustumGeo[0]
开发者ID:aaronfang,项目名称:personal_scripts,代码行数:60,代码来源:getFacesInsideFrustum.py
示例7: create_ik
def create_ik(self):
"""Ik spline"""
# Create curve
tmp_curve = curve.create_from_nodes(self.joints, name=name.set_suffix(self.name, 'ikCrv'), degree=3)
self.curve = curve.rebuild_curve(tmp_curve, 3)[0]
start_joint, end_joint = self.ik_joints[0], self.ik_joints[-1]
logger.info("Creating Ik using nodes: %s" % self.joints)
self.ik, self.effector = cmds.ikHandle(name=name.set_suffix(self.name, 'ikh'), sj=start_joint, ee=end_joint, curve=self.curve, createCurve=False, sol="ikSplineSolver", ns=3)
# Add to setups
self.setups.extend([self.ik, self.curve])
# Set attrs
cmds.setAttr("%s.dTwistControlEnable" % self.ik, 1)
cmds.setAttr("%s.dWorldUpAxis" % self.ik, 1)
cmds.setAttr("%s.dWorldUpType" % self.ik, 4)
cmds.setAttr("%s.dWorldUpVector" % self.ik, 1.0, 0.0, 0.0, type="float3")
cmds.setAttr("%s.dWorldUpVectorEnd" % self.ik, 1.0, 0.0, 0.0, type="float3")
# Turn on cvs
cmds.select(self.curve, r=True)
cmds.toggle(cv=True)
# Create clusters
clusters = OrderedDict()
clusters['bot'] = cmds.cluster(["%s.cv[0]" % self.curve, "%s.cv[1]" % self.curve])[1]
clusters['mid'] = cmds.cluster(["%s.cv[2]" % self.curve, "%s.cv[3]" % self.curve])[1]
clusters['top'] = cmds.cluster(["%s.cv[4]" % self.curve, "%s.cv[5]" % self.curve])[1]
xform.match_pivot(start_joint, clusters['bot'])
xform.match_pivot(end_joint, clusters['top'])
self.clusters = clusters
开发者ID:eddiehoyle,项目名称:link,代码行数:35,代码来源:spline.py
示例8: parent_cluster
def parent_cluster(cluster_name):
cluster_parent = cmds.textField('UI_cluster_clusterName', q=True, tx=True)
cluster_parent = cluster_parent.replace (" ", "_")
cluster_parent = cmds.createNode( 'transform', n= 'trn_' + cluster_parent, ss=True)
centre = cmds.objectCenter("loc_guide_deformer", gl=True)
cmds.move(centre[0], centre[1], centre[2], cluster_parent)
cmds.cluster (name = cluster_name, bs = True, wn = (cluster_parent, cluster_parent))
cmds.delete("loc_guide_deformer")
开发者ID:MaxIsJames,项目名称:max-scripts,代码行数:8,代码来源:softcluster.py
示例9: crvGuide
def crvGuide( ctrl = '' , target = '' ) :
# Create NURBs curve between control and target
# Returns : curve and two clusters
crv = pc.Dag( mc.curve( d = 1 , p = [ ( 0 , 0 , 0 ) , ( 0 , 0 , 0 ) ] ) )
clstr1 = pc.Dag( mc.cluster( '%s.cv[0]' % crv , wn = ( ctrl , ctrl ) )[ 0 ] )
clstr2 = pc.Dag( mc.cluster( '%s.cv[1]' % crv , wn = ( target , target ) )[ 0 ] )
mc.select( cl = True )
return crv , clstr1 , clstr2
开发者ID:myCodeTD,项目名称:pkmel,代码行数:9,代码来源:rigTools.py
示例10: rebuild
def rebuild(self, overrides={}):
"""
Rebuild the cluster deformer from the recorded deformerData
@param overrides: Dictionary of data overrides to apply
@type overrides: dict
"""
# Apply Overrides
self._data.update(overrides)
# ==========
# - Checks -
# ==========
# Check target geometry
for obj in self._data["affectedGeometry"]:
if not mc.objExists(obj):
raise Exception('Deformer affected object "' + obj + '" does not exist!')
# ====================
# - Rebuild Deformer -
# ====================
# Build Cluster Deformer and Handle
if not mc.objExists(self._data["name"]):
# Create New Cluster
cluster = mc.cluster(self.getMemberList(), n=self._data["name"])
self._data["name"] = cluster[0]
else:
# Check Cluster
if mc.objectType(self._data["name"]) != "cluster":
raise Exception('Object "' + self._data["name"] + '" is not a valid cluster deformer!')
# Rebuild Deformer
result = super(ClusterData, self).rebuild(overrides)
# Restore ClusterHandle Data
if self._data["clusterHandle"]:
if not mc.objExists(self._data["clusterHandle"]):
raise Exception('Weighted Node "' + self._data["clusterHandle"] + '" does not exist!')
try:
mc.cluster(
self._data["name"],
edit=True,
bindState=True,
wn=(self._data["clusterHandle"], self._data["clusterHandle"]),
)
except:
pass
# =================
# - Return Result -
# =================
return result
开发者ID:auqeyjf,项目名称:glTools,代码行数:54,代码来源:clusterData.py
示例11: pvLine
def pvLine(name, icon, joint):
j=mel.eval('curve -d 1 -p 0 0 0 -p 1 0 0 -k 0 -k 1 ;')
k=cmds.rename(name)
c1=cmds.cluster('%s.cv[0]' % k, n='%s_cluster' % k)
c2=cmds.cluster('%s.cv[1]' % k, n='%s_cluster' % k)
cmds.parentConstraint(icon, c1, mo=0)
cmds.parentConstraint(joint, c2, mo=0)
i=cmds.group(k,c1,c2, n='%s_pad' % name)
cmds.setAttr('%sHandle.visibility' % c1[0], 0)
cmds.setAttr('%sHandle.visibility' % c2[0], 0)
cmds.setAttr('%sShape.overrideDisplayType' % k, 2)
cmds.setAttr('%sShape.overrideEnabled' % k, 1)
return i
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:13,代码来源:fsaIconModule.py
示例12: createIKCtrlsOnJnts
def createIKCtrlsOnJnts(ikCrv, parentCtrl, size=1):
ikCVNum = ll.getCurveCVCount(ikCrv)
prev=parentCtrl
for i in range(1, ikCVNum):
clus = mc.cluster('%s.cv[%d]'%(ikCrv, i), n=parentCtrl.replace('masterctrl','ikClus%d')%i)
cvPos = mc.xform('%s.cv[%d]'%(ikCrv, i), q=1, ws=1, t=1)
mc.select(parentCtrl)
meval('wireShape("plus")')
ikCtrl = mc.rename(masterCtrl.replace('masterctrl','ikCtrl%d'%i))
mc.xform(ikCtrl, t=cvPos, ws=1)
mc.scale(size, size, size, ikCtrl, ocp=1)
mc.makeIdentity(ikCtrl, a=1, s=1)
mc.parent(ikCtrl, parentCtrl)
lsZeroOut(ikCtrl)
ctrlPR = lsZeroOut(ikCtrl, 'PR')
mc.addAttr(ikCtrl, ln='SPACE', at='bool', k=1)
mc.setAttr(ikCtrl+'.SPACE', l=1)
mc.addAttr(ikCtrl, ln='parent', at='float', dv=0, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='master', at='float', dv=1, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='world', at='float', dv=0, min=0, max=1, k=1)
mc.parentConstraint(ikCtrl, clus)
cons = mc.parentConstraint(prev, parentCtrl, ctrlPR, mo=1)[0]
wal = mc.parentConstraint(cons, q=1, wal=1)
if len(wal) > 1:
mc.connectAttr(ikCtrl+'.parent', '%s.%s'%(cons, wal[0]), f=1)
mc.connectAttr(ikCtrl+'.master', '%s.%s'%(cons, wal[1]), f=1)
prev=ikCtrl
开发者ID:sayehaye3d,项目名称:ls-rigging-tools,代码行数:27,代码来源:hair.py
示例13: alignJawCtrl
def alignJawCtrl() :
# Align jaw control to jaw joint.
# Select jaw control curve then jaw joint.
sels = mc.ls( sl = True )
ctrl = sels[0]
jnt = sels[1]
shp = mc.listRelatives( ctrl , shapes=True )[0]
mc.select( shp , r=True )
fstCv = 14
scdCv = 2
fstPos = mc.xform( '%s.cv[%s]' % (shp,fstCv) , q=True , ws=True , t=True )
scdPos = mc.xform( '%s.cv[%s]' % (shp,scdCv) , q=True , ws=True , t=True )
midPos = [ (fstPos[0]+scdPos[0])/2 , (fstPos[1]+scdPos[1])/2 , (fstPos[2]+scdPos[2])/2 ]
clstr = mc.cluster()[1]
mc.select( clstr , r=True )
mc.move( midPos[0] , midPos[1] , midPos[2] , '%s.rotatePivot' % clstr )
mc.move( midPos[0] , midPos[1] , midPos[2] , '%s.scalePivot' % clstr )
mc.delete( mc.pointConstraint( jnt , clstr ) )
tipJnt = mc.listRelatives( jnt , type = 'joint' )[0]
if tipJnt :
mc.delete( mc.aimConstraint(tipJnt,clstr,aim=(0,0,1),u=(1,0,0),wut='vector',wu=(1,0,0)))
开发者ID:myCodeTD,项目名称:pkmel,代码行数:30,代码来源:rigTools.py
示例14: on_btn_Start_clicked
def on_btn_Start_clicked(self, clicked=None):
if clicked == None:return
geometry = str(self.LET_Geometry.text())
joints = [jnt.strip() for jnt in str(self.LET_Skeleton.text()).split(',')]
joints = [jnt for jnt in joints if mc.objExists(jnt)]
self.progressBar_A.setMaximum(len(joints))
self.progressLabel_A.setText('0/%d'%len(joints))
for i, jnt in enumerate(joints):
#- create cluster
cluster = mc.cluster(geometry, rel=True)
#- copy weights
res = transSkinWeightsToCluster(geometry, geometry, jnt, cluster[0], self.progressBar_B, self.progressLabel_B)
#if res:
##- weight Node
#mc.cluster(cluster[0], e=True, wn=(jnt, jnt))
##- delete handle
#mc.delete(cluster[1])
#- progerss
self.progressBar_A.setValue(i+1)
self.progressLabel_A.setText('%d/%d'%(i+1, len(joints)))
self.progressBar_A.setValue(0)
self.progressBar_A.setMaximum(1)
self.progressLabel_A.setText('0/0')
开发者ID:blenderdeluxe,项目名称:RiggingTeamTools,代码行数:31,代码来源:transWeights.py
示例15: softSelectionClusterWeights
def softSelectionClusterWeights(*args):
sel = mc.ls(sl=True, o=True)
if not sel:
raise RuntimeError('Please select some vertices.')
weights = getSoftSelectionWeights()
if not weights:
raise RuntimeError('Please select some vertices.')
#get manipulator position for pivot
mc.setToolTo('Move')
moveMode = mc.manipMoveContext('Move', query=True, mode=True)
mc.manipMoveContext('Move', edit=True, mode=0)
position = mc.manipMoveContext('Move', query=True, position=True)
mc.manipMoveContext('Move', edit=True, mode=moveMode)
clusterNode, clusterHandle = mc.cluster(sel[0])
for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True):
weight = 0.0
if vert in weights.keys():
weight = weights[vert]
mc.percent(clusterNode, vert, v=weight)
#set cluster pivot
mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2]))
clusterShape = mc.listRelatives(clusterHandle, c=True, s=True)
mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2])
开发者ID:liudger,项目名称:ml_tools,代码行数:31,代码来源:ml_softWeights.py
示例16: createMasterCtrl
def createMasterCtrl(self, ctrl, offsetCtrl, curveShape, size, offsetScale):
cmds.file(PATH + curveShape + ".ma", i=True, rdn =True)
cmds.rename('control', ctrl)
cmds.file(PATH + "circle.ma", i=True, rdn =True)
cmds.rename('control', offsetCtrl)
cmds.xform(offsetCtrl, scale=[offsetScale, offsetScale, offsetScale ])
cmds.makeIdentity(offsetCtrl, apply=True, s=True)
cmds.parent(offsetCtrl, ctrl)
cmds.addAttr(ctrl, at='bool', ln="offsetCtrl", dv=1)
cmds.setAttr(ctrl + ".offsetCtrl", k=False, cb=True)
offsetCtrlShapes = cmds.listRelatives(offsetCtrl, shapes=True)
for offsetCtrlShape in offsetCtrlShapes:
cmds.connectAttr(ctrl+".offsetCtrl", offsetCtrlShape+".visibility")
cluster, clusterHandle = cmds.cluster(ctrl, name=ctrl+"_cluster")
cmds.setAttr(clusterHandle + '.visibility', 0)
cmds.setAttr(cluster + '.relative', 1)
cmds.parent(clusterHandle, ctrl)
cmds.addAttr(ctrl, at='double', ln="iconSize", minValue=0.1, dv=size, k=True)
cmds.setAttr(ctrl + ".iconSize", k=False, cb=True)
cmds.connectAttr(ctrl+".iconSize", clusterHandle+".scaleX")
cmds.connectAttr(ctrl+".iconSize", clusterHandle+".scaleY")
cmds.connectAttr(ctrl+".iconSize", clusterHandle+".scaleZ")
cmds.setAttr(ctrl+".offsetCtrl", 0)
开发者ID:adamfok,项目名称:afok_toolset,代码行数:30,代码来源:asset.py
示例17: createTemplate
def createTemplate(self , eyeMesh):
# create eye jnt
eyeJnt=[]
if 'L_' in str(eyeMesh):
helpClu = mc.cluster(eyeMesh)[0]
LeyeJnt = mc.joint(p=(0,0,0),name=eyeMesh+'_skin_jnt')
self.fromAtoB(eyeJnt,helpClu,1)
ReyeJnt = mc.mirrorJoint(mirrorYZ=True,mirrorBehavior=False,searchReplace=('L_', 'R_')
eyeJnt.append(LeyeJnt)
eyeJnt.append(ReyeJnt)
else:
self.mayaError('Please select the left eye.')
return eyeJnt
def createEyeRig(self):
if mc.objExists(self.eyeGlobalCtrl) == False:
EyesGlobalCtrl = mc.curve(d=1,p=[(-1.069806, 1.027703, 0),(-1.651954,1.89895,0),(-2.523201,2.481098,0),(-3.550904,2.68552,0),(-4.578607,2.481098,0),(-5.449854,1.89895,0),(-6.032002,1.027703,0),(-6.236424,0,0),(-6.032002,-1.027703,0),(-5.449854 ,-1.89895, 0),(-4.578607,-2.481098,0), (-3.550904,-2.68552,0),(-2.523201, -2.481098, 0),(-1.651954,-1.89895,0),(-1.069806,-1.027703,0),(1.058138,-1.032345,0),(1.642915, -1.907527,0),(2.518098,-2.492305,0),( 3.550443,-2.69765,0),(4.582788,-2.492305,0),(5.45797,-1.907527,0),( 6.042748,-1.032345,0),(6.248093,0,0),(6.042748,1.032345,0),( 5.45797,1.907527,0 ),(4.582788,2.492305,0),( 3.550443,2.69765,0),(2.518098,2.492305,0 ),(1.642915,1.907527,0),(1.058138,1.032345,0),( -1.069806,1.027703,0)],k=[0,1,2,3,4,5,6,7,8,9,10,11,12 ,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],n=self.eyeGlobalCtrl)
L_EyeAimCtrl = mc.curve(d=1,p=[(3.653116 ,0.946994,0), (3.653116 ,0 ,0),( 2.706122, 0, 0) , (3.653116 ,0, 0),(4.600109, 0 ,0) , (3.653116 ,0, 0) , (3.653116 ,-0.946994, 0) ],k=[0, 1, 2 ,3 ,4 ,5 , 6 ],n='L_'+self.eyeAimCtrl)
R_EyeAimCtrl = mc.curve(d=1,p=[(3.653116 ,0.946994,0), (3.653116 ,0 ,0),( 2.706122, 0, 0) , (3.653116 ,0, 0),(4.600109, 0 ,0) , (3.653116 ,0, 0) , (3.653116 ,-0.946994, 0) ],k=[0, 1, 2 ,3 ,4 ,5 , 6 ],n='R_'+self.eyeAimCtrl)
mc.parent(L_EyeAimCtrl , EyesGlobalCtrl)
mc.parent(R_EyeAimCtrl , EyesGlobalCtrl)
self.fastGrp('On' , ['zero','con','sdk'],L_EyeAimCtrl)
self.fastGrp'On' , ['zero','con','sdk'],R_EyeAimCtrl)
zeroGrp = self.fastGrp('On' , ['zero','con','sdk'],EyesGlobalCtrl)[2]
开发者ID:wangqinghuaTudou,项目名称:test,代码行数:27,代码来源:Eye.py
示例18: copy_joint_weights_to_cluster
def copy_joint_weights_to_cluster(skin_mel_node, joint_mel_node):
'''
'''
#- initlize api nodes
skin_mfn_node = OpenMayaAnim.MFnSkinCluster(pymel.core.PyNode(skin_mel_node).__apiobject__())
joint_dag_path = OpenMaya.MDagPath(pymel.core.PyNode(joint_mel_node).__apiobject__())
#- get joint influcenced points and weight values
components = OpenMaya.MSelectionList()
weights = OpenMaya.MDoubleArray()
skin_mfn_node.getPointsAffectedByInfluence(joint_dag_path, components, weights)
#- create cluster
component_strings = list()
components.getSelectionStrings(component_strings)
cluster_mel_node = mc.cluster(component_strings)[0]
clus_mfn_node = OpenMayaAnim.MFnWeightGeometryFilter(pymel.core.PyNode(cluster_mel_node).__apiobject__())
#- get geometry's dagpath and component
geo_dag_path = OpenMaya.MDagPath()
geo_comp_obj = OpenMaya.MObject()
components.getDagPath(0, geo_dag_path, geo_comp_obj)
#- convert skinweights type to cluster weights type
cluster_weights_array = OpenMaya.MFloatArray()
for v in weights:
cluster_weights_array.append(v)
#- set weights
clus_mfn_node.setWeight(geo_dag_path, geo_comp_obj, cluster_weights_array)
开发者ID:zclongpop123,项目名称:BlackBox,代码行数:30,代码来源:copy_joint_weights_to_cluster.py
示例19: setup_blendshape_lattice
def setup_blendshape_lattice(side = None,
blendShape = None,
divisions = [2,5,2],
ldv = [2,2,2],
parent = None):
#--- this method setups the lattice deformer
lat = cmds.lattice(blendShape,
divisions = divisions,
objectCentered = True,
ldv = ldv)
cmds.setAttr(lat[1] + '.v', 0)
cmds.parent(lat, 'Shapes')
points = cmds.ls(lat[1] + '.pt[*]', flatten = True)
for point in range(len(points)):
pos = cmds.xform(points[point], query = True, translation = True, worldSpace = True)
cPoint = node.nControl(position = pos,
color = 17,
size = 1,
shape = 1,
side = side,
description = "latPoint" + str(point),
parent = parent,
rotateOrder = 2)
cmds.setAttr(cPoint.control['transform'] + '.v', lock = False)
cmds.connectAttr('C_bedMid_CTL.latticeControls', cPoint.control['transform'] + '.v')
cls = cmds.cluster(points[point], name = side + '_latCluster' + str(point) + '_CLS')
for axis in 'xyz':
cmds.connectAttr(cPoint.control['transform'] + '.t' + axis, cls[1] + '.t' + axis)
cmds.parent(cls[1], 'Shapes')
cmds.setAttr(cls[1] + '.v', 0)
开发者ID:jonntd,项目名称:Public,代码行数:31,代码来源:tools_list.py
示例20: cluster_on_curve
def cluster_on_curve(self, crv):
"""Creates a cluster on each cv on the given curve.
@param crv: the curve
@type crv: String
@return: a list of all clusters
"""
clsName = str(crv)[:-4]
degree = cmds.getAttr(crv+".degree")
spans = cmds.getAttr(crv + ".spans")
cvs = degree + spans
clsReturn = list()
for i in range(0, cvs):
cmds.select(crv + ".cv[" + str(i) +"]", r=True)
cls = cmds.cluster(en=1)
grp = ""
if i==0:
cmds.rename(cls[1],(clsName + "Root" + "_" + 'CLS'))
grp = cmds.group(n=(clsName + "Root" + "_" + 'CLS' + "_" + 'GRP'))
elif i==(cvs-1):
cmds.rename(cls[1],(clsName + "End" + "_" + 'CLS'))
grp = cmds.group(n=(clsName + "End" + "_" + 'CLS' + "_" + 'GRP'))
else:
cmds.rename(cls[1],(clsName + str(i) + "_" + 'CLS'))
grp = cmds.group(n=(clsName + str(i) + "_" + 'CLS' + "_" + 'GRP'))
# END if
#clsAr[i] = grp
clsReturn.append(grp)
cmds.setAttr(grp + ".visibility", 0)
# END for
return clsReturn
开发者ID:jonntd,项目名称:Rigganator,代码行数:31,代码来源:rigconvenience.py
注:本文中的maya.cmds.cluster函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论