I figure if I answer keep answering these, all billboarding questions will go away
If you constrain your billboard to be rotating about only one axis, then the billboard’s normal sweeps out a plane during this rotation. If we project the vector from the camera to the center of the billboard onto this plane, that will be the vector we want to rotate to.
So, here would be pseudo-code. I haven’t tested this, so there will, of course, be mistakes like missing minus signs. But it wouldn’t be fun if I did all the work
Vector n = billboardNormal;
Vector c = cameraVector - billboardPositionVector;
Vector axis = axis we want to rotate around (i.e. direction of laser travel or sphere normal)
Vector temp;
Vector target;
float angle;
// If not already normalized, do this
n.normalize();
c.normalize();
// First need 2 orthogonal vectors to define a plane. One is n, the other is n x c
temp = n x c;
// Now temp and n define our plane. Project c onto this plane
// This is the sum of the projection of c onto n and temp
target = ((n % c) * n) + ((temp % c) * temp);
// target is the vector we want to rotate the billboard to
angle = acos(target % n) * 180.0 / PI;
i dont really know if that helps you, but its a code-sample wich works nicely and perhaps does some help here, too… the idea is simple: create a normalized angle ( as TTvec, here… and then you can rotate around it…:
TTvec r( 0, 1, 0 );
TTvec v( 1, 0, 0 );
r.RotateAroundMe( 90, v, v );
result should be v == ( 0, 0, 1 ) ( or ( 0, 0, -1 )hm… dont know )