wanted: Script to display UV seam on mesh without having to put an unwrap modfiier

wanted: Script to display UV seam on mesh without having to put an unwrap modfiier

Just display the UV seam (thick display) on poly mesh without the need for an unwrap modifier.

-need the ability see the seam easily so I can rotate problem areas away from viewable area.

thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Haider of Sweden's picture

.

Miauu, you're very skilled. One day, I will have to buy all your script packs.

I don't think your reply was for me, but in case it was, then I wasn't asking if it was possible to see the seems while working on the mesh (even though its a very useful feature).

I was rather wondering if there was a way to see the corresponding UV when you are selecting polys on a mesh. I don't know if you are aware of the way Maya works. You can work on UVs and poly meshes parallel.

Currently, I have to add a Unwrap modifier, select the faces I need to select, collapse and have them selected in the physical mesh.

Kind regards
Haider
www.haider.se

miauu's picture

.

Thank you.
Can you give a link to video where I can see what you mean?
What are the advantages of the workflow that you have described?

Haider of Sweden's picture

.

Unfortunately I couldn't find any video that shows exactly what I said, but I could try to explain the benefits.
Basically, it is like the UVWUnwrap, but in maya, you are still in Edit Poly. In other words, you can physically modify a mesh while seeing the UV.
In max, you cannot do both. Each time when you need to see the UV, you will have to add an Unwrap UV. Then you collapse, continue

Imagine the ability to have an open UV Editor plus the regular mesh tools.

A wild idea is that you have a popup window, which actually is a viewport with an isolated reference object that is "physically unwrapped" (you know, like in the old days when you did physically cut the object, put a planar map on it and then morph it back to the original shape).
This could be a hack, allowing you to see the "UV" while still able to edit the mesh.
Or that was maybe way too crazy? :-/

Kind regards
Haider
www.haider.se

Haider of Sweden's picture

Really cool script! Something

Really cool script!

Something else I have been wondering about is to see the UV like in maya, in other words, without having a unwrap modifier on it, allowing one to see the uv's in edit poly mode.

Is that doable in max?

Kind regards
Haider
www.haider.se

miauu's picture
PolyTools3D's picture

Here is a script that might

Here is a script that might be useful. Haven't tested too much, but it seems to work, although it's slow.

There is room for optimization and improvements so I hope someone can get their hands on it.

Hope someone find it useful.

(
 
	unRegisterRedrawViewsCallback cbDrawOpenEdges
 
	global RO_DISPLAY_UV_OE
	global cbDrawOpenEdges
	global cbSelectionChanged
 
	local vertexPos   = #()
	local uvChannel   = 1
	local edgesColor  = [0,255,0]
	local edgeOffset  = 0.03
	local forceRedraw = false
 
	fn cbDrawOpenEdges = (
		gw.setTransform (Matrix3 1)
		gw.setColor #line edgesColor
		for j in vertexPos do gw.polyLine j true
 
		-- Needed in some Max versions or used dirvers
		if forceRedraw do (
			gw.enlargeUpdateRect #whole
			gw.updateScreen()
		)
	)
 
	fn cbSelectionChanged mForce:false = (
 
		unRegisterRedrawViewsCallback cbDrawOpenEdges
 
		if ($ != undefined) do (
 
			setwaitcursor()
 
			st = timeStamp()
 
			obj = snapshotasmesh selection[1]
 
			allChannels = for j = 1 to meshop.getNumMaps obj where (meshop.getMapSupport obj j) collect j
 
			RO_DISPLAY_UV_OE.ddl_channel.items = for j in allChannels collect j as string
 
			if (mForce == false) do (
				uvChannel = allChannels[1]
				RO_DISPLAY_UV_OE.ddl_channel.selection = 1
			)
 
			numTFaces = meshop.getNumMapFaces obj uvChannel
			numTVerts = meshop.getNumMapVerts obj uvChannel
 
			facesTVertsIdx = for j = 1 to numTFaces collect (meshop.getMapFace obj uvChannel j)
 
			emesh = trimesh()
			setMesh emesh numverts:numTVerts numfaces:numTFaces
			setMesh emesh faces:facesTVertsIdx
 
			objOpenEdges = meshop.getOpenEdges obj
			meshOpenEdges = (meshop.getOpenEdges emesh) - objOpenEdges
 
			vertexPos = #()
 
			sharedFaces = meshop.getFacesUsingEdge emesh meshOpenEdges
			foundEdges = #()
 
			for j in sharedFaces do (
 
				objFaceVerts = getFace obj j
 
				edge1 = j*3 - 2
				edge2 = j*3 - 1
				edge3 = j*3
 
				n1 = (getFaceNormal obj j) * edgeOffset
 
				if (finditem meshOpenEdges edge1) > 0 do (
					v1Idx = objFaceVerts.x
					v2Idx = objFaceVerts.y
					if (findItem foundEdges [v1Idx, v2Idx] == 0) do (
						v1 = getVert obj v1Idx
						v2 = getVert obj v2Idx
						n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
						append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
						append foundEdges [v2Idx, v1Idx]
					)
				)
				if (finditem meshOpenEdges edge2) > 0 do (
					v1Idx = objFaceVerts.y
					v2Idx = objFaceVerts.z
					if (findItem foundEdges [v1Idx, v2Idx] == 0) do (
						v1 = getVert obj v1Idx
						v2 = getVert obj v2Idx
						n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
						append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
						append foundEdges [v2Idx, v1Idx]
					)
				)
				if (finditem meshOpenEdges edge3) > 0 do (
					v1Idx = objFaceVerts.z
					v2Idx = objFaceVerts.x
					if (findItem foundEdges [v1Idx, v2Idx] == 0) do (
						v1 = getVert obj v1Idx
						v2 = getVert obj v2Idx
						n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
						append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
						append foundEdges [v2Idx, v1Idx]
					)
				)
 
			)
 
			sharedFaces = meshop.getFacesUsingEdge obj objOpenEdges
 
			for j in sharedFaces do (
 
				objFaceVerts = getFace obj j
 
				edge1 = j*3 - 2
				edge2 = j*3 - 1
				edge3 = j*3
 
				n1 = (getFaceNormal obj j) * edgeOffset
 
				if (finditem objOpenEdges edge1) > 0 do (
					v1Idx = objFaceVerts.x
					v2Idx = objFaceVerts.y
					v1 = getVert obj v1Idx
					v2 = getVert obj v2Idx
					n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
					append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
				)
				if (finditem objOpenEdges edge2) > 0 do (
					v1Idx = objFaceVerts.y
					v2Idx = objFaceVerts.z
					v1 = getVert obj v1Idx
					v2 = getVert obj v2Idx
					n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
					append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
				)
				if (finditem objOpenEdges edge3) > 0 do (
					v1Idx = objFaceVerts.z
					v2Idx = objFaceVerts.x
					v1 = getVert obj v1Idx
					v2 = getVert obj v2Idx
					n3 = (normalize (cross n1 (v1-v2))) * edgeOffset
					append vertexPos #(v1+n1+n3, v2+n1+n3, v1-n1-n3, v2-n1-n3, v1-n1+n3, v2-n1+n3, v1+n1-n3, v2+n1-n3)
				)
 
			)
 
			format "Found %\tUV Open Edges in %s\n" vertexPos.count ((timeStamp() - st) / 1000.0)
 
			registerRedrawViewsCallback cbDrawOpenEdges
 
			delete obj
			delete emesh
 
			gc light:true
 
			setArrowCursor()
 
		)
 
		forceCompleteRedraw()
 
	)
 
 
	try(destroyDialog RO_DISPLAY_UV_OE) catch()
	rollout RO_DISPLAY_UV_OE "UV Open Edges" width:160 height:198
	(
		checkbutton bt_enable "Display UV Open Edges" pos:[8,8] width:144 height:32
		dropdownList ddl_channel "UV Channel:" pos:[8,72] width:120 height:40 enabled:false
		colorPicker cp1 "" pos:[131,90] width:21 height:21 enabled:true color:edgesColor modal:false
		checkbox chk_redraw "Force Redraw" pos:[8,46] width:100 height:16 enabled:false
		spinner spn_width "Edge Width:" pos:[8,120] width:120 height:16 range:[1,100,4] type:#integer fieldwidth:50
		button bt_update "Update" pos:[8,160] width:144 height:28 enabled:false
 
		fn destroy = (
			callbacks.removeScripts #selectionSetChanged
			unRegisterRedrawViewsCallback cbDrawOpenEdges
			forceCompleteRedraw()
		)
 
		on RO_DISPLAY_UV_OE close do destroy()
 
		on bt_enable changed arg do
		(
			bt_update.enabled = arg
			ddl_channel.enabled = arg
			chk_redraw.enabled = arg
			destroy()
 
			if (arg == true) do (
				callbacks.addscript #selectionSetChanged "cbSelectionChanged()"
				cbSelectionChanged()
			)
		)
 
		on bt_update pressed do cbSelectionChanged()
 
		on ddl_channel selected arg do (
			uvChannel = (ddl_channel.selected as integer)
			cbSelectionChanged mForce:true
		)
 
		on cp1 changed arg do edgesColor = arg
 
		on spn_width changed arg do edgeOffset = (arg-1)/100.0
 
		on chk_redraw changed arg do forceRedraw = arg
 
	)
 
	createDialog RO_DISPLAY_UV_OE
 
)
airbrush's picture

That's it!! nice job, I

That's it!!

nice job, I didn't notice any slow down on my machine?

Thanks :)

The only thing i would suggest to have is an automatic update. When i tweak the mesh I need to click the 'update' button, it should update on its own and loose the update button all together.
Still just like that it's very workable for what i wanted it to do.

JokerMartini's picture

Here is a start. Just fiddle

Here is a start. Just fiddle around and collect the tVerts and assign those point3 values to the gw.Polyline and you have yourself a display.

delete objects
myBox = box width:10 height:10 length:10 pos:[0,0,50] wirecolor:blue
convertToPoly myBox
 
unRegisterRedrawViewsCallback showObjectNames
fn showObjectNames = if (gw.wTransPoint [0,0,0]) != undefined do
(
	gw.setTransform (Matrix3 1)
 	gw.setColor #line green
-- 	gw.polyLine #([5,5,5],[10,10,10],[50,50,50]) true
 
	for o in objects where classof o == Editable_Poly do
	(
		vertsPts = for i = 1 to o.numVerts collect polyop.getVert o i
		gw.polyLine vertsPts true
	)	
 
	-- Update the viewports 
	gw.enlargeUpdateRect #whole
	gw.updateScreen()
)
registerRedrawViewsCallback showObjectNames
forceCompleteRedraw()

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

airbrush's picture

its a start...

its a start...

airbrush's picture

...finding a need for this

...finding a need for this more and more, anyone willing to give it a whirl?

much appreciated

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.