Model data processing method and model data processing device

Through technical means of vertex deduplication, quantization, map compression, material merging, integration and compression upload, the problems of low transmission speed and rendering efficiency of three-dimensional models are solved, and the model data is lightened and the rendering efficiency and transmission rate are improved.

CN119271640BActive Publication Date: 2025-03-28ZHEJIANG SUPCON INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411803904.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-03-28
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

In the prior art, the transmission speed and rendering efficiency of three-dimensional models are low, mainly due to the large model data, low compression efficiency and increased rendering pressure due to the increase in material redundancy.

Method used

By identifying and deleting duplicate vertices in the model, vertex quantization is performed; map data is compressed; model components with the same material attributes are merged; and the processed data is integrated and gzip compression uploaded.

Benefits of technology

Reduces the number of vertices and data storage size, improves rendering efficiency and transmission rate; compressed map data occupies less space, maintains better visual quality; the combined materials reduce the number of material switching times during rendering, and improves rendering speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271640B_ABST
    Figure CN119271640B_ABST
Patent Text Reader

Abstract

The present application provides a model data processing method and a model data processing device, wherein the method includes: obtaining the original model data of the target model; determining duplicate vertices, deleting the vertex data corresponding to the duplicate vertices, obtaining the deduplicated vertex data, and quantizing the deduplicated vertex data to obtain the processed vertex data; compressing the texture data according to the data type of the texture data to obtain the processed texture data; determining the model components with the same material attributes according to the material data and merging them to obtain the merged model components, and using the material data of the merged model components as the processed material data; compressing and uploading the processed vertex data, the processed texture data and the processed material data as new model data. The present application realizes the lightweight of the model data by reducing redundant data, optimizing the data structure and adopting an efficient compression algorithm, thereby improving the rendering efficiency and the transmission rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model data processing method and a model data processing device. Background Art

[0002] With the development of computer technology and the increase in Internet speed, 3D visualization technology has been widely used in many fields. As the core component of the application, the quality and optimization degree of the 3D model directly affect the user experience and system performance.

[0003] In existing 3D visualization projects, a variety of methods are usually used to deal with the data quality issues of 3D models, such as geometric simplification of models, compression algorithms for texture data, and optimization of rendering processes.

[0004] However, since the 3D model data itself may be very large, it will take a long time to transmit the model on the network, and the success rate of model loading may be affected by factors such as poor network conditions. When trying to compress the model data, you may encounter low compression efficiency or inability to effectively compress texture data. In addition, since the model is composed of a large number of components and the material definitions of each component are redundant, the rendering efficiency will also decrease. Therefore, how to improve the model transmission speed and rendering efficiency is one of the problems that technicians in this field need to solve urgently. Summary of the invention

[0005] The purpose of the present application is to provide a model data processing method and a model data processing device to address the deficiencies in the above-mentioned prior art, so as to solve the problems of low model transmission speed and rendering efficiency in the prior art.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, an embodiment of the present application provides a model data processing method, the method comprising:

[0008] Acquire original model data of the target model, wherein the original model data includes vertex data, texture data, and material data of multiple vertices of the target model;

[0009] Determine duplicate vertices among the plurality of vertices according to vertex data of each of the vertices, delete vertex data corresponding to the duplicate vertices in the vertex data of the plurality of vertices to obtain deduplicated vertex data, and perform quantization processing on the deduplicated vertex data to obtain processed vertex data;

[0010] According to the data type of the texture data, compressing the texture data to obtain processed texture data;

[0011] Determine, according to the material data, model components with the same material attributes in the target model, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data;

[0012] The processed vertex data, the processed texture data and the processed material data are used as new model data of the target model, and the new model data is compressed and uploaded.

[0013] In a second aspect, an embodiment of the present application provides a model data processing device, the device comprising:

[0014] An acquisition module, used for acquiring original model data of a target model, wherein the original model data includes vertex data, texture data and material data of a plurality of vertices of the target model;

[0015] A vertex deduplication module, used for determining duplicate vertices among the plurality of vertices according to vertex data of each of the vertices, deleting vertex data corresponding to the duplicate vertices in the vertex data of the plurality of vertices to obtain deduplicated vertex data, and performing quantization processing on the deduplicated vertex data to obtain processed vertex data;

[0016] A texture compression module, used for compressing the texture data according to the data type of the texture data to obtain processed texture data;

[0017] A material merging module, used to determine the model components with the same material attributes in the target model according to the material data, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data;

[0018] The compression uploading module is used to use the processed vertex data, the processed texture data and the processed material data as new model data of the target model, and compress and upload the new model data.

[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the model data processing method as described in any one of the first aspects above.

[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the model data processing method as described in any one of the first aspects above are executed.

[0021] According to the model data processing method and model data processing device of the embodiment of the present application, the vertex data, map data and material data of the target model are extracted, and duplicate vertices are identified and deleted to reduce the number of vertices; the vertex data after deduplication is quantized to further reduce the amount of data and obtain the processed vertex data; according to the type of map data, the map is compressed using a suitable compression algorithm to obtain the processed map data; the model components with the same material attributes are identified and merged to reduce the number of material switching times, simplify material management, obtain the processed material data, and then integrate the processed vertex data, map data and material data into new model data, and compress the new model data for uploading. According to the embodiment of the present application, by identifying and deleting duplicate vertices, the number of vertices is reduced, thereby reducing the amount of calculation required for rendering, and the quantization process further reduces the storage size of the vertex data, making the model data more compact, reducing storage requirements and loading time. The map data is compressed so that the compressed map data occupies less space while maintaining good visual quality, thereby speeding up the transmission speed of the map data in the network and reducing the demand for storage space. Furthermore, model components with the same material properties are merged, and the merged model components only need to load the material once, reducing the number of material switching times during rendering and the overhead caused by repeatedly loading the same material. The processed vertex data, texture data, and material data are integrated into new model data, and compressed and uploaded using compression technologies such as gzip, which further reduces the model file size and the bandwidth consumption of the model data during network transmission, and also speeds up the client's loading and decompression of the model. In summary, this application is based on technical means such as vertex deduplication and quantization, texture compression, material merging, and integration and compression uploading. By reducing redundant data, optimizing data structure, and adopting efficient compression algorithms, the lightweight model data is achieved, thereby improving rendering efficiency and transmission rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1A schematic diagram of a flow chart of a model data processing method provided in an embodiment of the present application is shown;

[0024] Figure 2 A schematic diagram of a flow chart of a repeated vertex determination method provided in an embodiment of the present application is shown;

[0025] Figure 3 A schematic flow chart of another method for determining repeated vertices provided in an embodiment of the present application is shown;

[0026] Figure 4 A schematic diagram of a flow chart of a method for determining a model component provided in an embodiment of the present application is shown;

[0027] Figure 5 A schematic diagram of a flow chart of a model grid classification method provided in an embodiment of the present application is shown;

[0028] Figure 6 A schematic diagram of a process of a hierarchical structure processing method provided in an embodiment of the present application is shown;

[0029] Figure 7 A schematic diagram of a flow chart of a model component merging method provided in an embodiment of the present application is shown;

[0030] Figure 8 A schematic diagram of the structure of a model data processing device provided in an embodiment of the present application is shown;

[0031] Fig. 9 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0033] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0034] In order to enable those skilled in the art to use the content of this application, the following implementation is provided in conjunction with the specific application scenario "model data lightweight service". For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is mainly described around the model data processing method, it should be understood that this is only an exemplary embodiment.

[0035] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0036] In the development process of visualization projects using 3D models, several key issues are often encountered. First, the model files may be large in size, which will result in long network transmission time, which in turn affects the speed of complete model loading. In response to the problem of large model files, although compression methods are usually used to reduce the file size, this sometimes leads to low compression efficiency and difficult to effectively compress the map part of the model. Secondly, it is common for multiple parts in the model file to share the same material properties, but since each part is defined as having an independent new material, this may slow down the overall rendering efficiency during the rendering process. In addition, for static models that are only used for display and do not require user interaction, if they contain too many parts, it will also increase the pressure of rendering, and ultimately reduce rendering efficiency.

[0037] In view of the above problems, an embodiment of the present application provides a model data processing method, which first performs model compression, merges duplicate or similarly positioned vertices into a single vertex through vertex deduplication, reduces the number of vertices while keeping the model geometry unchanged, and then compresses the vertex data and texture data, greatly reducing the storage size of the model file. Secondly, perform material deduplication, identify model components using the same material attributes and make them share the same material, and delete redundant materials to improve rendering efficiency. In addition, the geometric data of different components with the same material are merged into a new model component and assigned a unified material. Finally, the gzip compression setting on the server side is used to perform gzip compression again on the basis of the compressed model, further reducing the file size during network transmission. On this basis, by performing multi-faceted processing on the model data, the transmission volume of the model file can be significantly reduced before the browser renders, shortening the network transmission time, and eliminating factors affecting rendering efficiency.

[0038] Figure 1 A schematic diagram of a process flow of a model data processing method provided in an embodiment of the present application is shown. Figure 1 As shown, the method specifically comprises the following steps:

[0039] S101. Acquire original model data of a target model, where the original model data includes vertex data of multiple vertices of the target model, texture data, and material data.

[0040] Optionally, the vertex data includes position information, normals and texture coordinates, the position information is used to indicate the coordinate value of the vertex in the three-dimensional coordinate system, the normal is used to indicate the orientation of the surface where the vertex is located, and the texture coordinates are used to indicate the position of the texture map corresponding to the surface where the vertex is located.

[0041] Optionally, the map data of the target model refers to a picture applied to the surface of the target model to enhance the realism or artistic effect of the model, such as texture mapping.

[0042] Optionally, the material data includes texture data and non-texture attribute data of the material. The texture data includes: base color map, normal map, self-luminous map, metalness map, roughness map. The non-texture attribute data includes: base color, opacity, self-luminous color, metalness, roughness.

[0043] S102, determining duplicate vertices among a plurality of vertices according to vertex data of each vertex, deleting vertex data corresponding to the duplicate vertices in the vertex data of the plurality of vertices to obtain deduplicated vertex data, and performing quantization processing on the deduplicated vertex data to obtain processed vertex data.

[0044] Optionally, the duplicate vertices are vertices in all vertices of the target model whose positions are completely the same or whose position differences are so small that they can be ignored. Once the vertices are confirmed to be duplicate vertices, the vertex data corresponding to the duplicate vertices are deleted, and only one representative vertex is retained, thereby reducing the redundant data in the vertex data of the target model, thereby reducing the size of the model file, making the model data more streamlined and more suitable for fast loading and rendering.

[0045] Optionally, in order to further reduce the amount of data and improve the compressibility of the model, the deduplicated vertex data can be quantized. Quantization refers to converting continuous data into discrete values. During the quantization process, fixed-precision floating-point numbers can be used to approximate the original vertex coordinates, or the vertex coordinate values ​​can be rounded to the nearest integer to reduce data precision and thus reduce storage space requirements.

[0046] S103. Compress the texture data according to the data type of the texture data to obtain processed texture data.

[0047] Optionally, the texture data is a plurality of textures used to render the surface details of the target model, and each texture has a corresponding file type identifier MimeType, which is used to indicate the data type of the texture. By judging whether the data type of the texture is a preset type, it is determined whether to compress the texture data, and after the compression is completed, the original texture data is replaced with the new compressed texture data, that is, the processed texture data is obtained. In this way, the texture data whose data type is not the preset type is effectively compressed, and it is ensured that these textures can be correctly loaded and used during the model rendering process, which not only reduces the overall file size of the model, but also improves the performance of the model during network transmission and rendering.

[0048] S104. Determine the model components with the same material attributes in the target model according to the material data, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data.

[0049] Optionally, by comparing the material data of each component in the model, the model components with the same material properties are determined, that is, which components can share the same material. On this basis, the model components with the same material properties are further merged, specifically merging the geometric data of multiple components with the same material properties into a new component. It should be noted that when merging model components, it is necessary to pay attention to maintaining the original geometric shape and structure, and at the same time ensure that the merged model components can still correctly reference the shared material.

[0050] Optionally, after the model parts are merged, the material data needs to be updated to reflect the merged model parts status, including associating the merged parts to the shared material before the merge, so as to ensure that the material is only loaded once during rendering, rather than loading the same material multiple times. In addition, the merged model parts will use the updated material data, and since the updated material data has been optimized and redundant material references have been removed, the number of material switches during rendering can be effectively reduced, thereby improving rendering speed.

[0051] S105: Use the processed vertex data, processed texture data and processed material data as new model data of the target model, and compress and upload the new model data.

[0052] Optionally, the processed vertex data, processed texture data and processed material data have been optimized by deduplication, compression and other means to reduce redundancy and storage size. In order to further improve the network transmission speed of the model file, the optimized vertex data, texture data and material data are integrated into a new model data set. Based on the integrated new model data, the configuration can be enabled on the server side and gzip compression can be enabled (commonly used servers such as Nginx, Apache and servers developed by Node all support configuration and enabling gzip compression), which is equivalent to secondary compression of the compressed model, further improving the transmission efficiency of the model file. After gzip compression transmission is enabled on the server side, the browser will automatically compress and decompress the model file, which is very efficient and fast.

[0053] Optionally, gzip is a commonly used lossless data compression format that can significantly reduce the size of the file. Configuring and enabling gzip compression on the server side means that the server will compress the model data before sending it, and the receiver (such as a browser) will automatically decompress it after receiving the model data. After gzip compression, the compressed model data is uploaded to the server. Since the model data has been compressed, the time required for network transmission will be reduced, thereby improving transmission efficiency. In other words, even if the model has been optimized in many ways in the initial stage, the file size can be further reduced through the gzip compression function on the server side, thereby accelerating network transmission.

[0054] Based on this, according to the model data processing method provided by the embodiment of the present application, by identifying and deleting duplicate vertices, the number of vertices is reduced, thereby reducing the amount of calculation required for rendering, and the quantization process further reduces the storage size of the vertex data, making the model data more compact, reducing storage requirements and loading time. The texture data is compressed so that the compressed texture data occupies less space while maintaining good visual quality, thereby speeding up the transmission speed of the texture data in the network and reducing the demand for storage space. Further, the model components with the same material attributes are merged, and the merged model components only need to load the material once, reducing the number of material switching times during rendering and the overhead caused by repeatedly loading the same material. The processed vertex data, texture data and material data are integrated into new model data, and compressed and uploaded using compression technologies such as gzip, which further reduces the model file size and the bandwidth consumption of the model data during network transmission, and also speeds up the speed of loading and decompressing the model on the client. To summarize, this application is based on technical means such as vertex deduplication and quantization, texture compression, material merging, and integration and compressed uploading. By reducing redundant data, optimizing data structure and adopting efficient compression algorithms, it achieves lightweight model data, thereby improving rendering efficiency and transmission rate.

[0055] Figure 2 FIG. 1 is a flow chart of a method for determining repeated vertices provided in an embodiment of the present application. As a possible implementation method, refer to Figure 2 As shown, the above step S102 determines the repeated vertices among the multiple vertices according to the vertex data of each vertex, and specifically includes the following steps:

[0056] S201. Determine a vertex identifier of each vertex according to vertex data of each vertex.

[0057] Optionally, vertex data includes position information, normals and texture coordinates, which respectively describe the position of the vertex in three-dimensional space, surface orientation and texture mapping position. The position information is used to determine the specific position of the vertex in three-dimensional space, usually represented by three floating-point numbers, such as (2.5, -3.7, 0.8). The normal is used for lighting calculations and determines how lighting affects the brightness and color of the vertex and its adjacent faces. It is also usually represented by three floating-point numbers, such as (-0.3, 0.4, 0.1). The texture coordinates, also known as UV coordinates, are used to determine which part of the texture map should be attached to which position on the model surface, usually represented by two floating-point numbers, such as (0.2, 0.9).

[0058] Figure 3 FIG. 2 is a flow chart of another method for determining repeated vertices provided in an embodiment of the present application. Figure 3 As shown, the method specifically comprises the following steps:

[0059] S301 . Scaling the position information, normal and texture coordinates of each vertex according to a preset tolerance value to obtain processed position information, processed normal and processed texture coordinates of each vertex.

[0060] Exemplarily, a preset tolerance value tolerance is determined, such as 0.1, to determine whether two floating-point numbers less than the preset tolerance value are still equal, thereby avoiding the problem caused by the precision of floating-point numbers. Further, the floating-point numbers used to represent the position information, normals, and texture coordinates of each vertex are normalized. Specifically, the floating-point numbers of the position information, normals, and texture coordinates of each vertex are divided by the preset tolerance value tolerance to scale the position information, normals, and texture coordinates of each vertex, scale the values ​​of the floating-point numbers used to represent the position information, normals, and texture coordinates of each vertex to a larger range, and round the obtained values ​​to obtain an integer, as shown in the following formula (1):

[0061] (1)

[0062] in, Represents a floating point number, Indicates the mapping function corresponding to the scaling process, tolerance indicates the preset tolerance value, represents the rounding function, The function is shown in the following formula (2):

[0063] (2)

[0064] For example, taking the position information (2.5, -3.7, 0.8) as an example, the floating point number 2.5 is scaled using the above formulas (1) and (2) to obtain the integer 25, and the corresponding processed position information includes the three integers 25, -37 and 8. Similarly, the floating point numbers used to represent the position information, normal and texture coordinates of each vertex are scaled in turn to obtain the processed position information, processed normal and processed texture coordinates of each vertex.

[0065] S302 , generating a position attribute string according to the processed position information of each vertex, generating a normal attribute string according to the processed normal of each vertex, and generating a texture attribute string according to the processed texture coordinates of each vertex.

[0066] Exemplarily, the position information of the vertex is recorded as position, the normal is recorded as normal, and the texture coordinate is recorded as uv, so that there are vertices A, vertex B, vertex C and vertex D, and the vertex data of vertex A is {position: [2.5, -3.7, 0.8], normal: [-0.3, 0.4, 0.1], uv: [0.2, 0.9]}, the vertex data of vertex B is {position: [2.51, -3.7, 0.8], normal: [-0.3, 0.41, 0.1], uv: [0.2, 0.89]}, and the vertex data of vertex C is {position: [3.0, -4.0, 1.0], normal: [-0.2, 0.5, 0.2], uv: [0.3, 0.8]} , the vertex data of vertex D is {position: [1.5, -3.0, 0.5], normal: [-0.4, 0.3, 0.0], uv: [0.1, 0.7]} as an example, the vertex data of the above vertices are scaled based on the above formulas (1) and (2), and on the basis of obtaining the integers corresponding to each floating-point number, the integers are connected together using commas to form a string. For example, for vertex A, the position attribute string corresponding to position: [2.5, -3.7, 0.8] is "25, -37, 8", the normal attribute string corresponding to normal: [-0.3, 0.4, 0.1] is "-3, 4, 1", and the texture attribute string corresponding to uv: [0.2, 0.9] is "2, 9".

[0067] S303: Combine the position attribute string, the normal attribute string, and the texture attribute string to generate a vertex identifier for each vertex.

[0068] For example, continuing with the above example for vertex A, the position attribute string corresponding to position: [2.5, -3.7, 0.8] is "25, -37, 8", the normal attribute string corresponding to normal: [-0.3, 0.4, 0.1] is "-3, 4, 1", and the texture attribute string corresponding to uv: [0.2, 0.9] is "2, 9". The attribute data strings of vertex A generated are connected using the "|" symbol to obtain the vertex identifier corresponding to vertex A as "25, -37, 8|-3, 4, 1|2, 9".

[0069] For example, for the above-mentioned vertex B, the position attribute string corresponding to position: [2.51, -3.7, 0.8] is "25, -37, 8", the normal attribute string corresponding to normal: [-0.3, 0.41, 0.1] is "-3, 4, 1", and the texture attribute string corresponding to uv: [0.2, 0.89] is "2, 9". By connecting the attribute data strings of the generated vertex B using the "|" symbol, the vertex identifier corresponding to vertex B can be obtained as "25, -37, 8|-3, 4, 1|2, 9".

[0070] For example, for the above-mentioned vertex C, the position attribute string corresponding to position: [3.0, -4.0, 1.0] is "30, -40, 10", the normal attribute string corresponding to normal: [-0.2, 0.5, 0.2] is "-2, 5, 2", and the texture attribute string corresponding to uv: [0.3, 0.8] is "3, 8". By connecting the attribute data strings of the generated vertex C using the "|" symbol, the vertex identifier corresponding to vertex C can be obtained as "30, -40, 10|-2, 5, 2|3, 8".

[0071] For example, for the above-mentioned vertex D, the position attribute string corresponding to position: [1.5, -3.0, 0.5] is "15, -30, 5", the normal attribute string corresponding to normal: [-0.4, 0.3, 0.0] is "-4, 3, 0", and the texture attribute string corresponding to uv: [0.1, 0.7] is "1, 7". The attribute data strings of the generated vertex D are connected using the "|" symbol to obtain the vertex identifier corresponding to vertex D as "15, -30, 5|-4, 3, 0|1, 7".

[0072] In addition, after obtaining the vertex data of the target model, an array UniqueVertices for storing the deduplicated vertices and an index array NewIndices for storing the deduplicated vertices can be created. After determining the vertex identifier of the vertex, a hash table can be created to store the new index relationship between the vertex and the corresponding unique vertex identifier, and then all the vertex data are traversed. According to the vertex identifier of each vertex calculated, first determine whether the vertex is in the hash table. If not, set the vertex to the hash table. Since the index value in the computer starts from 0, for example, the index corresponding to the first point is 0, then the corresponding array length is 1, so the index value corresponding to the vertex is the array length of UniqueVertices minus 1, and then put the vertex into UniqueVertices. Further, obtain the index array of the original vertex of the model, loop through the original vertex index array, obtain the vertex corresponding to the index (without deduplication), then find the new index corresponding to the vertex from the hash table, and store the index in the new vertex index array NewIndices, and use UniqueVertices and NewIndices to replace the vertex data and index data in the original model.

[0073] S202: Determine duplicate vertices according to vertex identifiers of each vertex.

[0074] Optionally, if the vertex identifiers of two vertices are the same, or the error between the vertex identifiers is less than a tolerance value, the two vertices are determined to be duplicate vertices.

[0075] For example, taking the vertex identifier corresponding to the above vertex A as "25, -37, 8|-3, 4, 1|2, 9" and the vertex identifier corresponding to vertex B as "25, -37, 8|-3, 4, 1|2, 9 as an example, it can be seen that the vertex identifiers of vertex A and vertex B are the same, then vertex A and vertex B are determined to be duplicate vertices, and vertex deduplication processing can be performed.

[0076] For example, the vertex identifier corresponding to the above vertex A is "25, -37, 8|-3, 4, 1|2, 9", and the vertex identifier corresponding to vertex D is "15, -30, 5|-4, 3, 0|1, 7". Obviously, the vertex identifiers of vertex A and vertex D are different, so vertex A and vertex B are not duplicate vertices.

[0077] Based on this, it is allowed to identify vertices as duplicate vertices within a certain tolerance range, which can make the model more flexible. Even if the coordinates of the vertices have a slight deviation, as long as the deviation is within the set tolerance range, it can be regarded as a duplicate vertex for deduplication. In this way, by identifying duplicate vertices through vertex identification and then performing vertex deduplication processing, the redundant part of the model data can be significantly reduced.

[0078] As a possible implementation, the above step S102 performs quantization processing on the deduplicated vertex data to obtain processed vertex data, including:

[0079] Determine the quantization range and quantization accuracy of the position information of the target vertex, the quantization range and quantization accuracy of the normal, and the quantization range and quantization accuracy of the texture coordinates; quantize the position information of the target vertex according to the preset mapping strategy, the quantization range and quantization accuracy of the position information to obtain the quantized position information; quantize the normal of the target vertex according to the preset mapping strategy, the quantization range and quantization accuracy of the normal to obtain the quantized normal; quantize the texture coordinates of the target vertex according to the preset mapping strategy, the quantization range and quantization accuracy of the texture coordinates to obtain the quantized texture coordinates; use the quantized position information, quantized normal and quantized texture coordinates as processed vertex data.

[0080] Optionally, the quantization range refers to the maximum and minimum value interval that the data can represent, and the quantization accuracy is used to determine the size of the discrete integer range, which determines the density of the values ​​that can be represented within the interval. The position information of the target vertex is quantized, that is, the continuous position coordinate values ​​are mapped to a discrete value set, thereby reducing the accuracy of the data, but also reducing the amount of data. The normal of the target vertex is quantized. Since the normal is used to describe the surface direction of the vertex, the quantization process can reduce the number of bits required to store the normal. The texture coordinates of the target vertex are quantized. Since the texture coordinates are used to determine the position of the map on the vertex, the quantization process can also reduce the number of bits required to store the texture coordinates.

[0081] For example, the position information needs to calculate the bounding box size of the model, and the size of the bounding box range can be used as the quantization range of the position information. The quantization range of the normal is [-1, 1], and the quantization range of the texture coordinates is [0, 1]. For position information, low-precision scenes can use 8-bit quantization accuracy, and medium-precision scenes can use 16-bit quantization accuracy. If the above two quantization accuracies cannot meet the actual application requirements, the accuracy needs to be further improved, such as using 24-bit or 32-bit quantization accuracy. For normals, 8-bit quantization accuracy can be used. For texture coordinates, 8-bit quantization accuracy can be used.

[0082] For example, the quantization process may be performed based on the following formula (3):

[0083] (3)

[0084] in, represents the quantization function, Represents the floating point number to be quantized, Indicates the minimum value of the quantization range, Indicates the maximum value of the quantization range, represents the rounding function, N represents the size of the integer range, which is , such as the range of 8-bit integers is =256.

[0085] For example, assuming that the quantization range of the position information of vertex A is [-10, 10], the position information needs to be quantized into a 16-bit integer (the range of a 16-bit integer is 65536). =5.25, the value after mapping and quantization using the above formula (3) is:

[0086]

[0087] Exemplarily, after the deduplicated vertex data is quantized, the quantized position information, quantized normals and quantized texture coordinates need to be used as processed vertex data to replace the original model data, and the quantization parameters related to different attributes, such as the quantization range and quantization accuracy, need to be stored.

[0088] Based on this, the position information, normals and texture coordinates contained in the deduplicated vertex data are quantized, and continuous floating-point data are mapped to discrete integer values ​​to reduce data accuracy, thereby reducing storage space and speeding up network transmission.

[0089] As a possible implementation, the above step S103 compresses the texture data according to the data type of the texture data to obtain processed texture data, including:

[0090] Traverse each texture data of the target model to obtain the file format type of each texture data; determine whether the file format type of each texture data is a preset type, if not, compress the texture data to obtain processed texture data.

[0091] For example, the preset type is image / webp. Each texture data in the target model is traversed and its file format type is obtained. The file format type can be obtained by checking the MimeType of the texture file. For each texture, check whether its MimeType is the preset type (such as image / webp). If the texture format is not the preset type, it means that this texture needs to be compressed. For non-preset types of textures, use an appropriate compression library (such as libwebp) to compress them.

[0092] It should be noted that the purpose of compression is to reduce the file size while maintaining image quality. After compression, the original texture data is replaced with the new compressed texture data, and its MimeType is updated to the preset type (such as image / webp). At the same time, in order to ensure that the compressed texture can be correctly parsed during rendering, it is also necessary to add corresponding extension support (such as EXT_texture_webp) to the model so that the renderer can recognize and correctly process WebP format textures.

[0093] Based on this, the size of the map file is effectively reduced, the network transmission speed is improved, and it is ensured that the model can load and use the compressed map data normally when rendering.

[0094] Figure 4 A flow chart of a method for determining a model component provided by an embodiment of the present application is shown. As a possible implementation, the above step S104 determines the model components with the same material attributes in the target model according to the material data, and specifically includes the following steps:

[0095] S401. Store the texture data and non-texture attribute data of the material corresponding to each model component included in the target model in a texture array and an attribute array respectively.

[0096] Exemplarily, all texture-related data are separated from the material data of the target model, and the separated texture data are stored in a texture array textures, where each item of data in the texture array textures records the texture information of the corresponding material. The separated non-texture attribute data are stored in another attribute array attributes, where each item of data in the attribute array attributes records the non-texture attribute information of the corresponding material.

[0097] S402: Compare whether the array length of the first texture array of the material corresponding to the first model component is equal to the array length of the second texture array of the material corresponding to the second model component.

[0098] Optionally, the first model component and the second model component are any two model components among the multiple model components included in the target model. Comparing whether the array length of the first texture array of the material corresponding to the first model component is equal to the array length of the second texture array of the material corresponding to the second model component is mainly to verify whether the material texture data of the two model components are consistent or have the same structure.

[0099] Exemplarily, if the array length of the first texture array of the material corresponding to the first model component is equal to the array length of the second texture array of the material corresponding to the second model component, it can be considered that the material texture data of the first model component and the second model component are consistent in quantity, which means that they have the same type of textures. Conversely, if the lengths of the two are not equal, it means that there is a difference in the quantity of the material texture data of the two model components, which means that one of the components has extra textures or lacks some textures. Through this comparison, it can be ensured that the model components have a consistent data structure when rendering, thereby avoiding rendering problems caused by mismatched texture data.

[0100] S403, if so, traverse the first texture array and the second texture array, and compare the byte data in the first texture array and the second texture array in turn to see if they are the same; if so, traverse the first attribute array of the material corresponding to the first model component and the second attribute array of the material corresponding to the second model component to generate a first attribute string of the first model component and a second attribute string of the second model component; compare the first attribute string of the first model component and the second attribute string of the second model component to see if they are the same; if so, determine that the first model component and the second model component are model components with the same material attributes.

[0101] For example, if the lengths of the two texture arrays are equal, the two arrays are further looped through and the byte data of each texture is compared in turn. As long as the byte data of one texture is found to be different, the two materials are determined to be unequal. When all textures are equal, the attribute arrays of the two materials are traversed and each item of data in the array is connected with a comma to form a new attribute string. Finally, the two attribute strings generated are compared. If the two strings are different, it means that the two materials are unequal. If the strings are the same, it means that the two materials are equal.

[0102] Based on this, by accurately determining whether two materials are equal, we ensure that the materials are compared comprehensively at a detailed level, thus avoiding misjudgments due to minor differences.

[0103] As a possible implementation manner, after determining the model components having the same material attributes in the target model according to the material data, the method further includes:

[0104] Obtain the material quantity of each material contained in the target model, and determine whether the material quantity of each material is greater than a first preset value; if so, group the materials contained in the target model to obtain multiple material groups, and perform material deduplication processing on each material group to obtain deduplicated material data.

[0105] Optionally, the first preset value can be set to 1. If the number of all materials is less than or equal to 1, the repeated operation is skipped. If the number of materials is greater than 1, all materials need to be grouped according to whether they are the same.

[0106] Optionally, deduplication processing is performed on each material group to obtain deduplication material data, including:

[0107] Traverse each material group to determine whether the length of the grid data contained in each material group is greater than a second preset value; if so, obtain the first material in the material group, and traverse the remaining materials in the material group except the first material, and obtain the grid data associated with each remaining material, and set the material corresponding to the grid data associated with each remaining material to the first material to obtain the deduplicated material data.

[0108] For example, the first material is taken from the list materials of all current materials, and it is used as the initial group group, and this group is added to the group list groups, and then the remaining materials in the materials list are traversed to check whether each material is the same as the material in the group group. For each traversed material, if it is found to be the same as the material in the group, it is added to the current group group and removed from the materials list. If no material is found to be the same as the material in the group, the next material is traversed. Every time a group group can no longer find a new identical material, a new ungrouped material is selected from materials to create a new group and added to groups. When the length of the materials list becomes 0, it means that all materials have been divided into different groups according to their similarities, and the grouping operation is completed.

[0109] Exemplarily, perform material deduplication operation on each group in groups. Specifically, loop through groups to determine whether the length of each group is greater than 1. If the length of the group is less than or equal to 1, it means that the material has no duplicate materials and no deduplication operation is required. If the length of the group is greater than 1, it means that the material has duplicate materials. Get the first material material in the group, loop through the remaining materials in the group, get the mesh data associated with the material, set the material of the mesh data to material, and put the remaining materials into the removeMaterials array. In addition, further remove redundant materials, loop through the removeMaterials array, and delete each material in the removeMaterials array from the model data.

[0110] Based on this, by grouping all materials according to whether they are the same, materials with the same properties can be effectively identified and merged. This can reduce the number of duplicate materials in the model, thereby reducing the storage size of the model and improving rendering efficiency. Furthermore, after deduplication of materials, the number of materials that need to be loaded and processed during rendering is reduced, thereby reducing the number of material switches and improving rendering speed.

[0111] Figure 5 A schematic diagram of a model grid classification method provided in an embodiment of the present application is shown. Figure 5 As shown, after performing material deduplication processing on each material group to obtain deduplicated material data, the method further includes:

[0112] S501, traverse the deduplicated material data, and determine whether each traversed target material is stored in the initial hash table.

[0113] Optionally, create an empty initial hash table, which is used to store materials and the model mesh arrays corresponding to the materials, and the initial hash table uses the materials as keys and the model mesh arrays corresponding to the materials as key values. Create an initial hash table of materials and model mesh arrays, loop through the deduplicated material data, and first determine whether the material is in the key of the initial hash table.

[0114] S502. If the target material is not stored in the initial hash table, the target material is stored in the initial hash table as a new key, and the model mesh corresponding to the target material is added to the new model mesh array, and the new model mesh array is used as the key value of the target material.

[0115] For example, if the current material is not in the key of the hash table, the material is set as the key to the initial hash table, and its value is set to an empty array, indicating that the current material has not been associated with other meshes. The model mesh corresponding to the current material is obtained, and the reference (or related information) of the mesh is placed in the array of the corresponding material key in the initial hash table to record which meshes use the same material.

[0116] S503. If the target material is stored in the initial hash table, obtain the model mesh array corresponding to the target material, and add the model mesh corresponding to the target material to the model mesh array corresponding to the target material to obtain an updated hash table.

[0117] For example, if the target material already exists in the initial hash table, it means that other meshes have used the same material. The model mesh array using the material is directly obtained, and the model mesh corresponding to the current material is added to the array. After traversing all materials, a complete updated hash table will be obtained, in which each material key corresponds to an array containing all model meshes using the material.

[0118] Based on this, the final updated hash table classifies the model meshes according to the material, which can effectively manage each material and its corresponding meshes, facilitating subsequent optimization processing.

[0119] Figure 6 A schematic diagram of a hierarchical structure processing method provided in an embodiment of the present application is shown. Figure 6 As shown, before merging the model components with the same material properties to obtain the merged model components, the method further includes:

[0120] S601, traverse the hierarchical structure tree of the target model to determine whether the current node is a model grid node.

[0121] Optionally, the model mesh node is a node containing geometric data. The hierarchical structure tree usually represents the hierarchical relationship between the various components in the model. Starting from the root node of the model, the entire hierarchical structure tree is traversed. For each traversed node, its attributes are checked to determine whether the node is a model mesh node. If the current node contains geometric data, it can be confirmed that this is a model mesh node. Usually these nodes have specific tags or attributes, or contain specific geometric data arrays.

[0122] S602: If the current node is a model grid node, determine whether the parent node of the current node is the root node of the target model; if not, calculate the world transformation information of the current node, and move the current node below the root node based on the world transformation information.

[0123] Optionally, the world transformation information includes: world position, world rotation and world scale. If the current node is a model mesh node, check whether its parent node is the root node of the target model. If it is a root node, no further processing is required. If the parent node of the current node is not a root node, calculate the world transformation matrix of the current node. The world transformation matrix contains the position, rotation and scale information of the current node relative to the global coordinate system. On this basis, use the calculated world transformation matrix to move the current node and its child nodes as a whole to the bottom of the root node, which means that the current node is treated as a direct child node of the root node, and its transformation information is updated to reflect the new position relative to the root node.

[0124] S603. If so, traverse the remaining nodes to determine whether each remaining node is a model grid node and whether the parent node of each remaining node is the root node of the target model, until all model grid nodes in the target model are moved below the root node, and delete the nodes in the hierarchical structure tree that do not belong to the model grid nodes to obtain a new hierarchical structure tree.

[0125] Exemplarily, in order to move all model grid nodes in the model below the root node and delete the intermediate nodes that are no longer needed, for all remaining nodes, determine whether each remaining node is a model grid node. If the current remaining node is a model grid node, check whether its parent node is the root node of the target model. If the parent node of the current remaining node is not the root node, calculate the world transformation matrix of the current remaining node, and use the calculated world transformation matrix to move the current remaining node and its child nodes as a whole below the root node. Repeat the above process until all model grid nodes have been moved below the root node, delete the intermediate nodes that are no longer needed in the hierarchical structure tree, and obtain a new hierarchical structure tree.

[0126] Based on this, the hierarchical structure of the model is simplified, all mesh nodes are directly mounted under the root node, and the correct world transformation information is retained. This not only simplifies the rendering process, but also improves rendering efficiency and the convenience of model management.

[0127] Figure 7 The following is a flow chart of a method for merging model components provided in an embodiment of the present application. Figure 7 As shown, the above steps merge the model components with the same material properties to obtain the merged model components, which specifically include the following steps:

[0128] S701, traverse the updated hash table to obtain each material and the model grid array corresponding to each material.

[0129] Exemplarily, the updated hash table is looped through to obtain each material and its corresponding model mesh array, where the model mesh array is a collection of model meshes with the same material attributes, and the model meshes are used to indicate model components.

[0130] S702. Determine whether to merge the model meshes included in the model mesh array according to the length of the model mesh array corresponding to each material.

[0131] Exemplarily, if the length of the model grid array is equal to 1, it is determined that the model grids contained in the model grid array do not need to be merged and are directly skipped. Conversely, if the length of the model grid array is greater than 1, it is determined that the model grids contained in the model grid array need to be merged.

[0132] S703. If yes, then obtain the world transformation information of the model grid contained in the model grid array, generate a world position change matrix according to the world transformation information, and convert each target attribute of the model grid contained in the model grid array to the world space based on the world position change matrix, and concatenate each target attribute in sequence to generate a merged grid attribute.

[0133] Exemplarily, for the model meshes that need to be merged, the model mesh array is looped through, and for each model mesh, its world position, world rotation and world scale are obtained, and a world position transformation matrix is ​​generated based on these parameters. On this basis, the attributes affected by the world coordinates in the model mesh, such as position, normal, etc., are obtained, and these attributes are applied to the world position transformation matrix calculated above, and converted to the world space, and then each target attribute is spliced ​​into a new mesh attribute in order. Based on this. The model meshes that need to be merged are converted to a unified world space, and their respective attributes are spliced ​​into a new mesh attribute for subsequent merging operations.

[0134] Exemplarily, position Position1 of model 1, position Position2 of model 2 and position Position3 of model 3 are spliced ​​into a new position Position4, normal Normal1 of model 1, normal Normal2 of model 2 and normal Normal3 of model 3 are spliced ​​into a new normal Normal4, and so on. Other attributes (such as UV coordinates, colors, etc.) are also spliced ​​in a similar manner to form a new set of model attributes, that is, the merged mesh attributes.

[0135] S704, merging the vertex indices of the model meshes contained in the model mesh array to obtain merged mesh data, and generating a target model mesh according to the merged mesh attributes and the merged mesh data.

[0136] Exemplarily, the target model mesh is used to indicate the merged model component. The original vertex index array value [0, 1, 2] of the first model mesh (assuming a triangle mesh consisting of 3 vertices) is merged with the vertex index array value [0, 1, 2, 2, 3, 0] of the second model mesh (assuming two triangle meshes consisting of 4 vertices). Starting from the second model mesh, the mesh vertex index value of the current loop needs to be added with the number of vertices of the previous model mesh. Therefore, the vertex index value of the second model mesh needs to be added with the number of vertices of the first model mesh (3 vertices) to obtain the adjusted index value [3, 4, 5, 5, 6, 3]. The adjusted index value is concatenated with the vertex index of the first model mesh to obtain the merged vertex index value [0, 1, 2, 3, 4, 5, 5, 6, 3].

[0137] Exemplarily, a new model mesh is generated using the merged mesh attributes (such as position, normal, UV, etc.) and the merged vertex indices. Since all vertices have been transformed to the world space before merging, the position of the new mesh can be set to [0, 0, 0], the rotation to [0, 0, 0], and the scale to [1, 1, 1].

[0138] In addition, in order to merge multiple model meshes and optimize the model structure, the merged mesh is assigned to the corresponding material, and the mesh is added to the root node of the model. The model mesh array is looped through, each model mesh is removed from the root node, the model mesh data is deleted, and the key of the processed material is deleted from the hash table.

[0139] Based on this, multiple model meshes are effectively merged and a new model mesh is generated, thereby simplifying the model structure and releasing no longer needed mesh data, reducing memory usage. This not only simplifies the model structure but also improves rendering efficiency.

[0140] Based on the same inventive concept, a model data processing device corresponding to the model data processing method is also provided in the embodiment of the present application. Since the principle of solving the problem by the model data processing device in the embodiment of the present application is similar to the above-mentioned model data processing method in the embodiment of the present application, the implementation of the model data processing device can refer to the implementation of the model data processing method, and the repeated parts will not be repeated.

[0141] Reference Figure 8 , which is a schematic diagram of the structure of a model data processing device provided in an embodiment of the present application, the model data processing device 800 includes: an acquisition module 801, a vertex deduplication module 802, a texture compression module 803, a material merging module 804 and a compression upload module 805, wherein:

[0142] An acquisition module 801 is used to acquire original model data of a target model, where the original model data includes vertex data, texture data and material data of multiple vertices of the target model;

[0143] Vertex deduplication module 802, used for determining duplicate vertices among multiple vertices according to vertex data of each vertex, deleting vertex data corresponding to the duplicate vertices in the vertex data of multiple vertices to obtain deduplicated vertex data, and performing quantization processing on the deduplicated vertex data to obtain processed vertex data;

[0144] A texture compression module 803 is used to compress the texture data according to the data type of the texture data to obtain processed texture data;

[0145] The material merging module 804 is used to determine the model components with the same material attributes in the target model according to the material data, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data;

[0146] The compression upload module 805 is used to use the processed vertex data, the processed texture data and the processed material data as new model data of the target model, and compress and upload the new model data.

[0147] Based on this, according to the model data processing device of the embodiment of the present application, by identifying and deleting duplicate vertices, the number of vertices is reduced, thereby reducing the amount of calculation required for rendering, and the quantization process further reduces the storage size of the vertex data, making the model data more compact, reducing the storage requirements and loading time. The texture data is compressed so that the compressed texture data occupies less space while maintaining good visual quality, thereby speeding up the transmission speed of the texture data in the network and reducing the demand for storage space. Further, the model components with the same material attributes are merged, and the merged model components only need to load the material once, reducing the number of material switching times during rendering and the overhead caused by repeatedly loading the same material. The processed vertex data, texture data and material data are integrated into new model data, and compressed and uploaded using compression technologies such as gzip, which further reduces the model file size and the bandwidth consumption of the model data during network transmission, and also speeds up the speed of loading and decompressing the model on the client. To summarize, this application is based on technical means such as vertex deduplication and quantization, texture compression, material merging, and integration and compressed uploading. By reducing redundant data, optimizing data structure and adopting efficient compression algorithms, it achieves lightweight model data, thereby improving rendering efficiency and transmission rate.

[0148] In a possible implementation manner, the vertex deduplication module 802 is specifically used to:

[0149] Determine the vertex identifier of each vertex according to the vertex data of each vertex;

[0150] Based on the vertex identifier of each vertex, duplicate vertices are determined.

[0151] In a possible implementation, the vertex data includes position information, normals, and texture coordinates, wherein the position information is used to indicate the coordinate value of the vertex in a three-dimensional coordinate system, the normal is used to indicate the orientation of the surface where the vertex is located, and the texture coordinates are used to indicate the position of the texture map corresponding to the surface where the vertex is located; the above-mentioned vertex deduplication module 802 is specifically used to:

[0152] Scaling the position information, normal and texture coordinates of each vertex according to a preset tolerance value to obtain processed position information, processed normal and processed texture coordinates of each vertex;

[0153] Generate a position attribute string according to the processed position information of each vertex, generate a normal attribute string according to the processed normal of each vertex, and generate a texture attribute string according to the processed texture coordinates of each vertex;

[0154] The position attribute string, the normal attribute string, and the texture attribute string are combined to generate the vertex identifier of each vertex.

[0155] In a possible implementation manner, the deduplicated vertex data includes position information, normals, and texture coordinates of a target vertex, where the target vertex is a vertex other than a duplicate vertex among the multiple vertices; the vertex deduplication module 802 is specifically used for:

[0156] Determine the quantization range and quantization accuracy of the position information of the target vertex, the quantization range and quantization accuracy of the normal, and the quantization range and quantization accuracy of the texture coordinates;

[0157] According to the preset mapping strategy, the quantization range and the quantization accuracy of the position information, the position information of the target vertex is quantized to obtain the quantized position information;

[0158] According to the preset mapping strategy, the quantization range and the quantization precision of the normal, the normal of the target vertex is quantized to obtain the quantized normal;

[0159] According to the preset mapping strategy, the quantization range and the quantization precision of the texture coordinates, the texture coordinates of the target vertex are quantized to obtain the quantized texture coordinates;

[0160] The quantized position information, the quantized normal and the quantized texture coordinates are used as processed vertex data.

[0161] In a possible implementation manner, the above-mentioned texture compression module 803 is specifically used for:

[0162] Traverse each texture data of the target model and obtain the file format type of each texture data;

[0163] It is determined whether the file format type of each texture data is a preset type. If not, the texture data is compressed to obtain processed texture data.

[0164] In a possible implementation manner, the material merging module 804 is specifically used to:

[0165] The texture data and non-texture attribute data of the corresponding materials of each model component contained in the target model are stored in the texture array and the attribute array respectively. The texture data includes: base color map, normal map, self-illumination map, metalness map, roughness map, and the non-texture attribute data includes: base color, opacity, self-illumination color, metalness, and roughness;

[0166] Comparing whether the array length of a first texture array of a material corresponding to a first model component is equal to the array length of a second texture array of a material corresponding to a second model component, wherein the first model component and the second model component are any two model components among a plurality of model components included in the target model;

[0167] If so, traverse the first texture array and the second texture array, and compare the byte data in the first texture array and the second texture array in turn to see if they are the same. If so, traverse the first attribute array of the material corresponding to the first model component and the second attribute array of the material corresponding to the second model component to generate the first attribute string of the first model component and the second attribute string of the second model component; compare the first attribute string of the first model component and the second attribute string of the second model component to see if they are the same. If so, determine that the first model component and the second model component are model components with the same material attributes.

[0168] In a possible implementation manner, the material merging module 804 is further used to:

[0169] Obtaining the material quantity of each material included in the target model, and determining whether the material quantity of each material is greater than a first preset value;

[0170] If so, the materials included in the target model are grouped to obtain multiple material groups, and each material group is deduplicated to obtain deduplicated material data.

[0171] In a possible implementation manner, the material merging module 804 is further used to:

[0172] Traversing each material group, and determining whether the length of the grid data contained in each material group is greater than a second preset value;

[0173] If so, get the first material in the material group, and traverse the remaining materials in the material group except the first material, and get the mesh data associated with each remaining material, and set the material corresponding to the mesh data associated with each remaining material as the first material to obtain the deduplicated material data.

[0174] In a possible implementation manner, the material merging module 804 is further used to:

[0175] Traverse the deduplicated material data to determine whether each target material traversed is stored in the initial hash table. The initial hash table is used to store materials and the model mesh array corresponding to the materials. The initial hash table uses the material as the key and the model mesh array corresponding to the material as the key value.

[0176] If the target material is not stored in the initial hash table, store the target material as a new key in the initial hash table, add the model mesh corresponding to the target material to the new model mesh array, and use the new model mesh array as the key value of the target material;

[0177] If the target material is stored in the initial hash table, the model mesh array corresponding to the target material is obtained, and the model mesh corresponding to the target material is added to the model mesh array corresponding to the target material to obtain an updated hash table.

[0178] In a possible implementation manner, the material merging module 804 is further used to:

[0179] Traverse the hierarchical structure tree of the target model to determine whether the current node is a model mesh node, which is a node containing geometric data;

[0180] If the current node is a model grid node, determine whether the parent node of the current node is the root node of the target model. If not, calculate the world transformation information of the current node, and move the current node to the bottom of the root node based on the world transformation information. The world transformation information includes: world position, world rotation and world scaling.

[0181] If so, traverse the remaining nodes to determine whether each remaining node is a model grid node and whether the parent node of each remaining node is the root node of the target model, until all model grid nodes in the target model are moved below the root node, and delete the nodes in the hierarchical structure tree that do not belong to the model grid nodes to obtain a new hierarchical structure tree.

[0182] In a possible implementation manner, the material merging module 804 is specifically used to:

[0183] Traverse the updated hash table to obtain each material and the model grid array corresponding to each material. The model grid array is a collection of model grids with the same material attributes. The model grid is used to indicate the model component.

[0184] According to the length of the model mesh array corresponding to each material, determine whether to merge the model meshes contained in the model mesh array;

[0185] If so, obtaining world transformation information of the model grid contained in the model grid array, generating a world position change matrix according to the world transformation information, converting each target attribute of the model grid contained in the model grid array to the world space based on the world position change matrix, and sequentially splicing each target attribute to generate a merged grid attribute;

[0186] The vertex indices of the model meshes contained in the model mesh array are merged to obtain the merged mesh data, and a target model mesh is generated according to the merged mesh attributes and the merged mesh data. The target model mesh is used to indicate the merged model component.

[0187] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0188] The present application embodiment also provides an electronic device 900, such as Fig. 9 As shown, it is a schematic diagram of the structure of an electronic device 900 provided in an embodiment of the present application, including: a processor 901, a memory 902, and optionally, a bus 903. The memory 902 stores machine-readable instructions executable by the processor 901. When the electronic device 900 is running, the processor 901 communicates with the memory 902 through the bus 903. When the machine-readable instructions are executed by the processor 901, the steps of the model data processing method described in any one of the above items are performed.

[0189] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the model data processing method as described in any one of the above items are executed.

[0190] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0191] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

[0192] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A model data processing method, characterized in that: include: Acquire original model data of the target model, wherein the original model data includes vertex data, texture data, and material data of multiple vertices of the target model; Determine duplicate vertices among the plurality of vertices according to vertex data of each of the vertices, delete vertex data corresponding to the duplicate vertices in the vertex data of the plurality of vertices to obtain deduplicated vertex data, and perform quantization processing on the deduplicated vertex data to obtain processed vertex data; According to the data type of the texture data, compressing the texture data to obtain processed texture data; Determine, according to the material data, model components with the same material attributes in the target model, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data; Using the processed vertex data, the processed texture data and the processed material data as new model data of the target model, and compressing and uploading the new model data; The step of determining the model components having the same material attributes in the target model according to the material data includes: The texture data and non-texture attribute data of the corresponding materials of each model component contained in the target model are stored in a texture array and an attribute array respectively, wherein the texture data includes: a base color map, a normal map, a self-luminous map, a metalness map, and a roughness map, and the non-texture attribute data includes: a base color, an opacity, a self-luminous color, a metalness, and a roughness; Comparing whether the array length of a first texture array of a material corresponding to a first model component is equal to the array length of a second texture array of a material corresponding to a second model component, wherein the first model component and the second model component are any two model components among a plurality of model components included in the target model; If so, traverse the first texture array and the second texture array, and compare the byte data in the first texture array and the second texture array in turn to see if they are the same; if so, traverse the first attribute array of the material corresponding to the first model component and the second attribute array of the material corresponding to the second model component to generate a first attribute string of the first model component and a second attribute string of the second model component; compare the first attribute string of the first model component and the second attribute string of the second model component to see if they are the same; if so, determine that the first model component and the second model component are model components with the same material attributes.

2. The method according to claim 1, characterized in that: The step of determining repeated vertices among the plurality of vertices according to the vertex data of each of the vertices comprises: Determine the vertex identifier of each vertex according to the vertex data of each vertex; The repeated vertices are determined according to the vertex identifiers of the vertices.

3. The method according to claim 2, characterized in that The vertex data includes position information, normals and texture coordinates, wherein the position information is used to indicate the coordinate value of the vertex in a three-dimensional coordinate system, the normals are used to indicate the orientation of the surface where the vertex is located, and the texture coordinates are used to indicate the position of the texture map corresponding to the surface where the vertex is located; Determining the vertex identifier of each vertex according to the vertex data of each vertex includes: Scaling the position information, the normal and the texture coordinates of each vertex according to a preset tolerance value to obtain processed position information, processed normal and processed texture coordinates of each vertex; Generate a position attribute string according to the processed position information of each vertex, generate a normal attribute string according to the processed normal of each vertex, and generate a texture attribute string according to the processed texture coordinates of each vertex; The position attribute character string, the normal attribute character string and the texture attribute character string are combined to generate a vertex identifier of each vertex.

4. The method according to claim 1, characterized in that The deduplicated vertex data includes position information, normals, and texture coordinates of a target vertex, and the target vertex is a vertex among the multiple vertices except the duplicate vertex; The step of quantizing the deduplicated vertex data to obtain processed vertex data includes: Determining the quantization range and quantization accuracy of the position information of the target vertex, the quantization range and quantization accuracy of the normal, and the quantization range and quantization accuracy of the texture coordinates; According to a preset mapping strategy, a quantization range and a quantization precision of the position information, the position information of the target vertex is quantized to obtain quantized position information; According to the preset mapping strategy, the quantization range and the quantization precision of the normal, the normal of the target vertex is quantized to obtain a quantized normal; According to a preset mapping strategy, a quantization range and a quantization precision of the texture coordinates, the texture coordinates of the target vertex are quantized to obtain quantized texture coordinates; The quantized position information, the quantized normal and the quantized texture coordinates are used as the processed vertex data.

5. The method according to claim 1, characterized in that: The step of compressing the texture data according to the data type of the texture data to obtain processed texture data includes: Traversing each of the texture data of the target model, and obtaining a file format type of each of the texture data; Determine whether the file format type of each of the texture data is a preset type, and if not, compress the texture data to obtain the processed texture data.

6. The method according to claim 1, characterized in that After determining the model components having the same material attributes in the target model according to the material data, the method further includes: Obtaining the material quantity of each material included in the target model, and determining whether the material quantity of each material is greater than a first preset value; If so, the materials included in the target model are grouped to obtain a plurality of material groups, and material deduplication processing is performed on each of the material groups to obtain deduplicated material data.

7. The method according to claim 6, characterized in that The performing material deduplication processing on each material group to obtain deduplicated material data includes: Traversing each of the material groups, and determining whether the length of the grid data contained in each of the material groups is greater than a second preset value; If so, obtain the first material in the material group, traverse the remaining materials in the material group except the first material, obtain the mesh data associated with each of the remaining materials, and set the material corresponding to the mesh data associated with each of the remaining materials to the first material to obtain the deduplicated material data.

8. The method according to claim 6, characterized in that After performing material deduplication processing on each material group to obtain deduplicated material data, the method further includes: Traversing the deduplicated material data, determining whether each traversed target material is stored in an initial hash table, wherein the initial hash table is used to store materials and model grid arrays corresponding to the materials, and the initial hash table uses the material as a key and the model grid array corresponding to the material as a key value; If the target material is not stored in the initial hash table, the target material is stored in the initial hash table as a new key, and the model mesh corresponding to the target material is added to a new model mesh array, and the new model mesh array is used as the key value of the target material; If the target material is stored in the initial hash table, the model mesh array corresponding to the target material is obtained, and the model mesh corresponding to the target material is added to the model mesh array corresponding to the target material to obtain an updated hash table.

9. The method according to claim 8, characterized in that Before merging the model components with the same material attributes to obtain the merged model components, the method further includes: Traversing the hierarchical structure tree of the target model to determine whether the current node is a model mesh node, wherein the model mesh node is a node containing geometric data; If the current node is the model grid node, determine whether the parent node of the current node is the root node of the target model, if not, calculate the world transformation information of the current node, and move the current node to the bottom of the root node based on the world transformation information, wherein the world transformation information includes: world position, world rotation and world scaling; If so, traverse the remaining nodes to determine whether each of the remaining nodes is a model grid node and whether the parent node of each of the remaining nodes is the root node of the target model, until all the model grid nodes in the target model are moved below the root node, and delete the nodes in the hierarchical structure tree that do not belong to the model grid nodes to obtain a new hierarchical structure tree.

10. The method according to claim 9, characterized in that The merging of the model components having the same material attributes to obtain the merged model components includes: Traversing the updated hash table to obtain each material and a model grid array corresponding to each material, wherein the model grid array is a set of model grids having the same material attributes, and the model grids are used to indicate model components; Determining whether to merge the model grids included in the model grid array according to the length of the model grid array corresponding to each material; If yes, then obtaining world transformation information of the model grid contained in the model grid array, generating a world position change matrix according to the world transformation information, converting each target attribute of the model grid contained in the model grid array to the world space based on the world position change matrix, and sequentially splicing each target attribute to generate a merged grid attribute; The vertex indices of the model meshes contained in the model mesh array are merged to obtain merged mesh data, and a target model mesh is generated according to the merged mesh attributes and the merged mesh data, wherein the target model mesh is used to indicate the merged model component.

11. A model data processing device, characterized in that: include: An acquisition module, used for acquiring original model data of a target model, wherein the original model data includes vertex data, texture data and material data of a plurality of vertices of the target model; A vertex deduplication module, used for determining duplicate vertices among the plurality of vertices according to vertex data of each of the vertices, deleting vertex data corresponding to the duplicate vertices in the vertex data of the plurality of vertices to obtain deduplicated vertex data, and performing quantization processing on the deduplicated vertex data to obtain processed vertex data; A texture compression module, used for compressing the texture data according to the data type of the texture data to obtain processed texture data; A material merging module, used to determine the model components with the same material attributes in the target model according to the material data, merge the model components with the same material attributes to obtain merged model components, and use the material data of the merged model components as processed material data; A compression uploading module, used for taking the processed vertex data, the processed texture data and the processed material data as new model data of the target model, and compressing and uploading the new model data; The material merging module is used to store the texture data and non-texture attribute data of the materials corresponding to each model component included in the target model in a texture array and an attribute array respectively, wherein the texture data includes: a basic color map, a normal map, a self-luminous map, a metalness map, and a roughness map, and the non-texture attribute data includes: a basic color, opacity, a self-luminous color, metalness, and roughness; compare whether the array length of the first texture array corresponding to the material of the first model component is equal to the array length of the second texture array corresponding to the material of the second model component, wherein the first model component and the second model component are multiple model components included in the target model. any two model components in the component; if so, traverse the first texture array and the second texture array, and compare the byte data in the first texture array and the second texture array in turn to see if they are the same; if so, traverse the first attribute array of the material corresponding to the first model component and the second attribute array of the material corresponding to the second model component to generate a first attribute string of the first model component and a second attribute string of the second model component; compare the first attribute string of the first model component and the second attribute string of the second model component to see if they are the same; if so, determine that the first model component and the second model component are model components with the same material attributes.

Citation Information

Patent Citations

  • Model data processing method and device, equipment and storage medium

    CN115391696A