gluLookAt explanation?

后端 未结 3 1858
生来不讨喜
生来不讨喜 2020-12-23 21:10

Trying to understand gluLookAt, especially the last 3 parameters.

Can someone please explain ?

gluLookAt(camera[0], camera[1], camera[2], /* look f         


        
3条回答
  •  礼貌的吻别
    2020-12-23 21:52

    Sketchup to the rescue!

    GluLookAt params

    Your image has an 'up' to it that can be separate from the world's up. The blue window in this image can be thought of as the 'near-plane' that your imagery is drawn on: your monitor, if you will. If all you supply is the eye-point and the at-point, that window is free to spin around. You need to give an extra 'up' direction to pin it down. OpenGL will normalize the vector that you supply if it isn't unit length. OpenGL will also project it down so that it forms a 90 degree angle with the 'z' vector defined by eye and at (unless you give an 'up' vector that is in exactly the same direction as the line from 'eye' to 'at'). Once 'in' (z) and 'up' (y) directions are defined, it's easy to calculate the 'right' or (x) direction from those two.

    In this figure, the 'supplied' up vector is (0,1,0) if the blue axis is in the y direction. If you were to give (1,1,1), it would most likely rotate the image by 45 degrees because that's saying that the top of the blue window should be pointed toward that direction. Consequently the image of the guy would appear to be tipped (in the opposite direction).

提交回复
热议问题