Select mirrored UV shells in maya .

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2014   #1
Select mirrored or stacked UV shells in maya?

Hey, I'm curious if someone knows of a maya script that can select UV shells that are mirrored or stacked in the UV layout?

I'm working on a weapon model and I usually create a "bake target" for baking textures to where I displace the overlapping/mirrored UVs temporarily for baking purposes. This is usually part of the process so not that big of a deal, but somehow I removed my bake target from the scene this time by accident.

So now I don't feel like going through my UVs and selecting each and every shell that is overlapping and moving it out of 0-1 space.

And thus I was hoping to find some kind soul out there that has a script that can do this already? Anyone?

Last edited by ChrisDeKitchen : 02 February 2014 at 07:44 PM.
 
Old 02 February 2014   #2
If selecting the mirrored/overlapping faces isn't too time consuming, you can ctrl+right click>To UV
__________________

gibby3d.com
 
Old 02 February 2014   #3
Have you checked the plethora of UV tool sets on creativecrash, one of them is bound to have this.
If not, give me a holla.
__________________
blogfolio
 
Old 02 February 2014   #4
I'm curious how you approached this problem, Paul. Is python fast enough to handle something like this? Or did you use the API?
__________________

gibby3d.com
 
Old 02 February 2014   #5
python commands are fast enough
one way to implemented it is to just leave one shell of the selected shells and move the rest, the user still needs to select a set of shells, but that's very quick.

The full monte is determine what shells are overlapping within some tolerances.
-convert the selection to faces
-get a list of faces per shell
-gather info for each shell, it's UV bounds and what ever else you want to use to determine overlap, like total area, uv count, center, etc
-sort the list of shells using the info you've gathered
-for each shell if the last shell and the current shells info are within tolerance, add the current shell to the set with the last, if not, put it in a new set
-for each shell set leave one shell move the rest.
__________________
blogfolio
 
Old 02 February 2014   #6
I found the tricky part for me was getting the shells quickly. More than a few searches referenced Owen Burgess' post on Maya Station:
http://mayastation.typepad.com/maya...-a-uv-set-.html

I simply modified his getuvshells script to return the values in 'uvShellArray'. From there I could easily determine which uvs belonged to each shell. Lastly, I determined overlap via centroid as you suggested.
__________________

gibby3d.com
 
Old 02 February 2014   #7
@jgibz - nice! for forever I was using this shitty method with selection constraints to find the shells, but recently wrote a method using MFnMesh.getUvShellsIds to do the same, huge speed improvement.

o the ugliness
def getShells(sel):
	if sel:
		currentTool=cmds.currentCtx()
		cmds.setToolTo('selectSuperContext') #TODO - hide uv editor b/c this uses selections
		biglist=cmds.ls( cmds.polyListComponentConversion( sel, tf=1 ) , fl=1 )
		shells=[]
		#aShell=[]
		while len(biglist) > 0:
			cmds.select( biglist[0], r=1 )
			cmds.polySelectConstraint(t=0)
			cmds.polySelectConstraint(sh=1,m=2)
			cmds.polySelectConstraint(sh=0,m=0)
			aShell=cmds.ls( sl=1, fl=1 )
			shells.append( aShell )
			biglist=list( set(biglist) - set(aShell) )
		cmds.setToolTo(currentTool)
		return shells # [ [faces in uv shell 1], [faces in shell 2], [etc] ]

used this as my shell heuristics sorting method
def uvp_shellSetify(shellSet, tol=[0.0,0.0,0.0]):
	#sort shells by area, boundSize, piv
	#shell in list=shell(1) and next shell(2) if next shells similar;
	#fract(piv1)==fract(piv2)+or-%		check option
	pivTol=tol[0] #0.005
	#bound1==bound2+or-%				check option
	boundTol=tol[1] #0.1
	#area1==area2+or-%					check option
	areaTol=tol[2] #0.5
	shellSet=sorted(shellSet, key=op.itemgetter(-1)) #area
	shellSet=sorted(shellSet, key=lambda a: (a[-2][0][1]-a[-2][0][0])*(a[-2][1][1]-a[-2][1][0]) ) #bound Size
	shellSet=sorted(shellSet, key=lambda a: a[-2][0][0]+((a[-2][0][1]-a[-2][0][0])*0.5) ) #piv, center bound U
	shellSet=sorted(shellSet, key=lambda a: a[-2][1][0]+((a[-2][1][1]-a[-2][1][0])*0.5) ) #piv, center bound V
	sharedShellSet=[shellSet[0]]
	#sss=0
	for i in range(len(shellSet)-1):
		shell1=shellSet[i]
		shell2=shellSet[i+1]
		bUsize1=shell1[-2][0][1]-shell1[-2][0][0]
		bUsize2=shell2[-2][0][1]-shell2[-2][0][0]		
		bVsize2=shell2[-2][1][1]-shell2[-2][1][0]
		bVsize1=shell1[-2][1][1]-shell1[-2][1][0]
		area1=shell1[-1]
		area2=shell2[-1]		
		piv1=[ shell1[-2][0][0]+(bUsize1*0.5), shell1[-2][1][0]+(bVsize1*0.5)]
		piv2=[shell2[-2][0][0]+(bUsize2*0.5), shell2[-2][1][0]+(bVsize2*0.5)]
		pivD = math.sqrt( ((piv1[0]-piv2[0])*(piv1[0]-piv2[0]))+((piv1[1]-piv2[1])*(piv1[1]-piv2[1])) )
		isSet=False
		if pivD<pivTol:												#center pivot is close enough
			if bUsize2<bUsize1+(bUsize1*boundTol):	#bound U size is percentage of size close enough
				if bVsize2<bVsize1+(bVsize1*boundTol):#bound V size is percentage of size close enough
					if area2<area1+area1*areaTol:
						isSet=True
						#sharedShellSet[-1].insert(1,shell2[0])
						sharedShellSet[-1][0].extend(shell2[0])
		if isSet==False:
			sharedShellSet.append(shell2)
			
	for i in range(len(sharedShellSet)):
		bound=uvp_bound(sharedShellSet[i][0])
		sharedShellSet[i]=[sharedShellSet[i][0],bound,sharedShellSet[i][-1]]
		
	shellSet=sharedShellSet
	return shellSet
__________________
blogfolio
 
Old 02 February 2014   #8
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:57 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.