[Translate] Projection transform Projection Transform (Direct3D 9)

Source: Internet
Author: User

You can assume that a projection transformation is a way to control the inside of a camera. He can do the analogy to select a leak plate for the camera. It is the most difficult to understand in three kinds of transformations. This article covers only a few of the following.

A typical projection transformation is scaling and perspective projection. The projection transforms the optic vertebrae into a cube. Nearly large and far small. This is the application of perspective to the scene.

In the visual vertebral body, the distance between the camera and the transformed space origin is defined as D, so the projection matrix looks like this:

The watch matrix shifts the camera through the Z-D to the origin. The translation matrix is then multiplied by their two matrices to get the following matrix perspective transformations convert the apparent vertebral body into a new coordinate space. Note that the view heap is turned into a cube, the upper right corner of the origin is moved to the middle of the scene, and in the perspective transformation, the X and y directions range from 1 to 1. The z-direction range is 0 (in front of the plane), 1 (behind the plane) this human matrix pan and zoom model is based on the distance between the camera and the section, but currently does not take into account the angle of view size, and it can produce a remote object with a Z-value almost the same, which makes it difficult to try to compare.   The following matrix solves the problem and adjusts vertices based on the aspect ratio of the viewport, making it a good choice for perspective projection. In this matrix, Zn is the z-value of the near clipping plane. Variable WhAnd QHas the following meanings. Attention FoVW and FoVh represents the angle of view of the viewport in both horizontal and vertical directions, measured in radians

For applications, using perspective angles to define the scale factor for x and Y may not be as convenient as using the viewport's size in the horizontal and vertical directions (in camera space). You can use mathematical deduction to derive the following two formulas for calculating W and H using the viewport size, which are equivalent to the previous formula.

In these two formulas,ZN represents the position of the near clipping plane, and thevW and vh variables represent the width and height of the viewport in the camera space.

For C + + applications, these two sizes correspond directly to the Width and Height members of the D3DVIEWPORT9 structure. (This is not equivalent, since vW and vh are in the camera space, and Width and Height are in the screen space)

Whatever formula you decide to use, it is important to set the z-N as large as possible, as the Z-value of the proximity camera changes little. This makes the depth comparison with the 16-bit z-cache a bit more complicated.

As with the world transformation and observation transformations, the application calls the Idirect3ddevice9::settransform method to set the projection matrix.

[Translate] projection transform Projection Transform (Direct3D 9)

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.