hey there, I am trying to rotate m_up and m_front by offset (in degrees). the function below only rotates around the x-axis for now. But I also needs to rotate around the y-axis. I am not quite sure how to achieve this.
(when I first multiply m_up & m_front by rotate_x and then by rotate_y. the camera seems to rotate a bit about the z-axis)
(I am using row vectors).
void Camera::rotate(const Vec3<GLfloat>& offset) {
GLfloat p = RADIANS(offset.x); /* pitch */
GLfloat h = RADIANS(offset.y); /* heading */
GLfloat b = RADIANS(offset.z); /* bank */
Mat3<GLfloat> rotate_x{
1.0f, 0.0f, 0.0f,
0.0f, cosf(p), sinf(p),
0.0f, -sinf(p), cosf(p)
};
Mat3<GLfloat> rotate_y{
cosf(h), 0.0f, -sinf(h),
0.0f, 1.0f, 0.0f,
sinf(h), 0.0f, cosf(h),
};
Mat3<GLfloat> rotate_z{
cosf(b), sinf(b), 0.0f,
-sinf(b), cosf(b), 0.0f,
0.0f, 0.0f, 1.0f
};
/* currently only rotates around x-axis! */
m_front = m_front * rotate_x;
m_up = m_up * rotate_x;
}