Notifications
Clear all

[Closed] polyop.getFaceSelection or is my matrix math wrong

hi

trying to apply a uvwModifier to a selection faces and it works if the polyObj has had its xForm reset but when there is any rotation on the polyObj the gizmo doesent align to the faces correctly
Any suggestion on why this is would be appreciated, i have tried the in coordsys but it didnt make any difference

polyObj = selection[1]
ia_theFaces = (polyop.getFaceSelection polyObj as array)
p3_totalFaceNormal = [0,0,0]
for i in ia_theFaces do
(
	 p3_totalFaceNormal += (polyop.getFaceNormal polyObj i)
)
p3_avgFaceNormal= ( normalize p3_totalFaceNormal )

worldUpVec = [0,0,1]
rightVec = normalize (cross worldUpVec p3_avgFaceNormal) 
upVec = normalize ( cross rightVec p3_totalFaceNormal )
theMatrix = matrix3 rightVec upVec p3_totalFaceNormal [0,0,0] 
uvwMapMod = UVWmap()
modPanel.addmodtoselection uvwMapMod
uvwMapMod.Gizmo.transform = theMatrix 

cheers
Dave

2 Replies
polyObj = selection[1]
ia_theFaces = (polyop.getFaceSelection polyObj as array)
p3_totalFaceNormal = [0,0,0]
for i in ia_theFaces do
(
	 p3_totalFaceNormal += (polyop.getFaceNormal polyObj i)
)
p3_avgFaceNormal= ( normalize p3_totalFaceNormal )

worldUpVec = [0,0,1]
rightVec = normalize (cross worldUpVec p3_avgFaceNormal) 
upVec = normalize ( cross rightVec p3_totalFaceNormal )
theMatrix = matrix3 rightVec upVec p3_totalFaceNormal [0,0,0] 
uvwMapMod = UVWmap()
modPanel.addmodtoselection uvwMapMod
uvwMapMod.Gizmo.transform = theMatrix*inverse(selection[1].transform)

Your problem is you get face normal in world space and gizmo transform is not.
You should search for “Modifier Sub-Object Transform Properties” if you need additional information. Search for modTM in the maxscript doc.
Cheers

thanks i shall start reading