MXS: How to get UV size from collapsed object via maxscript?


#1

Hello all.

Is there any way to get the UV size from a collapsed object via maxscript?
Suppose some object was previously UV mapped with certain dimensions, then its entire stacks were collapsed. Now I need to get the size of this UV mapping.


#2
fn getUVBounds mobj mapch = 
(
	minUV = [1e+012, 1e+012, 1e+012];
	maxUV = [-1e+012, -1e+012, -1e+012];
	
	if meshop.getmapsupport mobj  mapch do
	(	
		num_map_faces = meshop.getNumMapFaces mobj mapch
		for f = 1 to num_map_faces do
		(	
			mfverts = meshop.getmapface mobj mapch f;
			mvert = meshop.getmapvert mobj mapch mfverts[1];
		
			if mvert.x < minUV.x then minUV.x = mvert.x;
			if mvert.y < minUV.y then minUV.y = mvert.y;
			if mvert.z < minUV.z then minUV.z = mvert.z;	
			
			if mvert.x > maxUV.x then maxUV.x = mvert.x;
			if mvert.y > maxUV.y then maxUV.y = mvert.y;
			if mvert.z > maxUV.z then maxUV.z = mvert.z;

			mvert = meshop.getmapvert mobj mapch mfverts[2];
			
			if mvert.x < minUV.x then minUV.x = mvert.x;
			if mvert.y < minUV.y then minUV.y = mvert.y;
			if mvert.z < minUV.z then minUV.z = mvert.z;	
			
			if mvert.x > maxUV.x then maxUV.x = mvert.x;
			if mvert.y > maxUV.y then maxUV.y = mvert.y;
			if mvert.z > maxUV.z then maxUV.z = mvert.z;
				
			mvert = meshop.getmapvert mobj mapch mfverts[3];
			
			if mvert.x < minUV.x then minUV.x = mvert.x;
			if mvert.y < minUV.y then minUV.y = mvert.y;
			if mvert.z < minUV.z then minUV.z = mvert.z;	
			
			if mvert.x > maxUV.x then maxUV.x = mvert.x;
			if mvert.y > maxUV.y then maxUV.y = mvert.y;
			if mvert.z > maxUV.z then maxUV.z = mvert.z;
		)
	)
	#(minUV, maxUV);	
)	

getUVBounds $ 1

you could add a visited bitarray so as not to visit the same vert more than once but I don’t think you’d win much!


#3

Hi, Klvnk!
Thanks for the answer. But as a result of executing the function, I see only the number of UV tiles, but I do not see the size of the UV tile. Is it even possible to get the size of a single UV tile?
Suppose there was an object with a UVWMap modifier with gizmo sizes [length = 100] and [width = 100"]. This object was collapsed and now I don’t know what size of the UV gizmo existed before the collapse and I need to know this size. Is there any way to get the [length] and [width] for single tile of UV map?