Notifications
Clear all

[Closed] FFD – local to world space on rotated object

Hi!
The code below convert local to world space for FFD control points and works fine if the object is not rotated. But when the object with applyed FFD mod is rotated the function that converts local to world produces the strange results – see the attached image.

(
 	function LocalFFDToWorld curObj topMod pos =
 	(			
 		objTM = curObj.objecttransform
 		modTM = (getModContextTM curObj topMod) * topMod.lattice_transform.value
 		modBBMin = getModContextBBoxMin curObj topMod
 		modBBMax = getModContextBBoxMax curObj topMod
 		size = modBBMax - modBBMin
 		thePoint = modBBMin * inverse topMod.lattice_transform.rotation + (pos * size) * (inverse modTM) * objTM
 	)
 	
 	local topMod = modpanel.getCurrentObject()	
 	local theMaster = topMod[#master]
 	local theCount = theMaster.numsubs
 	animateAll topMod
 	
 	for i = 1 to theCount where theMaster[i].value != undefiend do
 	(
 		point pos:( LocalFFDToWorld selection[1] topMod theMaster[i].value)
 	)	
 )
2 Replies

because your final expression is wrong. it has to be:


thePoint = (modBBMin + pos * size) * (inverse modTM) * objTM

Works. Thank you.