Notifications
Clear all

[Closed] gizmo view align

I just wanted to recreate the “view align” function in uvmap() modifier.
So here is my atempt :


 (	
 	delete objects
 	obj = sphere()
 	select obj
 	max modify mode
 	
 	addmodifier obj (uvwmap())
 	modo = obj.modifiers[#uvwmap]		
 		
 	objTM = obj.objecttransform
 	modTM = (getModContextTM obj modo)	
 
 	viewTM = inverse (getViewTM())
 	viewTM.row3 = -viewTM.row3
 	newModTM = viewTM
 	newModTM.row4 = obj.center	
 		
 	modo.gizmo.transform = newModTM * modTM * (inverse objTM)
 )
 

Problem is the gizmo is not oriented to the right direction (Z/up).
What did I miss ?

1 Reply

I ended up with alignement method from mxs help “How do I align uvw_modifier’s gizmo to a selected face ?” :
http://help.autodesk.com/cloudhelp/2015/ENU/MAXScript-Help/files/GUID-1193B0E7-10DF-4D3F-A89F-29FF0A291646.htm

(
   	delete objects
   	obj = sphere()
   	select obj
   	max modify mode
   	addmodifier obj (uvwmap())
   	modo = obj.modifiers[#uvwmap]
   
   	viewDir = (inverse (getViewTM())).row3
   	faceNormal = -viewDir
   	worldUpVector = [0,0,1]
   	rightVector = normalize (cross worldUpVector faceNormal)	
   	upVector = normalize ( cross rightVector faceNormal )
   	theMatrix = matrix3 rightVector upVector faceNormal [0,0,0]
   	
   	modo.gizmo.transform = theMatrix
   )