Пример #1
0
def unfoldBandUVs(object, divisions=1, history=True):
	"""
	This definition unfolds object band UVs.

	:param object: Object. ( String )
	:param divisions: Extrusion divisions. ( Integer )
	:param history: Keep construction history. ( Boolean )
	"""

	edgesCount = cmds.polyEvaluate(object, edge=True)
	edges = cmds.ls(object + ".e[0:" + str(edgesCount - 1) + "]", fl=True, l=True)

	cmds.select(object)
	cmds.polySelectConstraint(m=3, t=0x8000, w=1)
	cmds.polySelectConstraint(m=0)
	for i in range(divisions):
		mel.eval("GrowPolygonSelectionRegion();")
	bandEdges = cmds.ls(sl=True, fl=True, l=True)
	bandFaces = cmds.ls(cmds.polyListComponentConversion(bandEdges, fe=True, tf=True), fl=True)
	cmds.select(bandFaces)
	cmds.polyForceUV(unitize=True)
	cmds.polySelectConstraint(m=3, t=0x8000, sm=1)
	seamsEdges = cmds.ls(sl=True, fl=True, l=True)
	weldEdges = list(set(bandEdges).difference(set(seamsEdges)))
	cmds.polyMapSewMove(weldEdges)
	cmds.polyLayoutUV(bandFaces, scale=1, rotateForBestFit=0, layout=1)
	uvs = cmds.polyListComponentConversion(bandFaces, toUV=1)
	cmds.polyEditUV(uvs, u=1, v=0)

	not history and cmds.delete(object, ch=True)
Пример #2
0
def unfoldBandUVs(object, divisions=1, history=True):
	"""
	Unfolds object band UVs.

	:param object: Object.
	:type object: str
	:param divisions: Extrusion divisions.
	:type divisions: int
	:param history: Keep construction history.
	:type history: bool
	"""

	edgesCount = cmds.polyEvaluate(object, edge=True)
	edges = cmds.ls(object + ".e[0:" + str(edgesCount - 1) + "]", fl=True, l=True)

	cmds.select(object)
	cmds.polySelectConstraint(m=3, t=0x8000, w=1)
	cmds.polySelectConstraint(m=0)
	for i in range(divisions):
		mel.eval("GrowPolygonSelectionRegion();")
	bandEdges = cmds.ls(sl=True, fl=True, l=True)
	bandFaces = cmds.ls(cmds.polyListComponentConversion(bandEdges, fe=True, tf=True), fl=True)
	cmds.select(bandFaces)
	cmds.polyForceUV(unitize=True)
	cmds.polySelectConstraint(m=3, t=0x8000, sm=1)
	seamsEdges = cmds.ls(sl=True, fl=True, l=True)
	weldEdges = list(set(bandEdges).difference(set(seamsEdges)))
	cmds.polyMapSewMove(weldEdges)
	cmds.polyLayoutUV(bandFaces, scale=1, rotateForBestFit=0, layout=1)
	uvs = cmds.polyListComponentConversion(bandFaces, toUV=1)
	cmds.polyEditUV(uvs, u=1, v=0)

	not history and cmds.delete(object, ch=True)
Пример #3
0
def faceUnwarp(selFaces):
    selEdges = cmds.polyListComponentConversion(selFaces,ff=1,te=1)
    selEdges = cmds.ls(selEdges, fl=1)
    selBorderEdges = cmds.polyListComponentConversion(selFaces,bo=1,ff=1,te=1)
    selBorderEdges = cmds.ls(selBorderEdges, fl=1)
    selInnerEdges = list( set(selEdges) - set(selBorderEdges))
    cmds.polyMapCut(selEdges,ch=1)
    cmds.polyForceUV(selFaces,unitize=1)
    cmds.polyMapSewMove(selInnerEdges)
Пример #4
0
def combine(comps=None, move=None, hist=None):
    """Sews all internal edges of given shell [Select uv shell]"""
    
    hist = True if hist is None else hist
    lssl = cm.ls(comps, type="float3")
    if not lssl:
        lssl = cm.ls(sl=1, type="float3")

    inner_e = cm.polyListComponentConversion(lssl, internal=1, te=1)
    if move:
        cm.polyMapSewMove(inner_e, nf=10, lps=0, ch=hist)
    else:
        cm.polyMapSew(inner_e, ch=hist)
def unwrapRibbon():
    selList = cmds.ls(sl=1,o=1)
    selListPoly = cmds.filterExpand(selList,sm=12)
    selListEdge = cmds.polyListComponentConversion(selListPoly,te=1)
    selListFace = cmds.polyListComponentConversion(selListPoly,tf=1)
    selListUV = cmds.polyListComponentConversion(selListPoly,tuv=1)

    selListEdge = map(lambda x: x+'.e[*]', selListPoly)
    for i in selListEdge:
        cmds.polyMapCut(i,ch=1)
    cmds.polyForceUV(selListFace,unitize=1)
    for i in selListEdge:
        cmds.polyMapSewMove(i)
Пример #6
0
	def Action_Apply(self):
		maya_cmds.undoInfo(openChunk=True)
		try:
			items = self.window.Text_Items.toPlainText().strip().split('\n')

			if self.window.Check_Unitize.isChecked():
				maya_cmds.polyForceUV(items, unitize=True)
				maya_cmds.polyMapSewMove(items, caching=True)

			if self.window.Check_Cut.isChecked():
				cutType = self.window.Combo_CutType.currentText()
				if cutType == 'Automatic':
					maya_cmds.u3dAutoSeam(items, splitShells=self.window.Float_CutTolerance.value())
				elif cutType == 'Manual':
					maya_cmds.polyMapCut(maya_cmds.sets(self.window.Line_CutName.text().strip(), q=True))

			if self.window.Check_Unfold.isChecked():
				maya_cmds.u3dUnfold(items, iterations=self.window.Int_UnfoldIteration.value(), pack=False)

			if self.window.Check_Optimize.isChecked():
				maya_cmds.u3dOptimize(items, iterations=self.window.Int_OptimizeIteration.value())

			if self.window.Check_Layout.isChecked():
				paramRotate = {}
				if self.window.Check_LayoutRotation.isChecked():
					paramRotate = {
						'rotateStep': self.window.Float_LayoutRotationStep.value(),
						'rotateMin': self.window.Float_LayoutRotationMin.value(),
						'rotateMax': self.window.Float_LayoutRotationMax.value()
					}
				maya_cmds.u3dLayout(
					items,
					mutations=self.window.Int_LayoutIteration.value(),
					resolution=self.window.Int_LayoutResolution.value(),
					preRotateMode=self.window.Combo_LayoutAlign.currentIndex(),
					preScaleMode=1,
					tileMargin=self.window.Int_LayoutTileSpaceL.value() / float(self.window.Int_LayoutTileSpaceH.value()),
					shellSpacing=self.window.Int_LayoutShellSpaceL.value() / float(self.window.Int_LayoutShellSpaceH.value()),
					**paramRotate
				)

			self.Event_ItemsCoverage()
		except Exception as e:
			print >> stderr, str(e)
		maya_cmds.undoInfo(closeChunk=True)
def unitizeAndSew():
	# store UV seam as vertex becase f**k you Maya
	eval("PolySelectConvert 3")
	vtx_seam = cmds.ls(selection=True)
	eval("PolySelectConvert 4")

	#select UV shell, and convert to faces and unitize
	eval("polySelectBorderShell 0")
	eval("PolySelectConvert 1")
	cmds.polyForceUV(unitize=True)

	#convert shell to vertex and subtract the stored vertex seam, and then convert back to UV, because f**k you Maya
	eval("PolySelectConvert 3")
	cmds.select(vtx_seam, deselect=True)
	eval("PolySelectConvert 4")

	#stitch together the UV's that are not by the seam
	cmds.polyMapSewMove()
Пример #8
0
def unwrapCylindrical():
    # Variables and selection
    mode = cmds.radioButtonGrp('mode', q=True, select=True)
    seam = cmds.ls(sl=True)

    cmds.SelectEdgeRingSp()
    cmds.ConvertSelectionToContainedFaces()

    body = cmds.ls(sl=True)

    # Chooses desired seams
    numEdges = (len(seam))
    if (numEdges == 1):
        seamSel = (seam[0])
    else:
        seamSel = (seam[0:numEdges])

    bodySel = (body[0:(len(body))])

    # Unwraps with or without unfolding

    if (mode == 1):
        cmds.polyPlanarProjection()
        cmds.select(seamSel, r=True)
        cmds.polyMapCut()
        cmds.unfold()

    elif (mode == 2):
        cmds.select(bodySel, r=True)
        cmds.ConvertSelectionToFaces()
        shell = cmds.ls(sl=True)
        cmds.polyForceUV(unitize=True)

        cmds.ConvertSelectionToContainedEdges()

        cmds.select(seamSel, d=True)
        cmds.polyMapSewMove()
        cmds.select(shell, r=True)
        cmds.ConvertSelectionToUVs()
        cmds.polyLayoutUV()
        cmds.select(shell, r=True)
Пример #9
0
def unfoldBandRegular(seamsEdges, history=False):
	"""
	This definition unfolds object band UVs using given seamsEdges.
	
	:param seamsEdges: Seams edges. ( List )
	:param history: Keep construction history. ( Boolean )
	"""

	seamsEdges = filter(lambda x: re.search(r"e\[\d+\]", x), cmds.ls(seamsEdges, fl=True, l=True))
	if not seamsEdges:
		return

	object = seamsEdges[0].split(".")[0]
	edgesCount = cmds.polyEvaluate(object, edge=True)
	edges = cmds.ls(object + ".e[0:{0}]".format(str(edgesCount - 1)), fl=True, l=True)
	cmds.polyForceUV(object, unitize=True)
	print edges, seamsEdges
	cmds.select(list(set(edges).difference(seamsEdges)))
	cmds.polyMapSewMove(list(set(edges).difference(seamsEdges)), ch=True)

	not history and cmds.delete(object, ch=True)
 def pack_vert_uvs(mesh, progressBar, progressStep):  # 151
     # cm.polyTriangulate(mesh, ch=0) # move to smooth_copy() by Hiura
     anim_uvs = cm.polyUVSet(mesh, create=1, uvSet="anim_map")
     cm.polyUVSet(mesh, currentUVSet=1, uvSet=anim_uvs[0])
     cm.polyAutoProjection(mesh,
                           lm=0,
                           pb=0,
                           ibd=1,
                           cm=0,
                           l=2,
                           sc=1,
                           o=1,
                           p=6,
                           ps=0.2,
                           ws=0,
                           ch=0)
     cm.polyMapSewMove(mesh)
     lastProgress = 0  # added by Hiura
     for i in range(self.vert_count):
         current_position = (float(i) + 0.5) / self.vert_count
         # cm.polyColorPerVertex(mesh, rgb=[current_position, .5, 0]) # deleted by Hiura
         # >>>> modified by Hiura ( based on bryan_smyth'post )
         # cm.polyEditUV(mesh + ".map[" + str(i) + "]", u=current_position, v=.501961, r=0)
         vertex_u, vertex_v = get_vertex_uv(i)
         cm.polyEditUV(mesh + ".map[" + cm.polyListComponentConversion(
             mesh + ".vtx[%d]" % i, fv=True,
             tuv=True)[0].split("[")[-1][:-1] + "]",
                       u=vertex_u,
                       v=vertex_v,
                       r=0)
         # <<<< modified by Hiura
         self.vertex_uv_position.append(vertex_u)
         # >>>> added by Hiura
         nowProgress = int(
             float(progressStep) * float(i) / float(self.vert_count))
         if nowProgress > lastProgress:
             cm.progressBar(progressBar,
                            edit=True,
                            step=int(nowProgress - lastProgress))
             lastProgress = nowProgress
Пример #11
0
def unwrapByAngle():
    unf = cmds.checkBox('unf', q=True, v=True)
    lyt = cmds.checkBox('lyt', q=True, v=True)

    cmds.polyForceUV(unitize=True)
    cmds.selectType(pe=True)
    cmds.polySelectConstraint(m=3, t=0x8000,
                              sm=2)  # Constrains selection to soft edges
    selEdges = cmds.ls(sl=True)
    cmds.polyMapSewMove()
    cmds.polySelectConstraint(sm=0)  # Turns off constraint

    # Unfold if chosen
    if (unf == 1):
        cmds.unfold()

    # Layout if chosen
    if (lyt == 1):
        cmds.select(selEdges)
        cmds.ConvertSelectionToShell()
        cmds.ConvertSelectionToUVs()
        cmds.polyLayoutUV(sc=1, ws=True, rbf=2)
Пример #12
0
def unwrapBySeams():

    # Variables and Selection
    unf = cmds.checkBox('unf', q=True, v=True)
    lyt = cmds.checkBox('lyt', q=True, v=True)
    selEdges = cmds.ls(sl=True)
    cmds.ConvertSelectionToShell()

    cmds.polyForceUV(unitize=True)
    cmds.ConvertSelectionToEdges()
    cmds.select(selEdges, d=True)
    cmds.polyMapSewMove()

    # Unfold if chosen
    if (unf == 1):
        cmds.unfold()

    # Layout if chosen
    if (lyt == 1):
        cmds.select(selEdges)
        cmds.ConvertSelectionToShell()
        cmds.ConvertSelectionToUVs()
        cmds.polyLayoutUV(sc=1, ws=True, rbf=2)
Пример #13
0
def unfoldBandRegular(seamsEdges, history=False):
	"""
	Unfolds object band UVs using given seamsEdges.
	
	:param seamsEdges: Seams edges.
	:type seamsEdges: list
	:param history: Keep construction history.
	:type history: bool
	"""

	seamsEdges = filter(lambda x: re.search(r"e\[\d+\]", x), cmds.ls(seamsEdges, fl=True, l=True))
	if not seamsEdges:
		return

	object = seamsEdges[0].split(".")[0]
	edgesCount = cmds.polyEvaluate(object, edge=True)
	edges = cmds.ls(object + ".e[0:{0}]".format(str(edgesCount - 1)), fl=True, l=True)
	cmds.polyForceUV(object, unitize=True)
	print edges, seamsEdges
	cmds.select(list(set(edges).difference(seamsEdges)))
	cmds.polyMapSewMove(list(set(edges).difference(seamsEdges)), ch=True)

	not history and cmds.delete(object, ch=True)
Пример #14
0
 def sewFaces(self, faceA, faceB):
     cmds.select([faceA, faceB])
     cmds.polyMapSewMove((cmds.polyListComponentConversion(ff=True, te=True, internal=True)), ch=False, cch=True)
     cmds.select(d=True)
Пример #15
0
def polyMapSewMove(*args, **kwargs):
    res = cmds.polyMapSewMove(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res