Hi there! I'm new at scripting, so pls don't lynch me. I read a whole bunch of threads, and didn't find what I looked for.
I'm trying to write a script that converts the component pivot to the object pivot
. In other words, it translates and rotates
the object pivot to fit the current component pivot.
Getting the translation isn't diffcult, e.g. you can just cluster your component selection and use xform to get its position. Apart from that, there are several tools which can already do this, like D+Shift or Edit Pivot.
But when I select a component in component space, the handle orientation also adapts in a pretty intelligent way. X points in normal direction, z and y become tangents with z pointing towards a specific edge. I can't really figure what the actual rules are, but it looks sensible in most cases.
Here are some examples:
<img src="https://us.v-cdn.net/5021068/uploads/editor/0u/d0toqdxvrdow.png" alt="" title="Image: https://us.v-cdn.net/5021068/uploads/editor/0u/d0toqdxvrdow.png">
As modeller, it would have helped me in many cases if I had been able to keep this orientation as object orientation. Sure, I could just select all faces, press D, click on a face of which I want the orientation, and then translate all selected faces, but that's obviously a workaround.
I also saw someone who used a helping plane and parenting in order to achieve this, but I could'nt test it, since it was a very old script that didn't work at all in Maya 2019.
able to query vertex normals, but in order to rotate my object pivot, I'd need at least one sensible tangent, so that z and y are not arbitrary.
I know that it is possible to compute a tangent that is as close to Y-up as possible (like in automatic joint orientation), but that's not what Maya does in my example images.
For one face, I may be able to use the angles of the border vertices, but what about a single vertex?
Long story short: Is there any mastermind who knows how Maya gets this accurate orientation, or who knows another solution?
Thanks in advance!