[3D Basics] various rotation and base transformations in 3D games (2)

Source: Internet
Author: User

Finally, I started writing the second article in the [3D Basics] series.ArticleThe content in this article is believed to be of great importance to many people, because it involves camera coordinate system transformation, billboard implementation principle, convex/convex ing and space switching. According to the previous habits, the important content is marked in red. The most basic linear algebra theory is not proved, and the DX left-hand coordinate system is used.

The first problem is the form and principle of uvn coordinate transformation.

We know that the conversion from a 3D world space to a camera space coordinate is achieved through the uvn matrix. The calculation format is as follows:
| UX, VX, nx |
| X, y, z | * | Uy, Vy, NY |
| Uz, VZ, NZ |
U v n is the right, top, and front vectors of the camera, and has been normalized. Now we can understand the geometric meaning of this vector matrix multiplication. The operation is decomposed as follows:
X0 = | x, y, z | dot | UX, Uy, uz |
Y0 = | x, y, z | dot | VX, Vy, VZ |
Z0 = | x, y, z | dot | NX, NY, NZ |
Is it a bit eye-catching? In ry, the dot product of one vector V1 and another normalized vector V2 returns the signed projection length of V1 on the V2 vector. Therefore, x0, y0, and z0 are vectors | x, y, z | the projection length on the U, V, and n vectors. In the camera coordinate space, the right vector u of the camera will be used as the X axis, V will be used as the Y axis, and N will be used as the Z axis. Therefore, after the transformation, the new vectors are | x0, y0, z0 |.

An important matrix property: the inverse matrix of an orthogonal matrix is equal to its transpose matrix.

Second problem: the plane of the camera is aligned with the rotation of the announcement board.

In fact, the announcement board is implemented in two steps. The first step is to rotate the announcement board in parallel with the camera plane, and the second step is to translate the rotated fixed point to the specified space position.
Let's just talk about the principle of the first step. The so-called alignment with the video plane is actually a rectangle located on the XY plane after being rotated. We know the result after rotation and find the coordinates of the Quadrilateral before rotation, use the rotated result to multiply the uvn matrix inverse matrix. For example:
| UX, Uy, uz |
| 2, 0, 0 | * | VX, Vy, VZ | [the u v n matrix is an orthogonal matrix 〕
| NX, NY, NZ |

The third problem is the transformation of the concave-convex ing space.
The principle is exactly the same as that of Question 1 and Question 2. We need to cut the space and convert the light vector into the cut space using the matrix composed of the cut space vector, and then calculate the light, over!

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.