Flash basic Theory Class 17th chapter back culling and 3D lighting Ⅰ

Source: Internet
Author: User

Back to "flash Basic Theory Class-Catalog"

The 16th chapter describes all the basics of building a 3D stereo model: How to create dots, lines, make shapes with polygons, and how to set colors for each polygon. However, we can only make the color transparency of 50% to see the correct effect. Although the system to make a 3D stereo model is not bad, but this is still a lack of realism.

This chapter, by introducing the back culling (not drawing the back of the polygon), the depth of sorting (15th chapter made a little introduction, but this time to look at it from the polygon angle), and 3D lighting, to correct this problem.

I think it would be surprising to have a 3D model of these three technologies. After learning the first two techniques, we will be able to create a 3D stereo model that looks very real. Using 3D lights can make them vivid.

Before I begin, I'd like to make a statement about the source of the technology. Almost all of the code in this chapter comes from the technology of the tenth chapter of Todd Yard's Macromedia Flash MX Studio Book. Todd is also a technical commentator in this book, so it's not like plagiarism without anyone's permission! Macromedia Flash MX Studio may be the only special material I can find suitable for this chapter, and I'll check it whenever I want to use these advanced 3D technologies. Because we have been in this book for more than four years (according to technical books, is an ancient book) across the three versions of Flash, I am very willing to allow the content of the book to continue to develop and be able to keep pace with the times.

This chapter is based on the rotated, extruded, 3D letter A of the previous chapter. This makes the code very complex, as long as a little bit of error will be very obvious, when everything is right the effect will be awesome yo!

Back remove

The back culling was mentioned many times in the previous chapter. Next, we'll learn everything about it and figure out how it works.

Don't forget, our earlier models were all semi-transparent. The reason is that the polygon is drawn every time, but the order of the drawing is not controlled. So a polygon behind the model is drawn in front of the model, causing some strange results. In focusing on the modeling basics, we set the transparency of all polygons to 50% in order to postpone this part of the discussion backwards. Now it's time to deal with it.

Overall, the back culling is very simple. Draws only the polygons that are facing us, not the back. This technique is just like its name. You should remember that the dots of each polygon are arranged clockwise. While it is absolutely unnecessary in the previous example, we are about to see why it is so important and why it is necessary to develop such a habit from the outset.

Obviously, if the dots facing our polygons are arranged in a clockwise order, they will all be counterclockwise when they turn their backs to us.

As shown in Figure 17-1, we have a triangle facing us. (Because all the polygons we use are triangles, I often confuse these two words.) In most cases, I use "polygon" as a general name, and "Triangle" is a special polygon with three corners.

Fig. 17-1 the point of a triangle facing us is arranged in a clockwise direction

In Figure 17-2, I rotate the triangle and see the opposite direction.

Figure 17-2 a triangle with its back to us is arranged in a counter-clockwise direction

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.