I asked a question a while back that was about finding the yaw and pitch rotations for the equivelant of a direction (normalized) vector. That's no longer a problem (thanks again Reed), but now I am doing a billboarded light beam and I need the z rotation (aka roll)
So I already have the x and y rotations, how do I compute roll with the direction vector from my camera to the light.
Thanks in advance.
One vector isn't enough to pin down the roll. You can see that rolling the vector would just rotate it around its own axis and wouldn't change it at all. Roll only matters when you have a full coordinate system with three axes.
That being said, you can calculate roll by looking at the left/right axis of the coordinate system. If you use the convention of x = forward, y = left, z = up, then the roll is atan2(left.z, sqrt(left.x\\^2 + left.y\\^2)). Note that you can only roll up to +/- 90 degrees in this scheme; then there will be a discontinuity in the Euler angles.
Thanks for the advice.
You're making it sound a bit like I'm going about this wrong. My goal here is (and I'm sure your familiar with it) I have a 2D light beam that has a fixed X and Y orientation (those being the direction that the spot light is pointed in). The only thing left to do is to keep the side of the beam facing towards me (hence billboarding).
Is there a better or more elegant way to achieve this?
In that case, you can use the camera's view direction. If your beam texture is laid out with the direction of the light parallel to the U axis, you can calculate the V axis for the texture in world space by crossing the spotlight direction with the camera's view direction. Those U and V axes should be enough to construct the appropriate screen-facing quad.
take the cross product of your view vector and beam vector, it will give you the side vector.
and use an object space quad instead of a screen space billboard.