[3D basic]3d all kinds of rotation and base transformation in game (2)

Source: Internet
Author: User

Finally began to write the [3D Foundation] series of the second article, the content of this article is believed for many people is very important, because it involves camera coordinate system transformation, billboard implementation principle, bump map tangent space transformation and so on. In the past, the important content is marked with a red font, which is not proved by the most basic linear algebra theory, and the DX left-handed coordinate system is used.

First question: UVN camera coordinate transformation form and principle.

We know that the conversion of 3D world space to camera space coordinates is realized by UVN matrix, and the operation format is as follows:

| Ux, Vx, Nx |
| x, y, z | * | Uy, Vy, Ny |
         | Uz, Vz, Nz |
The U V N is the right, top, and front vector of the camera, and is normalized. Now let's understand the geometric meaning of this vector matrix multiplication. The operations are 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 of a point, geometry, a vector V1 with another normalized vector V2 the dot product, the result is V1 on the V2 vector of the signed projection length. So here X0, Y0, Z0 are vectors | x,y,z | The projection length on the U, V, 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 is used as the z axis, so the new vector is transformed to | X0, Y0, Z0 |.

A very important matrix property: the inverse matrix of the orthogonal matrix equals the transpose matrix.

Second question: The camera plane aligns the rotation of the bulletin board.

In fact, the bulletin board is implemented in two steps, the first step is to rotate the bulletin board parallel to the camera plane, the second step will rotate the fixed point to the specified space position.

We only say that the first step of the principle, the so-called alignment with the visual plane, in fact, is a rectangle after rotation in the XY plane, known as the result of rotation, the rotation before the four-dimensional coordinates, with the results of rotation by UVN matrix inverse matrix on the OK. Such as:

| Ux, Uy, Uz |
| 2, 0, 0 | * | Vx, Vy, Vz |   〔U V N矩阵为正交矩阵〕
         | Nx, Ny, Nz |

Third problem: The transformation of the bump map tangent space.

The principle is the same as the problem 1 and 21 modulo, need to cut space, use the matrix of tangent space vector to convert the ray vector into the tangent space, 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.