Casting model mesh simplification method based on Unity3D platform
By simplifying the mesh structure of casting models on the Unity3D platform, the large rendering pressure caused by high-complexity models is solved, and smoother rendering and higher system performance is achieved, while retaining the accuracy and key features of the model.
Patent Information
- Application Number
- CN202411361480.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-02-18
AI Technical Summary
Casting 3D models are under great rendering pressure due to high complexity, making it difficult to render effectively on resource-constrained platforms, affecting user experience and system performance.
The casting model grid simplification method based on the Unity3D platform is adopted to simplify the mesh structure, reduce the number of vertices and triangles, and reduce the rendering and computing burden. Specific steps include initialization steps, progressive grid simplification, vertex edge folding cost estimates, and simplified result generation.
Significantly reduces model rendering time and GPU load, improves Unity's frame rate, makes animation and interaction smoother, is suitable for memory-constrained platforms, and retains the key details and geometric features of the model.
Smart Images

Figure CN119478287A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a mesh simplification technology, in particular to a casting model mesh simplification method based on a Unity3D platform. Background Art
[0002] During the foundry production process, the management and operation of sand casting workshops typically rely on physical workflows and manual data recording. While this approach has supported the industry's basic needs for decades, in today's world of increasing informatization and automation, traditional methods are showing numerous limitations. For example, traditional methods struggle to achieve efficient production scheduling and quality control, and information transmission delays make real-time monitoring and optimization of the production process difficult, impacting production efficiency and product quality.
[0003] The development of digital twin technology has opened up new opportunities for transformation in traditional foundries. Digital twin technology creates a virtual model that corresponds to the physical workshop, simulating, analyzing, and optimizing actual production processes within a virtual environment. By combining advanced sensor technology, the internet, and the Industrial Internet of Things, digital twins can collect real-time data from within the workshop, enabling in-depth data analysis and visualization, and enabling real-time monitoring and management of production processes.
[0004] However, 3D models of castings are often very complex, containing a large number of vertices and faces, which poses significant challenges for real-time rendering and data processing. Highly complex 3D models not only increase the computational burden but also increase rendering times, impacting the user experience. Highly complex models can significantly degrade system performance, especially on resource-constrained platforms such as mobile devices and VR. Therefore, effectively simplifying casting models and reducing their complexity has become a key issue in improving the application of digital twin technology in foundries. Summary of the Invention
[0005] The present invention provides a casting model mesh simplification method based on the Unity3D platform. It simplifies the mesh structure of the casting model, reduces the number of vertices and triangles of the model, thereby reducing the rendering and computing burden, solving the problem of high rendering pressure caused by the high complexity of the casting 3D model, and ensuring the accuracy of the 3D model while simplifying it.
[0006] In order to achieve the above object, the present invention provides the following technical solutions: Based on the casting model mesh simplification method based on the Unity3D platform, it includes the following steps: Initialization step: obtain the original mesh data of the casting model and construct the associated data structure of vertices and faces; Progressive mesh simplification: repeatedly performing edge collapse operations; Vertex folding cost estimation: Calculate the vertex edge folding cost and sort according to the calculated cost; Simplified result generation: Reconstruct the simplified casting 3D model and output the simplified mesh.
[0007] The initialization step includes the following two specific operations: 1) Obtain the original mesh data of the casting model: Use Unity's MeshFilter or SkinnedMeshRenderer components to extract raw mesh data from 3D models, including vertices, triangles, normals, UV coordinates, etc.
[0008] Get the world coordinates of the vertex.
[0009] 2) Construct the associated data structure of vertices and patches: Use the Vertex and Triangle classes to represent vertices and triangles, and build the association relationship between them.
[0010] By building a dictionary of unique vertices and a list of duplicate vertices, sorting and storing unique vertices and their world coordinates, and generating a list of triangle indices for each sub-mesh, an optimized data structure is created to facilitate subsequent mesh processing and simplification operations.
[0011] The progressive mesh simplification includes the following operations: 1) Edge folding operation: Determines whether vertex v has any adjacent vertices. If vertex v has no adjacent vertices, sets the folding target to null and the folding cost to -0.01f (a negative value indicates invalid or no folding cost), and then returns.
[0012] If v has adjacent vertices, traverse all vertices u adjacent to v and initialize the folding cost EdgeCost between all adjacent vertices.
[0013] If the calculated folding cost is less than the initial folding cost, the folding target u of its vertex v and its folding cost EdgeCost are updated.
[0014] Perform edge collapse operations and update vertex and face information.
[0015] 2) Repeated execution: Repeat the above steps until the predetermined number of vertices or degree of simplification is reached. The termination of the simplification process can be controlled by loops and conditional judgments.
[0016] The vertex-edge folding cost evaluation includes the following operations:
[0017] Traverse the adjacent faces of vertex v, and create a separate Side list for the faces that contain vertex u. The faces in the list contain both vertex v and vertex u.
[0018] For a certain adjacent face of vertex v, the dot product Dotprod of its normal with each face in the Side list is calculated by the function, and then the curvature Curvature is calculated.
[0019] The curvature is calculated by the mean curvature, and its formula is And select the minimum curvature MinCurvature from all the curvatures Curvature calculated for the adjacent surface at vertex v, and then pass Get the curvature cost of vertex v.
[0020] If v is a boundary vertex and has multiple faces in its Side list, set fCurvature to 1.0f to avoid collapsing at the boundary.
[0021] Therefore, the edge collapse cost of each vertex v is calculated. The cost calculation takes the following factors into account: Edge Length: Longer edges have higher folding costs.
[0022] Curvature: Maintains the curvature of the mesh surface. The greater the curvature, the higher the folding cost.
[0023] Border Lock: The collapse cost of border vertices is set to a maximum value.
[0024] Its folding cost EdgeCost can be obtained by the formula get.
[0025] Call the above calculation method to evaluate the collapse cost for each vertex.
[0026] 2) Vertex queue sorting: Use a priority queue or heap structure to store the vertices, sorted according to the calculated folding cost.
[0027] The simplified result generation includes the following operations: 1) Reconstruct the simplified casting 3D model: Use the ConsolidateMesh method to reconstruct the simplified 3D model based on the simplified vertex and face data. Generate new mesh data, including vertices, triangles, normals, etc.
[0028] 2) Output the simplified mesh: Output the simplified mesh data for rendering or further processing.
[0029] The present invention adopts the above technical solution to achieve the following beneficial effects: The present invention has the following significant advantages: 1. Significantly reduce model rendering time and GPU load, especially in complex scenes or low-performance devices, improve Unity's frame rate, and make animation and interaction smoother.
[0030] 2. The simplified model uses less memory space and is suitable for memory-constrained platforms (such as mobile devices and VR).
[0031] 3. Retain the key details and geometric features of the casting model. Through the optimized mesh simplification algorithm, the original shape and accuracy of the model are maintained as much as possible while simplifying the model.
[0032] 4. Provide a user-friendly simplified operation interface and multiple simplification options to meet the simplification needs of casting models of different complexities, ensuring that users can select appropriate simplification parameters and methods according to specific application scenarios.
[0033] 5. Through automation and batch processing functions, the efficiency of the casting model simplification process is improved, manual operation time is reduced, and it adapts to the needs of large-scale casting model processing.
[0034] By achieving the above-mentioned beneficial effects, the present invention will significantly improve the application effect of casting models in digital twins and other virtual environments, and promote the digital and intelligent transformation of foundries. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of an embodiment. DETAILED DESCRIPTION
[0036] The present invention is further described below with reference to the accompanying drawings and examples. It should be understood that the following examples are merely one or more manifestations of the present invention and are not intended to be a complete limitation on the invention disclosed herein. Any improvements known to those skilled in the art based on the invention or technical solutions disclosed herein should fall within the scope of protection claimed in this application.
[0037] A casting model mesh simplification method based on the Unity3D platform, the method comprising the following steps: 1.1 Initialization steps 1.1.1 Obtain the original mesh data of the casting model: Use Unity's MeshFilter or SkinnedMeshRenderer components to extract raw mesh data from 3D models, including vertices, triangles, normals, UV coordinates, etc.
[0038] Get the world coordinates of the vertex.
[0039] 1.1.2 Construct the associated data structure of vertices and patches: Use the Vertex and Triangle classes to represent vertices and triangles, and build the association relationship between them.
[0040] By building a dictionary of unique vertices and a list of duplicate vertices, sorting and storing unique vertices and their world coordinates, and generating a list of triangle indices for each sub-mesh, an optimized data structure is created to facilitate subsequent mesh processing and simplification operations.
[0041] 1.2 Progressive Mesh Simplification 1.2.1 Edge folding operation: Determines whether vertex v has any adjacent vertices. If vertex v has no adjacent vertices, sets the folding target to null and the folding cost to -0.01f (a negative value indicates invalid or no folding cost), and then returns.
[0042] If v has adjacent vertices, traverse all vertices u adjacent to v and initialize the folding cost EdgeCost between all adjacent vertices.
[0043] If the calculated folding cost is less than the initial folding cost, the folding target u of its vertex v and its folding cost EdgeCost are updated.
[0044] Perform edge collapse operations and update vertex and face information.
[0045] 1.2.2 Repeated execution: Repeat the above steps until the predetermined number of vertices or degree of simplification is reached. The termination of the simplification process can be controlled by loops and conditional judgments.
[0046] 1.3 Vertex-edge folding cost evaluation 1.3.1 Calculate vertex edge collapse cost: The actual length EdgeLength from vertex u to vertex v is calculated by the function Vector3.Magnitude. The bounding box size is MeshSize. Then the formula Get its normalized edge length fEdgeLength.
[0047] Traverse the adjacent faces of vertex v, and create a separate Side list for the faces that contain vertex u. The faces in the list contain both vertex v and vertex u.
[0048] For a certain adjacent face of vertex v, the dot product Dotprod of its normal with each face in the Side list is calculated by the function, and then the curvature Curvature is calculated.
[0049] The curvature is calculated by the mean curvature, and its formula is And select the minimum curvature MinCurvature from all the curvatures Curvature calculated for the adjacent surface at vertex v, and then pass Get the curvature cost of vertex v.
[0050] If v is a boundary vertex and has multiple faces in its Side list, set fCurvature to 1.0f to avoid collapsing at the boundary.
[0051] Therefore, the edge collapse cost of each vertex v is calculated. The cost calculation takes the following factors into account: Edge Length: Longer edges have higher folding costs.
[0052] Curvature: Maintains the curvature of the mesh surface. The greater the curvature, the higher the folding cost.
[0053] Border Lock: The collapse cost of border vertices is set to a maximum value.
[0054] Its folding cost EdgeCost can be obtained by the formula get.
[0055] Call the above calculation method to evaluate the collapse cost for each vertex.
[0056] 1.3.2 Vertex Queue Sorting Use a priority queue or heap structure to store the vertices, sorted according to the calculated folding cost.
[0057] 1.4 Simplifying result generation 1.4.1 Reconstruct the simplified casting 3D model: Use the ConsolidateMesh method to reconstruct the simplified 3D model based on the simplified vertex and face data.
[0058] Generate new mesh data, including vertices, triangles, normals, etc.
[0059] 1.4.2 Output the simplified mesh: Output the simplified mesh data for rendering or further processing.
[0060] As an embodiment of the present invention, the simplified method is put into practical use in the form of script files and plug-ins, and the plug-in integrates model export, batch processing and calibration interface, error handling and user prompt functions. 1) Model export function The plugin supports exporting simplified casting models to multiple formats and provides material export options: Export format: supports multiple formats such as OBJ, FBX, PLY, etc., making it easy to use simplified models in different platforms and software.
[0061] Material export: Users can choose whether to export the material of the casting model and set the material export options (such as color, texture, etc.) to maintain the visual effect of the casting model in the virtual environment.
[0062] 2) Batch processing and scripting interface The plug-in also provides the following advanced features to improve the efficiency of the casting model simplification process: Batch processing: supports simplifying multiple casting 3D models at one time, significantly improving work efficiency and adapting to the large-scale casting processing needs in industrial production.
[0063] Scripted interface: Provides an API interface that allows developers to call plug-in functions through scripts to achieve automated processing, reduce manual intervention, and adapt to the assembly line operation mode.
[0064] 3) Error handling and user prompts If an error occurs during the simplification process (such as a mesh not found or invalid simplification parameters), the plugin will display detailed error information in the console and provide solution suggestions. During the simplification and export process, the plugin will also output progress and status information to the console, helping users understand the current operation progress and ensuring a smooth simplification process.
[0065] The above is a mesh simplification method for casting models. It is based on the Unity3D platform and is used in practice according to Figure 1 The logic shown is operated and processed.
[0066] The specific steps are as follows: 1. Environment configuration and plug-in import 1.1 Environmental Preparation Make sure you have the Unity 3D engine installed and create a new Unity project.
[0067] Install Blender (or other 3D modeling software) in your development environment to create and export 3D models of castings.
[0068] 1.2 Plugin file import Put the MeshSimplificationWindow.cs script file into the Assets folder of the Unity project. MeshSimplificationWindow.cs is one of the C# files, which is mainly responsible for presenting the UI interface in the Insprctor window for easy operation after installation.
[0069] Open Unity and confirm that the plugin has been successfully imported. Check if the "MeshSimplification" option appears in Unity's Tools menu.
[0070] 2. Create and import casting 3D models 2.1 Casting model creation Create a 3D casting model using Blender. Adjust the model's size, rotation angle, and normal vectors for each mesh face.
[0071] Apply materials, textures, and maps to the casting model to ensure it displays correctly in Unity.
[0072] 2.2 Export casting model Export the casting model from Blender as an OBJ format, making sure to select Mesh and Texture in the export options.
[0073] Import the exported OBJ casting model file into the Unity project.
[0074] 3. Enable mesh simplification 3.1 Mounting Script In Unity, attach the MeshSimplify script to the model you want to simplify. The simplification information will be displayed in the Insprctor window of the model. The MeshSimplify script is mainly responsible for calling the specific simplification algorithm.
[0075] 3.2 Display current scene information In the Unity window, click Game mode, click Static in the upper left corner of the window, and a pop-up window will appear.
[0076] The pop-up window will automatically display the mesh information in the current scene, including the number of vertices, the number of triangles, and the storage size occupied by the model.
[0077] 4. Grid simplification operation 4.1 Selecting Simplified Constraints Check the Edge Length, Curvature, and Boundary Lock constraints.
[0078] 4.2 Selecting Simplified Parameters In the Insprctor window, select the percentage level of mesh simplification, this time 50%.
[0079] Set the minimum number of meshes after simplification and choose whether to display the simplified casting model in the scene.
[0080] 4.3 Performing Mesh Simplification Click the "Simplify" button, the plug-in will call the SimplifyMesh method in the MeshSimplification class to simplify the selected 3D casting model.
[0081] After simplification is completed, the number of triangle meshes and the number of fixed points are displayed in the Insprctor window for comparison with the original mesh.
[0082] 5. Casting model export and visualization 5.1 Set the export format In the plugin window, select the storage location and file format (such as OBJ, FBX, or PLY) for the simplified casting model.
[0083] Choose to add materials when exporting casting models.
[0084] 5.2 Exporting the Simplified Model Click the "Export" button to save the simplified 3D casting model to the specified location.
[0085] The simplified 3D casting model is displayed in the Unity scene, showing its simplified vertex count, mesh count, and storage size.
[0086] 6. Simplify the use of models 6.1 Using Simplified Casting Models in Other Scenarios Import the saved simplified 3D casting model file into other Unity projects or scenes and drag it into the scene to use it.
[0087] By reducing the number of vertices and triangle meshes, the simplified casting model significantly reduces rendering time and GPU load, making it suitable for complex scenes or low-performance devices.
[0088] The simplification method of the present invention is based on the idea of edge folding, and optimizes and improves the vertex merging strategy and error evaluation in the traditional mesh simplification algorithm; by introducing edge length, curvature and boundary locking factors, the folding cost of merging any two vertices is effectively evaluated, effectively avoiding geometric distortion.
[0089] Therefore, the plug-in equipped with the present invention can significantly reduce the rendering time and GPU load of the model in Unity3D by simplifying the casting model, especially in complex scenes or low-performance devices; and the lower polygon count helps to improve Unity's frame rate, making animation and interaction smoother.
[0090] The technical solution of the present invention is specifically aimed at the high complexity and special geometric features of casting models. Through optimized simplified algorithms and a user-friendly operation interface, it significantly improves the application effect of casting models in the digital twin environment and promotes the digital and intelligent transformation of foundries.
Claims
1. A casting model mesh simplification method based on Unity3D platform, characterized by: It includes the following steps: Initialization step: obtain the original mesh data of the casting model and construct the associated data structure of vertices and faces; Progressive mesh simplification: repeatedly performing edge collapse operations; Vertex folding cost estimation: Calculate the vertex edge folding cost and sort according to the calculated cost; Simplified result generation: Reconstruct the simplified casting 3D model and output the simplified mesh.
2. The casting model mesh simplification method based on Unity3D platform according to claim 1, characterized in that: The initialization step includes the following two specific operations: 1) Get the original mesh data of the casting model: Use Unity's MeshFilter or SkinnedMeshRenderer components to extract raw mesh data from 3D models, including vertices, triangles, normals, UV coordinates, etc. Get the world coordinates of the vertex; 2) Construct the associated data structure of vertices and patches: Use Vertex and Triangle classes to represent vertices and triangles, and build the relationship between them; By building a dictionary of unique vertices and a list of duplicate vertices, sorting and storing unique vertices and the world coordinates of vertices, and generating a list of triangle indices for each sub-mesh, an optimized data structure is created to facilitate subsequent mesh processing and simplification operations.
3. The casting model mesh simplification method based on Unity3D platform according to claim 1, characterized in that: The progressive mesh simplification includes the following operations: 1) Edge folding operation: Determine whether vertex v has adjacent vertices. If vertex v has no adjacent vertices, set the folding target to null and the folding cost to -0.01f (a negative value indicates invalid or no folding cost), and then return; If v has adjacent vertices, traverse all vertices u adjacent to v and initialize the folding cost EdgeCost between all adjacent vertices; If the calculated folding cost is less than the initial folding cost, update the folding target u of vertex v and its folding cost EdgeCost; Perform edge collapse operations and update vertex and face information; 2) Repeated execution: Repeat the above steps until the predetermined number of vertices or simplification degree is reached; The termination of the simplification process can be controlled by loops and conditional judgments.
4. The casting model mesh simplification method based on Unity3D platform according to claim 1, characterized in that: The vertex edge folding cost evaluation includes the following operations: 1) Calculate the vertex edge folding cost: The actual length EdgeLength from vertex u to vertex v is calculated by the function Vector3.Magnitude. The size of its bounding box is MeshSize. Then the formula Get its normalized side length ; Traverse the adjacent faces of vertex v, and create a Side list for the faces that contain vertex u. The faces in the list contain both vertex v and vertex u. For a certain adjacent face of vertex v, the dot product Dotprod between it and the normal of each face in the Side list is calculated by the function, and then the curvature Curvature is calculated; The calculated curvature is achieved through the average curvature, and its formula is And select the minimum curvature MinCurvature from all the curvatures Curvature calculated for the adjacent surface at vertex v, and then pass Get the curvature cost of vertex v; If v is a boundary vertex and has multiple faces in its Side list, set fCurvature to 1.0f to avoid folding at the boundary; Therefore, the edge collapse cost of each vertex v is calculated, and the cost calculation takes into account the following factors: Edge Length: The longer the edge, the higher the folding cost; Curvature: Maintain the curvature of the mesh surface. The greater the curvature, the higher the folding cost. Border Lock: The folding cost of border vertices is set to the maximum value; Its folding cost EdgeCost can be obtained by the formula get; Call the above calculation method to evaluate the folding cost for each vertex; 2) Vertex queue sorting: Use a priority queue or heap structure to store the vertices, sorted according to their computed folding cost.
5. The casting model mesh simplification method based on Unity3D platform according to claim 1, characterized in that: The simplified result generation includes the following operations: 1) Reconstruct the simplified casting 3D model: Use the ConsolidateMesh method to reconstruct the simplified 3D model based on the simplified vertex and face data; Generate new mesh data, including vertices, triangles, normals, etc. 2) Output the simplified mesh: Output the simplified mesh data for rendering or further processing.