本文整理汇总了Python中maya.cmds.polyUVSet函数的典型用法代码示例。如果您正苦于以下问题:Python polyUVSet函数的具体用法?Python polyUVSet怎么用?Python polyUVSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polyUVSet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: closestUV
def closestUV(mesh, point=(0, 0, 0), uvSet=""):
"""
Get the UV of the closest point on a mesh to a specified point
@param mesh: Mesh to query
@type mesh: str
@param point: Find the closest point to THIS point
@type point: tuple
"""
# Check mesh
if not isMesh(mesh):
raise Exception('Object "' + mesh + '" is not a valid mesh!')
# Check uvSet
if not uvSet:
currentUvSet = mc.polyUVSet(mesh, q=True, cuv=True)
if not currentUvSet:
raise Exception('Mesh "' + mesh + '" has no valid uvSet!')
uvSet = currentUvSet[0]
if not mc.polyUVSet(mesh, q=True, auv=True).count(uvSet):
raise Exception('Invalid UV set "' + uvSet + '" specified!"')
# Get mesh function set
meshFn = getMeshFn(mesh)
# Get closest UV
pnt = OpenMaya.MPoint(point[0], point[1], point[2], 1.0)
uv = OpenMaya.MScriptUtil()
uv.createFromList([0.0, 0.0], 2)
uvPtr = uv.asFloat2Ptr()
meshFn.getUVAtPoint(pnt, uvPtr, OpenMaya.MSpace.kWorld, uvSet)
# Return result
return (uv.getFloat2ArrayItem(uvPtr, 0, 0), uv.getFloat2ArrayItem(uvPtr, 0, 1))
示例2: getUVs
def getUVs(self):
# Getting current uvset
currUVSet = cmds.polyUVSet( self.name, q=True, currentUVSet=True )[0]
for i, uvSet in enumerate(self.uvSets):
self.uvs[uvSet] = []
# Setting uvSet temp
cmds.polyUVSet( self.name, currentUVSet=True, uvSet=uvSet )
# Get uv maps
uvMaps = cmds.polyListComponentConversion( self.name, ff=1, tuv=1 )
# verts = PolyFace.findWindingOrder(self.name)
# print(self.vtxFaceNames)
# cmds.polyListComponentConversion('pPlane2.vtxFace[2][1]', tuv=1 )
if( uvMaps ):
# uvMaps = cmds.filterExpand( uvMaps, expand=True, sm=35 )
uvMaps = [cmds.polyListComponentConversion(vtxFace, tuv=1 ) for vtxFace in self.vtxFaceNames ]
# Check to make sure there are uv's on this face.
for uvMap in uvMaps:
# Get my uvValues
uvCoords = cmds.polyEditUV( uvMap, q=True )
self.uvs[uvSet].append(uvCoords)
# Returning to orginal uvSet
cmds.polyUVSet( self.name, currentUVSet=True, uvSet=currUVSet)
示例3: jointify
def jointify(name=''):
from maya.cmds import *
# get mesh transforms
import ezLib.transform
mTrfs = ezLib.transform.get(shape='mesh')
if not mTrfs:
raise IOError, 'No mesh shapes found!'
if not name:
p = mTrfs[0].split('|')[1]
if p[0:14] == 'cryExportNode_':
name = p.split('_')[1]
else:
name = 'jointify'
js = []
counts = []
for mt in mTrfs:
sn = mt.split('|')[-1]
# create joints at transform positions
pos = xform(mt, q=1, t=1, ws=1)
j = createNode('joint', n=(sn + 'joint'))
xform(j, t=pos)
js.append(j)
# plug each channel driver into the appropriate joint
for t in 'trs':
for d in 'xyz':
input = listConnections((mt + '.' + t + d), p=1)
if input:
connectAttr(input[0], (j + '.' + t + d))
# collect nr of verts - this method collects also children if any
counts.append(len(ls(polyListComponentConversion(mt, tv=1), fl=1)))
dupMesh = duplicate(mTrfs, renameChildren=1)
dupMesh = polyUnite(dupMesh, ch=0)
# check for multiple UVsets
uvSets = polyUVSet(dupMesh, q=1, allUVSets=1)
for i in range(1,len(uvSets)):
# for each set other than the 1st: set it, copy to 1st, delete it
polyUVSet(dupMesh, currentUVSet=1, uvSet=uvSets[i])
polyCopyUV(dupMesh[0] + '.map[*]', uvSetNameInput=uvSets[i], uvSetName=uvSets[0])
polyUVSet(dupMesh, uvSet=uvSets[i], delete=1)
# cleanup history crap
delete(dupMesh, ch=1)
sc = skinCluster(js, dupMesh)[0]
vtxNr = 0
for i in range(len(js)):
vtxSel = dupMesh[0] + '.vtx[' + str(vtxNr) + ':' + str(vtxNr + counts[i] - 1) + ']'
skinPercent(sc, vtxSel, transformValue=[js[i], 1])
vtxNr += counts[i]
root = createNode('joint', n=name + 'rootjoint')
setAttr(root + '.drawStyle', 2)
parent(js, root)
select(root, dupMesh)
示例4: runCmd
def runCmd(self):
setName = cmds.textFieldButtonGrp(self.setNameFld, tx=1, q=1)
#print('setName:{0}'.format(setName))
curSel = cmds.ls(sl=1,fl=1)
for sel in curSel:
for uset in cmds.polyUVSet(sel,auv=1,q=1):
if uset == setName:
cmds.polyUVSet(sel,uvSet=setName,d=1)
cmds.deleteUI(self.window)
示例5: replaceLightMap
def replaceLightMap(self, none):
self.currentMapCheck = cmds.optionMenuGrp(self.uvSetChoice, q=True, v=True)
if self.inputLightmap == self.currentMapCheck:
OpenMaya.MGlobal.displayError("Can't overwrite uv set of the same name.")
cmds.deleteUI(self.replaceWindow)
else:
OpenMaya.MGlobal.displayInfo("Lightmap '" + self.inputLightmap + "' exists, overwriting")
cmds.polyUVSet(self.selFace, uvs=self.inputLightmap, d=True) #delete lightmap if already exists
self.copyAndLayout()
cmds.deleteUI(self.replaceWindow)
示例6: uvsetTgl
def uvsetTgl():
shape_node = cmds.ls(sl=True, fl=True, dag=True, type='shape')
current_uvset = cmds.polyUVSet(shape_node[0],q=True, currentUVSet=True)
for shape in shape_node:
uvsets = cmds.polyUVSet(shape,q=True,auv=True)
if "map1" and "atlasUV" in uvsets:
if current_uvset[0] == 'map1':
cmds.polyUVSet(shape, currentUVSet=True, uvSet="atlasUV")
elif current_uvset[0] == 'atlasUV':
cmds.polyUVSet(shape, currentUVSet=True, uvSet="map1")
else:
cmds.polyUVSet(shape, currentUVSet=True, uvSet="map1")
elif "map1" in uvsets and "atlasUV" not in uvsets:
cmds.polyUVSet(shape, currentUVSet=True, uvSet="map1")
示例7: __init__
def __init__( self, face ):
'''
This class will contain 3 Vertex Class (triangle) and the winding order
'''
self.name = face
# Face ID
self.faceID = self.getFaceID()
self.vertex = []
self._getVertex()
self.numOfVertex = len(self.vertex)
# Remember the order of these vertex line up with the Vertex Object held in
# self.vertex
self.windingOrder = PolyFace.findWindingOrder(self.name)
self.vertexCoords = []
self.getVertexCoords()
# This will be according to the face we're currently recording.
self.normals = []
self.vtxFaceNames = self.getNormals()
# http://xyz2.net/mel/mel.005.htm
self.uvSets = cmds.polyUVSet(self.name, query=True, allUVSets=True)
self.uvs = {}
self.getUVs()
示例8: setmesh
def setmesh(nodename):
cmds.select(nodename)
exts = getnames()
va, na, pa, uva = exts
nva, nna, npa, nuva = [nodename+"."+ext for ext in exts]
# Vertices first.
vl = cmds.xform(nodename+'.vtx[:]', q=True, os=True, t=True)
cmds.addAttr(longName=va, dt="string")
cmds.setAttr(nva, str(vl), type="string")
# Polygons (called faces in Maya).
pcnt = cmds.polyEvaluate(f=True)
cmds.addAttr(longName=pa, dt="string")
pll = []
for x in range(pcnt):
fvl = cmds.polyInfo(nodename+".f[%i]" % x, faceToVertex=True)
p = fvl[0].split()[2:]
pll += ["[" + ",".join(p) + "]"]
pll = "[" + ",".join(pll) + "]"
cmds.setAttr(npa, pll, type="string")
pl = eval(pll)
# Normals and UVs (needs polygons).
nll = []
# UVs are only used if user has set a non-default UV-set
# name (use right-click menu).
cmds.select(nodename)
hasUv = (cmds.polyUVSet(q=True, allUVSets=True) != ['map1'])
uvcnt = 0
#print("Set is: "+str(cmds.polyUVSet(q=True, allUVSets=True)))
cmds.addAttr(longName=na, dt="string")
if hasUv:
cmds.addAttr(longName=uva, dt="string")
uvll = []
for polyidx in range(pcnt):
poly = pl[polyidx]
for vtxidx in poly:
sel = nodename+".vtxFace["+str(vtxidx)+"]["+str(polyidx)+"]"
cmds.select(sel)
n = cmds.polyNormalPerVertex(q=True, xyz=True);
nll += n
if hasUv:
uv_names = cmds.polyListComponentConversion(fromVertexFace=True, toUV=True)
if uv_names:
uv_name = uv_names[0]
cmds.select(uv_name)
uv = cmds.polyEditUV(q=True)
uvll += uv
uvcnt += 1
#print "Normals: "+str(nll)
cmds.setAttr(nna, str(nll), type='string')
if hasUv:
#print "UVs: "+str(uvll)
cmds.setAttr(nuva, str(uvll), type='string')
return (1, len(vl)/3+len(pl)+len(nll)/3+uvcnt)
示例9: __init__
def __init__(self):
self.lightmap = "Lightmap"
for self.sel in selection:
print "test"
cmds.select(self.sel)
faceCount = cmds.polyEvaluate(self.sel, face=True)
self.selFace = self.sel + ".f[0:"+str(faceCount)+"]"
self.uvList = cmds.polyUVSet(self.selFace, q=True, auv=True)
self.uvSetOptions()
示例10: getAllUVsCoords
def getAllUVsCoords( vertex ):
uvSets = Vertex.getUVSets(vertex)
currUVSet = cmds.polyUVSet( vertex, q=True, currentUVSet=True )[0]
totalUVs = []
for uvSet in uvSets:
# Set uv to this current uvSet.
cmds.polyUVSet( vertex, currentUVSet=True, uvSet=uvSet )
# getting a list of the coords
uvCoords = Vertex.getCurrentCoords( vertex )
totalUVs.append(uvCoords)
# Returns the current set back to its orginal
cmds.polyUVSet( vertex, currentUVSet=True, uvSet=currUVSet)
return totalUVs
示例11: removeExtraUVSets
def removeExtraUVSets():
from maya.cmds import polyUVSet, polyCopyUV
import ezLib.transform
mts = ezLib.transform.get(shape='mesh')
for m in mts:
uvSets = polyUVSet(m, q=1, allUVSets=1)
for i in range(1,len(uvSets)):
# for each set other than the 1st: set it, copy to 1st, delete it
polyUVSet(m, currentUVSet=1, uvSet=uvSets[i])
polyCopyUV(m + '.map[*]', uvSetNameInput=uvSets[i], uvSetName=uvSets[0])
polyUVSet(m, uvSet=uvSets[i], delete=1)
# copy vertexColorsWithoutTransferNode
#obj = ls(sl=1, tr=1)
#vtxs = ls(obj[0] + '.vtx[*]', fl=1)
#for v in vtxs:
# vtx = '.' + v.split('.')[1]
# rgb = polyColorPerVertex(obj[0] + vtx, q=1, rgb=1)
# a = polyColorPerVertex(obj[0] + vtx, q=1, a=1)[0]
# polyColorPerVertex(obj[1] + vtx, a=a, rgb=rgb)
示例12: process
def process(self, instance):
"""Process all the nodes in the instance 'objectSet'"""
meshes = cmds.ls(instance, type='mesh', long=True)
invalid = []
for mesh in meshes:
uvSets = cmds.polyUVSet(mesh, query=True, allUVSets=True)
if len(uvSets) != 1:
invalid.append(mesh)
if invalid:
raise ValueError("Nodes found with multiple UV sets: {0}".format(invalid))
示例13: getUVs
def getUVs(self):
# Getting current uvset
currUVSet = cmds.polyUVSet( self.name, q=True, currentUVSet=True )[0]
for i, uvSet in enumerate(self.uvSets):
self.uvs[uvSet] = []
# Setting uvSet temp
cmds.polyUVSet( self.name, currentUVSet=True, uvSet=uvSet )
# Get uv maps
uvMaps = cmds.polyListComponentConversion( self.name, ff=1, tuv=1 )
if( uvMaps ):
uvMaps = cmds.filterExpand( uvMaps, expand=True, sm=35 )
# Check to make sure there are uv's on this face.
for uvMap in uvMaps:
# Get my uvValues
uvCoords = cmds.polyEditUV( uvMap, q=True )
self.uvs[uvSet].append(uvCoords)
# Returning to orginal uvSet
cmds.polyUVSet( self.name, currentUVSet=True, uvSet=currUVSet)
示例14: shadeUVShells
def shadeUVShells():
uvSet = 'map1'
data = []
shellDict = {}
goldenRatio = 0.618033988749895 # use golden ratio
selList = om.MSelectionList()
om.MGlobal.getActiveSelectionList( selList )
selListIter = om.MItSelectionList( selList, om.MFn.kMesh )
uvShellArray = om.MIntArray()
while not selListIter.isDone():
pathToShape = om.MDagPath()
selListIter.getDagPath(pathToShape)
meshNode = pathToShape.fullPathName()
uvSets = cmds.polyUVSet( meshNode, query=True, allUVSets =True )
if (uvSet in uvSets):
shapeFn = om.MFnMesh(pathToShape)
shells = om.MScriptUtil()
shells.createFromInt(0)
shellsPtr = shells.asUintPtr()
shapeFn.getUvShellsIds(uvShellArray, shellsPtr, uvSet)
# Convert uvShellArray
for index, value in enumerate(uvShellArray):
shellDict.setdefault(value,[]).append(index)
# Assign shaders
for index, value in shellDict.iteritems():
shaderNode = cmds.shadingNode( 'surfaceShader', asShader=True )
faceShell = cmds.polyListComponentConversion( [('%s.map[%s]' % ( meshNode, u )) for u in value ], toFace=True )
cmds.select( faceShell )
cmds.hyperShade( assign=shaderNode )
hue = random.random()
hue += goldenRatio
hue %= 1
rgbColor = colorsys.hsv_to_rgb(hue, random.uniform(0.8, 1), random.uniform(0.8, 1))
cmds.setAttr( shaderNode + ".outColor", *rgbColor, type="double3" )
shellDict.clear()
uvShellArray.clear()
selListIter.next()
cmds.select(clear=True)
示例15: __init__
def __init__(self):
self.lightmap = "Lightmap"
self.shellSpacingSlider = "shellSpacingSlider"
self.spacingPresets = ["Custom", "2048 Map", "1024 Map", "512 Map", "256 Map", "128 Map", "64 Map", "32 Map"]
self.spacingPresetValues = [3.2, .05, .1, .2, .4, .8, 1.6, 3.2]
self.presetSelect = "presetSelect"
for self.sel in selection:
print "test"
cmds.select(self.sel)
faceCount = cmds.polyEvaluate(self.sel, face=True)
self.selFace = self.sel + ".f[0:"+str(faceCount)+"]"
self.uvList = cmds.polyUVSet(self.selFace, q=True, auv=True)
self.uvSetOptions()