本文整理汇总了Python中maya.cmds.rebuildCurve函数的典型用法代码示例。如果您正苦于以下问题:Python rebuildCurve函数的具体用法?Python rebuildCurve怎么用?Python rebuildCurve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rebuildCurve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createOnCurve
def createOnCurve( curve=None, numOfJnts=5, parent=True ):
"""
create specified number of joints on input curve
"""
curve = curveUtil.getShape(curve)
if numOfJnts < 2 :
cmds.error( "number of joints must be greater than 1.")
newJnts = []
curve = cmds.duplicate(curve)[0]
cmds.rebuildCurve (curve , ch=False ,rpo=True ,rt=0 ,end=1 ,kr=0 ,kcp=False ,kep=True ,kt=0 , s=200 , d=1 , tol=0.01 )
curveShape = curveUtil.getShape(curve)
cmds.select(clear=True)
segSize = 1.0/ (numOfJnts-1)
for i in range(numOfJnts):
pos = curveUtil.getPointAtParam(curveShape, segSize*i, 'world')
if not parent:
cmds.select(clear=True)
newJnts.append( cmds.joint(p=pos) )
cmds.delete(curve)
return newJnts
示例2: finalize
def finalize(self):
log.debug("returnList: %s"% self.returnList)
log.debug("createdList: %s"% self.createdList)
buffer = [] #self.i_module.templateNull.templateStarterData
log.debug("starting data: %s"% buffer)
#Make sure we have enough points
#==============
handles = self.i_module.templateNull.handles
if len(self.returnList) < handles:
log.warning("Creating curve to get enough points")
curve = curves.curveFromPosList(self.returnList)
mc.rebuildCurve (curve, ch=0, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0,s=(handles-1), d=1, tol=0.001)
self.returnList = curves.returnCVsPosList(curve)#Get the pos of the cv's
mc.delete(curve)
#Store info
#==============
for i,p in enumerate(self.returnList):
buffer.append(p)#need to ensure it's storing properly
#log.info('[%s,%s]'%(buffer[i],p))
#Store locs
#==============
log.debug("finish data: %s"% buffer)
self.templateNull.__setattr__('templateStarterData',buffer,lock=True)
#self.i_module.templateNull.templateStarterData = buffer#store it
log.info("'%s' sized!"%self.i_module.getShortName())
dragFactory.clickMesh.finalize(self)
示例3: createCurve
def createCurve(ptList,start,end,group=''):
'''
'''
# Initialize Curves
crvList = []
for pt in ptList:
pos = mc.pointPosition(pt)
curve = mc.curve(p=[pos,pos],d=1)
curve = mc.rename(curve,pt+'_curve')
crvList.append(curve)
# Track Curves
for i in range(start,end+1):
mc.currentTime(i)
for n in range(len(ptList)):
pos = mc.pointPosition(ptList[n])
mc.curve(crvList[n],a=True,p=pos)
# Remove Initial CV and Rebuild
for crv in crvList:
mc.delete(crv+'.cv[0]')
mc.rebuildCurve(crv,ch=False,rpo=True,rt=0,end=1,kr=2,kcp=True,kep=True)
# Group Curves
if group:
# Check Group
if not mc.objExists(group): group = mc.group(em=True,n=group)
# Parent Curves to Group
mc.parent(crvList,group)
# Return Result
if group: return [group]
else: return crvList
示例4: crvTendon
def crvTendon(curve,geo,precision=4,prefix='tendon'):
'''
'''
# rebuildCurve degree 1
baseCurve = mc.rebuildCurve(curve,ch=0,s=1,d=1,rpo=1,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1)
# create cv locators
baseLocs = glTools.utils.curve.locatorCurve(baseCurve,prefix=prefix+'_baseCrv')
# generate geo constraint curve
geoCurve = mc.rebuildCurve(baseCurve,ch=1,s=precsion,d=1,rpo=0,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1)
geoCurveLocs = glTools.utils.curve.locatorCurve(geoCurve,prefix=prefix+'_geoCrv')
# generate reference curve
refCurve = mc.rebuildCurve(baseCurve,ch=1,s=precsion,d=1,rpo=0,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1)
refCurveInfo = mc.createNode('curveInfo',n=prefix+'_ref_curveInfo')
mc.connectAttr(refCurve+'.worldSpace[0]',refCurveInfo+'.inputCurve',f=True)
refCurveLocs = []
for i in range(precsion+1):
refNull = mc.group(em=True,n=prefix+'_ref'+str(i)+'_null')
mc.connectAttr(refCurveInfo+'.controlPoints['+str(i)+']',refNull+'.t')
refCurveLocs.append(refNull)
# Locator Constraints
for i in range(precsion+1):
mc.pointConstraint(refCurveLocs[i],geoCurveLocs[i])
mc.geometryConstraint(geo,geoCurveLocs[i])
# fitBspline
bSpline = mc.fitBspline(geoCurve,ch=1)
示例5: createCurveaBasedOnLocator
def createCurveaBasedOnLocator( prevLoc, loc, baseName, hrsSys ):
leastSquaresMod = mn.createNode( 'leastSquaresModifier' )
origCurv = crv.Curve( mc.curve( d = 1, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
index = mm.eval( 'getNextFreeMultiIndex( "'+ hrsSys.name +'.inputHair", 0 )' )
origCurv.name = 'spiderWeb_base_'+ baseName + '_' + str( index ) + '_CRV'
mc.rebuildCurve( origCurv.name, rpo = 1, rt = 0, end = 1, kr = 0, kcp = 1, kep = 1, kt =0, s= 4, d = 1, tol = 0.01 )
origCurv.a.intermediateObject.v = 1
controledCurv = origCurv.duplicate()
origCurv.shape.attr( 'worldSpace[0]' ) >> leastSquaresMod.a.inputNurbsObject
prevLoc.attr( 'worldPosition[0]') >> leastSquaresMod.attr( 'pointConstraint[0].pointPositionXYZ' )
leastSquaresMod.attr( 'pointConstraint[0].pointConstraintU' ).v = 0
loc.attr( 'worldPosition[0]') >> leastSquaresMod.attr( 'pointConstraint[1].pointPositionXYZ' )
leastSquaresMod.attr( 'pointConstraint[1].pointConstraintU' ).v = 1
leastSquaresMod.a.outputNurbsObject >> controledCurv.shape.a.create
controledCurv.shape.attr( 'worldMatrix[0]' ) >> leastSquaresMod.a.worldSpaceToObjectSpace
fol = mn.createNode( 'follicle' )
fol.a.restPose.v = 1
fol.a.startDirection.v = 1
fol.a.pointLock.v = 3
fol.a.degree.v = 3
fol.a.sampleDensity.v = 3
fol.a.outHair >> hrsSys.attr( 'inputHair[' + str( index ) + ']' )
hrsSys.attr( 'outputHair[' + str( index ) + ']' ) >> fol.a.currentPosition
controledCurv.shape.attr( 'worldSpace[0]' ) >> fol.a.startPosition
curv = crv.Curve( mc.curve( d = 3, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
curv.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_CRV'
fol.a.outCurve >> curv.a.create
folPar = fol.parent
folPar.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_FOL'
return curv, folPar
示例6: __init__
def __init__(self, curve_sel, vertex_list):
self.curve_sel = curve_sel
self.verts = vertex_list
self.find_length = Find_Out()
self.link_length = self.find_length.edge_length(self.verts)
self.chain_length = self.find_length.curve_length(self.curve_sel)
self.link_total = int(self.chain_length/self.link_length)
cmds.duplicate(self.curve_sel, n = 'buildCurve')
cmds.rebuildCurve('buildCurve', ch = 1, rpo = 1, rt = 0, end = 1, kr = 2, kep = 1, kt = 0, kcp = 0, s = self.link_total/2, d = 3, tol = 0.01 )
self.num_cv = int(cmds.getAttr ('buildCurve.degree'))+ (cmds.getAttr ('buildCurve.spans'))
for dummy_cv in range(self.num_cv):
dummy_cv_pos = (cmds.getAttr ('buildCurve.cv['+ str(dummy_cv) +']'))
if dummy_cv == 0:
cmds.joint(n=self.curve_sel+'_jointRoot',p = dummy_cv_pos[0])
elif dummy_cv == self.num_cv - 1:
cmds.joint(n=self.curve_sel+'_jointEnd', p = dummy_cv_pos[0])
else:
cmds.joint(n=self.curve_sel+'_joint_'+(str(dummy_cv)),p = dummy_cv_pos[0])
cmds.delete('buildCurve')
cmds.ikHandle( sj = (self.curve_sel+'_jointRoot'), ee = (self.curve_sel+'_jointEnd'), c = self.curve_sel,
sol = 'ikSplineSolver', scv = 0, pcv = 0, ccv = 0, ns = 4)
示例7: buidleUpCurve
def buidleUpCurve(startOBJ, endObj, upOBJ):
startPosition = mc.xform(startOBJ, q=True, ws=True, t=True)
endPosition = mc.xform(endObj, q=True, ws=True, t=True)
upPosition = mc.xform(upOBJ, q=True, ws=True, t=True)
offsetVector = (upPosition[0] - startPosition[0]) * 0.25, (upPosition[1] - startPosition[1]) * 0.25, (upPosition[2] - startPosition[2]) * 0.25
startPosition = (startPosition[0] + offsetVector[0]), (startPosition[1] + offsetVector[1]), (startPosition[2] + offsetVector[2])
endPosition = (endPosition[0] + offsetVector[0]), (endPosition[1] + offsetVector[1]), (endPosition[2] + offsetVector[2])
Curve = mc.curve(d=1, p=(startPosition, endPosition))
mc.rebuildCurve(Curve, ch=0, s=3, d=3)
return Curve
示例8: build
def build( curve=None, numOfJnts=10, name="brow" ):
# soften input curve and delete history
curve = util.rename(curve, name=(name+"Low"), suffix="crv")[0]
curve = curveUtil.getShape( curve=curve )
cmds.rebuildCurve(curve, ch=0, rpo=1, rt=0, end=1, kr=0, kcp=1, kep=1, kt=0, s=4, d=3, tol=0.01 )[0]
cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1 )
# create the high res curve
curveHigh = cmds.rebuildCurve(curve, ch=0, rpo=0, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=numOfJnts, d=1, tol=0.01 )[0]
curveHigh = util.rename(curveHigh, name=(name+"High"), suffix="crv")[0]
return curve, curveHigh
示例9: RebuildWithNCVs
def RebuildWithNCVs (self,numberOfCvs,curve ):
if cmds.getAttr (curve+".form")==2:
if numberOfCvs >= 3:
curve = cmds.rebuildCurve(curve, spans = numberOfCvs,keepRange = 2)[0]
return curve
else:
return None
else:
if numberOfCvs >= 4:
curve = cmds.rebuildCurve(curve, spans = numberOfCvs - 3,keepRange = 2)[0]
return curve
else:
return None
示例10: createInterpolatedCurve
def createInterpolatedCurve(curve1, curve2, v):
interpolatedCurve = mc.duplicate(curve1, rr=True, rc=True)[0]
for shape in mc.listRelatives(curve2,shapes=True,fullPath=True):
cvList = (mc.ls([shape+'.cv[*]'],flatten=True))
mc.rebuildCurve(interpolatedCurve, ch=0, rpo=1, rt= 0, end = 1, kr = 0, kcp = 0, kep = 1, kt = 0, s = len(cvList)-3, d = 3, tol = 0)
for i in range(len(cvList)):
pos1 = mc.pointPosition('%s.cv[%i]' % (interpolatedCurve,i))
pos2 = mc.pointPosition('%s.cv[%i]' % (curve2,i))
newPos = ((pos2[0]-pos1[0])*v+pos1[0], (pos2[1]-pos1[1])*v+pos1[1], (pos2[2]-pos1[2])*v+pos1[2])
mc.move(newPos[0], newPos[1], newPos[2], '%s.cv[%i]' % (interpolatedCurve,i), a=True)
return interpolatedCurve
示例11: makeCenterCurve
def makeCenterCurve( crvs, rebuildSpanRate= 1.0 ):
crvShapes = []
for crv in crvs:
crvShape = getShape( crv )
if not crvShape: continue
crvShapes.append( crvShape )
lengthAll = 0.0
crvInfo = cmds.createNode( 'curveInfo' )
for crvShape in crvShapes:
if not cmds.isConnected( crvShape+'.local', crvInfo+'.inputCurve' ):
cmds.connectAttr( crvShape+'.local', crvInfo+'.inputCurve', f=1 )
length = cmds.getAttr( crvInfo+'.arcLength' )
lengthAll += length
cmds.delete( crvInfo )
lengthAverage = lengthAll / len( crvShapes )
rebuildSpans = int( lengthAverage * rebuildSpanRate )
for crvShape in crvShapes:
cmds.rebuildCurve( crvShape, constructionHistory=0,
replaceOriginal=1,
rebuildType=0,
endKnots=1,
keepRange=0,
keepControlPoints=0,
keepEndPoints=1,
keepTangents=0,
s=rebuildSpans, d=3, tol=0.01 )
fnNurbsCurve = om.MFnNurbsCurve( getDagPath( crvShapes[0] ) )
numCVs = fnNurbsCurve.numCVs()
points = []
for i in range( numCVs ):
points.append( [0,0,0] )
curve = cmds.curve( p=points, d=3 )
for i in range( numCVs ):
sumPoints = om.MVector(0,0,0)
for crvShape in crvShapes:
sumPoints += om.MVector( *cmds.xform( crvShape+'.controlPoints[%d]' % i, q=1, os=1, t=1 ) )
averagePoints = sumPoints / len( crvShapes )
cmds.move( averagePoints.x, averagePoints.y, averagePoints.z, curve+'.controlPoints[%d]' % i, os=1 )
return curve
示例12: CurveShapes
def CurveShapes(self):
getSel=self.selection_grab()
if getSel:
pass
else:
return
getNames=cmds.ls(sl=1, fl=1)
if ".e[" not in str(getNames[0]):
print "selection needs to be continuous edges of two seperate polygon objects: first select one, then continuous edge and then the continuous edge on a seperate poly object that you want to deform it along"
return
else:
pass
getFirstGrp = getNames[0].split(".")[0]
getSecondGrp = getNames[-1:][0].split(".")[0]
if getFirstGrp == getSecondGrp:
print "Only one poly object has been detected. Select one object and it's continuous edge and then select another object and select it's continuous edge for the first object to align to."
return
else:
pass
firstList=[(each) for each in getNames if each.split(".")[0]==getFirstGrp]
secondList=[(each) for each in getNames if each.split(".")[0]==getSecondGrp]
'''create childfirst curve'''
cmds.select(firstList)
cmds.CreateCurveFromPoly()
getFirstCurve=cmds.ls(sl=1, fl=1)
'''get cv total of curve'''
getFirstCurveInfo=cmds.ls(sl=1, fl=1)
numberCV=str(pm.PyNode(getFirstCurveInfo[0]).numCVs())
cmds.delete(getFirstCurve[0], ch=1)
'''wrap child mesh to curve'''
cmds.select(cmds.ls(getFirstGrp)[0], r=1)
cmds.wire(w=getFirstCurve[0], gw=0, en=1.000000, ce=0.000000, li=0.000000, dds=[(0, 500)] )
'''create parent curve'''
cmds.select(secondList)
cmds.CreateCurveFromPoly()
getSecondCurve=cmds.ls(sl=1, fl=1)
getSecondCurveInfo=cmds.ls(sl=1, fl=1)
'''rebuilt curve to match first curve built'''
cmds.rebuildCurve(getSecondCurve[0], getFirstCurve[0], rt=2 )
getSecondCurve=cmds.ls(sl=1, fl=1)
getSecondCurveInfo=cmds.ls(sl=1, fl=1)
cmds.delete(getSecondCurve[0], ch=1)
'''wrap parent curve to parent mesh'''
cmds.select(getSecondCurve[0], r=1)
cmds.select(cmds.ls(getSecondGrp)[0], add=1)
cmds.CreateWrap()
'''blend child curve to parent curve'''
cmds.blendShape(getSecondCurve[0], getFirstCurve[0],w=(0, 1.0))
return getFirstGrp, getSecondGrp
示例13: build
def build(startPt=[-1,0,0],endPt=[1,0,0],attachments=2,outputMesh=False,radius=0.2,prefix='tendon'):
'''
'''
#
# Get points
startPt = glTools.utils.base.getMPoint(startPt)
endPt = glTools.utils.base.getMPoint(endPt)
# Get offset
offsetVec = endPt - startPt
offsetInc = 1.0/(attachments-1)
# Get Point List
ptList = []
for i in range(attachments-1):
pt = startPt + (offsetVec * offsetInc)
ptList.append(pt[0],pt[1],pt[2])
# Build tendon curve base
tendonCrv = glTools.utils.curve.createFromPointList(ptList,1,prefix)
# Generate tendon curve locators
tendonLocList = glTools.utils.curve.locatorCurve(tendonCrv,freeze=False,prefix=prefix)
# Rebuild tendon curve
if attachments > 2:
tendonRebuild = mc.rebuildCurve(tendonCrv,ch=1,rpo=1,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1,s=0,d=3,tol=0.01)
示例14: edgeLoopCrv
def edgeLoopCrv(meshEdgeList,rebuild=False,rebuildSpans=0,form=2,keepHistory=True,prefix=''):
'''
Generate a curve from a mesh edge loop.
@param meshEdgeList: List of mesh edges to generate curve from
@type meshEdgeList: list
@param rebuild: Rebuild curve to degree 3
@type rebuild: bool
@param rebuildSpans: Number of spans to rebuild the resulting curve to
@type rebuildSpans: int
@param form: Form of the resulting curve. 0 = Open, 1 = Periodic, 2 = Best Guess.
@type form: str
@param keepHistory: Maintain construction history
@type keepHistory: bool
@param prefix: Name prefix for newly created nodes
@type prefix: str
'''
# Check edge list
if not meshEdgeList:
raise Exception('Invalid mesh edge list provided!!')
meshEdgeList = mc.ls(meshEdgeList,fl=True)
# Check prefix
if not prefix: prefix = glTools.utils.stringUtils.stripSuffix(meshEdgeList[0].split('.')[0])
# Convert edge selection to nurbs curve
crvDegree = 1
if rebuild: crvDegree = 3
curve = mc.polyToCurve(ch=keepHistory,form=form,degree=crvDegree)[0]
# Rebuild as degree 3
if rebuild and rebuildSpans:
curve = mc.rebuildCurve(curve,ch=keepHistory,rpo=1,rt=0,end=1,kr=0,kcp=1,kep=1,kt=1,s=rebuildSpans,d=3,tol=0.01)[0]
# Rename curve
curve = mc.rename(curve,prefix+'_curve')
# Return result
return curve
示例15: trimFromBeginning
def trimFromBeginning(inputCurves, shortestLength):
newCurves = []
for obj in inputCurves:
parent = mc.listRelatives(obj, parent=True)
r = random.random()*(1-shortestLength)
obj = mc.rebuildCurve(obj, ch=0, rpo=1, rt=0, end=1, kr=0, kcp=1, kep=1, kt=0, s = 10, d = 3, tol = 0)[0]
curves = mc.detachCurve( '%s.u[%f]' % (obj, r), ch=0, cos=True, rpo=1 )
mc.delete(curves[-1])
mc.rebuildCurve(curves[0], ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt= 0, s = 0, d = 3, tol = 0)
curves[0] = mc.rename(curves[0], obj)
if parent:
curves[0] = mc.parent(curves[0], parent)[0]
newCurves.append(curves[0])
return newCurves