Aligning a feather to a face in a mesh


I´m currently working on a script to automate the process of creating the controllers for a feather system. It´s based on the attachment controller.

I use a pflow to distribute the feathers. In the end, i have a bunch of single geometry feathers with their pivot point in the base of each. The Z Axis is paralel to the feather. I have found the baricentric coordinates and the correct face to feed the attachment constraint with and that works fine!

The problem is the feather changes orientation! When i tried to re-orient it by script, by storing the orientation in world coordinates and them aplying it later like feather.transform = oldTransform it just didn´t work!

But the odd thing is, when i try to align it by hand with the align tool in max, it just works!

Also, when i type: feather.rotation before and after the aplication of the attachment controller, it shows the same quaternion values, but if i use feather.transform.rotationpart the values are different!

So i have the idea to somehow extract the difference of the two angles and them apply it in reverse, but i can´t understand how to do it because of lack of matematical knoledge.

Any ideas? Thanks in advance!


Comment viewing options

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

You got it wrong. By using

You got it wrong. By using the attach constraint, i get the rotation alignment for free. The thing is, i also got a rotation about the Z axis of the face I just aligned. The positioning of the feather and it´s rotation is already solved by a particle flow system that is later baked in separate geometry for each feather (hence a separete attach controller for each feather).

What happens is that a rotation is derived from the rotation controller and the position controller! So, if i access it by feather.rotation i get a different result as if i was to type feather.transform.rotationpart. What i don´t know how to do is apply the offset of the quaternion rotation from the original rotation and the post attachment constraint rotation in reverse so that i would have the same rotation that was originaly intended.

Any clues? Thanks for the help, anyway! :)

Graph's picture

my guess is you wanna first

my guess is you wanna first position then rotate it, that wont work
you got the barycoords and verts in order? get the vector the face is pointing in then use the matrixfromNormal function and change its positionpart and you oughta be good to go
any rotational offset from the face normal should be applied before the position just to be sure

Raphael 'Insanto' Steves

Comment viewing options

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