View Full Version : [Solved] GLM::lookAt and vectors.

06-04-2011, 06:17 AM
Hey all,

I'm having a few issues with my Camera class. My camera class produces a matrix made with GLM lookAt, where it uses the position, target and up vectors. I think I know how the matrix is generated, which is then passed to the shader. I was trying to have the camera rotate around a point in the middle of the screen, like how rotate works in most RTS games. Just rotating the position vector doesn't work though, because it moves the camera up and down too. Another problem is zooming. I'm not sure how to move the camera along the line that points to the center of the screen (the target vector, if I understand correctly?). Could anyone enlighten me on how these two operations work?

Thanks in advance,


Edit: After trying a few things, I realized the camera wasn't rotation around the y-axis, but rather the vector that points to the origin. That's why I had to translate the camera to the origin first, rotate and then translate back to get proper results. The zoom method was easier than expected too: Normalize the difference between the position and the target vector, multiply that vector by the zoom amount and add it to the position. Thanks anyway :P