View Full Version : glm rotate

03-16-2015, 01:27 PM
Now I have a forward vector for the camera (0,0,-1). I'm rotating it around global x-axis for 2 degrees, and use the transformed vector for glm's lookAt function. But when running, it doesn't just stop at the positive 2 degrees around x-axis, instead it continues to rotate upward. While using the same method for another object, the object only rotate for that amount of degrees as expected. Why using it for the camera's forward vector will constantly rotate it?

mat4 rotation;
rotation = glm::rotate(2.0f, vec3(1,0,0));
forwardVector = mat3(rotation)* forwardVector;
viewMatrix = lookAt(eye, eye+forwardVector, vec3(0,1,0));

03-16-2015, 03:17 PM
So instead of looking left (positive rotation value goes counter clockwise) you want to look right but you look up right? If that is right then you should rotate around Y-axis because that is the axis you rotate around when looking around you. X-axis is used to look up and down, Y-axis is used to look left and right and Z-axis is used to tilt the camera.
Change rotation = glm::rotate(2.0f, vec3(1,0,0)); to rotation = glm::rotate(2.0f, vec3(0,1,0));