   Rotating a quad/billboard to always point"up"
  In the engine I'm using, there is a quad effect that displays a texture that always faces the camera in the same orientation. We're using this effect for distance planets in 3D space, so the effect looks strange when you roll and all the planets roll as well.  I have the ability to set the rotation angle of the effect, so if I can determine the correct angle to rotate them, I can keep their apparent orientation fixed "up" relative to the camera. The problem is, given the camera's transform, I don't know how to determine which angle to rotate the quad so that it appears to always be oriented up to the observer. Any thoughts?   
  The camera transform is a matrix. Used forwards, it basically describes how unit axis vectors in your current space become unit axis vectors in your new space; the new vectors are PART of the camera matrix. The camera matrix goes from world to camera space.Hence, if you invert the matrix, so you can use it the other way (from camera to world), you then have a matrix which contains a set of vectors which are the unit axis vectors of the camera in worldspace.This means that there's a row or a column (depending on which kind of matricies you're using) which represents the UP axis that the viewer sees only in world space. The other two represent the direction of viewing (in or out of the screen) and the X axis.Exactly how you get this depends on the system you're using. In opengl you use GetFloatv(GL_MODELVIEW_MATRIX) to get the matrix, invert it and then pull out rows.A useful trick to know at this point is that if you clear the bottom and right of the 4x4 matrix, you get the 3x3 rotation elements plus some 0,0,0,1 components. Since a rotation matrix has determinant of 1, it can be inverted by transposing it. (flipping it about the diagonal).Once you know what the camera up vector is, determining the rotation angle is a dot product and a acos().