I\'m working on a FPS style camera to fly around my 3D scene using OpenGL. I\'m using GLM for the mathmetics and I calculate a direction vector with a glm::rotate on the x-a
I'm not entirely sure what the problem is, but when I use LookAt for an FPS cam I also include a forward unit vector.
E.g (copied relevant segments from some code I have) - using quaternions (orientation), but I'm sure matrices will have the same result)
static glm::vec3 defaultUpVector() { return glm::vec3(0, 1, 0); }
static glm::vec3 defaultForwardVector() { return glm::vec3(0, 0, -1); }
pUpVector = defaultUpVector() * orientation;
pLookAt = position + (defaultForwardVector() * orientation);
pView = glm::lookAt(position, pLookAt, pUpVector);
upvector and lookat are both vec3, and view is mat4
Hope this helps.
EDIT: I notice you are using a direction, so I would probably look at where you use rotate.
This will set the quat for an FPS cam with no roll
pLocalOrientation =
glm::angleAxis(pLocalEularAngles.x, glm::vec3(1, 0, 0)) *
glm::angleAxis(pLocalEularAngles.y, glm::vec3(0, 1, 0));
pLocalOrientation == orientation (for the example)
If you decide to use quats.