UVW Mapping Gizmo Align

i have to objects, both of them have a simple planar UVW_Mapping on it and i try to match the one gizmo to the other - like the alignment "Acquire" button in the UVW Mapping modifier. i need a working script solution because i want it animated and aligned over time.

already tried it by my self by matching the modTM`s of the Gizmos but with no luck....in the end it got a bit to confusing for my skills, would be different if the scripting help would be much more informative...

cheers Cruzifer

Comments

Comment viewing options

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

Hey there, maybe this helps

Hey there,
maybe this helps :)
I dont know if this is the best method of acquiring the position tho. I would have liked to do it with "in coordsys world" but the modifiers[#UVW_Mapping].gizmo.pos isn't affected by it.

fn matchGizmo srcObj targetObj =
(
	-- check for a UVW Mapping modifier on both objects
	if srcObj.modifiers[#UVW_Mapping] != undefined AND targetObj.modifiers[#UVW_Mapping] != undefined then
	(
		-- grab all the modifier values off the srcObj
		targetObj.modifiers[#UVW_Mapping].maptype = srcObj.modifiers[#UVW_Mapping].maptype
		targetObj.modifiers[#UVW_Mapping].utile = srcObj.modifiers[#UVW_Mapping].utile
		targetObj.modifiers[#UVW_Mapping].uflip = srcObj.modifiers[#UVW_Mapping].uflip = off
		targetObj.modifiers[#UVW_Mapping].vtile = srcObj.modifiers[#UVW_Mapping].vtile 
		targetObj.modifiers[#UVW_Mapping].vflip = srcObj.modifiers[#UVW_Mapping].vflip
		targetObj.modifiers[#UVW_Mapping].wtile = srcObj.modifiers[#UVW_Mapping].wtile
		targetObj.modifiers[#UVW_Mapping].wflip = srcObj.modifiers[#UVW_Mapping].wflip 
		targetObj.modifiers[#UVW_Mapping].length = srcObj.modifiers[#UVW_Mapping].length
		targetObj.modifiers[#UVW_Mapping].width = srcObj.modifiers[#UVW_Mapping].width
		targetObj.modifiers[#UVW_Mapping].axis = srcObj.modifiers[#UVW_Mapping].axis
		targetObj.modifiers[#UVW_Mapping].length = srcObj.modifiers[#UVW_Mapping].length
		targetObj.modifiers[#UVW_Mapping].width = srcObj.modifiers[#UVW_Mapping].width 
		targetObj.modifiers[#UVW_Mapping].height = srcObj.modifiers[#UVW_Mapping].height
 
		-- grab the gizmo for scale and rotation
		targetObj.modifiers[#UVW_Mapping].gizmo.transform = srcObj.modifiers[#UVW_Mapping].gizmo.transform
 
		-- since the position of the gizmo is in relation to the center of the srcObj we just get it and apply it afterwards. the gizmo is still good for rotation and scaling tho
		centerDifference = srcObj.center-targetObj.center
		targetObj.modifiers[#UVW_Mapping].gizmo.pos = targetObj.modifiers[#UVW_Mapping].gizmo.pos + centerDifference
	)
	else
	(
		Messagebox("One or more Object does not have a UVW_Mapping")
	)
 
)
 
	srcObj = $objA
	targetObj = $objB
 
	matchGizmo srcObj targetObj

~Markus

Comment viewing options

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