Unity mesh: The mesh contains vertices and multiple triangular surface arrays. The triangular surface array is only the subscript of the vertex array. A triangle faces three subscripts. For each vertex pair, there will be a normal, UV texture coordinate, color and tangent. These can be increased or decreased as needed. All vertex information is stored in an array of the same size. Therefore, if your grid has 10 vertices, you need an array of 10 to save the normal and other attributes.
- Description: mesh is a component in Unity called a grid component. Generally, mesh refers to the mesh of a model. A 3D model is made up of polygon, A complex polygon is actually made up of multiple triangular surfaces. Therefore, the surface of a 3D model is composed of multiple connected triangles. In a 3D space, the points that constitute these triangles and the set of triangle edges are mesh: 1.
Figure 1
- Therefore, modeling is to draw a series of triangles, and positioning a triangle requires only three vertices. For example, to draw a Pentagon:
It has five vertices, but in unity it is drawn by converting them into a series of triangles. So now I want to think about how many triangles can be combined into the Pentagon above? (1) first: composed of (, 3), (, 4) and (, 5) three triangles (2) second: composed, 5), (2, 4, 5) AND (2, 3, 4). Of course, there are many kinds of arrangement schemes for triangles in the same shape, however, not all solutions can be combined into the desired graphics. For example, in the Unity mesh class, the array mesh. vertices is used to store triangle vertex coordinates. When the number of vertices exceeds three, different connection points draw different shapes, array mesh. triangles is used to record the order of triangles. Since each triangle is drawn, it is necessary to know the order of its three vertices. Therefore, to draw n triangles, we need to know the order of 3 * n vertices.
- Mesh is a component (grid component) in unity. 3D mesh is the most important graphic element in unity, multiple components exist in unity to render standard mesh or skin mesh, tail, 3D lines. Mesh Filter
Text mesh Renderer text Renderer Skinned Mesh Renderer skin mesh Renderer)
- The general understanding is: mesh refers to the mesh of the model, and modeling refers to building a grid. Mesh contains several main attributes (vertex coordinate, normal, texture coordinate, triangle draw sequence, etc.). Therefore, creating a mesh is to draw a triangle, and painting a triangle is to locate three points.
The Mesh Filter component contains a mesh component. You can obtain the model mesh component based on meshfilter, or set the mesh content for meshfilter. Mesh Renderer is a component used to render the mesh. The role of meshfilter is to throw the mesh to meshrenderer to draw and display models or ry.
- UV: (1) Baidu explanation: here refers to the coordinates of the u and v texture textures (similar to the X, Y, and Z axes of the spatial model ), he defines the location information of each vertex on the image. These vertices are associated with the 3D model to determine the location of the surface texture map, UV precisely maps each point in an image to the surface of a model object.
- Differences between materials, textures, and textures)
The three concepts in the entire CG field are similar. In general practice, the hierarchical relationship is: material (material) includes map, texture (texture) texture is the most basic unit of data input. bitmaps are basically used in the game field. In addition, procedural texture maps (MAP) actually contain another layer of meaning: the ing function is to map a texture to a 3D object surface through UV coordinates. Textures contain a lot of information except textures, such as UV coordinates and texture Input and Output Control. Material is a dataset. The main function is to provide the Renderer with data and illumination algorithms. textures are part of the data. textures are also divided into different types based on their purposes, such as diffuse, map, specular map, normal map, gloss map, etc. Another important part is the illumination model shader, which is used to achieve different effects. |
- If the mesh of the imported model has skin information, unity automatically creates a skinned mesh Renderer.
Note: When Using Mesh Filter, A meshrenderer component must be provided at the same time, because it needs to be rendered, text mesh: text filter, used to display 3D text mesh Renderer: Grid Renderer, the material used to render the mesh display of the game object mesh Renderer can place multiple textures to display the appearance of the game object
Private void gettriangle () {meshfilter filter = gameobject. addcomponent <meshfilter> (); mesh = new mesh (); filter. sharedmesh = mesh; // construct the three vertices of a triangle and assign them to the mesh. vertices mesh. vertices = new vector3 [] {New vector3 (, 1), new vector3 (, 0), new vector3 (, 5 ),}; // construct the vertex sequence mesh of the triangle. triangles = new int [] {0, 1, 2}; mesh. recalculatenormals (); mesh. recalculatebounds (); // use shader to build a material and set the Material color material MAT = new material (shader. find ("diffuse"); mat. setcolor ("_ color", color. yellow); // construct a meshrenderer and assign the above material to Renderer. sharedmaterial // render the mesh constructed above to the screen meshrenderer Renderer = gameobject. addcomponent <meshrenderer> (); Renderer. sharedmaterial = MAT;} private void getpentagon () {meshfilter filter = gameobject. addcomponent <meshfilter> (); mesh = new mesh (); filter. sharedmesh = mesh; mesh. vertices = new vector3 [] {New vector3 (1, 0, 0), new vector3 (3, 0, 0), new vector3 (0, 2, 0 ), new vector3 (4, 2, 0), new vector3 (2, 4, 0),}; mesh. triangles = new int [] {0, 3, 1, 0, 2, 3, 2, 4, 3}; mesh. recalculatenormals (); mesh. recalculatebounds (); material MAT = new material (shader. find ("diffuse"); mat. setcolor ("_ color", color. blue); meshrenderer Renderer = gameobject. addcomponent <meshrenderer> (); Renderer. sharedmaterial = MAT ;} |
What is grid?