tags:

views:

56

answers:

1

I am trying to implement a "Look At" behavior for planes moving around a sphere so they always face the camera.

What I figured out so far, I know the normal that the plane should have and I know that its rotation around its local Z axis should always be 0. I thought it was a pretty trivial operation to figure out the missing rotation values (X, Y) but so far, I found nothing.

So in short : How can I extract orientation information of a plane using its normal and one rotation value?

Or, if anyone has a better solution than using the normal, it would be welcome.

Thanks.

+1  A: 

Think about it like this. You've got two vectors in your plane's local coordinate system and two vectors in your cameras local coordinate system. You want a transform matrix which will transform between these coordinate systems so that the vectors line up.

Do it in two steps. I'm not sure, but I think that you're trying to rotate the plane's normal to align with the eye vector. If you normalize these two vectors, you can get an axis of rotation from their cross product and the cosine of the rotation angle from their dot product. Use that to create a transform matrix.

Now you want to do it again. Again, I'm not sure, but I think that you're saying that you want to align the plane's local Z axis with the camera's up vector. So, transform the Z axis by that transform matrix and once again compute a rotation which will map that to the camera's up vector. Use this to create a second transform matrix.

Now multiply the two matrices to get a single matrix which transforms from the plane's local coordinate system to the camera's.

Is that what you're after?

MPG
Thanks, using your solution (and tweaking a thing or two for technological reasons), I got it to work.
Mexican Seafood