how to create my own gluLookAt?

Started by
3 comments, last by python_regious 19 years, 7 months ago
anyone here knows how glulookat works? is it possible to do what glulookat is doing by just pure glrotate and gltranslate?
Advertisement
Quote:Original post by _nomad_
anyone here knows how glulookat works? is it possible to do what glulookat is doing by just pure glrotate and gltranslate?


Yep, and yep - but you'll get gimbal lock.

gluLookAt uses the inverse of a standard "frame" matrix, so:

[ Sx Sy Sz -Px ][ Ux Uy Uz -Py ][ Fx Fy Fz -Pz ][  0  0  0  1 ]


Where, S, U, F and P are the side, up, front and position vectors of the camera respectively.

Load this into the modelview matrix before anything, and it'll transform the scene to around the camera.
If at first you don't succeed, redefine success.
hmm...so if I load that up to the modelview matrix before anything, i will not get gimbal lock? Thanks.
Quote:Original post by _nomad_
hmm...so if I load that up to the modelview matrix before anything, i will not get gimbal lock? Thanks.


why would you not just use gluLookAt?

-me
Quote:Original post by Palidine
Quote:Original post by _nomad_
hmm...so if I load that up to the modelview matrix before anything, i will not get gimbal lock? Thanks.


why would you not just use gluLookAt?

-me


Because of the way it works? It wants a point 1 unit along the front vector, instead of just the front vector. That seems a little pointless to me, considering I have to calculate that point from the front vector in the first place, and all gluLookAt does is calculate the front vector from that point again.

I point you to This thread.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement