Align object to face (stick)
Hello, I need to correct a problem in a script that I need
I need an object stuck in the face of a normal
my code in ScriptController in transform for de face 76 in sphere02
dependsOn $Sphere02
(
Pos= polyop.getFaceCenter $sphere02 76
Norm = (polyop.getFaceNormal $sphere02 76)
worldUpVector = [0,0,1]
rightVector = normalize(cross worldUpVector Norm)
upVector = normalize(cross rightVector Norm)
matrix3 rightVector upVector Norm Pos
)
In principle it works, but there are problems in the rotation of the object aligned....obviously not well
any suggestions?
(attach my example 3ds max 2009)
thank you!!!
(sorry for my bad inglish)
Attachment | Size |
---|---|
orient.max | 232 KB |
Comments
what we needed was that
what we needed was that attached to the center of the face selected...
$sphere02.dir produces an incorrect rotation in the object attached...
I could solve it with help from Cesar Saez in http://www.foro3d.com/f115/maxscript-orientar-objeto-a-normal-de-66833.html
two faces were used to calculate a vector from worldUpVector...
thanks anyway!!!
Do you want to keep the
Do you want to keep the attached object from rotating on its z axis? If that is the case, use an axis of the base object instead of worldUpVector. For example, use $sphere02.dir instead of [0,0,1].