I have a quaternion derived from sensors that rotates the "camera" within an OpenGL ES scene. Also I apply the inverse of this quaternion to certain objects in the scene, so they are "facing" the "camera" - this works as expected. The issue is that I need to negate rotation on the Z axis for these objects. How do I come up with a quaternion which has no rotation within the Z component?
My tests: I have attempted to extract euler Angles, create a negating quaternion and build the rotation matrix for these objects from the multiplication of the two quaternions - results are incorrect.
glm::quat rMQ = cam->getCameraQuaternion();// retrieve camera quat
glm::vec3 a = glm::eulerAngles((rMQ))* 3.14159f / 180.f; // Euler angle set derived
glm::quat rMZ = glm::angleAxis(-a.z, vec3(0.0f, 0.0f, 1.0f)); // negating quaternion
glm::mat4 fM = glm::inverse(glm::mat4_cast(rMQ*rMZ)); //final mat4 for GL rotation