OBJ file data compression method, parsing method and system
By performing hex conversion on OBJ file data, the problem of increased resource package volume and processing cost in the existing technology is solved, efficient data compression and decompression is achieved, and the transmission and parsing speed of 3D models is improved.
Patent Information
- Application Number
- CN201811532504.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-14
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2038-12-14
AI Technical Summary
In the existing technology, in order to compress OBJ files, third-party tools need to be added to the 3D model resource package, which increases the size of the resource package and the data processing cost.
By performing base conversion on the data in the OBJ file, the number of bytes in the converted hex category is smaller than the default hex category, thereby achieving data compression and performing compression and decompression without using third-party tools.
It effectively reduces the size of OBJ files, improves data transmission and analysis speed, reduces the resource package size of 3D model software, and expands the scope of application.
Smart Images

Figure CN111324587B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a data compression method, parsing method and system for an OBJ file. Background Art
[0002] OBJ file is a common 3D model standard file format developed by Alias|Wavefront for workstation-based 3D model (3-Dimensions Model) modeling and animation software "Advanced Visualizer". OBJ files are usually used for file transfer and mutual import between 3D model software. OBJ files can store 3D model information such as vertices, normals, texture coordinates, and materials in plain text.
[0003] In order to save the transmission and parsing time of OBJ files, third-party tools are usually used in the prior art to compress the data in OBJ files, wherein the third-party tools may be ZIP (zone information protocol), FBX (FeedBack eXterminator), etc.
[0004] However, using third-party tools to compress and parse OBJ files usually requires adding the third-party tools to the 3D model resource package in advance, which not only increases the size of the 3D model resource package, but also increases the cost of data processing. Summary of the invention
[0005] The technical problem to be solved by the embodiments of the present invention is to overcome the defects in the prior art that in order to compress OBJ files, a third-party tool needs to be added to the 3D model resource package, which increases the volume of the 3D model resource package and increases the data processing cost. A compression method, a parsing method and a system for OBJ file data are provided.
[0006] The embodiment of the present invention solves the above technical problems through the following technical solutions:
[0007] A method for compressing data of an OBJ file, the method comprising:
[0008] Identify the OBJ file, and obtain the data in the OBJ file;
[0009] The default base category of the data is converted to obtain compressed data, wherein the compressed data has a converted base category, and the number of bytes of the converted base category is less than the number of bytes of the default base category.
[0010] Preferably, the data includes integer data, and the integer data has a first default base category;
[0011] The converting the default base type of the data to obtain compressed data includes:
[0012] The first default base type of the integer data is base-converted to obtain first compressed data, wherein the first compressed data has a first converted base type.
[0013] Preferably, the integer data includes surface composition index data and / or smoothing group data.
[0014] Preferably, the data includes floating point data, and the floating point data has a second default base category;
[0015] The converting the default base type of the data to obtain compressed data includes:
[0016] The second default base type of the floating point data is base-converted to obtain second compressed data, wherein the second compressed data has a second converted base type.
[0017] Preferably, performing base conversion on the second default base category of the floating point data to obtain the second compressed data comprises:
[0018] The floating point data is converted into intermediate integer data and floating point scaling factors, and the conversion formula is:
[0019] a=±m×10^e
[0020] Wherein, a represents floating point data, m represents intermediate integer data, e represents floating point scaling factor, m is a positive integer, and e is an integer;
[0021] The second default base category of the intermediate integer data and the floating-point scaling factor is converted to obtain compressed intermediate integer data and compressed floating-point scaling factor, and the compressed intermediate integer data and compressed floating-point scaling factor constitute the second compressed data.
[0022] Preferably, the compressed floating-point scaling factors are stored in a compressed OBJ file in a separate row, wherein the row storing the compressed floating-point scaling factors is before the row storing the compressed intermediate integer data.
[0023] Preferably, the floating point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
[0024] Preferably, the compression method further comprises:
[0025] The header of the compressed data is deleted, and only one header is added to a plurality of compressed data of the same type.
[0026] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0027] In order to solve the above technical problems, an embodiment of the present invention further provides a method for parsing data of an OBJ file, the method comprising:
[0028] Identify the compressed OBJ file and obtain the compressed data in the OBJ file;
[0029] The converted base type of the compressed data is converted to obtain parsed data, wherein the parsed data has a default base type, and the number of bytes of the default base type is greater than the number of bytes of the converted base type.
[0030] Preferably, the compressed data comprises compressed integer data, and the compressed integer data has a first converted base type;
[0031] The converting the converted base type of the compressed data to obtain parsed data includes:
[0032] The first converted radix type of the compressed integer data is subjected to radix conversion to obtain first parsed data, wherein the first parsed data has a first default radix type.
[0033] Preferably, the compressed integer data includes surface composition index data and / or smoothing group data.
[0034] Preferably, the compressed data comprises compressed floating point data, and the compressed floating point data has a second converted base type;
[0035] The converting the converted base type of the compressed data to obtain parsed data includes:
[0036] The second converted radix type of the compressed floating point data is subjected to radix conversion to obtain second parsed data, wherein the second parsed data has a second default radix type.
[0037] Preferably, the compressed floating point data includes compressed intermediate integer data and compressed floating point scaling factors;
[0038] Performing base conversion on the second converted base type of the compressed floating point data to obtain second parsed data includes:
[0039] Performing base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data;
[0040] The second converted base type of the compressed floating point scaling factor is base-converted to obtain a parsed floating point scaling factor:
[0041] The parsed intermediate integer data and the parsed floating-point scaling factor are combined into parsed floating-point data, and the combination formula is:
[0042] a1=±m1×10^e1
[0043] Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
[0044] Preferably, the compressed floating-point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
[0045] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0046] In order to solve the above technical problems, an embodiment of the present invention further provides a data compression system for an OBJ file, the compression system comprising:
[0047] A first data acquisition module, used for identifying the OBJ file and acquiring the data in the OBJ file;
[0048] The first base conversion module is used to perform base conversion on the default base category of the data to obtain compressed data, wherein the compressed data has a converted base category, and the number of bytes of the converted base category is less than the number of bytes of the default base category.
[0049] Preferably, the data includes integer data, and the integer data has a first default base category;
[0050] The first base conversion module includes a first compression submodule, which is used to perform base conversion on the first default base category of the integer data to obtain first compressed data, and the first compressed data has a first converted base category.
[0051] Preferably, the integer data includes surface composition index data and / or smoothing group data.
[0052] Preferably, the data includes floating point data, and the floating point data has a second default base category;
[0053] The first base conversion module includes a second compression submodule, and the second compression submodule is used to perform base conversion on the second default base category of the floating-point data to obtain second compressed data, and the second compressed data has a second converted base category.
[0054] Preferably, the second compression submodule includes:
[0055] The decomposition unit is used to convert the floating point data into intermediate integer data and floating point scaling factors, and the conversion formula is:
[0056] a=±m×10^e
[0057] Wherein, a represents floating point data, m represents intermediate integer data, e represents floating point scaling factor, m is a positive integer, and e is an integer;
[0058] A conversion unit is used to perform base conversion on the second default base category of the intermediate integer data and the floating-point scaling factor to obtain compressed intermediate integer data and compressed floating-point scaling factor, wherein the compressed intermediate integer data and the compressed floating-point scaling factor constitute second compressed data.
[0059] Preferably, the compression system further comprises a storage module, wherein the storage module is used to store the compressed floating-point scaling factors in a compressed OBJ file in a separate row, wherein the row storing the compressed floating-point scaling factors is before the row storing the compressed intermediate integer data.
[0060] Preferably, the floating point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
[0061] Preferably, the compression system further comprises:
[0062] The storage structure adjustment module is used to delete the header of the compressed data and add only one header to multiple compressed data of the same type.
[0063] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0064] In order to solve the above technical problems, an embodiment of the present invention further provides a data parsing system for an OBJ file, the parsing system comprising:
[0065] A second data acquisition module, used for identifying the compressed OBJ file and acquiring compressed data in the OBJ file;
[0066] The second binary conversion module performs base conversion on the converted base category of the compressed data to obtain parsed data, wherein the parsed data has a default base category, and the number of bytes of the default base category is greater than the number of bytes of the converted base category.
[0067] Preferably, the compressed data comprises compressed integer data, and the compressed integer data has a first converted base type;
[0068] The first binary conversion module includes a first parsing submodule, which is used to perform base conversion on the first converted base category of the compressed integer data to obtain first parsed data, and the first parsed data has a first default base category.
[0069] Preferably, the compressed integer data includes surface composition index data and / or smoothing group data.
[0070] Preferably, the compressed data comprises compressed floating point data, and the compressed floating point data has a second converted base type;
[0071] The second binary conversion module includes a second parsing submodule, which is used to perform base conversion on the second converted base category of the compressed floating-point data to obtain second parsed data, and the second parsed data has a second default base category.
[0072] Preferably, the compressed floating point data includes compressed intermediate integer data and compressed floating point scaling factors;
[0073] The second parsing submodule includes:
[0074] a decompression unit, configured to perform base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data; and perform base conversion on the second converted base type of the compressed floating-point scaling factor to obtain a parsed floating-point scaling factor:
[0075] A combining unit is used to combine the parsed intermediate integer data and the parsed floating-point scaling factor into parsed floating-point data, and the combining formula is:
[0076] a1=±m1×10^e1
[0077] Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
[0078] Preferably, the compressed floating-point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
[0079] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0080] To solve the above technical problems, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for compressing the data of the OBJ file when executing the computer program, or implements the steps of the method for parsing the data of the OBJ file when executing the computer program.
[0081] To solve the above technical problems, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the OBJ file data compression method are implemented, or when the computer program is executed by a processor, the steps of the OBJ file data parsing method are implemented.
[0082] The positive and progressive effects of the present invention are:
[0083] The technical solution of the embodiment of the present invention can obtain compressed data by converting the default base category of the data of the OBJ file into a base category with a smaller number of bytes without the intervention of a third-party compression tool. In this way, not only can the data accuracy be guaranteed not to be affected, but also the size of the OBJ file can be effectively reduced. The size of the compressed OBJ file is 50%-60% of the original OBJ file, which improves the data transmission speed and model parsing speed of the OBJ file in the 3D model. In addition, there is no need to pre-install third-party tools in the 3D model software, which effectively reduces the size of the 3D model resource package and expands the scope of application of the 3D model software.
[0084] Furthermore, the technical solution of the embodiment of the present invention identifies multiple compressed data of the same type in the OBJ file with a header, thereby optimizing the storage structure of the data in the OBJ file and further reducing the size of the OBJ file. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] Figure 1 This is a flow chart of a method for compressing data of an OBJ file according to Embodiment 1 of the present invention;
[0086] Figure 2 This is a flow chart of a method for compressing data of an OBJ file according to Embodiment 2 of the present invention;
[0087] Figure 3 is a schematic diagram of a specific application scenario of Embodiment 2 of the present invention;
[0088] Figure 4is a structural block diagram of a data compression system for an OBJ file according to Embodiment 3 of the present invention;
[0089] Figure 5 is a structural block diagram of a data compression system for an OBJ file according to a fourth embodiment of the present invention;
[0090] Figure 6 is a flow chart of a method for parsing data of an OBJ file according to Embodiment 5 of the present invention;
[0091] Figure 7 It is a structural block diagram of the data parsing system of the OBJ file of the sixth embodiment of the present invention;
[0092] Figure 8 It is a structural diagram of an electronic device that implements a data compression method and / or parsing method for an OBJ file according to a seventh embodiment of the present invention. DETAILED DESCRIPTION
[0093] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.
[0094] Example 1
[0095] A method for compressing data in an OBJ file, such as Figure 1 As shown, the compression method may include the following steps:
[0096] Step S11: identifying the OBJ file, and acquiring the data in the OBJ file;
[0097] Step S12: performing base conversion on the default base category of the data to obtain compressed data, wherein the compressed data has a base category after conversion, and the number of bytes of the base category after conversion is less than the number of bytes of the default base category.
[0098] In this embodiment, the OBJ file may be composed of multiple lines of text, and the text is in a readable text format encoded in Unicode.
[0099] The default base type can be preset by a program developer. Preferably, the default base type is decimal.
[0100] As a non-limiting implementation of Example 1, the data may include integer data, and the integer data has a first default base category;
[0101] The step of converting the default base category of the data to obtain compressed data may include: converting the first default base category of the integer data to obtain first compressed data, wherein the first compressed data has a first converted base category.
[0102] Specifically, the integer data may include surface composition index data and / or smoothing group data.
[0103] As another non-limiting implementation of Example 1, the data may further include floating point data, and the floating point data has a second default base category;
[0104] The converting the default base type of the data to obtain compressed data may include:
[0105] The second default base type of the floating point data is base-converted to obtain second compressed data, wherein the second compressed data has a second converted base type.
[0106] Specifically, the floating-point data may include one or more of vertex coordinate data, normal data, and texture coordinate data.
[0107] Furthermore, the first default base type and the second default base type may be the same or different; the first converted base type and the second converted base type may be the same or different. For example, the first default base type of the integer data may be decimal, and the second default base type of the floating point data may be decimal; after base conversion, the first converted base type may be thirty-two bases, and the second converted base type may be sixty-four bases.
[0108] It should be noted that technical personnel in this field can select the first conversion base category and the second conversion base category according to the specific requirements for the OBJ file volume in different application scenarios, as long as the number of bytes corresponding to the conversion base category is smaller than the number of bytes corresponding to the default base category. This embodiment does not impose any restrictions on this.
[0109] This embodiment can convert the default base type of the OBJ file data into a base type with fewer bytes to obtain compressed data without the intervention of a third-party compression tool, thereby effectively reducing the size of the OBJ file and improving the data transmission and parsing speed of the OBJ file in the 3D model. In addition, there is no need to pre-install a third-party compression tool in the 3D model software, which effectively reduces the size of the 3D model resource package, making the 3D model software suitable for occasions with strict requirements on the size of the resource package.
[0110] Example 2
[0111] This embodiment is a further improvement on the basis of embodiment 1. Figure 2 After step S12, the following steps may also be included:
[0112] Step S13: deleting the header of the compressed data, and adding only one header to a plurality of compressed data of the same type.
[0113] In this embodiment, the data type of the OBJ file can be distinguished according to the meaning represented by the data in the OBJ file. For example, data representing model vertices can be considered as vertex coordinate data type, data representing normals can be considered as normal data type, and so on.
[0114] Furthermore, the plurality of compressed data may be a plurality of data vectors. The header may be a mark used to distinguish different types of data.
[0115] Specifically, the prefix may be a letter or symbol written before all bytes of the data vector, such as v, s, t, @, vt, etc. The same type of data may be identified by the same letter or symbol, whereas different types of data may be identified by different letters or symbols.
[0116] It is understandable that those skilled in the art can adaptively select appropriate letters or symbols as prefixes according to programming habits and specific application scenarios, as long as the prefixes of different categories of data are unambiguous and can be clearly distinguished, and this embodiment does not limit this.
[0117] Please refer to Figure 3 . Figure 3 It is a schematic diagram of a specific application scenario of Example 2.
[0118] In this specific application scenario, the OBJ file includes vertex coordinate data, normal data, texture coordinate data, surface composition index data, and smooth group data. Among them, the vertex coordinate data is a floating-point data vector, identified by the letter v; the normal data is a floating-point data vector, identified by the letter vn; the texture coordinate data is a floating-point data vector, identified by the letter vt; the surface composition index data is an integer data vector, identified by the letter f; and the smooth group data is an integer data vector, identified by the letter s.
[0119] In this application scenario, the data in the OBJ file to be compressed includes integer data and floating-point data, and the default base types of the integer data and the floating-point data are both decimal.
[0120] During the specific implementation process, when converting integer data, it is only necessary to directly convert the decimal integer data into a sixty-four-digit character string; when converting floating-point data, it is necessary to convert the decimal floating-point data into intermediate integer data and a floating-point scaling factor that retain the positive and negative signs, and then convert the intermediate integer data and the floating-point scaling factor into a sixty-four-digit character string.
[0121] More specifically, the corresponding relationship between the floating-point data, the intermediate integer data, and the floating-point scaling factor can be expressed as:
[0122] a=±m×10^e
[0123] Among them, a represents floating-point data, m represents intermediate integer data, e represents a floating-point scaling factor, m is a positive integer, and e is an integer.
[0124] Next, the intermediate integer data m and the floating-point scaling factor e are converted into a sixty-four-decimal character string.
[0125] In this specific application scenario, the vertex coordinate data, normal data and texture coordinate data can be decimal floating point data of uniform precision. Therefore, for the vertex coordinate data, normal data and texture coordinate data, the floating point scaling factors e of the three types of data are the same, while the intermediate integer data m are different from each other.
[0126] For example, converting the decimal data vector (-1.09660 0.00000 1.05044) to base 64 gives (-qNs 0pFk), where the intermediate integer data corresponding to -1.09660 can be expressed as -109660, and the base 64 corresponding to -109660 can be expressed as -qNs; the intermediate integer data corresponding to 1.05044 can be expressed as 105044, and the base 64 corresponding to 105044 can be expressed as pFk. The floating point scaling factors e corresponding to the data -1.09660 and 1.05044 are the same, both -5, and after converting -5 to base 64, -5 is still obtained.
[0127] By using the aforementioned compression method, other decimal data vectors (including integer data and floating-point data) in the OBJ file can be converted into sexagesimal data and stored accordingly, which will not be described in detail here.
[0128] Next, the compressed floating-point scaling factor may be stored in a separate row in the compressed OBJ file, wherein the row storing the compressed floating-point scaling factor is before the row storing the compressed intermediate integer data, so as to facilitate calling when parsing the compressed OBJ file.
[0129] As a variation, the floating point scaling factor e may also be stored separately in another independent file. In this case, the original OBJ file can obtain two files after the data base conversion, one is the converted OBJ file, and the other is a file that stores the floating point scaling factor e separately. Correspondingly, during the parsing process, the converted OBJ file and the file storing the floating point scaling factor e need to be simultaneously imported into the parsing software to obtain the data of the OBJ file before compression.
[0130] Furthermore, in order to optimize the data storage structure in the OBJ file, the header of the compressed data may be deleted, and only one header may be added to multiple compressed data of the same type.
[0131] Taking vertex coordinate data as an example, Figure 3 In the example, the vertex coordinate data includes data vectors from the 5th to the 10th rows, each of which contains the same header v, and the data vectors from the 5th to the 10th rows include a total of 6 headers v. When optimizing the data storage structure, a unified header @v representing the entire vertex coordinate data is written in the 4th row, and the 6 identification headers v of the data vectors from the 5th to the 10th rows are deleted, thereby effectively reducing the number of bytes of data in the OBJ file.
[0132] The same optimization method can be used to optimize the storage structure of normal data, mapping coordinate data, surface composition index data, and smooth group data in turn to further reduce the number of bytes in the OBJ file.
[0133] Example 3
[0134] A compression system for OBJ file data, such as Figure 4 As shown, the compression system 1 may include:
[0135] A first data acquisition module 2, used for identifying the OBJ file and acquiring the data in the OBJ file;
[0136] The first base conversion module 3 is used to perform base conversion on the default base category of the data to obtain compressed data, wherein the compressed data has a converted base category, and the number of bytes of the converted base category is less than the number of bytes of the default base category.
[0137] Furthermore, the data may include integer data, and the integer data has a first default base category; the first base conversion module 3 may include a first compression submodule 31, and the first compression submodule 31 is used to perform base conversion on the first default base category of the integer data to obtain first compressed data, and the first compressed data has a first converted base category.
[0138] Specifically, the integer data may include surface composition index data and / or smoothing group data.
[0139] Furthermore, the data may also include floating-point data, which has a second default base category; the first base conversion module 3 may include a second compression submodule 32, which is used to perform base conversion on the second default base category of the floating-point data to obtain second compressed data, and the second compressed data has a second converted base category.
[0140] Further, the second compression submodule 32 may include:
[0141] The decomposition unit 321 is used to convert the floating point data into intermediate integer data and floating point scaling factors, and the conversion formula is:
[0142] a=±m×10^e
[0143] Wherein, a represents floating point data, m represents intermediate integer data, e represents floating point scaling factor, m is a positive integer, and e is an integer;
[0144] The conversion unit 322 is used to perform base conversion on the second default base category of the intermediate integer data and the floating-point scaling factor to obtain compressed intermediate integer data and compressed floating-point scaling factor, and the compressed intermediate integer data and compressed floating-point scaling factor constitute the second compressed data.
[0145] Furthermore, the compression system 1 may also include a storage module 4, which is used to store the compressed floating-point scaling factor in a separate row in the compressed OBJ file, wherein the row storing the compressed floating-point scaling factor is before the row storing the compressed intermediate integer data.
[0146] Specifically, the floating-point data may include one or more of vertex coordinate data, normal data, and texture coordinate data.
[0147] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0148] For more details about the working principle and working mode of the compression system in Example 3, please refer to the relevant description of the compression method in Example 1, which will not be repeated here.
[0149] Example 4
[0150] Embodiment 4 discloses another OBJ file data compression system, such as Figure 5As shown, the compression system 6 is further improved on the basis of the embodiment 3. The structures and working principles of the first data acquisition module 2, the first base conversion module 3 and the storage module 4 are the same as those of the corresponding modules in the embodiment 3.
[0151] The compression system 6 may further include a storage structure adjustment module 5, which is used to delete the header of the compressed data and add only one header to multiple compressed data of the same type.
[0152] For more details about the working principle and working mode of the compression system in Example 4, please refer to the relevant description of the compression method in Example 2, which will not be repeated here.
[0153] Example 5
[0154] A method for parsing data of an OBJ file, such as Figure 6 As shown, the parsing method may include the following steps:
[0155] Step S21: identifying the compressed OBJ file and obtaining the compressed data in the OBJ file;
[0156] Step S22: performing base conversion on the converted base category of the compressed data to obtain parsed data, wherein the parsed data has a default base category, and the number of bytes of the default base category is greater than the number of bytes of the converted base category.
[0157] Further, the compressed data may include compressed integer data, the compressed integer data having a first converted base category;
[0158] The performing base conversion on the converted base category of the compressed data to obtain parsed data may include: performing base conversion on the first converted base category of the compressed integer data to obtain first parsed data, wherein the first parsed data has a first default base category.
[0159] Specifically, the compressed integer data may include surface composition index data and / or smooth group data.
[0160] Further, the compressed data may also include compressed floating point data, the compressed floating point data having a second converted base type;
[0161] The performing base conversion on the converted base category of the compressed data to obtain parsed data may include: performing base conversion on the second converted base category of the compressed floating-point data to obtain second parsed data, wherein the second parsed data has a second default base category.
[0162] In a specific implementation, the compressed floating-point data may include compressed intermediate integer data and a compressed floating-point scaling factor;
[0163] The step of performing base conversion on the second converted base type of the compressed floating-point data to obtain second parsed data may include: performing base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data; performing base conversion on the second converted base type of the compressed floating-point scaling factor to obtain a parsed floating-point scaling factor.
[0164] The parsed intermediate integer data and the parsed floating-point scaling factor are combined into parsed floating-point data, and the combination formula is:
[0165] a1=±m1×10^e1
[0166] Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
[0167] Specifically, the compressed floating-point data may include one or more of vertex coordinate data, normal data, and texture coordinate data.
[0168] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0169] In the process of parsing data, it is determined whether the compressed data should be restored to floating point data or integer data by identifying the headers of different types of compressed data.
[0170] Please also refer to Figure 3 , Figure 6 In a non-limiting application scenario, for example: Figure 3 The compressed data in the illustrated embodiment is parsed. When a row of data is identified as a prefix @v, it can be determined that the rows of data after @v are all data of the same type identified by @v as a prefix, until another prefix @vn is identified. At this time, the next type of data is counted until the next prefix @vt is identified, and so on. Multiple types of data can be identified and counted. Among them, data types with @v, @vn, and @vt as prefixes can be identified as floating-point data, and data types with @s and @f as prefixes can be identified as integer data.
[0171] In specific implementation, for compressed data with @v, @vn, @vt as the prefix, in the process of parsing floating-point data, the floating-point scaling factor should be applied to its parsing process. For example, for the compressed hexadecimal data pFk, it is converted into decimal data 105044, and the floating-point scaling factor is applied to the parsing process, that is, 105044 is converted into decimal data. -5 By multiplying, we can get the parsed floating point data 1.05044. For compressed data with @s and @f as prefixes, they can be identified as integer data during the parsing process, so the floating point scaling factor will not be applied to its parsing process.
[0172] It is understandable that those skilled in the art can use the parsing method in this embodiment to parse the compressed data obtained by the compression method in embodiment 1 or embodiment 2. It can also be said that the data parsing process can restore the default base category of the original data. Generally, for the parsed data, multiple data of the same type are still identified by only one header.
[0173] Example 6
[0174] A data parsing system for OBJ files, such as Figure 7 As shown, the analysis system 7 may include:
[0175] The second data acquisition module 8 is used to identify the compressed OBJ file and acquire the compressed data in the OBJ file;
[0176] The second binary conversion module 9 performs base conversion on the converted base category of the compressed data to obtain parsed data, wherein the parsed data has a default base category, and the number of bytes of the default base category is greater than the number of bytes of the converted base category.
[0177] Further, the compressed data may include compressed integer data, the compressed integer data having a first converted base category;
[0178] The first binary conversion module 9 may include a first parsing submodule 91, which is used to perform base conversion on the first converted base category of the compressed integer data to obtain first parsed data, wherein the first parsed data has a first default base category.
[0179] Specifically, the compressed integer data may include surface composition index data and / or smooth group data.
[0180] Further, the compressed data may also include compressed floating point data, the compressed floating point data having a second converted base type;
[0181] The second binary conversion module 9 may include a second parsing submodule 92, which is used to perform base conversion on the second converted base category of the compressed floating-point data to obtain second parsed data, wherein the second parsed data has a second default base category.
[0182] Further, the compressed floating point data may include compressed intermediate integer data and compressed floating point scaling factors;
[0183] The second parsing submodule 92 may include:
[0184] The decompression unit 921 is configured to perform base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data; and perform base conversion on the second converted base type of the compressed floating-point scaling factor to obtain a parsed floating-point scaling factor:
[0185] The combining unit 922 is used to combine the parsed intermediate integer data and the parsed floating-point scaling factor into parsed floating-point data, and the combining formula is:
[0186] a1=±m1×10^e1
[0187] Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
[0188] Specifically, the compressed floating-point data may include one or more of vertex coordinate data, normal data, and texture coordinate data.
[0189] Preferably, the default base type is decimal, and the converted base type is sexagesimal.
[0190] For more details about the working principle and working mode of the analysis system in Example 6, please refer to the relevant description of the analysis method in Example 5, which will not be repeated here.
[0191] Example 7
[0192] Figure 8 A schematic diagram of the structure of an electronic device provided in Embodiment 7 of the present invention. The electronic device may include a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the data compression method of the OBJ file in any one of Embodiments 1 to 2 or the data parsing method of the OBJ file in Embodiment 5 when executing the computer program.
[0193] Understandably, Figure 8The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0194] like Figure 8 As shown, the electronic device 10 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 10 may include, but are not limited to, the at least one processor 11, the at least one memory 12, and a bus 13 connecting different system components (including the memory 12 and the processor 11).
[0195] The bus 13 may include a data bus, an address bus and a control bus.
[0196] The memory 12 may include a volatile memory, such as a random access memory (RAM) 121 and / or a cache memory 122 , and may further include a read-only memory (ROM) 123 .
[0197] The memory 12 may also include a program tool 125 (or utility) having a set (at least one) of program modules 124, such program modules 124 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.
[0198] The processor 11 executes various functional applications and data processing by running the computer program stored in the memory 12, such as the OBJ file data compression method provided in Example 1 or Example 2 of the present invention or the OBJ file data parsing method in Example 5.
[0199] The electronic device 10 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, etc.). Such communication may be performed via an input / output (I / O) interface 15. Furthermore, the model generating electronic device 10 may also communicate with one or more networks (e.g., a local area network LAN, a wide area network WAN, and / or a public network) via a network adapter 16.
[0200] like Figure 8 As shown, the network adapter 16 can communicate with other modules of the model-generated electronic device 10 through the bus 13. Those skilled in the art should understand that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated electronic device 10, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
[0201] It should be noted that, although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above may be embodied in one unit / module. Conversely, the features and functions of one unit / module described above may be further divided into multiple units / modules for embodiment.
[0202] Example 8
[0203] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the OBJ file data compression method in any one of Embodiments 1 to 2 or the OBJ file data parsing method in Embodiment 5 are implemented.
[0204] Among them, more specific forms in which computer-readable storage media can be used include but are not limited to: portable disks, hard disks, random access memories, read-only memories, erasable programmable read-only memories, optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0205] In a possible implementation manner, the present invention can also be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of the OBJ file data compression method in any one of Examples 1 to 2 or the OBJ file data parsing method in Example 5.
[0206] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.
[0207] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that this is only for illustration and the protection scope of the present invention is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but these changes and modifications all fall within the protection scope of the present invention.
Claims
1. A method for compressing data of an OBJ file, characterized in that: The compression method comprises: Identify the OBJ file, and obtain the data in the OBJ file; Performing base conversion on the default base category of the data to obtain compressed data, wherein the compressed data has a converted base category, and the number of bytes of the converted base category is less than the number of bytes of the default base category; The data includes integer data and floating point data, the integer data has a first default base category, and the floating point data has a second default base category; The converting the default base type of the data to obtain compressed data includes: Performing base conversion on the first default base category of the integer data to obtain first compressed data, wherein the first compressed data has a first converted base category; Performing base conversion on the second default base category of the floating-point data to obtain second compressed data, wherein the second compressed data has a second converted base category; The first default base category is the same as or different from the second default base category, and the first converted base category is the same as or different from the second converted base category.
2. The method for compressing data of an OBJ file according to claim 1, characterized in that: The integer data includes surface composition index data and / or smoothing group data.
3. The method for compressing data of an OBJ file according to claim 1, characterized in that: Performing base conversion on the second default base category of the floating-point data to obtain second compressed data includes: The floating point data is converted into intermediate integer data and floating point scaling factors, and the conversion formula is: a=±m×10^e Wherein, a represents floating point data, m represents intermediate integer data, e represents floating point scaling factor, m is a positive integer, and e is an integer; The second default base category of the intermediate integer data and the floating-point scaling factor is converted to obtain compressed intermediate integer data and compressed floating-point scaling factor, and the compressed intermediate integer data and compressed floating-point scaling factor constitute the second compressed data.
4. The method for compressing data of an OBJ file according to claim 3, characterized in that: The compression method further comprises: The compressed floating-point scaling factors are stored in a compressed OBJ file in a separate row, wherein the row storing the compressed floating-point scaling factors is before the row storing the compressed intermediate integer data.
5. The method for compressing data of an OBJ file according to claim 1, characterized in that: The floating point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
6. The method for compressing data of an OBJ file according to claim 1, characterized in that: The compression method further comprises: The header of the compressed data is deleted, and only one header is added to a plurality of compressed data of the same type.
7. The method for compressing data of an OBJ file according to claim 1, characterized in that: The default base type is decimal, and the converted base type is sexagesimal.
8. A method for parsing data of an OBJ file, characterized in that: The analysis method comprises: Identify the compressed OBJ file and obtain the compressed data in the OBJ file; Performing base conversion on the converted base category of the compressed data to obtain parsed data, the parsed data having a default base category, the number of bytes of the default base category being greater than the number of bytes of the converted base category; The compressed data includes compressed integer data and compressed floating point data, the compressed integer data has a first converted base type, and the compressed floating point data has a second converted base type; The converting the converted base type of the compressed data to obtain parsed data includes: Performing base conversion on the first converted base type of the compressed integer data to obtain first parsed data, wherein the first parsed data has a first default base type; Performing base conversion on the second converted base type of the compressed floating point data to obtain second parsed data, wherein the second parsed data has a second default base type; The first converted base category is the same as or different from the second converted base category, and the first default base category is the same as or different from the second default base category.
9. The method for parsing data of an OBJ file according to claim 8, characterized in that: The compressed integer data includes surface composition index data and / or smoothing group data.
10. The method for parsing data of an OBJ file according to claim 8, characterized in that: The compressed floating point data includes compressed intermediate integer data and compressed floating point scaling factors; Performing base conversion on the second converted base type of the compressed floating point data to obtain second parsed data includes: Performing base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data; The second converted base type of the compressed floating point scaling factor is base-converted to obtain a parsed floating point scaling factor: The parsed intermediate integer data and the parsed floating-point scaling factor are combined into parsed floating-point data, and the combination formula is: a1=±m1×10^e1 Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
11. The method for parsing data of an OBJ file according to claim 10, characterized in that: The compressed floating-point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
12. The method for parsing data of an OBJ file according to claim 8, characterized in that: The default base type is decimal, and the converted base type is sexagesimal.
13. A data compression system for an OBJ file, characterized in that: The compression system comprises: A first data acquisition module, used for identifying the OBJ file and acquiring the data in the OBJ file; A first base conversion module is used to perform base conversion on the default base category of the data to obtain compressed data, wherein the compressed data has a base category after conversion, and the number of bytes of the base category after conversion is less than the number of bytes of the default base category; The data includes integer data and floating point data, the integer data has a first default base category, and the floating point data has a second default base category; The first base conversion module includes a first compression submodule, the first compression submodule is used to perform base conversion on the first default base category of the integer data to obtain first compressed data, the first compressed data having a first converted base category; The first base conversion module includes a second compression submodule, the second compression submodule is used to perform base conversion on the second default base category of the floating point data to obtain second compressed data, the second compressed data having a second converted base category; The first default base category is the same as or different from the second default base category, and the first converted base category is the same as or different from the second converted base category.
14. The OBJ file data compression system according to claim 13, characterized in that: The integer data includes surface composition index data and / or smoothing group data.
15. The OBJ file data compression system according to claim 13, characterized in that: The second compression submodule comprises: The decomposition unit is used to convert the floating point data into intermediate integer data and floating point scaling factors, and the conversion formula is: a=±m×10^e Wherein, a represents floating point data, m represents intermediate integer data, e represents floating point scaling factor, m is a positive integer, and e is an integer; A conversion unit is used to perform base conversion on the second default base category of the intermediate integer data and the floating-point scaling factor to obtain compressed intermediate integer data and compressed floating-point scaling factor, wherein the compressed intermediate integer data and the compressed floating-point scaling factor constitute second compressed data.
16. The OBJ file data compression system according to claim 15, characterized in that: The compression system further includes a storage module, which is used to store the compressed floating-point scaling factors in a compressed OBJ file in a separate row, wherein the row storing the compressed floating-point scaling factors is before the row storing the compressed intermediate integer data.
17. The OBJ file data compression system according to claim 13, characterized in that: The floating point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
18. The OBJ file data compression system according to claim 13, characterized in that: The compression system also includes: The storage structure adjustment module is used to delete the header of the compressed data and add only one header to multiple compressed data of the same type.
19. The OBJ file data compression system according to claim 13, characterized in that: The default base type is decimal, and the converted base type is sexagesimal.
20. A data parsing system for an OBJ file, characterized in that: The analysis system comprises: A second data acquisition module, used for identifying the compressed OBJ file and acquiring compressed data in the OBJ file; a binary conversion module, performing base conversion on the converted base category of the compressed data to obtain parsed data, wherein the parsed data has a default base category, and the number of bytes of the default base category is greater than the number of bytes of the converted base category; The compressed data includes compressed integer data and compressed floating point data, the compressed integer data has a first converted base type, and the compressed floating point data has a second converted base type; The first binary conversion module includes a first parsing submodule, the first parsing submodule is used to perform base conversion on the first converted base category of the compressed integer data to obtain first parsed data, the first parsed data having a first default base category; The second binary conversion module includes a second parsing submodule, the second parsing submodule is used to perform base conversion on the second converted base category of the compressed floating-point data to obtain second parsed data, the second parsed data having a second default base category; The first converted base category is the same as or different from the second converted base category, and the first default base category is the same as or different from the second default base category.
21. The OBJ file data parsing system according to claim 20, characterized in that: The compressed integer data includes surface composition index data and / or smoothing group data.
22. The OBJ file data parsing system according to claim 20, characterized in that: The compressed floating point data includes compressed intermediate integer data and compressed floating point scaling factors; The second parsing submodule includes: a decompression unit, configured to perform base conversion on the second converted base type of the compressed intermediate integer data to obtain parsed intermediate integer data; and perform base conversion on the second converted base type of the compressed floating-point scaling factor to obtain a parsed floating-point scaling factor: A combining unit is used to combine the parsed intermediate integer data and the parsed floating-point scaling factor into parsed floating-point data, and the combining formula is: a1=±m1×10^e1 Among them, a1 represents the parsed floating-point data, m1 represents the parsed intermediate integer data, e1 represents the parsed floating-point scaling factor, m1 is a positive integer, and e1 is an integer.
23. The OBJ file data parsing system according to claim 20, characterized in that: The compressed floating-point data includes one or more of vertex coordinate data, normal data, and texture coordinate data.
24. The OBJ file data parsing system according to claim 20, characterized in that: The default base type is decimal, and the converted base type is sexagesimal.
25. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor implements the steps of the OBJ file data compression method described in any one of claims 1-7 when executing the computer program, or implements the steps of the OBJ file data parsing method described in any one of claims 8-12 when executing the computer program.
26. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for compressing data of an OBJ file described in any one of claims 1 to 7 are implemented; or, when the computer program is executed by a processor, the steps of the method for parsing data of an OBJ file described in any one of claims 8 to 12 are implemented.
