A Unity-based method for controlling pipeline medium flow rate

By combining 3D pipeline models with program scripts in Unity, calculating pipeline lengths and standardizing flow velocity units, the problem of inconsistent medium flow velocity representation in 3D pipeline models was solved, achieving efficient and accurate medium flow velocity control.

CN120765862BActive Publication Date: 2025-11-14WUHAN HAIYI HIGH END EQUIP STRUCTURE DESIGN CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511292349.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-11
Publication Date
2025-11-14
Estimated Expiration
2045-09-11

AI Technical Summary

Technical Problem

In Unity, the flow velocity representation of the medium in the 3D model of the pipeline is inconsistent with the flow velocity in the actual pipeline system. Existing technologies that control this through UV animation suffer from large errors and low efficiency.

Method used

By combining the 3D model of the pipeline with Unity program scripts, the pipeline length is calculated and the flow velocity data unit is standardized. The UV animation shader script is created using the ShaderGraph editor to achieve precise control of the medium flow velocity.

Benefits of technology

It achieves realistic simulation of pipeline medium flow velocity in virtual scenarios, improves calculation accuracy and work efficiency, and has reusability and parameter configurability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120765862B_ABST
    Figure CN120765862B_ABST
Patent Text Reader

Abstract

This invention discloses a pipeline medium flow velocity control method based on Unity. First, a 3D pipeline model is established, followed by UV unwrapping. The 3D pipeline model is then imported into Unity. The vertices of the 3D pipeline model are obtained, and its length is calculated. Flow velocity data from pipeline measuring points is received. This flow velocity data is then converted into medium flow velocity data within the system. A UV animation script for the pipeline medium flow is created. A UV material sphere is created and assigned to the 3D pipeline model. The medium flow velocity data is passed to the velocity attribute of the UV material sphere, enabling the system to control the medium flow velocity of the 3D pipeline model using the pipeline flow velocity data provided by the system. This invention offers advantages such as reusability, configurable parameters, and high calculation accuracy. It can perform length calculations based on a proportionally constructed 3D model, while also saving time, improving work efficiency, and avoiding errors from manual calculations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of virtual simulation of industrial systems, and in particular to a pipeline medium flow rate control method based on Unity. Background Technology

[0002] Currently, the representation of pipe flow velocity in Unity is mainly controlled by UV offset in UV animation, without taking into account the fact that the length units of the actual pipe length and the length units of the 3D pipe model are inconsistent. Therefore, the medium flow velocity representation in the 3D pipe model cannot be consistent with the medium flow velocity in the actual pipe system. Summary of the Invention

[0003] In view of the current state of the technology and existing problems, this invention provides a pipeline medium flow velocity control method based on Unity. This invention combines a 3D pipeline model with Unity scripting to address the need for consistency between the medium flow velocity in a 3D virtual scene and the actual flow velocity in the pipeline system, while also solving problems such as the difficulty, large error, and low efficiency of manual algorithms.

[0004] The technical solution adopted in this invention is as follows: A pipeline medium flow rate control method based on Unity includes the following steps:

[0005] Step 1: First, create a 3D model of the pipeline.

[0006] Step 2: Perform UV unwrapping on the completed 3D pipeline model.

[0007] Step 3: Import the constructed 3D pipeline model into the Unity project to provide a 3D model foundation for subsequent pipeline length calculations and 3D scene representation.

[0008] Step 4: Obtain the vertices of the 3D model of the pipeline using Unity scripts, and calculate the length of the 3D model of the pipeline using the vertices.

[0009] Step 5: Receive flow velocity data from various pipeline measuring points in the system pipeline to provide data support for subsequent pipeline flow velocity measurements.

[0010] Step 6: Input the flow velocity data from the pipeline measuring points into the system, and unify the measurement units in the flow velocity data with the length measurement units of the pipeline 3D model to calculate the flow velocity of the medium through the pipeline 3D model.

[0011] Step 7: Create a UV animation shader script for the pipeline medium flow in the ShaderGraph editor.

[0012] Step 8: In the Unity project, right-click on the Shader script and select the Create Material operation to export the Shader script with the UV animation of the pipeline medium flow as a UV material sphere.

[0013] Step 9: Assign the UV material sphere to the 3D model of the pipeline in the Unity project.

[0014] Step 10: Transfer the converted medium flow velocity data to the velocity attribute of the UV material sphere of the pipeline 3D model to complete the control of the medium flow velocity of the pipeline 3D model by the pipeline flow velocity data provided by the system pipeline.

[0015] The beneficial effects of this invention are: it has the advantages of reusability, configurable parameters, and high calculation accuracy. It can perform length calculations based on a proportionally constructed 3D model, while also saving time and improving work efficiency, avoiding errors from manual calculations. Through pipeline length calculation and configurable UV animation material sphere flow velocity, it achieves the effect of simulating the realistic flow velocity of the medium in a virtual scene. Attached Figure Description

[0016] Figure 1 This is a flowchart of the pipeline medium flow rate control method based on Unity according to the present invention;

[0017] Figure 2 This is a shader script flowchart for constructing UV animation of pipeline medium flow in the ShaderGraph editor according to an embodiment of the present invention. Detailed Implementation

[0018] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0019] like Figure 1 As shown, a pipeline medium flow rate control method based on Unity includes the following steps:

[0020] Step 1: First, create a 3D model of the pipeline in 3ds Max according to the customer's requirements.

[0021] Step 2: Perform UV unwrapping on the completed 3D pipeline model.

[0022] Step 3: Import the constructed 3D pipeline model into the Unity project to provide a 3D model foundation for subsequent pipeline length calculations and 3D scene representation.

[0023] Step 4: Obtain the vertices of the 3D model of the pipeline using Unity scripts, and calculate the length of the 3D model of the pipeline using the vertices.

[0024] The steps for calculating the length of a 3D model of a pipeline using vertices are as follows:

[0025] A1. Obtain all vertices of the 3D model of the pipeline and form a vertex array.

[0026] A2. Traverse the vertex array of the 3D model of the pipeline, find the vertex that is called only once, and define the vertex that is called only once as the initial vertex.

[0027] A3. Starting from the initial vertex, traverse the vertex array to find all vertices adjacent to the current vertex, forming multiple triangles.

[0028] A4. For each triangle face obtained, the Cross method of the Vector3 vector class is used to input each vertex of the triangle face to calculate the Cross vector of the triangle face. Then, the normal vector of the triangle face is obtained through the normalized property of the Cross vector.

[0029] A5. Accumulate the normal vectors of all triangles adjacent to the current vertex, and divide by the number of triangles adjacent to the current vertex to obtain the average normal vector of the current vertex.

[0030] A6. By using the index of the current vertex in the vertex array, and taking advantage of the indexing properties of the vertex array, obtain the normal corresponding to the current vertex from the normals array in the mesh properties of the pipeline 3D model.

[0031] A7. Using the Angle method of the Vector3 vector class, obtain the angle between the normal corresponding to the current vertex and the average normal of the current vertex. This angle is the curvature of the vertex in the pipeline 3D model.

[0032] A8. When the curvature value of a vertex in the 3D model of the pipeline is greater than 10 degrees, record the vertex corresponding to the curvature value. This vertex is the vertex at the bend in the 3D model of the pipeline.

[0033] A9. Perform Euclidean distance calculation on the vertex coordinates of all bends in the 3D model of the pipeline to obtain the length of the 3D model of the pipeline.

[0034] Normally, the length data of a 3D pipeline model can be calculated and output by 3D modelers in 3D modeling software. However, with multiple 3D pipeline models, this process can be very labor-intensive for the project team. Therefore, using Unity scripts to perform this calculation can effectively save project time, improve work efficiency, greatly reduce calculation errors caused by manual calculations, and improve calculation accuracy.

[0035] Step 5: Receive flow velocity data from various measuring points in the system pipeline to provide data support for subsequent pipeline flow velocity measurements. The measuring point data format is shown in Table 1:

[0036] Table 1 Measurement Point Data Table

[0037] .

[0038] Step 6: Input the flow velocity data from the pipeline measuring points into the system, and unify the measurement units in the flow velocity data with the length measurement units of the pipeline 3D model to calculate the flow velocity of the medium through the pipeline 3D model.

[0039] For example, if the flow velocity data at the pipeline measuring point is 2 m / s, but the length unit of the pipeline 3D model is centimeters, then the flow velocity data at the pipeline measuring point needs to be multiplied by 100 to convert it to 200 cm / s; and 200 cm / s is used as the flow velocity of the medium in the pipeline 3D model.

[0040] The unit conversion process is not static. Developers can adjust the flow rate conversion algorithm according to the actual project needs to achieve the desired flow rate. Furthermore, the flow rate conversion process is globally unique. Therefore, by modifying this conversion process, the appearance of medium flow rate in all pipe 3D models within a Unity project can be uniformly adjusted, achieving flexible parameter configuration. For example, the normal conversion unit is 1 meter = 100 centimeters, but due to project requirements, a slower flow rate may be needed. In this case, the conversion can be adjusted to 1 meter = 150 centimeters or even lower. Specific adjustments can be made based on project needs.

[0041] In Unity projects, the standard unit in 3D space is the meter, while the unit of flow velocity data at various pipe measurement points in a system pipeline may be centimeters per second, meters per second, or even other units. Therefore, the adjustability of the unit conversion process can maximize the flexibility of flow velocity performance.

[0042] Step 7: Create a UV animation shader script for the pipeline medium flow in the ShaderGraph editor.

[0043] First, create a new shader script in your Unity project via the menu bar: Assets -> Create -> Shader Graph -> URP -> Little Shader Graph. Then, double-click the shader script, and the Unity project will automatically open it in the Shader Graph editor mode. Next, set this shader script as a fragment shader in the Shader Graph editor panel. Figure 2 Set the normal properties in the Shader Graph.

[0044] like Figure 2As shown, the Shader script flow for constructing the UV animation of pipeline medium flow in the ShaderGraph editor in this embodiment is as follows:

[0045] B1. Create a two-dimensional vector in the ShaderGraph editor to represent the flow velocity of the pipeline medium, providing a data interface for subsequent input of pipeline medium flow velocity data.

[0046] B2. In the ShaderGraph editor, call the Time function provided by ShaderGraph and get the time value from it. The unit of the time value is seconds.

[0047] B3. Use the multiplication function in the ShaderGraph editor to multiply the time value by the pipeline medium velocity property to obtain a two-dimensional vector. This two-dimensional vector represents the displacement in seconds.

[0048] B4. Create a Tiling And Offset function in the ShaderGraph editor, and assign the UV displacement to the Offset property of the Tiling And Offset function to perform UV displacement operation on the 3D model of the pipeline. Then, obtain the UV coordinate information after displacement through the Out property of the Tiling And Offset function.

[0049] B5. Create a texture map in the ShaderGraph editor to provide a data interface for subsequent texture maps that represent the medium.

[0050] B6. In the ShaderGraph editor, create a SampleTexture2D function and assign the texture map and the UV information after displacement to the texture and UV properties of the SampleTexture2D function respectively to obtain a texture map with UV displacement animation properties.

[0051] B7. Assign the texture map with UV displacement animation properties to the normal property of the fragment shader, thus creating a shader script with UV animation of pipeline medium flow.

[0052] Step 8: In the Unity project, right-click on the Shader script and select the Create Material operation to export the Shader script with the UV animation of the pipeline medium flow as a UV material sphere.

[0053] The construction of the UV animation material sphere (where the UV material sphere provides a "flow rate" attribute) can adjust the amount of displacement of the texture map in seconds based on the change of the flow rate attribute value, thereby affecting the visual appearance of the flow rate of the UV animation material sphere.

[0054] Step 9: Assign the UV material sphere to the 3D model of the pipeline in the Unity project.

[0055] Drag the created UV material sphere to the Material property of the pipeline 3D model in the Unity project to complete the UV material assignment operation for the pipeline 3D model.

[0056] Step 10: Transfer the converted medium flow velocity data to the velocity attribute of the UV material sphere of the pipeline 3D model to complete the control of the medium flow velocity of the pipeline 3D model by the pipeline flow velocity data provided by the system pipeline.

[0057] This method uses Unity scripts to parse the mesh data of the pipeline 3D model, extracts vertex data and face data from the mesh data, and then uses the curvature algorithm to obtain all vertices at the bends in the pipeline 3D model. The length of the pipeline 3D model is obtained by calculating the Euclidean distance between the coordinates of the vertices at each bend in the pipeline 3D model.

[0058] By receiving pipeline flow velocity data from the system pipeline, converting the units of the flow velocity data to the units of the pipeline 3D model length, the medium flow velocity in the pipeline 3D model is obtained. The converted medium flow velocity data is then transmitted to the velocity attribute of the UV material sphere of the pipeline 3D model, thereby realizing the control of the medium flow velocity in the pipeline 3D model by the pipeline flow velocity data provided by the system pipeline.

[0059] This method first constructs a 1:1 scale 3D model of the system pipeline, and the system can provide flow velocity sensor data for each pipeline. Based on this, it utilizes the length calculation of the 3D pipeline model, the conversion between the system pipeline flow velocity data unit and the 3D pipeline model length unit, and a UV material sphere with media flow animation to form a technique for simulating and controlling the flow velocity of the media in the 3D pipeline model in a virtual scene.

Claims

1. A pipeline medium flow rate control method based on Unity, characterized in that, The method comprises the following steps: Step 1: First, create a 3D model of the pipeline; Step 2: Perform UV unwrapping on the completed 3D pipeline model; Step 3: Import the constructed 3D pipeline model into the Unity project to provide a 3D model foundation for subsequent pipeline length calculations and 3D scene representation; Step 4: Obtain the vertices of the 3D model of the pipeline using Unity scripts, and calculate the length of the 3D model of the pipeline using the vertices; Step 5: Receive flow velocity data from various pipeline measuring points in the system pipeline to provide data support for subsequent pipeline flow velocity measurements; Step 6: Input the flow velocity data from the pipeline measuring points into the system, and unify the measurement units in the flow velocity data with the length measurement units of the pipeline 3D model to calculate the flow velocity of the medium through the pipeline 3D model. Step 7: Create a UV animation shader script for the pipeline medium flow in the ShaderGraph editor; Step 8: In the Unity project, right-click on the Shader script and select the Create Material operation to export the Shader script with the UV animation of the pipeline medium flow as a UV material sphere. Step 9: Assign the UV material sphere to the 3D model of the pipeline in the Unity project; Step 10: Transfer the converted medium flow velocity data to the velocity attribute of the UV material sphere of the pipeline 3D model to complete the control of the medium flow velocity of the pipeline 3D model by the pipeline flow velocity data provided by the system pipeline. In step four, the steps for calculating the length of the 3D model of the pipeline using vertices are as follows: A1. Obtain all vertices of the 3D model of the pipeline and form a vertex array; A2. Traverse the vertex array of the 3D model of the pipeline, find the vertex that is called only once, and define the vertex that is called only once as the initial vertex; A3. Starting from the initial vertex, traverse the vertex array to find all vertices adjacent to the current vertex, forming multiple triangles; A4. For each triangle face obtained, the Cross method of the Vector3 vector class is used to input each vertex of the triangle face to calculate the Cross vector of the triangle face. Then, the normal vector of the triangle face is obtained through the normalized property of the Cross vector. A5. Accumulate the normal vectors of all triangles adjacent to the current vertex, and divide by the number of triangles adjacent to the current vertex to obtain the average normal vector of the current vertex. A6. By using the index of the current vertex in the vertex array, and taking advantage of the indexing properties of the vertex array, obtain the normal corresponding to the current vertex from the normals array in the mesh properties of the pipeline 3D model; A7. Using the Angle method of the Vector3 vector class, obtain the angle between the normal corresponding to the current vertex and the average normal of the current vertex. This angle is the curvature of the vertex in the pipeline 3D model. A8. When the curvature value of a vertex in the 3D model of the pipeline is greater than 10 degrees, record the vertex corresponding to the curvature value. This vertex is the vertex at the bend in the 3D model of the pipeline. A9. Perform Euclidean distance calculation on the vertex coordinates of all bends in the 3D model of the pipeline to obtain the length of the 3D model of the pipeline.

2. The pipeline medium flow rate control method based on Unity according to claim 1, characterized in that, In step seven, the shader script flow for building the UV animation of the pipeline medium flow in the ShaderGraph editor is as follows: B1. Create a two-dimensional vector in the ShaderGraph editor to represent the flow velocity of the pipeline medium, providing a data interface for subsequent input of pipeline medium flow velocity data; B2. Use the ShaderGraph editor to call the Time function provided by ShaderGraph and obtain the time value from it; B3. Use the multiplication function in the ShaderGraph editor to multiply the time value by the pipeline medium velocity property to obtain a two-dimensional vector, which represents the displacement in seconds. B4. Create a Tiling And Offset function in the ShaderGraph editor, and assign the UV displacement to the Offset property of the Tiling And Offset function to realize the UV displacement operation of the pipeline 3D model. Then, obtain the UV coordinate information after displacement through the Out property of the Tiling And Offset function. B5. Create a texture map in the ShaderGraph editor to provide a data interface for the texture map of the subsequent medium representation; B6. Create a SampleTexture2D function in the ShaderGraph editor, and assign the texture map and the UV information after displacement to the texture property and UV property of the SampleTexture2D function respectively to obtain a texture map with UV displacement animation properties. B7. Assign the texture map with UV displacement animation properties to the normal property of the fragment shader, thus creating a shader script with UV animation of pipeline medium flow.

Citation Information

Patent Citations

  • Method for realizing dynamic simulation of fluid characteristics in three-dimensional pipeline based on shader

    CN118334224A