Windows Phone 7 xNa development-matrix-based Positioning

Source: Internet
Author: User

3D rendering brings many new challenges: 3D graphics are rendered by models rather than simple bitmaps. We need to switch to a different angle to observe the motion close to or away from the screen, at the same time, we need to tell xNa in a completely different way where we want to draw the image.

We use a matrix-based system when preparing 3D rendering. A matrix can encode a series of movements and transformations into a compact structure and then apply them to the graphics we want to draw. Most of the calculations required to perform this operation are encapsulated in the form of xNa functions, so we do not need to pay too much attention to the internal running mode.

Like any other things, it may take some time to get used to matrix transformations for thinking, but once you get used to them, you will find them very useful tools. In fact, you may find that you prefer matrix transformation compared to the xNa sprite rendering method.

During 3D rendering, xNa usually uses an abstract coordinate system instead of a pixel-based Coordinate System in Sprite rendering. That is to say, pixel is not concerned here. Although it sounds like a disadvantage at the beginning, it is of great benefit to get rid of pixel coordinates.

When we initialize xNa, we can tell it the size of the screen, and then the coordinate system will automatically expand for size matching. Therefore, if you move the image object to the right for a certain distance, the actual moving distance is irrelevant to the background buffer size. Therefore, we should consider using a smaller buffer to improve performance without changing any rendering.Code.

When talking about drawing, xNa cannot draw anything more complex than a triangle. At first glance, this seems very strict, but in fact, you will find that it is not what we use in some sample projects.

Each triangle is called a surface when being drawn. Vertices that constitute triangles are called vertices. The figure shows two triangle surfaces created using four vertices. Two vertices are shared by two triangles.

In fact, these vertices are not displayed by xNa. They only display the surfaces defined by them. The vertices in the graph only show their functions.

Only a line is available except a triangle.

When rendering the genie, each independent drawing call provides all the information required for drawing. 3D rendering methods are slightly different. XNa maintains a large amount of state value information, such as the texture currently used for rendering, whether Transparency is enabled, and whether illumination is enabled.

To make the rendering effect consistent with expected, these statuses must be set before the rendering call. Once the status is set, the status value is maintained until it is changed again.

Related Article

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.