本文整理汇总了Python中maya.cmds.polyUVSet函数的典型用法代码示例。如果您正苦于以下问题:Python polyUVSet函数的具体用法?Python polyUVSet怎么用?Python polyUVSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polyUVSet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:33,代码来源:mesh.py
示例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)
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:29,代码来源:export_uv.py
示例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)
开发者ID:ewerybody,项目名称:melDrop,代码行数:58,代码来源:poly.py
示例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)
开发者ID:aaronfang,项目名称:personal_scripts,代码行数:9,代码来源:deleteUVset.py
示例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)
开发者ID:mcassin,项目名称:GADTools,代码行数:10,代码来源:dcollins_uvLightmap.py
示例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")
开发者ID:aaronfang,项目名称:personal_scripts,代码行数:15,代码来源:uvSetTgl.py
示例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()
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:27,代码来源:export_beforeClearn.py
示例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)
开发者ID:highfestiva,项目名称:life,代码行数:58,代码来源:maya_export_script.py
示例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()
开发者ID:mcassin,项目名称:GADTools,代码行数:9,代码来源:dcollins_uvLightmap.py
示例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
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:18,代码来源:export_beforeClearn.py
示例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)
开发者ID:ewerybody,项目名称:melDrop,代码行数:20,代码来源:poly.py
示例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))
开发者ID:yamahigashi,项目名称:pyblish-magenta,代码行数:11,代码来源:validate_mesh_single_uv_set.py
示例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)
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:22,代码来源:export_beforeClearn.py
示例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)
开发者ID:Regnareb,项目名称:Maya,代码行数:51,代码来源:shadeUVShells.py
示例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()
开发者ID:RinglingGameArt,项目名称:GADTools,代码行数:14,代码来源:dcollins_uvLightmap.py
示例16: makeSeamless
def makeSeamless(meshName):
"""Makes a supplied mesh "seamless" in Unity by deleting its UV coordinates, smoothing normals, triangulating, and clearing material assignments"""
# clear uvs so there are no seams or tangents
uvs = cmds.polyUVSet(meshName, q=True, auv=True)
for uv in uvs:
try: cmds.polyUVSet(meshName, e=True, uvSet=uv, delete=True)
except: pass
uvSet = cmds.polyUVSet(meshName, q=True, auv=True)[0]
sel = om.MSelectionList()
sel.add(meshName)
dagPath = om.MDagPath()
sel.getDagPath(0, dagPath)
fn = om.MFnMesh(dagPath)
fn.clearUVs(uvSet)
# smooth normals so there are no normal separations
cmds.polySoftEdge(meshName, a=180, ch=True)
# triangulate geometry
cmds.polyTriangulate(meshName)
# apply a single material so there are no submesh separations
cmds.sets(meshName, e=True, forceElement='initialShadingGroup')
# delete all history
cmds.delete(meshName, ch=True)
cmds.select(clear=True)
开发者ID:0xb1dd1e,项目名称:PipelineConstructionSet,代码行数:23,代码来源:blendShapes.py
示例17: deleteEmptyUVSets
def deleteEmptyUVSets():
"""
Function to remove empty uv's
"""
getMeshes = cmds.ls(type = 'mesh', l = True)
emptyExists = False
if getMeshes:
for eachMesh in getMeshes:
selectionList = om.MSelectionList()
selectionList.add(eachMesh)
nodeDagPath = selectionList.getDagPath(0)
shapeFn = om.MFnMesh(nodeDagPath)
## Now fetch data from shapeFn
shapeName = shapeFn.name()
currentUVSets = shapeFn.getUVSetNames()
validUVSets = []
getFaceCount = shapeFn.numPolygons
try:
[[validUVSets.extend([eachUVset]) for eachUVset in shapeFn.getFaceUVSetNames(x) if
eachUVset not in validUVSets] for x in range(0, getFaceCount)]
except:
uvsets = None
for eachUVSet in currentUVSets:
if eachUVSet not in validUVSets:
logger.info('Removing empty UVSet %s from %s' % (eachUVSet, eachMesh))
cmds.select(eachMesh, r = True)
try:
cmds.polyUVSet(delete = True, uvSet = eachUVSet)
emptyExists = True
except:
cmds.warning('Failed to empty uv set %s of %s...' % (eachUVSet, eachMesh))
if emptyExists:
cmds.headsUpMessage('YOU HAD EMPTY UV SETS CLEANED UP!!', time = 3)
开发者ID:jamesbdunlop,项目名称:defaultMayaLibrary,代码行数:37,代码来源:sg_asset_lib.py
示例18: deleteEmptyUVSets
def deleteEmptyUVSets():
"""
Function to remove empty uv's
"""
getMeshes = cmds.ls(type = 'mesh', l = True)
emptyExists = False
if getMeshes:
for eachMesh in getMeshes:
selectionList = om.MSelectionList()
selectionList.add(eachMesh)
nodeDagPath = selectionList.getDagPath(0)
shapeFn = om.MFnMesh(nodeDagPath)
## Now fetch data from shapeFn
shapeName = shapeFn.name()
#debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('shapeName:', shapeName), verbose = False)
currentUVSets = shapeFn.getUVSetNames()
#debug(None, method = 'uv_getUVs._getUVSets', message = 'Fetching uvsets now..', verbose = False)
validUVSets = []
getFaceCount = shapeFn.numPolygons
try:
[[validUVSets.extend([eachUVset]) for eachUVset in shapeFn.getFaceUVSetNames(x) if eachUVset not in validUVSets] for x in range(0, getFaceCount) ]
except:
uvsets = None
for eachUVSet in currentUVSets:
if eachUVSet not in validUVSets:
print 'Removing empty UVSet %s from %s' % (eachUVSet, eachMesh)
cmds.select(eachMesh, r = True)
try:
cmds.polyUVSet(delete = True, uvSet = eachUVSet)
emptyExists = True
except:
cmds.warning('Failed to empty uv set %s of %s...' % (eachUVSet, eachMesh))
if emptyExists:
cmds.headsUpMessage('YOU HAD EMPTY UV SETS CLEANED UP! MAKE SURE YOU EXPORT SHD.XML AS WELL!', time = 3)
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:36,代码来源:maya_asset_MASTERCLEANUPCODE.py
示例19: searchUVSet
def searchUVSet(mesh_list, multiple_UV_set, not_UV_set):
# get mesh list
for mesh in mesh_list:
uvset_list = cmds.polyUVSet(mesh, query=True, allUVSets=True)
uvset_count = len(uvset_list)
if uvset_count == 1:
continue
# Multiple UVSet
elif uvset_count > 1:
uvname_list = []
for uvset_name in uvset_list:
uvname_list.append(uvset_name)
multiple_UV_set.update({mesh: uvname_list})
# Not has UVSet
elif uvset_count == 0:
not_UV_set.append(mesh)
开发者ID:MikiYamashiro,项目名称:MayaDataCheck,代码行数:16,代码来源:checkUVSet.py
示例20: validateUVs
def validateUVs(mesh):
'''
'''
# Initiate check
check = 0
# Get meshFn
meshFn = glTools.utils.mesh.getMeshFn(mesh)
# Get UV Sets
uvSetList = mc.polyUVSet(mesh,q=True,allUVSets=True)
if not uvSetList:
print('No UV Set : '+mesh)
check += 1
for uvSet in uvSetList:
# Get UV values
uArray = OpenMaya.MFloatArray()
vArray = OpenMaya.MFloatArray()
meshFn.getUVs(uArray,vArray,uvSet)
# Check empty UV set
if not uArray.length() and not vArray.length():
print('Empty UV Set : '+mesh+' - '+uvSet)
check += 1
# Check U values
for i in range(uArray.length()):
if math.isnan(uArray[i]):
print('Found NaN : '+mesh+'.uv['+str(i)+']')
check += 1
if math.isinf(uArray[i]):
print('Found INF : '+mesh+'.uv['+str(i)+']')
check += 1
# Check V values
for i in range(vArray.length()):
if math.isnan(vArray[i]):
print('Found NaN : '+mesh+'.uv['+str(i)+']')
check += 1
if math.isinf(vArray[i]):
print('Found INF : '+mesh+'.uv['+str(i)+']')
check += 1
# Return result
return check
开发者ID:auqeyjf,项目名称:glTools,代码行数:47,代码来源:validateAttr.py
注:本文中的maya.cmds.polyUVSet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论