CN115391696A - Model data processing method, device, equipment and storage medium - Google Patents

Model data processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN115391696A
CN115391696A CN202211032977.2A CN202211032977A CN115391696A CN 115391696 A CN115391696 A CN 115391696A CN 202211032977 A CN202211032977 A CN 202211032977A CN 115391696 A CN115391696 A CN 115391696A
Authority
CN
China
Prior art keywords
data
model
model data
type
lightweight
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211032977.2A
Other languages
Chinese (zh)
Inventor
奚燕
龚佑海
李亚仙
吴珍珍
刘雪朝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Supcon Information Industry Co Ltd
Original Assignee
Zhejiang Supcon Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Supcon Information Industry Co Ltd filed Critical Zhejiang Supcon Information Industry Co Ltd
Priority to CN202211032977.2A priority Critical patent/CN115391696A/en
Publication of CN115391696A publication Critical patent/CN115391696A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a model data processing method, a device, equipment and a storage medium, wherein the method comprises the following steps: receiving a lightweight model data file sent by sending terminal equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: a type record segment, an index and length record segment, and a data record segment; analyzing and converting the lightweight model data file to obtain data in a target format; and rendering according to the data in the target format to display the target model. By processing the model data file into a lightweight model data file and transmitting the lightweight model data file, the memory size of the model data in the storage space can be saved, and the lightweight model data file with a smaller memory can also obtain a higher transmission speed during data transmission.

Description

Model data processing method, device, equipment and storage medium
Technical Field
The present application relates to the field of model data processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for processing model data.
Background
Virtual simulation based on real data by a browser is a common trend, higher requirements are provided for diversified display forms of scenes and the bearing capacity of model data, and a model lightweight technology is developed in order to solve the problems of low loading speed, long request time, low rendering frame rate and the like of large scenes and mass data.
In the current model lightweight technology, for a model with high complexity, in order to reduce the loading time of the model in a browser, a method is generally adopted, in which the model is compressed at a sending end and transmitted to the browser end, and then the model is analyzed and rendered by the browser end.
However, for a model with higher complexity, the compression rate of the existing method is lower, and the decompression time is longer when the model is larger, so how to improve the loading efficiency of the model in the browser becomes a problem to be solved urgently.
Disclosure of Invention
An object of the present application is to provide a method, an apparatus, a device, and a storage medium for processing model data, so as to solve the problem of low loading efficiency of a model in a browser in the prior art.
In order to achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides a model data processing method, where the method includes:
receiving a lightweight model data file sent by sending end equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: the data recording device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types;
analyzing and converting the lightweight model data file to obtain data in a target format, wherein the target format comprises: a key-value pair format;
and rendering according to the data in the target format to display a target model.
Optionally, the analyzing and converting the lightweight model data file to obtain model data in a target format includes:
determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file;
if so, creating an analysis sub-thread from a main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread.
Optionally, the analyzing and converting each model data by the sub-thread to obtain model data in a target format includes:
reading a plurality of data types from the type recording section of the model data according to a preset sequence and the type occupation length;
reading the data of each data type from the data recording segment of the model data in sequence according to the byte code initial index and the byte code length of the data of each data type recorded in the index and length recording segment of the model data;
sequentially forming key value pairs by the data types and the data of each data type, wherein the key of each key value pair is a data type, and the value of each key value pair is data of the data type;
and combining the key value pairs into the model data of the target format.
Optionally, the lightweight model data file is generated by the sending end device through the following steps:
extracting a plurality of data types and data of each data type from an original model data file, wherein the data of the data types and the data of each data type are presented in a key-value pair mode;
carrying out lightweight processing on the extracted data of each data type to obtain lightweight data;
and recombining the lightweight data to obtain recombined model data, and storing the recombined model data into the lightweight model data file.
Optionally, the weight reduction treatment includes at least one of:
if the current grid and other grids share the geometric data, deleting the current grid;
adding materials corresponding to each grid in the model into the same set for deduplication, and deleting materials which are not referenced by any grid from the set;
merging the geometric data of the grids with the same material for the static model;
if the distance between the current vertex and other vertexes is smaller than a preset threshold value, deleting the current vertex;
carrying out format conversion on the chartlet data;
performing thinning processing on the animation data;
geometric data is subjected to low precision.
Optionally, the recombination process comprises:
traversing the key value pairs corresponding to the data of the multiple data types and the data of each data type, and extracting the data of the multiple data types and the data of each data type;
arranging the data of each data type according to a preset sequence to obtain the arranged data;
arranging the plurality of data types according to a preset sequence and the type occupation length to obtain the arranged data types;
determining byte code initial indexes and byte code lengths of the data types according to the arranged data;
and sequentially connecting the arranged data types, the byte code initial index and the byte code length of the data of each data type and the arranged data in series to obtain the recombined model data.
In a second aspect, another embodiment of the present application provides a model data processing apparatus, including:
the receiving module is used for receiving a lightweight model data file sent by sending terminal equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: the device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types;
the analysis module is used for analyzing and converting the lightweight model data file to obtain data in a target format, and the target format comprises: a key-value pair format;
and the display module is used for rendering according to the data in the target format so as to display the target model.
Optionally, the parsing module is further configured to:
determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file;
if so, creating an analysis sub-thread from a main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread.
Optionally, the parsing module is further configured to:
reading a plurality of data types from the type recording section of the model data according to a preset sequence and the type occupation length;
reading the data of each data type from the data recording segment of the model data in sequence according to the byte code initial index and the byte code length of the data of each data type recorded in the index and length recording segment of the model data;
sequentially combining the plurality of data types and the data of each data type into a key value pair, wherein the key of the key value pair is a data type, and the value of the key value pair is data of the data type;
and combining the key value pairs into the model data of the target format.
Optionally, the receiving module is further configured to:
and creating a request sub-thread from the main thread, and sending a model data acquisition request to the sending end equipment by the request sub-thread so as to trigger the sending end equipment to send the lightweight model data file.
In a third aspect, another embodiment of the present application provides an electronic device, including: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate with each other through the bus, and the processor executes the machine-readable instructions to execute the steps of the model data processing method.
In a fourth aspect, another embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the steps of the above model data processing method.
The beneficial effect of this application is:
receiving a lightweight model data file sent by sending end equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: a type record segment, an index and length record segment, and a data record segment; analyzing and converting the lightweight model data file to obtain data in a target format; and rendering according to the data in the target format to display the target model. By processing the model data file into a lightweight model data file and transmitting the lightweight model data file, the memory size of the model data in the storage space can be saved, and the lightweight model data file with a smaller memory can also obtain higher transmission speed during data transmission, so that the loading and analysis speed of the model data in the browser is improved.
Drawings
To more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 illustrates an architecture diagram of a service system provided in an embodiment of the present application;
FIG. 2 is a flow chart of a method for processing model data provided by an embodiment of the present application;
fig. 3 is a flowchart illustrating a lightweight analysis method according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a method for parsing model data according to an embodiment of the present application;
FIG. 5 is a flow chart illustrating a method for model data weight reduction provided by an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for reorganizing model data according to an embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of a model data processing apparatus according to an embodiment of the present application;
fig. 8 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are only for illustration and description purposes and are not used to limit the protection scope of the present application. Further, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
In the current model lightweight technology, for a model with higher complexity, such as a model of a large scene, in order to reduce the loading time of the model in a browser, a general method is to compress the model by a sending end or a server, transmit the compressed model to the browser, and analyze and render model data by the browser.
However, the existing model compression method has a low model compression rate for a large scene, and after a sending end or a server compresses a model and transmits the compressed model to a browser, the time for loading and analyzing the model by the browser is long, so how to improve the loading efficiency of the model in the browser becomes a problem to be solved urgently.
Based on the above problems, the present application provides a model data processing method, which is applied to a model data transceiving rendering scene shown in fig. 1, as shown in fig. 1, first, a sending end device may compress model data into a lightweight model data file, then, the sending end device responds to a file request of a receiving end device, and sends the lightweight model data file to the receiving end device, after the receiving end device receives the lightweight model data file, the receiving end device may parse the model data file to obtain model data, and perform scene creation and model rendering according to the model data, so as to implement fast loading of large scene model data, wherein the sending end device may be a terminal device or a server, and the receiving end device may be a terminal device. The terminal device may be, for example, a desktop computer, a notebook computer, a mobile phone, a tablet computer, and the like.
Next, a model data processing method according to the present application will be described, which can be applied to the receiving-side device described above. As shown in fig. 2, the method includes:
s201: receiving a lightweight model data file sent by sending end equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data sequentially comprises: the data recording device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types.
Optionally, the sending end device may be an electronic device or a server for storing the model data, if the sending end device is an electronic device for storing the model data by the user, the electronic device may process the model data into a lightweight model data file, and if the sending end device is a server, in a possible implementation, a person in the art may upload the model data to the server through a browser, and the server processes the model data into the lightweight model data file.
Alternatively, the file type may be a unique type identifier for the lightweight model data file.
Optionally, the lightweight model data file may include model data of a plurality of models in one scene. Illustratively, 5 models are included in the scene a, which are model 1, model 2, model 3, model 4 and model 5, respectively, the lightweight model data file of the scene a received by the user may include the file type identifier and the model data of model 1, model 2, model 3, model 4 and model 5.
Optionally, the lightweight model data file may include at least one model data, and each model data sequentially includes: the data recording device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the data types can be node data types, grid data types, texture data types, map data types, animation data types and the like, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types.
Illustratively, the data record segment of model a may include: binary data, node data, mesh data, texture data, map data, animation data, and the like. The binary data comprises vertex data, vertex index data, normal line data, UV (ultraviolet) and other geometric coordinate data, texture mapping data and frame animation data which are used for storing the model; the node data is the description of the whole structure of the model, and is organized according to a tree structure and divided into Mesh grid nodes and non-Mesh grid nodes; the grid data is the description of the binary geometric data index corresponding to each grid and the material index information corresponding to the binary geometric data index; the texture data is description of texture information of the grid expression, such as color, chartlet, metal degree, roughness, high light reflection and the like; the mapping data comprises description of texture mapping used in the texture and binary data index information corresponding to the texture mapping; the animation data includes descriptions of information such as animation type, node index of animation body, interpolation mode, binary data index corresponding to frame animation, and the like.
S202: analyzing and converting the lightweight model data file to obtain data in a target format, wherein the target format comprises the following steps: key-value pair format.
Optionally, after receiving the lightweight model data file, the receiving end device may perform, because the loading of the general model data is performed in the browser, and the transmission process adopts a binary format, which is different from a format supported by the browser during parsing and conversion, the lightweight model data file may be first converted into a format that is resolvable by the browser, for example, the binary data is converted into a type array, and then the lightweight model data file is parsed and converted to obtain data in a target format.
Alternatively, the data in the target format may be data of each model in a key-value pair format. Illustratively, the data in the Object format may include node data converted into JSON (JavaScript Object notification) objects, mesh data, texture data, map data, and animation data.
S203: and rendering according to the data in the target format to display the target model.
Optionally, the target model may be a plurality of models included in a scene corresponding to the lightweight model data file requested by the receiving end device.
Optionally, rendering is performed according to the data in the target format, which may be based on a loader in a browser, and a scene is created and rendered using three.
For example, the rendering manner according to the data in the target format can be as follows:
for each map data in the target format, a loader can be used for decompressing and converting the binary data corresponding to the current map to construct a texture object;
for each material data in the data of the target format, a standard grid material object can be constructed according to attributes such as color, metal degree, roughness and the like of the material, and if a mapping exists, the mapping object is associated;
for each grid data in the target format, a geometric object can be generated by using binary geometric data corresponding to each grid, and then a material object is obtained according to a material index corresponding to the grid to jointly construct a networking object;
for each animation data in the data of the target format, constructing a key frame tracking object according to the type, interpolation mode, frame animation data and the like of the animation, then constructing an animation fragment object by using the object, and putting the animation fragment object into an animation set;
for each node data in the target format, if the current node is a Mesh grid node, associating a grid object, otherwise, creating a group object, and then organizing all the objects according to a tree structure as the values of the attribute fields of the child nodes of the three-dimensional object;
and (4) taking the animation set as the value of the animation attribute field of the three-dimensional object, and finally adding the three-dimensional object into the scene by using three.
In the embodiment of the application, the lightweight model data file sent by the sending terminal device is received, the model data sequentially comprises a type recording segment, an index and length recording segment and a data recording segment, the lightweight model data file is analyzed and converted to obtain data in a target format, and finally, the data in the target format is rendered to display the target model. The model data is stored into a lightweight model data file format and transmitted to the receiving terminal equipment, so that the file size of the model data can be effectively reduced, the lightweight model data file format is adopted for transmission in network transmission, and the network transmission speed can be effectively improved aiming at the model transmission of a large scene. Accordingly, fast rendering can be achieved at the receiving end device.
Next, a description will be given of a procedure of obtaining model data in a target format by analyzing and converting the lightweight model data file, where, as shown in fig. 3, the step S202 includes:
s301: and determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file.
Optionally, the main thread of the receiving end device may first identify the file type of the lightweight model data file, if the file type identifier of the lightweight model data file is identified, the next analysis may be performed, and if the file type identifier of the lightweight model data file is not identified, the next analysis is not performed.
S302: if so, creating an analysis sub-thread from the main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread.
Optionally, after the main thread recognizes the file type identifier of the lightweight model data file, a sub-thread may be created, and the plurality of model data in the lightweight model data file are sent to the sub-thread, and the sub-thread analyzes and processes the model data.
Optionally, the main thread may create a preset number of sub-threads to analyze and process the model data, or create the same number of sub-threads as the number of the models according to the number of the models in the lightweight model data file to analyze and process each model data, so as to obtain the model data in the target format, and send the model data in the target format to the main thread.
Optionally, the sub-thread may convert the model data into data in a target format, that is, data in a key-value pair format, and for example, the sub-thread may convert the node data, the mesh data, the texture data, the map data, and the animation data into a JSON object and send the converted data to the main thread.
In the embodiment of the application, the sub-threads are created through the main thread, each model data is analyzed and converted through the sub-threads to obtain the model data in the target format, the model data in the target format is sent to the main thread, the pressure of the main thread for analyzing the model data can be dispersed into a plurality of sub-threads, and the loading efficiency of the receiving end device on the model data in the received model file is improved.
Next, a description will be given of a procedure of obtaining model data in a target format by analyzing and converting each model data by a child thread, and as shown in fig. 4, the step S302 includes:
s401: and reading a plurality of data types from the type recording section of the model data according to a preset sequence and the type occupation length.
Optionally, the preset sequence may be an arrangement sequence of data types of the type record segments agreed by the receiving end device and the sending end device.
Optionally, the receiving end device and the sending end device may also agree on the type occupation length, so that the receiving end device may read a plurality of data types from the type recording segment of the model data according to the type occupation length and the preset sequence.
For example, assuming that the preset sequence is a node type, a mesh type, a material type, a map type, and an animation type, the receiving end device may sequentially read the node type, the mesh type, the material type, the map type, and the animation type of the model from the type recording segment of the model data according to the sequence.
S402: and sequentially reading the data of each data type from the data recording segment of the model data according to the byte code start index and the byte code length of the data of each data type recorded in the index and length recording segment of the model data.
Optionally, the index and length recording segment of the model data may record the byte code start index and byte code length of the data of each data type, for example, the byte code start index and byte code length may indicate that the 124 th to 159 th bits are the data of the grid type, and the sub-thread may read the grid data from the 124 th to 159 th bits.
S403: and sequentially forming a plurality of data types and data of each data type into key value pairs, wherein the keys of the key value pairs are the data types, and the values are the data of the data types.
Optionally, after the child thread reads data of each type, the child thread may sequentially combine the data of each data type and the data of each data type into a key-value pair, for example, combining { node type: node data as a set of key-value pairs, where the key of a key-value pair is a node type and the value of the key-value pair is node data.
S404: and combining the key value pairs into model data in a target format.
Optionally, after the sub-thread obtains key value pairs composed of a plurality of data types and data of each data type, each key value pair may be combined to obtain model data in a target format, and for example, each key value pair may be combined into a JSON object.
In the embodiment of the application, after receiving the lightweight model data file, the receiving end device can analyze the model data through the created sub-thread, and finally obtain the model data in the target format, and through the sub-thread, the multiple model data can be analyzed simultaneously, so that the efficiency of model analysis is improved.
Next, a procedure of generating the lightweight model data file by the transmitting-side device will be described, and as shown in fig. 5, the procedure includes:
s501: and extracting a plurality of data types and data of each data type from the original model data file, wherein the data of the data types and the data of each data type are presented in a key-value pair mode.
Optionally, the original model data file may include a plurality of original model data in a scene acquired by the receiving end device, and each original model data may include a plurality of data types and data of each data type.
Illustratively, the receiving end device acquires an original model data file of a scene a, where the scene a includes four models, i.e., a model 1, a model 2, a model 3, and a model 4, and the original model data file may include original model data of the four models, i.e., the model 1, the model 2, the model 3, and the model 4.
Illustratively, the data types of the model and the data of each data type are presented in the form of key-value pairs, which may be, for example, { model 1: { node type: node data }, { lattice type: mesh data }, { map type: mapping data }, { material type: texture data }, { animation type: animation data }, indicating that the data types of the model 1 comprise a node type, a grid type, a map type, a material type and an animation type.
S502: and performing weight reduction processing on the extracted data of each data type to obtain light-weight data.
Optionally, the extracted data of each data type may be subjected to weight reduction processing, where the weight reduction processing may be performed on the data of each data type, and the memory occupancy of the data after weight reduction processing may be lower than that of the original data.
Optionally, the data type of the lightweight data and the data type of the original model data may be the same, and only the data of each data type is subjected to the lightweight processing.
S503: and recombining the lightweight data to obtain recombined model data, and storing the recombined model data into a lightweight model data file.
Optionally, the lightweight data is subjected to a reorganization process, which may be to reorganize the lightweight data and the data types respectively corresponding thereto into a preset format, so as to obtain reorganized model data.
Alternatively, the restructured model data may be a byte array after the original model data is subjected to weight reduction and restructuring.
Note that the above-described lightening and restructuring process is only for model data of one model, the original model data file includes model data of a plurality of models, the lightening and restructuring process may be performed for each model data to obtain a lightened model data file, the model data may be stored for each model in the original model data, and the restructured model data obtained after the lightening and restructuring of the model data of the model object may be restructured model data for each model object.
In this embodiment, the sending end device may, after receiving a sending request from the receiving end device, perform the above-mentioned lightweight and reassembly processes using all model data of a scene indicated in the request as an original model data file to obtain a lightweight model data file, and send the file to the receiving end device; or, the sending end device may upload the stored model data of all scenes to the server, the server performs the above-mentioned lightening and restructuring processes, and after receiving the sending request of the receiving end device, the sending end device directly sends the lightened model data file corresponding to the scene indicated in the request to the receiving end device, and the receiving end device performs the above-mentioned parsing and loading processes of S201 to S203.
By carrying out light weight and recombination on the original model data, the memory size of the model file can be greatly reduced, and higher transmission speed can be obtained in the transmission process.
Next, the weight reduction treatment is specifically described, and the weight reduction treatment includes at least one of:
and if the current grid and other grids share the geometric data, deleting the current grid.
Optionally, if the current grid and other grids share geometric data, deleting the current grid, specifically traversing the grid data in the model data, sequentially judging whether the current grid and other grids share the same binary geometric data, if so, deleting the current grid data, and updating the data index referencing the grid.
And adding the materials corresponding to the grids in the model into the same set for duplication removal, and deleting the materials which are not referenced by any grids from the set.
Optionally, adding the material corresponding to each mesh in the model into the same set for deduplication, and deleting the material that is not referenced by any mesh from the set, specifically, traversing the mesh data in the model data, placing the material index corresponding to the mesh into a set for deduplication, then traversing the material data in the model data, and if the index of a certain material is not in the set, indicating that the material is a redundant material that is not referenced by any mesh, directly deleting the material.
For static models, the geometric data of meshes with the same material are merged.
Optionally, for the static model, merging the geometric data of the meshes with the same material, specifically, the merging may be: judging whether the current model is a static model according to parameters provided in the model, traversing the grid data in the model data if the current model is the static model, classifying the grid data according to material indexes, merging the grid geometric data of the same material, and replacing the original node data as merged grid node data; if the model before combination has a large number of components, the model after combination can greatly reduce the drawing and calling times and improve the rendering efficiency.
And if the distance between the current vertex and other vertexes is smaller than a preset threshold value, deleting the current vertex.
Optionally, if the distance between the current vertex and another vertex is smaller than the preset threshold, deleting the current vertex, which may specifically be: traversing node data in the model data, searching the Mesh data corresponding to the current node if the current node is a Mesh node, extracting binary vertex data, sequentially judging whether the distance between each vertex and other vertexes is smaller than a threshold value according to a given vertex welding threshold value, deleting the data of the vertex if the distance is smaller than the threshold value, and otherwise, continuing to circulate the next vertex.
And carrying out format conversion on the map data.
Optionally, format conversion is performed on the map data, and specifically, the format conversion may be: traversing the map data in the model data, acquiring binary data corresponding to each map, and converting the binary data into a KTX2 map format by using Basis Universal, wherein the map format can be directly used by a GPU without transcoding, and the file is generally smaller than common formats such as JPG, PNG and the like.
And performing thinning processing on the animation data.
Optionally, the thinning processing may be performed on the animation data, specifically: traversing animation data in the model data, extracting binary animation data according to the binary data index corresponding to the frame animation, dividing continuously and repeatedly appearing data into different sets, thinning the sets, and replacing the data before thinning with the thinned data to form new binary animation data.
Geometric data is subjected to low precision.
Optionally, the geometric data is subjected to low precision, which may specifically be: the method has the advantages that the low-precision integer data or few bits are used for replacing floating point data such as vertexes, normals and the like, and although certain precision is lost, the storage space of the model can be greatly reduced on the basis that the original shape of the model is kept as far as possible, and balance between model precision and model size is achieved.
In the embodiment of the application, the grid data, the material data, the node data, the map data, the animation data and the geometric data in the model data are subjected to light weight processing respectively, so that the memory size of the model data can be reduced, and compared with an original method for compressing the model data, the model storage occupation ratio is reduced, and the accuracy of the model is kept to the greatest extent.
The following is a description of the procedure of the rearrangement processing in S503, and as shown in fig. 6, the procedure of S503 includes:
s601: and traversing the plurality of data types and the key value pairs corresponding to the data of each data type, and extracting the data of the plurality of data types and each data type.
Optionally, the data of the multiple data types and the data of each data type may be presented in the form of key value pairs, and when performing the recombination processing, the data of the multiple data types and the data of each data type are extracted, or the key and the value in each key value pair are extracted respectively.
If the model data is directly serialized into a character string form, a lot of storage space can be wasted, and therefore the storage space can be greatly saved by extracting the field attribute value of the key value pair.
S602: and arranging the data of each data type according to a preset sequence to obtain the arranged data.
Optionally, the preset sequence may be an arrangement sequence of data of each data type agreed by the receiving end device and the sending end device, and after the arranged data is obtained by arranging the data in the agreed sequence, the arranged data may be converted into a byte array, where the byte array corresponds to the model data of one model object.
S603: and arranging the plurality of data types according to a preset sequence and the type occupation length to obtain the arranged data types.
Optionally, after the data of each data type is arranged according to a preset sequence, the data types may also be arranged according to the same sequence, and the length occupied by the type of each data type may be agreed in advance by the sending end device and the receiving end device.
S604: and determining the byte code start index and the byte code length of the data of each data type according to the arranged data.
Optionally, after the data of each data type is arranged, the length of the data of each data type may be sequentially determined as the byte code length according to the length of the arranged data, and the start position of the data of each data type may be determined as the byte code start index of the data of each data type.
For example, assuming that the position of the node data in the arranged data is 124-134 th bits, the start index of the node type data may indicate that the position of the node data in the arranged data is 124-134 th bits, and the length of the byte code may indicate that the length of the node data includes 10 bits.
S605: and sequentially connecting the arranged data types, the byte code initial index and the byte code length of the data of each data type and the arranged data in series to obtain the recombined model data.
Optionally, the arranged data types, the byte code start index and the byte code length of the data of each data type, and the arranged data are sequentially concatenated, for example, the data types, the byte code start index and the byte code length of the data of each data type may be added before the arranged data.
Optionally, the restructured model data may be model data obtained by converting the data obtained by the above concatenation into a byte array.
It should be noted that the above-mentioned processes of weight reduction and reorganization may be performed on each model in the original model data file, a file type identifier may be added to the lightweight model data file formed by all the model data after reorganization, and the receiving end device may perform further parsing and loading processes after recognizing the file type identifier.
In the embodiment of the application, the lightweight model data are recombined in an agreed mode, so that on one hand, the storage space can be saved, on the other hand, the receiving end equipment can also rapidly realize data analysis in an agreed mode, and the loading efficiency of the data on the receiving end equipment is greatly improved.
Based on the same inventive concept, a model data processing apparatus corresponding to the model data processing method is also provided in the embodiments of the present application, and because the principle of solving the problem of the apparatus in the embodiments of the present application is similar to the model data processing method described above in the embodiments of the present application, the implementation of the apparatus may refer to the implementation of the method, and repeated details are not described again.
Referring to fig. 7, a schematic diagram of a model data processing apparatus provided in an embodiment of the present application is shown, where the apparatus includes: a receiving module 701, an analyzing module 702, and a displaying module 703, wherein:
a receiving module 701, configured to receive a lightweight model data file sent by a sending end device, where the lightweight model data file includes: the file type and at least one model data, each model data includes in turn: the device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types;
the parsing module 702 is configured to parse and convert the lightweight model data file to obtain data in a target format, where the target format includes: a key-value pair format;
a display module 703, configured to render according to the data in the target format to display the target model.
Optionally, the parsing module 702 is further configured to:
determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file;
if so, creating an analysis sub-thread from the main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain the model data in the target format, and sending the model data in the target format to the main thread.
Optionally, the parsing module 702 is further configured to:
reading a plurality of data types from the type recording section of the model data according to a preset sequence and the type occupation length;
reading the data of each data type from the data recording segment of the model data in sequence according to the byte code initial index and the byte code length of the data of each data type recorded in the index and length recording segment of the model data;
sequentially forming a plurality of data types and data of each data type into key value pairs, wherein the keys of the key value pairs are the data types, and the values are the data of the data types;
and combining the key value pairs into model data in a target format.
Optionally, the receiving module 701 is further configured to:
and creating a request sub-thread from the main thread, and sending a model data acquisition request to the sending end equipment by the request sub-thread so as to trigger the sending end equipment to send the lightweight model data file. The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
According to the method and the device, the storage space occupied by the model data can be saved through the light-weight model data file, meanwhile, the multiple sub-threads are created through the main thread to analyze the received light-weight model data file, the sub-threads return the analyzed model data to the main thread to render, the analyzing and loading efficiency of the model in the browser can be improved, and the model loading effect for a large scene is particularly remarkable.
An embodiment of the present application further provides an electronic device, as shown in fig. 8, which is a schematic structural diagram of the electronic device provided in the embodiment of the present application, and includes: a processor 81, a memory 82 and a bus. The memory 82 stores machine-readable instructions (e.g., corresponding execution instructions of the receiving module 701, the parsing module 702, and the displaying module 703 in the apparatus in fig. 7) executable by the processor 81, when the computer device is running, the processor 81 and the memory 82 communicate via the bus, and the machine-readable instructions, when executed by the processor 81, perform the processing of the model data processing method.
The embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of the above model data processing method are performed.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and there may be other divisions in actual implementation, and for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or modules, and may be in an electrical, mechanical or other form.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, and various media capable of storing program codes.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application.

Claims (10)

1. A method of model data processing, comprising:
receiving a lightweight model data file sent by sending end equipment, wherein the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: the data recording device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types;
analyzing and converting the lightweight model data file to obtain data in a target format, wherein the target format comprises: a key-value pair format;
and rendering according to the data in the target format to display a target model.
2. The method of claim 1, wherein the parsing and converting the lightweight model data file to obtain model data in a target format comprises:
determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file;
if so, creating an analysis sub-thread from a main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread.
3. The method of claim 2, wherein the parsing and converting each of the model data by the child thread to obtain model data in a target format comprises:
reading a plurality of data types from the type recording section of the model data according to a preset sequence and the type occupation length;
reading the data of each data type from the data recording segment of the model data in sequence according to the byte code initial index and the byte code length of the data of each data type recorded in the index and length recording segment of the model data;
sequentially forming key value pairs by the data types and the data of each data type, wherein the key of each key value pair is a data type, and the value of each key value pair is data of the data type;
and combining the key value pairs into the model data of the target format.
4. The method of claim 1, wherein the lightweight model data file is generated by the sending end device by:
extracting a plurality of data types and data of each data type from an original model data file, wherein the data of the data types and the data of each data type are presented in a key-value pair mode;
performing lightweight processing on the extracted data of each data type to obtain lightweight data;
and recombining the lightweight data to obtain recombined model data, and storing the recombined model data into the lightweight model data file.
5. The method of claim 4, wherein the lightening process comprises at least one of:
if the current grid and other grids share geometric data, deleting the current grid;
adding the materials corresponding to each grid in the model into the same set for duplication removal, and deleting the materials which are not referenced by any grid from the set;
for the static model, merging the geometric data of the grids with the same material;
if the distance between the current vertex and other vertexes is smaller than a preset threshold value, deleting the current vertex;
carrying out format conversion on the chartlet data;
performing thinning processing on the animation data;
geometric data is subjected to low precision.
6. The method of claim 4, wherein the recombination process comprises:
traversing the plurality of data types and key value pairs corresponding to the data of each data type, and extracting the data of the plurality of data types and each data type;
arranging the data of each data type according to a preset sequence to obtain the arranged data;
arranging the plurality of data types according to a preset sequence and the type occupation length to obtain the arranged data types;
determining byte code initial indexes and byte code lengths of the data types according to the arranged data;
and sequentially connecting the arranged data types, the byte code initial indexes and the byte code lengths of the data types and the arranged data in series to obtain the recombined model data.
7. A model data processing apparatus, comprising:
the receiving module is used for receiving a lightweight model data file sent by sending end equipment, and the lightweight model data file comprises: the file type and at least one model data, each model data includes in turn: the data recording device comprises a type recording segment, an index and length recording segment and a data recording segment, wherein the type recording segment is used for recording a plurality of data types, the index and length recording segment is used for recording byte code start indexes and byte code lengths of data of the data types, and the data recording segment is used for recording the data of the data types;
the analysis module is used for analyzing and converting the lightweight model data file to obtain data in a target format, and the target format comprises: a key-value pair format;
and the display module is used for rendering according to the data in the target format so as to display the target model.
8. The apparatus of claim 7, wherein the parsing module is further configured to:
determining whether to carry out lightweight analysis or not by the main thread according to the file type in the lightweight model data file;
if so, creating an analysis sub-thread from a main thread, sending each model data to the sub-thread by the main thread, analyzing and converting each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread.
9. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing program instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is running, the processor executing the program instructions to perform the steps of the model data processing method according to any one of claims 1 to 6 when executed.
10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, performs the steps of the model data processing method according to one of claims 1 to 6.
CN202211032977.2A 2022-08-26 2022-08-26 Model data processing method, device, equipment and storage medium Pending CN115391696A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211032977.2A CN115391696A (en) 2022-08-26 2022-08-26 Model data processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211032977.2A CN115391696A (en) 2022-08-26 2022-08-26 Model data processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115391696A true CN115391696A (en) 2022-11-25

Family

ID=84123119

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211032977.2A Pending CN115391696A (en) 2022-08-26 2022-08-26 Model data processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115391696A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117874303A (en) * 2023-12-28 2024-04-12 荣耀终端有限公司 Data processing method and related device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117874303A (en) * 2023-12-28 2024-04-12 荣耀终端有限公司 Data processing method and related device

Similar Documents

Publication Publication Date Title
KR100695142B1 (en) Adaptive nth power of 2 n-ary tree generating method, and method and apparatus for encoding and decoding 3D volume data using it
US9245383B2 (en) Accelerated three-dimensional intersection testing using compressed volumes
EP1574996A2 (en) Adaptive 2n-ary tree generating method, and method and apparatus for encoding and decoding 3D volume data using it
US20130114910A1 (en) Method for compressing/decompressing a three-dimensional mesh
CN112989482B (en) BIM model data generation method and device and building method and device
CN115208414B (en) Data compression method, data compression device, computer device and storage medium
CN114116635A (en) Parallel decompression of compressed data streams
CN115391696A (en) Model data processing method, device, equipment and storage medium
CN113034663B (en) GIM model light weight processing method and device, equipment and storage medium
Pan et al. A Novel HDF‐Based Data Compression and Integration Approach to Support BIM‐GIS Practical Applications
CN114119927A (en) Model processing method and device for oblique photography model optimization
CN104123331A (en) Data querying method, device and system of client end application
CN115718726A (en) Lightweight and encrypted storage method for BIM model data
CN116126957A (en) Data format conversion method, device, equipment and storage medium
CN114092577A (en) Image data processing method, image data processing device, computer equipment and storage medium
CN113835890A (en) Rendering data processing method, device, equipment and storage medium
CN113761293A (en) Graph data strong-connectivity component mining method, device, equipment and storage medium
CN117278053B (en) GLTF-JSON format data compression method, system and device
KR101086772B1 (en) Method and apparatus for 3d mesh compression based quantization
EP4391538A1 (en) Point cloud coding method and apparatus, point cloud decoding method and apparatus, and computer and storage medium
CN114140569B (en) Three-dimensional scene serialization compression method
Isenburg Compression and streaming of polygon meshes
CN115982358B (en) Document splitting method, device, terminal equipment and computer readable storage medium
CN111062638B (en) Project resource processing method and device
EP4199361A1 (en) Compressed graph notation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination