Author: strongcoding
Mailbox: StrongCoding@qq.comDX group: 130302441
If the text is incorrect, please let us know. Thank you very much. Come on with me.
In this article, we will study the progressive grid together, and we will not talk much about nonsense. The topic is as follows:
1. Concept of gradient Mesh
Incremental mesh is implemented through the id3dxpmesh interface. this allows us to simplify our mesh model by simplifying edges. we can simplify, or to a certain extent, restore the previous mesh. it can be divided into three levels: High, Medium, and low.
Ii. Advantages of progressive Grid
The progressive mesh is like a paid terrain. Based on the distance from the camera, the rendering details can be reduced, which improves the rendering efficiency.
3. How to generate a gradient Grid
We use the d3dxgeneratepmesh method to implement the gradient mesh. Its prototype is as follows:
HresultD3dxgeneratepmesh (
Lpd3dxmesh Pmesh, // Original mesh Const DWORD * Padjacency, // Points to an array of adjacent information containing the original mesh Const d3dxattributeweights * Pvertexattributeweights,
// Weight of the source mesh vertex Quality
Const float * Pvertexweights, // Source mesh vertex weight DWORD Minvalue, // Specify the minimum number of vertices or faces we want to simplify DWORD Options, // Specify whether the above parameter refers to the vertex or the number of faces Lpd3dxpmesh * Pppmesh//Output our progressive Mesh
);
Iv. Instructions on vertex quality weight:
The vertex weight value allows us to specify a weight value for each vertex attribute. 0.0 indicates that there is no weight value. The higher the weight value of the vertex, the lower the possibility of overflow.
Prototype:
typedef struct D3DXATTRIBUTEWEIGHTS {
Float position; // The default vertex position is 1.0 float boundary; // The default hybrid weight is 1.0 float normal; // The default value is 1.0 float diffuse. // The default value is 0.0 float specular; // The default highlight value is 0.0 float texcoord [8]. // 8 textures: {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} float tangent; // tangent float binormal; // times normal} d3dxattributeweights, * lpd3dxattributeweights;
Note: The default quality weight value is recommended unless your application does not use it for an important reason.
5. Build the core id3dxpmesh of the progressive Grid Model
DWORDGetmaxfaces (); // Returns the maximum number of faces that can be set in the progressive mesh.
DWORDGetmaxvertices (); // Returns the maximum number of vertices that can be set in the progressive mesh.
DWORDGetminfaces (); // Returns the minimum number of faces that can be set in the progressive mesh.
DWORDGetminvertices (); // Returns the minimum number of vertices that can be set in the progressive mesh.
HresultSetnumfaces (DWORD Faces); // Set the number of faces that can be set in the progressive mesh to simplify or complicate the mesh.
HresultSetnumvertices (DWORD Vertices); // Set the number of vertices that can be set in the progressive mesh.
HRESULT TrimByFaces( DWORD NewFacesMin, DWORD NewFacesMax,
DWORD * rgiFaceRemap,DWORD * rgiVertRemap
); // Allows us to set the number of faces of the new smallest and largest gradient mesh, and return the re ing information of the surface or vertex.
HRESULT TrimByVertices( DWORD NewVerticesMin, DWORD NewVerticessMax,
DWORD * Rgifaceremap, DWORD * Rgivertremap); // Allows us to set the number of vertices of the new smallest and largest gradient mesh, and return the re ing information of the surface or vertex.