I am working on something that sounds simple enough, but unless there are some tools that will do this easily, it is much harder than you would think to figure it out.
I am trying to get the perspective camera to align itself with the normal to a selected face. I have worked out a way to calculate the face normal which is most likely a poor workaround, but it works.
I can modify the perspective camera's workspace just fine, but I am having a beast of a time keeping my head straight when it comes to rotating the camera's attributes to match the vector.
I get the normal, and then translate it to the origen. Then I force the camera's rotation order to be xyz.
Then I try and calculate the angle to set for the x rotation in the attribute for the camera (which as I see it would depend on the quadrant the vector is in on the yz plane.)
Once I get that, I do a similar thing to calculate a rotation around the y axis that should put me alligned with the vector.
It is dizzying though trying to keep the rotations straight and remember which direction you are rotating and all that crazy stuff. I have looked at aimConstraint, but that doesn't do what I want. Anybody know how to do this?
I thought I was right when I first coded it up, but it doens't work. It translates to a good location right off the selected face, but I cannot get the rotation right or the life of me.