Three-dimensional model file generation method, device and terminal equipment
By generating tree structure files and structure descriptions of the three-dimensional model, the problem of not being able to reuse the same part resources when building a three-dimensional model is solved, which improves resource utilization and reduces file space.
Patent Information
- Application Number
- CN202111503768.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2041-12-10
AI Technical Summary
When building a three-dimensional model, the existing technology cannot reuse the same part resources, resulting in increased computing load and 3-dimensional model files occupying more hard disk space.
By obtaining all parts in the three-dimensional model, classifying the sample parts, generating the structure description of each sample part, and generating a tree structure file based on the connection relationship between parts, and finally generating a description file of the three-dimensional model based on the tree structure file and the structure description.
Reuse of duplicate part resources is realized, resource utilization is improved, hard disk space occupancy of 3D model description files, and memory consumption when the application reads files.
Smart Images

Figure CN114241128B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of modeling, and in particular to a method, device and terminal equipment for generating files of a three-dimensional model. Background Art
[0002] In engineering design, the actual mechanical structure needs to be converted into a corresponding 3D model file to improve the delivery efficiency of designers and construction personnel. Vertex format is a description method used to describe mechanical structures. The application of the terminal device generates a 3D model file corresponding to the mechanical structure by recording the properties of all vertices of the mechanical structure.
[0003] However, the use of vertex format to describe mechanical structures requires an accurate description of the vertex order of the mechanical structure. When there are multiple identical parts in a mechanical structure, the application needs to repeatedly describe the same parts, increasing the computing load of the terminal device. At the same time, when the mechanical structure contains identical parts, it is still necessary to generate a corresponding resource file for each part separately. The application cannot reuse the same part resources to generate a 3D model file, resulting in the 3D model file occupying more hard disk space. Summary of the invention
[0004] In view of the defects of the prior art, the embodiment of the present application aims to provide a method, apparatus and terminal device for generating a file of a three-dimensional model, so as to solve the problem that the same part resources cannot be reused when constructing a three-dimensional model.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a file of a three-dimensional model, the method comprising:
[0006] Acquire all parts contained in the three-dimensional model, and classify the parts to obtain at least one sample part;
[0007] Generate a structural description corresponding to each of the sample parts;
[0008] Generate a tree structure file of the three-dimensional model according to the connection relationship between the parts;
[0009] A description file of the three-dimensional model is generated according to the tree structure file and the structure description.
[0010] In combination with the first aspect, in a first possible implementation manner, the structure description includes the configuration ID of the sample part, and after generating the tree structure file of the three-dimensional model according to the connection relationship between the parts, the method further includes:
[0011] Configure the instance ID of each of the parts, and determine the configuration ID of the sample part corresponding to the part;
[0012] The local transformation information corresponding to the part, the configuration ID and the instance ID are written into the node in the tree structure file.
[0013] In combination with the first aspect, in a second possible implementation manner, generating the tree structure file of the three-dimensional model according to the connection relationship between the parts includes:
[0014] According to the connection relationship between the parts, the active part and the driven part are determined;
[0015] The active part is used as a parent node, the driven part is used as a child node, and the child node is mounted to the corresponding parent node to generate a tree structure file of the three-dimensional model.
[0016] In combination with the first aspect, in a third possible implementation manner, generating a description file of the three-dimensional model according to the tree structure file and the structure description includes:
[0017] Obtaining a resource file referenced by the sample part, and generating a configuration file of the sample part according to the resource file and a structure description of the sample part;
[0018] A description file of the three-dimensional model is generated according to the configuration file and the tree structure file.
[0019] In combination with the first aspect, in a fourth possible implementation manner, after generating the structural description corresponding to each of the sample parts and before generating the tree structure file of the three-dimensional model according to the connection relationship between the parts, the method further includes:
[0020] Constructing a local space coordinate system corresponding to the part;
[0021] Based on the local space coordinate system, the part is locally transformed and local transformation information of the part is generated.
[0022] In combination with the first aspect, in a fifth possible implementation manner, after generating the structure description corresponding to each sample part, the method further includes:
[0023] A sample parts configuration table of the three-dimensional model is generated according to the structural description corresponding to each of the sample parts.
[0024] In a second aspect, an embodiment of the present application provides a file generation device for a three-dimensional model, the device comprising:
[0025] A parts acquisition module, used to acquire all parts contained in the three-dimensional model, and classify the parts to obtain at least one sample part, wherein each sample part is different;
[0026] A structure description module, used to generate a structure description corresponding to each of the sample parts;
[0027] A tree structure file module, used to generate a tree structure file of the three-dimensional model according to the connection relationship between the parts;
[0028] A description file module is used to generate a description file of the three-dimensional model according to the tree structure file and the structure description.
[0029] In conjunction with the second aspect, in a first possible implementation manner, the structure description includes a configuration ID of the sample part, and the device further includes:
[0030] An ID configuration module, used to configure the instance ID of each of the parts and determine the configuration ID of the sample part corresponding to the part;
[0031] The node writing module is used to write the local transformation information corresponding to the part, the configuration ID and the instance ID into the node in the tree structure file.
[0032] In a third aspect, an embodiment of the present application is a terminal device, comprising a processor and a memory, wherein the memory stores a program or instruction, and the program or instruction is executed by the processor so that the terminal device executes the steps of the above-mentioned three-dimensional model file generation method.
[0033] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a program or instruction stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for generating a file of a three-dimensional model.
[0034] The present application provides a method for generating a file of a three-dimensional model, the method comprising: obtaining all parts contained in the three-dimensional model, and classifying the parts to obtain at least one sample part; generating a structural description corresponding to each of the sample parts; generating a tree structure file of the three-dimensional model according to the connection relationship between the parts; generating a description file of the three-dimensional model according to the tree structure file and the structural description. In the process of exporting the description file of the three-dimensional model, it is not necessary to create a corresponding resource file for each part. The same parts share the structural description of the sample parts, which improves the utilization rate of repeated part resources, reduces the hard disk space occupied by the description file of the three-dimensional model, and thus reduces the memory consumed when the application reads the file of the three-dimensional model. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0036] Figure 1 A flowchart of a method for generating a file of a three-dimensional model provided in Embodiment 1 of the present invention is shown;
[0037] Figure 2 A schematic diagram showing the structure of a tree structure file of a three-dimensional model provided by Embodiment 1 of the present invention is shown;
[0038] Figure 3 A schematic diagram of the structure of a file generation device for a three-dimensional model provided in Example 2 of the present invention is shown. DETAILED DESCRIPTION
[0039] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0040] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0041] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0042] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0043] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0044] Example 1
[0045] See also Figure 1 , Figure 1 A flowchart of a method for generating a file of a three-dimensional model provided in Embodiment 1 of the present invention is shown. The method for generating a file of a three-dimensional model comprises the following steps:
[0046] Step 101: Acquire all parts contained in the three-dimensional model, and classify the parts to obtain at least one sample part.
[0047] All parts included in the three-dimensional model are obtained, and the same parts are classified to obtain sample parts. For example, if a three-dimensional model includes 3 identical screws and 5 identical gears, the same screws and gears are classified to obtain sample screws and sample gears.
[0048] Step 102: Generate a structural description corresponding to each of the sample parts.
[0049] It should be understood that the structural description of a part includes but is not limited to any part attributes such as the name, shape, and material of the part, which are not limited here.
[0050] As an example, after generating the structural description corresponding to each sample part, the method further includes:
[0051] A sample parts configuration table of the three-dimensional model is generated according to the structural description corresponding to each of the sample parts.
[0052] All structure descriptions are stored in a table, and this table is used as a sample part configuration table. The sample part configuration table and the configuration ID of the sample part can be used to quickly distinguish the types of parts included in the 3D model. At the same time, the part configuration table can be configured according to actual needs, and there is no limitation here.
[0053] Step 103: Generate a tree structure file of the three-dimensional model according to the connection relationship between the parts.
[0054] The instantiation of a part is the process of converting the abstract concept class of a part into a physical object of the part. In this embodiment, the structure description of the sample part can be reused to create an instance of each part. For example, assuming that the three-dimensional model includes 5 identical gears, after generating the structure description corresponding to the sample gear, the structure description of the sample gear is copied to obtain the instance description of the 5 gears. Each instance of the part is used as a node, and the nodes are associated according to the connection relationship between the parts to generate a tree structure file of the three-dimensional model.
[0055] As an example, the structure description includes the configuration ID of the sample part, and after generating the tree structure file of the three-dimensional model according to the connection relationship between the parts, it also includes:
[0056] Configure the instance ID of each of the parts, and determine the configuration ID of the sample part corresponding to the part;
[0057] The local transformation information corresponding to the part, the configuration ID and the instance ID are written into the node in the tree structure file.
[0058] For each instance of a part, a unique instance ID is configured in the 3D model based on the configuration ID of the sample part. The instance ID of the part can be used to accurately specify a specific part instance. In addition, a unique instance ID can also be directly configured for each part, which will not be described in detail here.
[0059] Quickly query the sample part corresponding to the part in the part configuration table to obtain the configuration ID of the sample part corresponding to the part. Write the local transformation information, configuration ID and instance ID corresponding to the part to the node as the description information of the child node. The specific part instance can be accurately queried through the description information in the tree structure file. At the same time, the spatial position of each part and the sample part corresponding to each part can also be quickly determined through the tree structure file.
[0060] According to the connection relationship between the parts, the connection relationship between the nodes is obtained. According to the connection relationship between the nodes, the nodes are associated to form an operation result of a tree structure. It should be understood that multiple 3D modeling applications, such as Unity, 3DSMax, Maya and other applications, can form a corresponding tree structure, which will not be repeated here.
[0061] As an example, generating the tree structure file of the three-dimensional model according to the connection relationship between the parts includes:
[0062] According to the connection relationship between the parts, the active part and the driven part are determined;
[0063] The active part is used as a parent node, the driven part is used as a child node, and the child node is mounted to the corresponding parent node to generate a tree structure file of the three-dimensional model.
[0064] Please also read Figure 2 , Figure 2 The schematic diagram of the structure of the tree structure file of the three-dimensional model provided by Example 1 of the present invention is shown. The tree structure is a nested structure, and the outer layer and the inner layer of the tree structure have similar structures, and the tree structure can be recursively represented. In this embodiment, the parent node and the child node are configured according to the slave relationship between two connected parts. Specifically, taking the arm, palm and finger of the robot model as an example, during the movement of the robot, the arm drives the palm to move, the arm part is the active part, and the palm part is the driven part. The arm part is the parent node and the palm part is the child node, and the child node is mounted to the parent node. Similarly, the palm part is the parent node and the finger part is the child node, and the child node is mounted to the parent node. In addition, the palm of the robot is provided with four identical fingers. According to the finger sample parts, four finger parts 1, finger part 2, finger part 3 and finger part 4 are obtained, and the nodes corresponding to the four finger parts are mounted to the nodes corresponding to the palm to form a tree structure of the three-dimensional model.
[0065] Step 104: Generate a description file of the three-dimensional model according to the tree structure file and the structure description.
[0066] After the current application generates a tree structure file of the 3D model and a structural description of each sample part, the tree structure file and the structural description can be packaged and exported as a description file of the 3D model. Other applications import the description file of the 3D model, load the structural description of the sample part into the corresponding part instance, and restore all parts in the 3D model through the local information of each part. The refined restoration of the 3D model is achieved without the need to transmit the corresponding resource file of each part. The hard disk space occupied by the description file of the 3D model is reduced, thereby reducing the memory consumed by the application when reading the 3D model file.
[0067] It should be understood that, in order to facilitate the export and import of three-dimensional models, the tree structure file and structure description in the current application can be sent to other applications respectively, which will not be elaborated here.
[0068] As an example, after generating the structural description corresponding to each of the sample parts and before generating the tree structure file of the three-dimensional model according to the connection relationship between the parts, the method further includes:
[0069] Constructing a local space coordinate system corresponding to the part;
[0070] Based on the local space coordinate system, the part is locally transformed and local transformation information of the part is generated.
[0071] The local space coordinate system is a coordinate system used for a tree structure. In this embodiment, the three-dimensional model space coordinate system is constructed with the pivot point of the three-dimensional model as the origin. The local space coordinate system is constructed with the pivot point of each parent node as the origin.
[0072] It should be understood that transformation refers to the translation, rotation and scaling of parts. The local transformation information of parts is based on the actual position of the parts, which will not be described here. The part instance is mounted to the corresponding parent node, and local transformation is performed based on the local space coordinate system to quickly determine the spatial position of the part through the local transformation information of the part.
[0073] As an example, generating a description file of the three-dimensional model according to the tree structure file and the structure description includes:
[0074] Obtaining a resource file referenced by the sample part, and generating a configuration file of the sample part according to the resource file and a structure description of the sample part;
[0075] A description file of the three-dimensional model is generated according to the configuration file and the tree structure file.
[0076] Resource files are files used by applications to describe parts. Multiple applications can share the resource files of the same part and use them to restore the 3D model. In this application, it is not necessary to store resource files for all parts. By copying the structural description of the sample part, an instance of each part is obtained, and the resource file of the sample part is written to the instance of the part. During the 3D model restoration process, the configuration files of the sample parts correspond to the nodes of the tree structure file to achieve refined restoration of the 3D model.
[0077] It should be understood that the format of the configuration file includes but is not limited to json, csv and other file formats, which are not limited here. In the process of exporting or importing the description file of the 3D model, the same parts share a sample part configuration file, which improves the utilization rate of repeated part resources of the 3D model, and is not limited to generating the export file through the vertices of the 3D model.
[0078] The present application provides a method for generating a file of a three-dimensional model, the method comprising: obtaining all parts contained in the three-dimensional model, and classifying the parts to obtain at least one sample part; generating a structural description corresponding to each of the sample parts; generating a tree structure file of the three-dimensional model according to the connection relationship between the parts; generating a description file of the three-dimensional model according to the tree structure file and the structural description. In the process of exporting the description file of the three-dimensional model, it is not necessary to create a corresponding resource file for each part. The same parts share the structural description of the sample parts, which improves the utilization rate of repeated part resources, reduces the hard disk space occupied by the description file of the three-dimensional model, and thus reduces the memory consumed when the application reads the file of the three-dimensional model.
[0079] Example 2
[0080] See also Figure 3 , Figure 3 The schematic diagram of the structure of the file generation device of the three-dimensional model provided by the second embodiment of the present invention is shown. The file generation device 200 of the three-dimensional model includes:
[0081] A parts acquisition module 210 is used to acquire all parts contained in the three-dimensional model and classify the parts to obtain at least one sample part, wherein each sample part is different;
[0082] A structure description module 220, used to generate a structure description corresponding to each of the sample parts;
[0083] A tree structure file module 230, used to generate a tree structure file of the three-dimensional model according to the connection relationship between the parts;
[0084] The description file module 240 is used to generate a description file of the three-dimensional model according to the tree structure file and the structure description.
[0085] As an example, the structure description includes the configuration ID of the sample part, and the file generation device 200 of the three-dimensional model further includes:
[0086] An ID configuration module, configured to configure an instance ID of a part identical to the sample part according to the configuration ID of the sample part, so as to mark the part;
[0087] The node writing module is used to write the local transformation information corresponding to the part, the configuration ID and the instance ID into the node in the tree structure file.
[0088] As an example, the tree structure file module 230 is also used to determine the active part and the driven part according to the connection relationship between the parts;
[0089] The active part is used as a parent node, the driven part is used as a child node, and the child node is mounted to the corresponding parent node to generate a tree structure file of the three-dimensional model.
[0090] As an example, the description file module 240 is further used to obtain a resource file referenced by the sample part, and generate a configuration file of the sample part according to the resource file and the structure description of the sample part;
[0091] A description file of the three-dimensional model is generated according to the configuration file and the tree structure file.
[0092] As an example, the three-dimensional model file generation device 200 further includes:
[0093] A coordinate system construction module, used to construct a local space coordinate system corresponding to the part;
[0094] The local transformation module is used to perform local transformation on the part based on the local space coordinate system and generate local transformation information of the part.
[0095] As an example, the three-dimensional model file generation device 200 further includes:
[0096] The configuration table module is used to generate a sample part configuration table of the three-dimensional model according to the structural description corresponding to each sample part.
[0097] The 3D model file generation device 200 is used to execute the corresponding steps in the above 3D model file generation method. The specific implementation of each function is not described one by one here. In addition, the optional examples in embodiment 1 are also applicable to the 3D model file generation device 200 of embodiment 2.
[0098] An embodiment of the present application also provides a terminal device, including a processor and a memory, wherein the memory stores a program or instruction, and the program or instruction is executed by the processor to enable the router to execute the steps of the above-mentioned three-dimensional model file generation method.
[0099] An embodiment of the present application also provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the above-mentioned three-dimensional model file generation method are implemented.
[0100] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0101] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0102] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0103] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for generating a file of a three-dimensional model, It is characterized in that The method comprises: Acquire all parts contained in the three-dimensional model, and classify the parts to obtain at least one sample part; Generate a structure description corresponding to each sample part, wherein the structure description includes a configuration ID of the sample part; According to the connection relationship between the parts, a tree structure file of the three-dimensional model is generated, including: configuring an instance ID of each part and determining a configuration ID of a sample part corresponding to the part; writing local transformation information corresponding to the part, the configuration ID and the instance ID into a node in the tree structure file; A description file of the three-dimensional model is generated according to the tree structure file and the structure description.
2. The method for generating a file of a three-dimensional model according to claim 1, It is characterized in that The step of generating a tree structure file of the three-dimensional model according to the connection relationship between the parts comprises: According to the connection relationship between the parts, the active part and the driven part are determined; The active part is used as a parent node, the driven part is used as a child node, and the child node is mounted to the corresponding parent node to generate a tree structure file of the three-dimensional model.
3. The method for generating a file of a three-dimensional model according to claim 1, It is characterized in that The step of generating a description file of the three-dimensional model according to the tree structure file and the structure description includes: Obtaining a resource file referenced by the sample part, and generating a configuration file of the sample part according to the resource file and a structure description of the sample part; A description file of the three-dimensional model is generated according to the configuration file and the tree structure file.
4. The method for generating a file of a three-dimensional model according to claim 1, It is characterized in that After generating the structural description corresponding to each of the sample parts and before generating the tree structure file of the three-dimensional model according to the connection relationship between the parts, the method further includes: Constructing a local space coordinate system corresponding to the part; Based on the local space coordinate system, the part is locally transformed and local transformation information of the part is generated.
5. The method for generating a file of a three-dimensional model according to claim 1, It is characterized in that After generating the structural description corresponding to each sample part, the method further includes: A sample parts configuration table of the three-dimensional model is generated according to the structural description corresponding to each of the sample parts.
6. A file generation device for a three-dimensional model, It is characterized in that The device comprises: A parts acquisition module, used to acquire all parts contained in the three-dimensional model, and classify the parts to obtain at least one sample part, wherein each sample part is different; A structure description module, used to generate a structure description corresponding to each of the sample parts; A tree structure file module, used to generate a tree structure file of the three-dimensional model according to the connection relationship between the parts; A description file module, used to generate a description file of the three-dimensional model according to the tree structure file and the structure description; The structure description includes a configuration ID of the sample part, and the apparatus further includes: An ID configuration module, used to configure the instance ID of each of the parts and determine the configuration ID of the sample part corresponding to the part; The node writing module is used to write the local transformation information corresponding to the part, the configuration ID and the instance ID into the node in the tree structure file.
7. A terminal device, It is characterized in that It comprises a processor and a memory, wherein the memory stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the file generation method of the three-dimensional model as described in any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method for generating a file of a three-dimensional model according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Data processing method and device for three-dimensional assembly and electronic equipment
CN111275828A