Introduction to 3D Graphics Programming (1)-cubic

Source: Internet
Author: User

Introduction to 3D Graphics Programming (1).      Cubics. "description" This article takes the cube as an example to introduce the 3D graphics programming Introduction Knowledge and explains some problems related to the graphics transformation on the computer. 3D geometric objects are many, in addition to the cube, but also can be cuboid, cylinder, cone, table, ball, ring, etc., this article does not introduce the geometric shape of the object programming, but also did not introduce the realistic object to draw the lighting model and shadow generation problem, using the algorithm is as simple as possible, More knowledge about 3D will be placed on the 3D Graphics Primer (2), (3), ... To introduce, here only the most basic 3D mapping problem. This article explains the use of the illustrations are generated by my previous custom software, all the code is copied from this software, so it is a practical test, can be successfully used.        The name of the software is called Cubics, the following is the start of the software screen. The following is a quick way to introduce the function of the software, when the various graphics have been enough impression, and then explain how they are specific programming.

1. After the program starts to see the interface, it has a ready-made cube, may carry on its enlargement loses small, turn left turn right, and so on various operations. The status line displays various parameters, and you can click on the tools in the bottom bar to observe the changes in the graph, while monitoring the change in the size of the parameters in the status row.
This software, although only a cube of a shape of objects, but there are different forms of painting to the screen, which are related to the data set of the hypothetical object (cube) itself, to the position of the object in space (distance and azimuth), and to the distance and phase of the person observing it, It also has to do with what the person wants to paint on the screen. To do this, the program sets various parameters for the object and changes the keys for various parameters. We can also decide whether to draw one or more, if it is more than one, they have a spatial relationship between each other, and so on.
This program to study what the function, you can see from the above 1 headings in the title row can be generally seen: cube design, rotation, translation, zoom, zoom, Perspective, copy, sight rotation and visual range change, four display models, use the cube to play the game ...
General procedures usually have a menu bar and tool bar, the tool bar in the menu is actually some of the tools, which seems to be a bit repetitive. To this end, the program does not set up a menu bar, and set up two toolbar, the Top Row Toolbar Tool button is generally relatively wide, it corresponds to the next row of several buttons in the bar, its purpose is to use the description of the role of the tool button. For example, when you click on the first button file on top, a panel pops up to explain the functional meaning of the two buttons that are entered and exported in the bottom row bar:
2. This procedure has no menu bar, and has 2 tool strips. The above figure shows the upper file operation corresponding to the output of the row and the lower input
and click on the second button Big O, will be displayed as shown below: 3. O represents the initial state, The Big O represents all the parameters back to the initial state, and all the other small o represent one of the parameters to the initial states

4. Press the bottom row o get the result, make red face you. The lower left corner is a coordinate frame, it rotates with the object, the big cross is the picture coordinates, for the Help, may click the upper row key to help below the row key to remove or restores.

5. In the above state, click the object to move right 4 times, the result, the coordinate frame display Blue Z axis

6. But if in the state of Figure 4, click the graph to move right 4 times, the result

7. If in the state of Figure 4, click to change the line of sight, move Left 4 times, then get win10 that window graphics

8. If on the basis of the above picture, and then the view up a few clicks, you can get the above figure
9. Click on the top row graphics zoom, pop-up above, explain the significance of graphics scaling and how to implement the panel
10. In addition to the color cube, click on the display model under the line can be displayed by the line composed of the square frame, there is no hidden line and surface. This kind of diagram is easy to cause confusion, can not see the face of 6 faces, but if this is a cube, then the area of the largest surface, that is from point 4567 surrounded by the surface is to leave our nearest side.

11. Click D to see the space coordinate position of the cubic 8 vertex

11. Click on the surface of the display model to display a black and white cube model, hidden lines and can not see the
12. Click on the top row object rotation, will pop up the pull panel, and then click the 4th item in the dropdown panel, can pop up the above graphics, can produce 3 sides have different color composition cubes, can see 24 kinds of 3 color different cubes. These 24 cube states can be set from either of these graphs and are repeated by 90 degrees around the x or Y or Z axes, but it is not possible to get more graphics.

13. These 24 cubes of different color states form a group called the Cayley Group. This 2-dimensional diagram can be represented by a 3-dimensional spherical surface, where the graph is very symmetrical.
14. A graphics array composed of 3x3=9 cubes

15. Another graphic array composed of 3x3=9 cubes

16. A graphic array composed of 3x3=9 cubes

17. Use 27 cubes to construct the Rubik's cube (initial rotation state)

18 using many cubes to construct tunnels

17. By many cubes can be spelled into a maze, here is a 3-storey, each layer can accommodate 9x9=81 cubes
18. The 2 keys with the help of the top row button are used to display a cross cursor (c,cursor) and a full-screen grid (G,grid) on the screen, so as to provide a reference for accurately calculating the size and position of the graphic. This figure is based on Figure 1, click on the results of G, and then point G, the grid disappears.

19. Change the background color to white. The background must be different from the color of the cube, so there is only black or white 2 colors available.
Make a game with one or more cubes. You can make a lot of games with cubes.      As I know, you can make the following three kinds of games: 1. Dice: Dice is the cube on its punctuation, it is easy to make dice games on the computer, it can be done with one or more.      2. Rubik's Cube: Rubik's Cube is also made up of many cubes, so it is not difficult to draw a cube of knowledge to draw a Rubik's Cube, and to rotate. 3. Maze: Since the cube as shown in Figure 17 can be a maze, so you can create a maze of games, so that everyone in the entrance to the exit from the exploration.

With 5 cubes to throw dice game, each cube by the initial state shown in Figure 1 randomly around the x,y rotation of 90 degrees N (n generally take 3 to 6) times to get, but no matter how big N is, the resulting shape must be the same as in Figure 12 and 13, which is one of the 24 element states of the Caley Group, if the cube state, Can add points, such as rotation times, plus 10 points. Of course, you can also use the 1,2,3,4,5,6 of the dice to play, and then according to the sum of the points of five children and whether or not with the flowers or even to statistical points, or with 6 different colors to replace 6 points, how to score different people can make different choices, But always must make the score of the size of the state of the probability of the size of the basic proportional to the reasonable.


HELP4: How to get the computer to draw a cube help

Yet to be explained in detail



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.