PDA

View Full Version : 3D 360 degree Panoramic Camera



lukemtesta
09-16-2012, 02:33 AM
Hi guys,

I need help creating a first person camera control which can pan 360 degrees. Y is taking as the up direction. If it was birds eye view it would be an easy case of xcosa and ysina. I am using glutPassiveMouseFunc to return the mouse co-ordinates of the screen and calibrated it to take the centre point of the screen as (0,0). I know how to rotate the camera (by changing lookat point in glulookat) for a half-sphere but not the full sphere. (purely problem is the z direction) I don't mind encountering gimbal lock.

Just to emphasise the camera works, its jsut an algorithm or mathematical expression calculating the new camera points from an (x,y) co-ordinate.

Thanks for any help you can other guys :)

thokra
09-17-2012, 03:40 AM
[..]which can pan 360 degrees.

I suppose you mean rotate around Y, right?


I know how to rotate the camera (by changing lookat point in glulookat) for a half-sphere but not the full sphere.

Well, you can simply calculate the basis vectors of the camera's coordinate system. For instance, you save yourself a forward vector which is simply rotated around y and in some initial position, i.e. (0, 0, -1). If you don't want rotation about X, the problem is as simple as the 2D case you described. Simply rotate the forward vector and use that vector as input to gluLookAt. If you're camera is supposed to be mobile, you need to also save the translated eye-point, which will be given to gluLookAt as well.

If you want to break your reliance on gluLookAt at some point, check it how the function is defined. This will give you all the math you need to implement a free camera.

lukemtesta
09-18-2012, 12:33 PM
Thanks man. I actually used this exact method to solve it in the end. I needed some sleep as 12 hours of straight coding doesn't help anyone get a solution :p

thokra
09-18-2012, 01:05 PM
I needed some sleep as 12 hours of straight coding doesn't help anyone get a solution :p

Nope. All it will get you in the end are herniated spinal discs. :)