Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to check overlapped UVW faces in specific map channel?

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
LayTiger
689 Views, 10 Replies

How to check overlapped UVW faces in specific map channel?

I tried xView "OverlappedUVWFaces.Check" first, but the function will return all overlapped uvw faces throughout all map channels.Then I found that "Select Overlapped Polygons" button in the UVW editor works well, so I tried to use the function to get overlapped uvw faces, but it seems not work in my code. Can somebody please help me?

LayTiger_2-1723085161534.png

LayTiger_3-1723085255626.png

fn CheckOverlappedUVWInSecondUV geo=
(
	local unwrapMod =  geo.modifiers["Unwrap_UVW"]
	local overlappingUVWFaces = #{}
	local uvChannel = 2
	if(classof (unwrapMod) == Unwrap_UVW and unwrapMod.getMapChannel() == UVChannel) then
	(
		unwrapMod.setMapChannel 2

		unwrapMod.selectOverlappedFaces()
		overlappingUVWFaces = unwrapMod.getSelectedFaces()
	)
	else
	(
		addModifier  geo (Unwrap_UVW())
		unwrapMod =  geo.modifiers["Unwrap_UVW"]
		unwrapMod.setMapChannel 2

		unwrapMod.selectOverlappedFaces()
		overlappingUVWFaces = unwrapMod.getSelectedFaces()
	)

	if overlappingUVWFaces.numberSet > 0 then
		return false
	else
		return true
)

 

10 REPLIES 10
Message 2 of 11
denisT.MaxDoctor
in reply to: LayTiger

Do you need to check just a fact of overlapping, or do you need to know which particular faces are overlapped?

Message 3 of 11
LayTiger
in reply to: denisT.MaxDoctor

I just need a fact of overlapping.
Message 4 of 11
denisT.MaxDoctor
in reply to: LayTiger

so you can use the xView and UVW_Mapping_Clear modifier(s) to temporarily clear unwanted channels.

 

of course, you can use a temp UVW_Unwrap modifier but it's the much heavier solution.

Message 5 of 11
denisT.MaxDoctor
in reply to: LayTiger

question #2: How big is your mesh? Large meshes can be critical for the xView

Message 6 of 11
LayTiger
in reply to: denisT.MaxDoctor

xView and UVW_Mapping_Clear modifier(s) actually works, thank you very much.

fn CheckOverlappedUVWInSecondUV geo=
(
	addModifier geo (UVW_Mapping_Clear())
	uvwClear = geo.modifiers["UVW_Mapping_Clear"]
	uvwClear.mapID = 1
	overlappingUVWFaces = #()
	OverlappedUVWFaces.Check currentTime geo &overlappingUVWFaces
	overlappingUVWFacesCount = overlappingUVWFaces.count
	deleteModifier geo uvwClear
	if(overlappingUVWFacesCount > 0) then
	(
		return false
	)
	return true
)
Message 7 of 11
LayTiger
in reply to: denisT.MaxDoctor

It's a game asset, usually have no more than 10000 faces, maybe it's ok to use xView?
Message 8 of 11
denisT.MaxDoctor
in reply to: LayTiger

Give it a try, who knows... 😁
I believe it should work with 100K, but not in real time of course.

Message 9 of 11
denisT.MaxDoctor
in reply to: LayTiger


@LayTiger wrote:

xView and UVW_Mapping_Clear modifier(s) actually works, thank you very much.

 

fn CheckOverlappedUVWInSecondUV geo=
(
	addModifier geo (UVW_Mapping_Clear())
	uvwClear = geo.modifiers["UVW_Mapping_Clear"]
	uvwClear.mapID = 1
	overlappingUVWFaces = #()
	OverlappedUVWFaces.Check currentTime geo &overlappingUVWFaces
	overlappingUVWFacesCount = overlappingUVWFaces.count
	deleteModifier geo uvwClear
	if(overlappingUVWFacesCount > 0) then
	(
		return false
	)
	return true
)

 


 

fn CheckOverlappedUVWInSecondUV geo excludeCh: =
(
	uvwClear = undefined 
	if excludeCh != unsupplied do
	(
		uvwClear = UVW_Mapping_Clear mapid:excludeCh
		addModifier geo uvwClear
	)
	
	overlappingUVWFaces = #()
	OverlappedUVWFaces.Check currentTime geo &overlappingUVWFaces

	if uvwClear != undefined do deleteModifier geo uvwClear

	overlappingUVWFaces.count != 0
)

 



Message 10 of 11
LayTiger
in reply to: denisT.MaxDoctor

wow, thank you for the optimized version!
Message 11 of 11
denisT.MaxDoctor
in reply to: LayTiger

It's not an optimization really... yours is good too. Mine is more “mxs stylish”. 😉  

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report