I'm trying to make rotation of the camera without roll effect.
I accumulate 3 angles from 0 to 359.9 degrees. Then I make 3 quaternions (glm::quat) from accumulated angles (half) with global axial vectors and multiply them into 1 quaternion. Then I convert this quaternion to rotation matrix. And at least I insert this 3x3 matrix into 4x4 view transform matrix (to [0][0] corner).
void View::rotate(const float& angleX, const float& angleY, const float& angleZ)
{
float rad = 3.14159265359/180.0;
pitchAngle += angleX;
degree360(pitchAngle);
yawAngle += angleY;
degree360(yawAngle);
rollAngle += angleZ;
degree360(rollAngle);
float angle_x = pitchAngle*rad/2;
float angle_y = yawAngle*rad/2;
float angle_z = rollAngle*rad/2;
glm::quat qX = glm::quat(angle_x, glm::vec3(1.0, 0.0, 0.0));
glm::quat qY = glm::quat(angle_y, glm::vec3(0.0, 1.0, 0.0));
glm::quat qZ = glm::quat(angle_z, glm::vec3(0.0, 0.0, -1.0));
glm::quat q = qZ * qX * qY;
glm::mat4 spin_mat = glm::mat4_cast(q);
matrix[0][0] = spin_mat[0][0];
matrix[0][1] = spin_mat[0][1];
matrix[0][2] = spin_mat[0][2];
matrix[1][0] = spin_mat[1][0];
matrix[1][1] = spin_mat[1][1];
matrix[1][2] = spin_mat[1][2];
matrix[2][0] = spin_mat[2][0];
matrix[2][1] = spin_mat[2][1];
matrix[2][2] = spin_mat[2][2];
}
I can't understand what I am doing wrong. This function rotate in strange incredible directions and angles.