OpenGL glulookat Function

Source: Internet
Author: User
Use the practical library function glulookat () to set the visual coordinate system. In practical programming applications, after modeling a scenario, you often need to select a proper perspective or constantly change the perspective to observe the scenario. The practical library function glulookat () provides such a function.
Void glulookat (gldouble eyex, gldouble eyey, gldouble Eyez,

Gldouble centerx, gldouble centery, gldouble centerz,

Gldouble UPX, gldouble upy, gldouble upz );

This function defines a view matrix and multiply it with the current matrix.

Eyex, eyey, and Eyez specify the position of the viewpoint

Centerx, centery, and centerz specify the position of the reference point

UPX, upy, and upz specify the upward direction of the viewpoint
Point of View e, point C, and point of view u are actually a visual coordinate system. The origin of this visual coordinate system is E, the line of sight (I .e., the Z axis) is the C-U, the Y axis is the point of view direction U, the rest of the X axis direction is the vector (C-E) * U ). Since the Y axis and the X axis are vertical, it is also required that the vector (C-U) and U be perpendicular to each other. This must be noted when setting this function parameter.
Since the Y axis and the X axis are vertical, it is also required that the vector (C-U) and U be perpendicular to each other. This must be noted when setting this function parameter.
It is okay if the application is not vertical, so I have found a more reasonable explanation.
Void glulookat (
Gldouble eyex,
Gldouble eyey,
Gldouble Eyez,
Gldouble centerx,
Gldouble centery,
Gldouble centerz,
Gldouble UPX,
Gldouble upy,
Gldouble upz
);

Eye = (eyex, eyey, Eyez) is the position of the viewpoint (origin)
Center = (centerx, centery, centerz) is the position of the center of the view.
Center-eye is in the negative direction of the Z axis.
Z = (eye-center)/| eye-center |
Up = (UPX, upy, upz)-eye indicates the top
X = up × Z/| up × z |
Y = z x

Well, the first floor is the correct solution. I 'd like to explain it in detail.
You can use the glulookat () function to change the viewpoint. The three sets of Parameters specify the camera position, the reference point of the orientation, and the camera upward direction.
Usually the viewpoint transformation operation is issued before the model transformation operation, so that the model transformation first takes effect on the object. In this way, the vertex of an object in a scenario must reach the desired position after model conversion, and then perform operations such as viewpoint location on the scene. Model Transformation and viewpoint transformation form a visual matrix of the model.
Glulookat (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
1. Changing the values of the first three parameters can simulate the movement of people in the actual environment;
2. Changing the value of the three parameters in the middle can simulate the rotation of the human eye, that is, the changes in the observed scenario.
3. The values of the last three parameters are special. They define not a point but a direction, that is, to determine which axis is taken as the upward direction, if the upward direction is the same as the direction from the observation point to the central point, the result will be uncertain.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.