Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am following a tutorial to learn OpenGL in which they used glm::lookAt() function to build a view but I cannot understand the working of glm::lookAt() and apparently, there is no detailed documentation of GLM. Can anyone help me understand the parameters and working of glm::lookAt() please?

GLM documentation says:

detail::tmat4x4<T> glm::gtc::matrix_transform::lookAt   
(   
    detail::tvec3< T > const &  eye,
    detail::tvec3< T > const &  center,
    detail::tvec3< T > const &  up 
)

My current understanding is that camera is located at eye and is faced towards center. (And I don't know what the up is)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
227 views
Welcome To Ask or Share your Answers For Others

1 Answer

The up vector is basically a vector defining your world's "upwards" direction. In almost all normal cases, this will be the vector (0, 1, 0) i.e. towards positive Y. eye is the position of the camera's viewpoint, and center is where you are looking at (a position). If you want to use a direction vector D instead of a center position, you can simply use eye + D as the center position, where D can be a unit vector for example.

As for the inner workings, or more details, this is a common basic function for building a view matrix. Try reading the docs for gluLookAt() which is functionally equivalent.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...