Model, View(Camera), Perspective (2)

This blog is written by observation space (space to observe the world from space) in the observation matrix (view matrix), also known as a camera (camera).

In essence, what the camera does not exist. The so-called observation of the space is actually an object in its own transformation (in the opposite direction conversion), resulting in a sense of our human observation, which is the function of the observation matrix: Matrix observe all the world coordinate transformation relative to the camera position the coordinates of the viewing direction.


 

But let's still call it a camera (camera).

To determine the location of a camera, you need to have three vectors.

The first one is pointing to the camera position vector (based on world coordinates).

The second is the direction vector of the camera , the camera is pointing to the location (target) in the opposite vector , in fact, here the direction vector is not very appropriate name, because in fact the actual vector and vector direction is reversed. (Ps: both cameras also positive axis z)

The third is the vector (the axis, based on the observation coordinates), the vector is determined little trouble, First we arbitrarily defined on a vector (based on the world coordinates), and the direction of the vector and to obtain a vector cross product Right vector (n x axle points, based on the observation coordinate), then the right-vector (x) and the direction vector (z) for cross product, is obtained on the vector (positive y pointing axle, based on the observation coordinates).

After obtaining the three-axis vector, we can use these three axes (determining a coordinate space) plus a translation vector to create a transform matrix, we can multiply a vector by any of the transformation matrix is ​​transformed into the coordinate space. And let's OpenGL eliminates the tedious process of the above, it provides a function lootAt, let us avoid the tedious steps above.

:: = View MAT4 GLM GLM :: MAT4 ( 1.0f ); 

View = GLM :: the lookAt (cameraPos, the Target, Up); 
// (position, target position, a vector)

Do not underestimate these parameters, it allows us to play out some flowers. For chestnut, for cameraPos, we can create a circular system based on time change (y-axis does not move, an xz axis changing), i.e., the frame changing x, z coordinates of each such sub camera rotating around the target point will a; and for Target, as if to let him change cameraPos to change, then pan the camera can achieve results.


Mentioned above is the focus (the Target) does not move, or change in synchronization with the case cameraPos next talk cameraPos fixed, where changes in the focus (Target).

First, we need to introduce the Euler angles (Euler Angles) concept, there are three Euler angles, namely, the pitch angle (pitch), the yaw angle (yaw), roll angle (roll) . More specific, detailed conceptual reference blog last to come out of the link.

After the value calculation can be updated by the Target to achieve the effect of the mouse to move around fps game perspective.

 

 

reference:

[1] how popular explanation Euler angles, quaternions introduced after Why?

 

Guess you like

Origin www.cnblogs.com/zhlabcd/p/11627263.html