Method for realizing decryption and decompression of 3D model in system cache
By using the ZipArchive class in the System.IO.Compression library to read and process ZIP compressed packages in the system cache, the problems of insufficient decompression performance and data security risks in traditional methods are solved, and efficient and secure 3D model decryption and decompression are achieved.
Patent Information
- Application Number
- CN202510397060.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-06-20
AI Technical Summary
The traditional ZIP packet processing method lacks performance and poses data security risks when decompressing 3D models, especially in the system cache, which cannot be effectively decrypted and decompressed.
Through the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compressed package is read, read it from disk into the system cache, retrieve the required FBX model files, and read its data stream into the MemoryStream object, and convert it into a format supported by Unity for packaging and loading.
Improve data processing efficiency and security, and realize efficient decryption and decompression of 3D models in system cache.
Smart Images

Figure CN120179182A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of decryption and decompression, and particularly to a method for realizing the decryption and decompression of 3D models in the system cache. Background Art
[0002] In modern game development and 3D modeling applications, the Unity engine is a widely used development tool that supports various 3D model formats (such as FBX) and can load these models into games or virtual environments; to optimize resource management and transmission efficiency, developers often package 3D models into ZIP compression packages, which can reduce the file size and speed up data transmission; however, the traditional ZIP package processing method usually requires decompressing the compression package to the local disk and then reading the model data from the decompressed file; although this method is effective, it has problems such as insufficient decompression performance and data security risks.
[0003] Therefore, the present invention provides a method for realizing the decryption and decompression of 3D models in the system cache. Summary of the Invention
[0004] The present invention provides a method for realizing the decryption and decompression of 3D models in the system cache. By using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compression package is read, and the ZIP compression package is read from the disk into the system cache; the required FBX model file is retrieved from the ZIP compression package, and the data stream of the required FBX model file is obtained through the GetEntry method of the ZipArchive class, and the data stream of the required FBX model file is read into the MemoryStream object in the system cache; the read FBX model file data is converted into a format supported by Unity, and the read FBX model file is packaged and loaded in the system cache according to the supported format; the 3D model resources loaded from the system cache are instantiated in unity and directly added to the application scene; effectively improving the data processing efficiency and data processing security.
[0005] The present invention provides a method for realizing the decryption and decompression of 3D models in the system cache, including: Step 1: By using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compression package is read, and the ZIP compression package is read from the disk into the system cache; Step 2: The required FBX model file is retrieved from the ZIP compression package, and the data stream of the required FBX model file is obtained through the GetEntry method of the ZipArchive class, and the data stream of the required FBX model file is read into the MemoryStream object in the system cache; Step 3: Convert the data of the read FBX model file into a format supported by Unity, package the read FBX model file according to the supported format, and perform a loading process in the system cache; Step 4: Instantiate the 3D model resource loaded from the system cache in unity and directly add the 3D model resource to the application scene.
[0006] According to a method for decrypting and decompressing a 3D model in a system cache provided by the present invention, by using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compressed package is read, and the ZIP compressed package is read from the disk into the system cache, including: Obtain the complete storage path of the ZIP compressed package on the local disk, and create a read-only file stream pointing to the ZIP compressed package according to the complete storage path; Associate with the read-only file stream through the ZipArchive class in the System.IO.Compression library, traverse the ZIP compressed package in a loop, and read the data stream of the ZIP compressed package; Create a cache stream in the system cache, and copy the data stream of the ZIP compressed package to the cache stream.
[0007] According to a method for decrypting and decompressing a 3D model in a system cache provided by the present invention, retrieve the required FBX model file from the ZIP compressed package, obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and read the data stream of the required FBX model file into a MemoryStream object in the system cache, including: Obtain the user's 3D model requirements and determine the required FBX model file; Traverse and search for the required FBX model file in the ZIP compressed package, and obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class; Read the data stream of the required FBX model file into a MemoryStream object in the system cache to obtain the cached FBX model file data.
[0008] According to a method for decrypting and decompressing a 3D model in a system cache provided by the present invention, it further includes: Perform a data integrity check on the cached FBX model file data. When the cached FBX model file data is consistent with the data stream of the required FBX model file, it is determined that the data integrity check is qualified, and the FBX model file data is directly read from the MemoryStream object in the system cache; When the data stream of the cached FBX model file is inconsistent with the data stream of the required FBX model file, traverse and search for the required FBX model file from the ZIP archive again, and obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class.
[0009] According to a method for decrypting and decompressing 3D models in the system cache provided by the present invention, convert the read FBX model file data into a format supported by Unity, and package and load the read FBX model file according to the supported format in the system cache, including: Obtain the format supported by Unity, and convert the read FBX model file data into the format supported by Unity. Among them, the format supported by Unity includes: AssetBundle format; Obtain the data volume of the read FBX model file data, and obtain the current loaded resource volume of the system cache; According to the historical loading process data, obtain the loading resource volume - maximum data volume mapping table, and determine the current maximum data volume of the current loaded resource volume; When the data volume of the read FBX model file data is not higher than the current maximum data volume, package and load the read FBX model file according to the supported format in the system cache; When the data volume of the read FBX model file data is higher than the current maximum data volume, package the read FBX model file according to the current maximum data volume and perform sub-packet loading processing in the system cache.
[0010] According to a method for decrypting and decompressing 3D models in the system cache provided by the present invention, it further includes: Monitor the process of packaging and loading the read FBX model file according to the supported format in the system cache in real time, obtain the current loading process data, and determine the loading process evaluation index according to the historical loading process data. Among them, the loading process evaluation index includes: data loading efficiency evaluation index, data loading integrity evaluation index, and data loading security evaluation index; Determine the current loading process evaluation value according to the current loading process data and the loading process evaluation index; If the current loading process evaluation value is not lower than the preset evaluation value, it is determined that the current loading process is safe and efficient.
[0011] According to a method for decrypting and decompressing 3D models in the system cache provided by the present invention, instantiate the 3D model resources loaded from the system cache in Unity and directly add the 3D model resources to the application scene, including: In Unity, use the Instantiate method to create an instance of the 3D model resource from the AssetBundle loaded from memory, and add the instance of the 3D model resource to the current application scene.
[0012] A method for implementing 3D model decryption and decompression in the system cache according to the present invention further includes: After adding the 3D model resource to the application scene, end the data stream of the required FBX model file and release the resources in the system cache.
[0013] Compared with the prior art, the beneficial effects of the present application are as follows: Read the data stream of the ZIP compressed package through the ZipArchive class in the System.IO.Compression library, read the ZIP compressed package from the disk into the system cache; retrieve the required FBX model file from the ZIP compressed package, obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and read the data stream of the required FBX model file into the MemoryStream object in the system cache; convert the read FBX model file data into a format supported by Unity, package the read FBX model file according to the supported format and perform a loading process in the system cache; instantiate the 3D model resource loaded from the system cache in unity and directly add the 3D model resource to the application scene; effectively improve the data processing efficiency and data processing security.
[0014] Other features and advantages of the present invention will be described in the following specification, and, in part, will be obvious from the specification, or will be understood by implementing the present invention. The objectives and other advantages of the present invention can be achieved and obtained by the structures specifically pointed out in the written specification and the drawings.
[0015] The technical solutions of the present invention will be further described in detail below through the drawings and embodiments. Description of the Drawings
[0016] The drawings are used to provide a further understanding of the present invention, and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation to the present invention. In the drawings: Figure 1 It is a flowchart of a method for implementing 3D model decryption and decompression in the system cache provided by an embodiment of the present invention. Detailed Embodiments
[0017] The following describes the preferred embodiments of the present invention with reference to the drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention and are not used to limit the present invention.
[0018] Example 1: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache, as Figure 1 shown, including: Step 1: Read the data stream of the ZIP compressed package through the ZipArchive class in the System.IO.Compression library, and read the ZIP compressed package from the disk into the system cache; Step 2: Retrieve the required FBX model file from the ZIP compressed package, obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and read the data stream of the required FBX model file into the MemoryStream object in the system cache; Step 3: Convert the read FBX model file data into a format supported by Unity, package the read FBX model file according to the supported format, and perform a loading process in the system cache; Step 4: Instantiate the 3D model resource loaded from the system cache in unity and directly add the 3D model resource to the application scene.
[0019] In this embodiment, the system is used for the database of decrypting and decompressing the compressed package.
[0020] In this embodiment, the ZipArchive class refers to a compressed file package in the ZIP archive format.
[0021] In this embodiment, the data stream of the ZIP compressed package refers to the continuous data sequence of the ZIP compressed package.
[0022] In this embodiment, the required FBX model file refers to a 3D model file format required by the user.
[0023] In this embodiment, the GetEntry method refers to a method for reading internal files of a ZIP compressed package, used to obtain a specified file.
[0024] In this embodiment, the MemoryStream object refers to the data stored in the form of an empty byte array, used to provide read and write operations on the data stream for the system cache.
[0025] In this embodiment, the format supported by Unity refers to a format that can be loaded in unity, for example, the AssetBundle format.
[0026] In this embodiment, the packaging process refers to the process of packaging the read FBX model file into a data packet according to the supported format for subsequent operations.
[0027] In this embodiment, instantiation refers to creating an instance of a 3D model resource from an AssetBundle loaded from memory according to the Instantiate method in Unity.
[0028] The working principle and beneficial effects of the above technical solution are as follows: By using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compressed package is read, and the ZIP compressed package is read from the disk into the system cache; the required FBX model file is retrieved from the ZIP compressed package, and the data stream of the required FBX model file is obtained through the GetEntry method of the ZipArchive class, and the data stream of the required FBX model file is read into the MemoryStream object in the system cache; the read FBX model file data is converted into a format supported by Unity, and the read FBX model file is packaged and loaded in the system cache according to the supported format; the 3D model resource loaded from the system cache is instantiated in Unity and directly added to the application scene; effectively improving the data processing efficiency and data processing security.
[0029] Embodiment 2: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache. By using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compressed package is read, and the ZIP compressed package is read from the disk into the system cache, including: Obtain the complete storage path of the ZIP compressed package on the local disk, and create a read-only file stream pointing to the ZIP compressed package according to the complete storage path; Associate with the read-only file stream through the ZipArchive class in the System.IO.Compression library, traverse the ZIP compressed package in a loop, and read the data stream of the ZIP compressed package; Create a cache stream in the system cache, and copy the data stream of the ZIP compressed package into the cache stream.
[0030] In this embodiment, the System.IO.Compression library is a database used by the system for decrypting and decompressing compressed packages.
[0031] In this embodiment, the ZipArchive class refers to a compressed file package representing the ZIP archive format.
[0032] In this embodiment, the complete storage path refers to the specific storage path of the ZIP compressed package on the local disk, and the ZIP compressed package can be effectively accessed according to the complete storage path.
[0033] In this embodiment, a read-only file stream refers to a data stream that only allows reading, and a data stream refers to a continuous sequence of data.
[0034] In this embodiment, the data stream of a ZIP compressed package refers to the continuous sequence of data of the ZIP compressed package.
[0035] In this embodiment, a cache stream refers to a blank continuous data sequence in the system cache used to cache the data stream of a ZIP compressed package.
[0036] The working principle and beneficial effects of the above technical solution are as follows: By using the ZipArchive class in the System.IO.Compression library, the data stream of the ZIP compressed package is read, and the ZIP compressed package is read from the disk into the system cache, which is beneficial to decrypting and decompressing the compressed package in the system cache, thereby ensuring data security.
[0037] Embodiment 3: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache. Retrieving the required FBX model file from the ZIP compressed package, obtaining the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and reading the data stream of the required FBX model file into the MemoryStream object in the system cache, including: Obtaining the user's 3D model requirements and determining the required FBX model file; Traversing and searching for the required FBX model file in the ZIP compressed package, and obtaining the data stream of the required FBX model file through the GetEntry method of the ZipArchive class; Reading the data stream of the required FBX model file into the MemoryStream object in the system cache to obtain the cached FBX model file data.
[0038] In this embodiment, the user's 3D model requirements refer to the user's requirements for 3D models. For example, the user requires a1 type of 3D model.
[0039] In this embodiment, an FBX model file refers to a 3D model file format.
[0040] In this embodiment, the GetEntry method refers to a method for reading internal files of a ZIP compressed package to obtain a specified file.
[0041] In this embodiment, the MemoryStream object refers to data stored in the form of an empty byte array, which is used to provide read and write operations on the data stream for the system cache.
[0042] In this embodiment, caching the FBX model file data refers to the data obtained by reading the data stream of the required FBX model file into a MemoryStream object in the system cache.
[0043] The working principle and beneficial effects of the above technical solution are as follows: By using the GetEntry method of the ZipArchive class to obtain the data stream of the required FBX model file, and reading the data stream of the required FBX model file into a MemoryStream object in the system cache, it lays the foundation for the subsequent FBX model file.
[0044] Embodiment 4: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache, which further includes: Perform data integrity verification on the cached FBX model file data. When the cached FBX model file data is consistent with the data stream of the required FBX model file, it is determined that the data integrity verification is qualified, and the FBX model file data is directly read from the MemoryStream object in the system cache; When the cached FBX model file data is inconsistent with the data stream of the required FBX model file, traverse and search for the required FBX model file again from the ZIP compressed package, and obtain the data stream of the required FBX model file by using the GetEntry method of the ZipArchive class.
[0045] In this embodiment, the data integrity verification refers to performing data comparison verification on the cached FBX model file data and the data stream of the required FBX model file.
[0046] The working principle and beneficial effects of the above technical solution are as follows: By performing data integrity verification on the cached FBX model file data, it is beneficial to ensure data security.
[0047] Embodiment 5: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache. Convert the read FBX model file data into a supported format by Unity, and perform packaging processing and loading processing on the read FBX model file according to the supported format, including: Obtain the supported format of Unity, and convert the read FBX model file data into the supported format of Unity, where the supported format of Unity includes: AssetBundle format; Obtain the data volume of the read FBX model file data, and obtain the current loaded resource volume of the system cache; Obtain the mapping table of loaded resource volume - maximum data volume according to the historical loading processing data, and determine the current maximum data volume of the current loaded resource volume; When the data volume of the FBX model file data read is not higher than the current maximum data volume, the read FBX model file is packaged according to the supported format and loaded in the system cache; When the data volume of the FBX model file data read is higher than the current maximum data volume, the read FBX model file is packaged according to the current maximum data volume according to the supported format and sub-packaged and loaded in the system cache.
[0048] In this embodiment, the supported format of unity refers to the format that can be loaded in unity. For example, the AssetBundle format.
[0049] In this embodiment, the data volume of the read FBX model file data is obtained to determine the data size.
[0050] In this embodiment, the current loaded resource volume refers to the resource volume used by the system cache in the current period to load and process the read FBX model file.
[0051] In this embodiment, the historical loading and processing data refers to the loading and processing data in the historical period.
[0052] In this embodiment, the loading resource volume - maximum data volume mapping table refers to the mapping table determined according to the historical loading and processing data, which is used to represent the relationship between the loading resource volume and the maximum data volume when ensuring the system cache performance.
[0053] In this embodiment, the current maximum data volume refers to the single - time maximum processable data volume in the current period under the premise of ensuring the system cache performance, determined according to the loading resource volume - maximum data volume mapping table and the current loading resource volume.
[0054] In this embodiment, the sub - package loading process refers to the process of packaging the read FBX model file according to the current maximum data volume according to the supported format and loading it sub - package by sub - package in the system cache.
[0055] The working principle and beneficial effects of the above - mentioned technical solution are: By converting the read FBX model file data into the supported format of Unity, packaging the read FBX model file according to the supported format and loading it in the system cache, the data processing efficiency and data processing security are effectively improved.
[0056] Embodiment 6: The embodiment of the present invention provides a method for decrypting and decompressing 3D models in the system cache, further including: Monitor the process of packing the read FBX model file according to the supported format and loading it in the system cache in real time, obtain the current loading process data, and determine the loading process evaluation metrics based on the historical loading process data. Among them, the loading process evaluation metrics include: data loading efficiency evaluation metrics, data loading integrity evaluation metrics, and data loading security evaluation metrics; Determine the current loading process evaluation value according to the current loading process data and the loading process evaluation metrics; If the current loading process evaluation value is not lower than the preset evaluation value, it is determined that the current loading process is safe and efficient.
[0057] In this embodiment, the current loading process data refers to the data obtained by monitoring in real time the process of packing the read FBX model file according to the supported format and loading it in the system cache.
[0058] In this embodiment, the loading process evaluation metrics refer to the metrics used to evaluate the loading process effect.
[0059] In this embodiment, the current loading process evaluation value refers to the quantization value determined according to the current loading process data and the loading process evaluation metrics and used to quantitatively represent the current loading process effect.
[0060] The working principle and beneficial effects of the above technical solution are: Monitor the process of packing the read FBX model file according to the supported format and loading it in the system cache in real time, determine the loading process evaluation metrics, and evaluate the current loading process, which is beneficial to ensuring the data processing efficiency and data security of the current loading process.
[0061] Embodiment 7: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in the system cache. Instantiate the 3D model resource loaded from the system cache in unity and directly add the 3D model resource to the application scene, including: In Unity, use the Instantiate method to create an instance of the 3D model resource from the AssetBundle loaded from memory, and add the instance of the 3D model resource to the current application scene.
[0062] In this embodiment, the Instantiate method refers to the method used to create a model instance in unity, which is used to ensure that the 3D model can be correctly displayed and interacted.
[0063] In this embodiment, the current application scene refers to the user's current application scene.
[0064] The working principle and beneficial effects of the above technical solution are as follows: By instantiating the 3D model resources loaded from the system cache in Unity and directly adding the 3D model resources to the application scene, the data security is effectively ensured.
[0065] Example 8: The embodiment of the present invention provides a method for decrypting and decompressing a 3D model in a system cache, further including: After adding the 3D model resources to the application scene, end the data stream of the required FBX model file and release the resources of the system cache.
[0066] The working principle and beneficial effects of the above technical solution are as follows: After adding the 3D model resources to the application scene, end the data stream of the required FBX model file and release the resources of the system cache, ensuring the performance of the system cache and avoiding resource consumption.
[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for implementing 3D model decryption and decompression in a system cache, characterized in that: include: Step 1: Use the ZipArchive class in the System.IO.Compression library to read the data stream of the ZIP compressed package and read the ZIP compressed package from the disk into the system cache; Step 2: Retrieve the required FBX model file from the ZIP compressed package, obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and read the data stream of the required FBX model file into the MemoryStream object in the system cache; Step 3: Convert the read FBX model file data into a format supported by Unity, package the read FBX model file according to the supported format, and load it into the system cache; Step 4: Instantiate the 3D model resource loaded from the system cache in Unity and directly add the 3D model resource to the application scene.
2. A method for implementing 3D model decryption and decompression in a system cache according to claim 1, characterized in that: Through the ZipArchive class in the System.IO.Compression library, read the data stream of the ZIP compressed package and read the ZIP compressed package from the disk into the system cache, including: Get the complete storage path of the ZIP compressed package on the local disk, and create a read-only file stream pointing to the ZIP compressed package based on the complete storage path; By associating the ZipArchive class in the System.IO.Compression library with the read-only file stream, the ZIP compressed package is traversed in a loop to read the data stream of the ZIP compressed package; Create a cache stream in the system cache and copy the data stream of the ZIP compressed package to the cache stream.
3. A method for implementing 3D model decryption and decompression in a system cache according to claim 1, characterized in that: Retrieve the required FBX model file from the ZIP compressed package, obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class, and read the data stream of the required FBX model file into the MemoryStream object in the system cache, including: Obtain user's 3D model requirements and determine the required FBX model files; Search the ZIP archive for the required FBX model file, and obtain the data stream of the required FBX model file through the GetEntry method of the ZipArchive class; Read the data stream of the required FBX model file into the MemoryStream object in the system cache to obtain the cached FBX model file data.
4. A method for implementing 3D model decryption and decompression in a system cache according to claim 3, characterized in that: Also includes: Perform data integrity check on cached FBX model file data. When the data stream of the cached FBX model file data is consistent with the data stream of the required FBX model file, the data integrity check is considered qualified, and the FBX model file data is directly read from the MemoryStream object in the system cache. When the cached FBX model file data is inconsistent with the data stream of the required FBX model file, the required FBX model file is searched again from the ZIP compressed package, and the data stream of the required FBX model file is obtained through the GetEntry method of the ZipArchive class.
5. The method for implementing 3D model decryption and decompression in system cache according to claim 1, characterized in that: Convert the read FBX model file data to a format supported by Unity, package the read FBX model file according to the supported format and load it into the system cache, including: Get the formats supported by Unity, and convert the read FBX model file data into the formats supported by Unity. The formats supported by Unity include: AssetBundle format; Get the data volume of the read FBX model file data and the current amount of loaded resources cached by the system; Obtain a mapping table of loading resource volume and maximum data volume according to historical loading processing data, and determine the current maximum data volume of the current loading resource volume; When the data volume of the read FBX model file data is not higher than the current maximum data volume, the read FBX model file is packaged according to the supported format and loaded into the system cache; When the data volume of the read FBX model file data is higher than the current maximum data volume, the read FBX model file is packaged according to the supported format according to the current maximum data volume and loaded in the system cache.
6. A method for implementing 3D model decryption and decompression in a system cache according to claim 5, characterized in that: Also includes: The process of packaging the read FBX model file according to the supported format and loading it in the system cache is monitored in real time, current loading processing data is obtained, and loading processing evaluation indicators are determined according to historical loading processing data, wherein the loading processing evaluation indicators include: data loading efficiency evaluation indicators, data loading integrity evaluation indicators, and data loading security evaluation indicators; Determine the current loading process evaluation value according to the current loading process data and the loading process evaluation index; If the current loading process evaluation value is not lower than the preset evaluation value, the current loading process is determined to be safe and efficient.
7. The method for implementing 3D model decryption and decompression in system cache according to claim 1, characterized in that: Instantiate the 3D model resources loaded from the system cache in Unity and directly add the 3D model resources to the application scene, including: In Unity, use the Instantiate method to create an instance of a 3D model resource from an AssetBundle loaded from memory, and add the instance of the 3D model resource to the current application scene.
8. The method for implementing 3D model decryption and decompression in system cache according to claim 1, characterized in that: Also includes: After adding the 3D model resource to the application scene, end the data flow of the required FBX model file and release the system cached resources.