A 3D model/scenario requires imaging and motion on the screen at least the following elements. You don't have to worry about the difficult mathematical skills or friends you have never touched. First, let's take a look at the specific computing methods.
Models and textures:
The three points are connected into a triangle, and many triangles form a model.
A texture is a plane (u, v), U, V, that is, the X, Y, it's just that we use X and Y, so we are afraid of repetition.
The Paster in flash3d calculates the second matrix parameter (matrix) of beginbitmapfill based on the different slope of each triangle and the UV corresponding to each vertex to fill the triangle with bitmap.
Exercise:
For friends who are new to graphics and mathematics, the following principle (two-dimensional and three-dimensional graphics are like this, but one more three-dimensional Z axis) will surely surprise you.
All the points/models that we think are moving are not actually moving (Relative Coordinate System), but moving is just a coordinate system. Moving, rotating, amplifying, and pivoting are all in the same principle, but they are moving, rotating, amplifying, and pivoting the coordinates of these points/models.
The movements of cameras are essentially clouds. The camera rotates around y clockwise, but the coordinate system of the model turns around y clockwise.
Any change of all vertices is obtained by multiplying a vertex (x, y, z) by a matrix. That's simple.
Never scare us away when we hear this. We don't need to study what a matrix is. We just need to know how to use it. In addition, we do not need to calculate by ourselves, such as mathematical algorithms.Flash3D engines are all well written.
If something is to be animated, whether it is two-dimensional or three-dimensional, it must multiply every point of it by a matrix, which cannot be escaped.
'Project' on the screen
Although it is '3d ', we actually watched it on a two-dimensional plane screen. Therefore, we must change the three-dimensional point (x, y, z) to only the point (x, y) displayed on the computer screen. The image can be said that the three-dimensional point is displayed as the point 'project' on the plane canvas.
Some friends may say that I just remove the Z values of X, Y, and Z. Yes, we can get a (x, y) point by directly removing it, but it looks a little strange that the projection graph does not change in size.
So we have 'perspective project'. The algorithm uses x, y divided by a z-related value W to get a perspective (x, y) that is close to big and small ), this is the most normal 3D image that we usually see.
The principle of graphics is to understandFlashThe basis of the core content of various 3D engines. Only by understanding this knowledge can you read the source code of the engine and then add it to the ranks of writing engine code, otherwise, it will only get lost in the sea of code (sometimes it will vomit = A =). Let's take this first step together, come on!