[0030] In order to make the object, technical solution, and advantages of the present invention clearer, the present invention will be further described in detail in conjunction with the following examples. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not constitute a conflict with each other. Apparently, the described embodiments are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of this application.
[0031] A Unity-based method for simulating oil flow in a hydraulic circuit pipeline. In specific implementation, the above method includes two aspects: constructing a hydraulic circuit and simulating oil movement.
[0032] In the first aspect, construct the hydraulic circuit.
[0033] (1) Carry out modeling of circuit components, convert formats, and import into Unity
[0034] Use SolidWorks software for 3D modeling, including circuit components such as gear oil pumps, relief valves, throttle valves, cylinders, pipes, and fittings.
[0035] Import the model built by SolidWorks software into 3ds Max software. Since the export format of the model built in SolidWorks is STEP, and Unity is not effectively compatible with the 3D model in this format, 3ds Max is used as the intermediate software for format conversion. SolidWorks outputs STEP format software, imports it into 3ds Max, and converts it to the FBX format compatible with Unity.
[0036] Convert the established 3D model into Unity3D, use the resources imported into the Unity platform and the built-in model of the platform to design and build scenes for hydraulic circuits, and set different shader parameters according to different models.
[0037] (2) Model optimization and scene rendering
[0038] Add lights and textures to the scene for rendering.
[0039] Design and make a GUI page in Unity, create a new Panel (drawing board component), name it MainPanel,
[0040] This MainPanel is the main carrier of the entire GUI page, and all the production processes are completed on it.
[0041] Add Button (button) components, Text (text components) and Slider (slider components) on the MainPanel page, and name them accurately and standardizedly. The added components can be arranged in a certain logical order.
[0042] Create a new Empty (blank) component in the MainPanel and rename it to All. This component is mainly used for the construction of hydraulic circuits and the design of oil movement. Adjust the size of the Empty (blank) component to make it a suitable display size. .
[0043] (3) After building the explanation scene, add a circuit diagram button and write a script to realize the function;
[0044] Create four new 3D Object Cubes (cubes) in the empty object All, and name them Cube1, Cube2, Cube3, and Cube4 in turn. These four three-dimensional graphics are positioning bodies for subsequent dragging of hydraulic components, which facilitates subsequent dragging operations and subsequent identification of dragging actions.
[0045] First, set two identical models for each part, and drag and drop them directly from the project interface to the scene interface. One of them has BoxColider and the other one doesn't.
[0046] A rigid body component is added to the part with BoxColider, and the script ModelsPosChange is added. This script has two functions, the first is dragging, and the second is trigger detection. The drag and drop function is to follow the mouse movement, and the corresponding mouse ray detection must have a BoxColider collider, so if there is no BoxColider model, it will always be in place.
[0047] The trigger detection function is to trigger the corresponding object to hide the current object and display another object. The final effect is that when the dragged object touches its corresponding position, a correct model will be generated at that position. Trigger detection is judged according to the Tag label.
[0048] (5) After the parts are set up, place them in order to form a hydraulic circuit diagram
[0049] Since the position placement of each hydraulic component is fixed and unique, each component must be given a corresponding coordinate point and a corresponding positioning point. If the appropriate coordinate point is reached, the model can be automatically absorbed to the anchor point.
[0050] Hydraulic components and connecting each hydraulic component through pipe joints and oil pipes form a complete throttling and speed regulating circuit. So far, the construction of the hydraulic circuit has been completed.
[0051] The second aspect is to simulate oil movement.
[0052] After building the hydraulic circuit, the next step is to simulate the flow of oil through the pipes.
[0053] Since the hydraulic circuit is a three-dimensional pipeline, which contains coordinates in the three directions of X, Y, and Z, the movement of oil in the pipeline can also be called the movement in three-dimensional space, so some key points can be located by fixed-point marking , transforming motion in three-dimensional space into motion in a two-dimensional plane.
[0054] At the corners of hydraulic components and pipelines, there is often a change in coordinates in one direction or even in two directions. Therefore, a mark point is taken at these coordinate conversion positions, and a total of 24 mark points are taken. There is a distance between each two mark points. There is only one coordinate axis change, and it only needs to be carried out along a straight line.
[0055] Therefore, the oil movement in the oil circuit is realized by the slow movement of the small ball in the oil pipe, as follows:
[0056] (1) Use the lambda expression to register the button event;
[0057] (2) There are a lot of small balls moving slowly in the oil circuit, use the control script GameManager to control the generation of small balls;
[0058] (3) Control the movement of the oil circuit.
[0059] In the event of the "oil movement" button, the expression of the button is mainly realized through the singleton mode. Several variables inside are called to control the movement of the oil circuit, so that the button click and the movement of the ball can be highly decoupled without interfering with each other. Two small balls are generated each time, and each small ball has an array path. Each small ball is hung with a SphereManager script, which is generated in the GameManager. After generation, it will automatically move according to the above two arrays.
[0060] In the constant pressure throttling and speed regulating circuit, the flow cross-sectional area of the throttle valve will control the speed of the oil moving in the oil circuit.
[0061] In order to intuitively reflect the working principle of the throttling speed regulating circuit, a tie bar is added to control the flow cross-sectional area of the throttle valve in the throttling speed regulating circuit, so as to control the speed of oil moving in the oil circuit.
[0062] First, add two UIs in the Main2Panel interface under the original Canvas; the first one is Text, which is used to display the text of the slider, and the second is a Slider slider, which is used to reflect the change of the flow cutoff of the throttle valve. The change of oil velocity after the area. After adding these two UI objects, add a script control object to realize the function. The added script is in the Main2PanelManager script above the parent object Main2Panel of the slider.
[0063] The product of this teaching design is released on the PC side, and the product is released when there is no problem after debugging.
[0064] First click on the File menu and select the Build Settings menu command. Click the Add Current button to add the current scene. Then select PC in the Platform (template), then select the Windows platform in the right interface, and finally click the Build button to select the folder where the released product is located to implement the release.
[0065] The above description only expresses the preferred implementation of the present invention, and the description thereof is relatively specific and detailed, but should not be construed as limiting the patent scope of the present invention. It should be noted that those skilled in the art can make several modifications, improvements and substitutions without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.