Automatic cutting method and system for 3D model in VR environment

By constructing a planar mesh and drawing a circular cutting size in a VR environment, generating the object's motion trajectory and converting it into vertices of a planar geometric shape, and determining the cutting and clipping area, the real-time and realism issues of 3D model cutting in existing technologies are solved, and the simulation process of dynamic cutting models is realized.

CN116168183BActive Publication Date: 2026-03-10JIANGXI KMAX IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-27
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing technologies cannot achieve real-time 3D model cutting, external contour cutting, and internal pattern drawing in VR environments, resulting in poor real-time performance and realism of simulation content, failing to meet the requirements of high real-time performance and high realism.

Method used

By constructing a planar mesh in a VR environment, drawing the circular cutting size, generating the object's motion trajectory, converting it into the vertices of a planar geometric figure, determining the cutting and trimming area, and performing internal shaping and outer contour cutting, the simulation process of a dynamic cutting model is realized.

Benefits of technology

It enables real-time slicing of 3D models and drawing of slicing patterns, improving the real-time performance and realism of simulation content in VR environments, and meeting the requirements of high real-time performance and high realism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116168183B_ABST
    Figure CN116168183B_ABST
Patent Text Reader

Abstract

The application discloses a kind of automatic cutting method and system of 3D model in VR environment, and the method steps include: constructing plane grid in VR environment and combining splicing to form the 3D model drawing board of specified size;Draw circular cutting size, as the minimum cutting size in cutting operation path;According to circular cutting size, cutting is carried out, and multiple path points are generated until the motion trajectory forms closed graph;Motion trajectory is converted into the vertex of plane geometric figure;According to the vertex of plane geometric figure obtained by conversion, the cutting clipping area is determined;When internal shaping cutting is carried out, according to the cutting of each path point generated on 3D model drawing board;When outer contour cutting is carried out, according to the cutting of determined cutting clipping area on 3D model drawing board, the cutting of final target model is completed.The application has the advantages of simple implementation method, high real-time and authenticity, strong flexibility, can present dynamic cutting model simulation process and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of VR environment virtual simulation content production technology, and in particular to an automatic cutting method and system for 3D models in a VR environment. Background Technology

[0002] When creating content in a VR environment, it's typically based on planar mesh cutting. OpenGL programming rules and clipping algorithms are used to calculate the number of windings to achieve polygon offset, simulating the cutting and shaping of 3D models, and ultimately achieving simulated CNC cutting. Currently, virtual simulation content creation in VR environments usually uses pre-made 3D models to represent the virtual simulation content. However, different scenarios have different 3D model requirements. To meet these diverse needs, a large number of 3D models need to be built, resulting in long processing times and poor real-time performance. Furthermore, directly using pre-made models also suffers from a lack of process visualization and poor synchronization, failing to meet the current requirements for high real-time performance and high realism in simulation content. For example, in CNC cutting, most current methods use pre-made simulation equipment models. The simulation results are simply displayed as the finished product model, failing to show the model's transformation process, thus lacking the realism of the simulation.

[0003] In existing technologies, the cutting of 3D models typically involves a simple bi-splitting method (such as...). Figure 1 As shown in (a), or surface cutting can be performed using a CSG Boolean operation-based cutting method (such as...). Figure 1 (As shown in (b)). However, the one-to-two cutting method is limited in function, and can only simply divide the model into two parts, and cannot perform multiple cuts; while the surface cutting based on CSG Boolean operations also cannot be performed multiple times for the same mesh, otherwise the mesh will break, and the graphics cannot be too complex, so it is impossible to achieve real-time cutting of 3D models, etc.

[0004] In summary, existing technologies cannot achieve real-time cutting of 3D models, cutting of external contours, and drawing of internal patterns in the process of developing virtual simulation applications for CNC cutting in VR environments. In other words, they cannot display or realize the simulation process of dynamic cutting models. Summary of the Invention

[0005] The technical problem to be solved by this invention is: in view of the technical problems existing in the prior art, this invention provides an automatic cutting method and system for 3D models in a VR environment that is simple to implement, real-time, highly realistic and flexible, and can realize the real-time cutting of 3D models, the cutting of external contours and the drawing of internal patterns, thereby realizing the dynamic cutting model simulation process.

[0006] To solve the above-mentioned technical problems, the technical solution proposed by this invention is as follows:

[0007] An automatic slicing method for 3D models in a VR environment, comprising the following steps:

[0008] Construct planar meshes in a VR environment and combine and stitch them together to form a 3D model canvas of a specified size;

[0009] Draw a circular cut size to serve as the minimum cut size in the cutting path;

[0010] Cut according to the circular cutting size to generate multiple path points until the object's movement trajectory formed by each path point forms a closed shape;

[0011] The trajectory of the object's motion is converted into vertices of a planar geometric figure;

[0012] The cutting and trimming region is determined based on the vertices of the transformed planar geometry;

[0013] When performing internal shaping and cutting, the cutting is carried out on the 3D model canvas according to the generated path points;

[0014] When cutting the outer contour, the cutting is performed on the 3D model drawing board according to the determined cutting area to complete the cutting of the final target model.

[0015] Furthermore, the step of cutting according to the drawn circular cutting size to generate multiple path points until the motion trajectory formed by each path point constitutes a closed shape includes:

[0016] Configure a coroutine function. During the process of cutting according to the circular cutting size, the coroutine function loops and stores the object position information points corresponding to each frame as the path points when it finishes the final stage of each frame.

[0017] The system iterates through the stored location information of each path point. If the first path point and the last path point coincide or the error is less than the size of the circular cut, the path point generation is considered complete, forming a closed object movement trajectory.

[0018] Furthermore, the vertices of the object's motion trajectory converted into a planar geometric figure include:

[0019] The dividing point is determined based on the distance between all path points of the object's motion trajectory and the grid boundary. Multiple path points are constructed from the dividing point to form a dividing extension line to form a closed geometric shape from the cut shape.

[0020] Based on the object's trajectory and the geometric area enclosed by the path points along the extension line, determine the vertices of the required planar geometric figure.

[0021] Furthermore, the step of forming the dividing extension line includes:

[0022] The path point with the largest Y-axis value among all path points of the object's motion trajectory is used as the dividing point;

[0023] Calculate the shortest distance from the dividing point to the grid boundary;

[0024] Between the shortest distance extended from the dividing point in the positive Y-axis direction, multiple path points are calculated at specified intervals to obtain path points in the positive direction of the dividing extension line;

[0025] Based on the path points in the positive direction of the extended segmentation line, the path points in the opposite direction are obtained, thus obtaining the path points in the opposite direction of the extended segmentation line.

[0026] Connect the extended dividing lines from the positive direction to the negative direction to form a closed shape.

[0027] Furthermore, determining the cutting and clipping region based on the vertices of the converted planar geometry includes: detecting the clipping range based on the vertices of the planar geometry, and calling a polygon clipping algorithm to determine the final cutting and clipping region.

[0028] Furthermore, when the polygon clipping algorithm is invoked, a positive wrapping rule is used, that is, only regions with a positive wrapping number are classified as inside the polygon. The positive wrapping rule is used to clean up overlapping and / or self-intersecting polygons in the preprocessing step.

[0029] Further, step S02 includes: defining the radius R of the circle and the number of segments N; calculating the angle using a predefined degree-to-radian function; calculating and storing the plane vertex based on the calculated angle, wherein the angle Angle of the i-th segment is specifically calculated according to Angle = Mathf.Deg2Rad*(-90f-360f / N*i), where Mathf.Deg2Rad represents the degree-to-radian function, i = 0, 1, ..., N, and the plane vertex is calculated according to the formula plane vertex = new Vector2(R*Mathf.Cos(Angle),R*Mathf.Sin(Angle)), where Mathf.Cos represents the cosine function, Mathf.Sin represents the sine function, and Vector2 represents a two-dimensional vector.

[0030] Furthermore, the construction of the planar mesh in step S01 includes: performing initialization definition, using an instantiation function to construct a polyhedral mesh through vertices and triangular faces, storing the vertex data of each mesh, and combining and splicing the meshes to form the 3D model canvas. The initialization definition includes defining any of the following: the size of the unit mesh, the edge list, the vertex data type of the cell, the initialization mesh, and the block class for updating the mesh.

[0031] An automatic cutting system for 3D models in a VR environment includes a processor and a memory, wherein the memory is used to store a computer program and the processor is used to execute the computer program to perform the method described above.

[0032] A computer-readable storage medium storing a computer program that, when executed, implements the method described above.

[0033] Compared with existing technologies, the advantages of this invention are as follows: This invention draws a planar grid on a plane to splice and combine it into a 3D model drawing board, then performs real-time cutting with the minimum circular cutting size to form the object's motion trajectory, and then determines the cutting area by converting the object's motion trajectory into the vertices of the planar geometric figure. Finally, it performs internal shaping cutting according to the trajectory and external contour cutting according to the cutting area, thus completing the cutting of the target model. It can quickly and accurately realize real-time cutting of the model and drawing of cutting patterns according to the motion trajectory when simulating CNC cutting in a VR environment, thereby efficiently realizing the simulation process of dynamic cutting model and effectively achieving the cutting simulation effect in the CNC cutting process. Attached Figure Description

[0034] Figure 1 These are schematic diagrams illustrating the effects of two traditional cutting methods.

[0035] Figure 2 This is a schematic diagram illustrating the implementation process of the automatic cutting method for 3D models in the VR environment in this embodiment.

[0036] Figure 3 This is a schematic diagram illustrating the specific process of automatic 3D model cutting in a VR environment in a specific application embodiment of the present invention.

[0037] Figure 4 This is a schematic diagram illustrating the process of building a 3D model canvas in Unity in a specific application embodiment of the present invention.

[0038] Figure 5 This is a schematic diagram of the 3D model drawing board effect constructed in a specific application embodiment of the present invention.

[0039] Figure 6 This is a schematic diagram illustrating the effect of generating an object's motion trajectory in a specific application embodiment of the present invention.

[0040] Figure 7 This is a schematic diagram illustrating the effect of generating segmentation extension lines in a specific application embodiment of the present invention.

[0041] Figure 8 This is a schematic diagram illustrating the effect of cutting based on planar geometry detection boundaries in a specific application embodiment of the present invention.

[0042] Figure 9 This is a schematic diagram illustrating the effect of motion trajectory cutting in CNC cutting in a specific application embodiment.

[0043] Figure 10 This is a schematic diagram of the simple outer contour cutting effect obtained in a specific application embodiment.

[0044] Figure 11 This is a schematic diagram of the complex outer contour cutting effect obtained in a specific application embodiment.

[0045] Figure 12 This is a schematic diagram of the internal cutting effect obtained in a specific application embodiment. Detailed Implementation

[0046] The present invention will be further described below with reference to the accompanying drawings and specific preferred embodiments, but this does not limit the scope of protection of the present invention.

[0047] like Figure 1 As shown, the steps of the automatic slicing method for 3D models in a VR environment in this embodiment include:

[0048] S01. Construct a planar mesh in the VR environment and combine and stitch it together to form a 3D model canvas of a specified size;

[0049] S02. Draw the circular cutting size as the minimum cutting size in the cutting path;

[0050] S03. Cut according to the size of the circle, generating multiple path points until the motion trajectory formed by each path point forms a closed shape;

[0051] S04. Convert the motion trajectory into vertices of a planar geometric figure;

[0052] S05. Determine the cutting and trimming region based on the vertices of the transformed planar geometric figure;

[0053] S06. When performing internal shaping and cutting, cut on the 3D model canvas according to the generated path points;

[0054] S07. When cutting the outer contour, cut on the 3D model drawing board according to the determined cutting area to complete the cutting of the final target model.

[0055] This embodiment draws a planar mesh on a plane to create a 3D model canvas. Then, it performs real-time cutting using the smallest circular cutting size to form the object's motion trajectory. By converting the object's motion trajectory into vertices of a planar geometric shape, the cutting and trimming area is determined. Finally, internal shaping cutting is performed according to the trajectory, and external contour cutting is performed according to the cutting and trimming area to complete the cutting of the target model. This allows for rapid and accurate real-time cutting and pattern drawing of the model based on the motion trajectory during CNC cutting simulation in a VR environment. This efficiently simulates the dynamic cutting process of the model and achieves the cutting simulation effect of CNC cutting.

[0056] In this embodiment, the construction of the planar mesh in step S01 specifically includes: performing initialization definition, using an instantiation function to construct a polyhedral mesh through vertices and triangular faces, storing the vertex data of each mesh, and combining and splicing the meshes to form a 3D model canvas. The above initialization definition specifically includes defining the size of the cell mesh, the edge list, the vertex data type of the cell, the block class for initializing and updating the mesh, etc., and the specific definitions can be selected according to actual needs.

[0057] After constructing the 3D model in the VR environment, it is necessary to determine the minimum cutting size in the cutting path. In this embodiment, a circular cutting size is drawn as the minimum cutting size in the running path. In this embodiment, the specific steps of drawing the circular cutting size in step S02 include:

[0058] S201. Define the radius R of the circle and the number of segments N;

[0059] S202. Calculate the angle using a predefined degree-to-radian function, that is, convert degrees to radians;

[0060] S203. Calculate and store the plane vertices based on the calculated angles.

[0061] In a specific application embodiment, the angle Angle of the i-th segment can be calculated according to the following formula (1):

[0062] Angle= Mathf.Deg2Rad * (-90f - 360f / N* i) (1)

[0063] Where Mathf.Deg2Rad represents the degree-to-radian conversion function, i = 0, 1, ..., N.

[0064] The specific vertex of the plane can be calculated according to the following formula (2):

[0065] Plane vertex = new Vector2(R*Mathf.Cos(Angle)R*Mathf.Sin(Angle))(2)

[0066] Here, Mathf.Cos represents the cosine function, Mathf.Sin represents the sine function, and Vector2 represents a two-dimensional vector.

[0067] In this embodiment, step S03 involves cutting according to the drawn circular cutting size to generate multiple path points until the motion trajectory formed by each path point creates a closed shape. The specific steps include:

[0068] S301. Path point generation: Configure a coroutine function. During the process of cutting according to the circular cutting size, the coroutine function loops and stores the object position information points corresponding to each frame as path points after the final stage of each frame is completed.

[0069] S302. End judgment: Traverse the stored position information of each path point. If the first path point and the last path point coincide or the error is less than the size of the circular cut, then the path point generation is completed, forming a closed object movement trajectory.

[0070] In the above steps of this embodiment, a series of path points are obtained by cyclically storing the object's position information. The process ends when the first and last path points coincide or the distance is less than the size of the circular cutting, thus forming the object's motion trajectory. This allows the object to be cut in real time using its motion trajectory.

[0071] In this embodiment, step S04, which converts the object's motion trajectory into vertices of a planar geometric figure, includes the following specific steps:

[0072] S401. Determine the dividing point based on the distance between all path points of the object's trajectory and the grid boundary. Starting from the dividing point, construct multiple path points to form a dividing extension line to form a closed geometric shape from the cut shape.

[0073] S402. Based on the trajectory of the object's motion and the range of the geometric figure enclosed by each path point on the extended dividing line, determine the vertices of the required planar geometric figure.

[0074] In this embodiment, the step S401 of forming the dividing extension line specifically includes:

[0075] S411. Obtain the path point with the largest Y-axis value among all path points of the object's motion trajectory and use it as the dividing point;

[0076] S412. Calculate the shortest distance S from the dividing point to the grid boundary;

[0077] S413. Calculate multiple path points at specified intervals between the shortest distances extended from the dividing point in the positive Y-axis direction to obtain the path points in the positive direction of the dividing extension line;

[0078] S414. Obtain the path points in the opposite direction based on the path points in the positive direction of the extension line of the segmentation, and thus obtain the path points in the opposite direction of the extension line of the segmentation.

[0079] S415. Connect the extension lines of the dividing line from the positive direction to the negative direction to form a closed figure.

[0080] Assuming the coordinates of the path point with the largest Y-axis among all path points of the motion trajectory are (X, Y), then after calculating the shortest distance S, the coordinates of the grid boundary point at the shortest distance S are (X, Y+S). The path point from the path point with the largest Y-axis to the grid boundary point at the shortest distance S (i.e., Y to S) is the required dividing extension line. By obtaining the path points in the positive and negative directions of the dividing extension line, and then connecting the beginning and end, a closed figure can be formed.

[0081] In this embodiment, step S05, determining the cutting and clipping region based on the vertices of the converted planar geometry, specifically includes: detecting the clipping range based on the vertices of the planar geometry, and calling a polygon clipping algorithm to determine the final cutting and clipping region. Assuming that the lowest point on the y-axis of the boundary of the planar geometry obtained in step S04 is H1, the highest point is H2, and the minimum x-axis point is X1, and the maximum x-axis point is X2, calling the polygon clipping algorithm based on this boundary range can achieve cutting and clipping within the specified range. Based on OpenGL's winding rules, this embodiment uses an algorithm for calculating offset polygons through winding, which can achieve fast and accurate cutting with a space complexity of only O(n+k) and a runtime of O((n+k)logn), where n is the number of input vertices, k is the number of self-intersections in the original offset curve, and logn is a logarithm. It also provides significant scalability and is applicable to inputs with multiple overlaps and self-intersecting polygons with arbitrary holes.

[0082] In this embodiment, the cutting direction of the mesh is the direction of the object's movement, following the polygon filling wrapping rules: even, odd, and non-zero (such as GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32). Other rules include positive values, negative values, and ABS_GTR_EQ_TWO (only in OpenGL). The polygon offset specifically follows:

[0083]

[0084] Where ω is the number of wraps, ψ is the return value, p represents the polygon, Rq is any ray from q, and e1 and e2 are two sides in polygon P. If a ray intersects e1 and e2 in polygon P, their contribution to the number of wraps at point q is +1 (or -1).

[0085] This embodiment defines a category, such as odd, non-zero, positive, negative, or "absolute value greater than or equal to 2," to classify a region as inside or outside by using a winding rule. If the calculated number of wraps in a region belongs to the selected category, it is classified as inside. In OpenGL, the following rules can be used: GLU.TESS-WINDING-ODD, and the winding rules GLU TESSWinding ODD and GLU TES Winding NONTZERO are commonly used in polygon filling procedures (only filling regions classified as inside). Winding rules can be used to implement CSG Boolean operations, such as union, difference, and intersection of contours. This embodiment specifically uses the winding rule GLU TESS winding ABS GEQ TWO to obtain the intersection point of two contours, and uses a positive winding rule: only regions with a positive number of wraps are classified as polygon inside. Any overlapping and / or self-intersecting polygons are first cleaned up in the preprocessing step using the positive winding rule.

[0086] In this embodiment, steps S06 and S07 can be implemented by defining enumeration types OutCut (contour cutting) and InsideCut (internal shaping). If it is internal cutting, the cutting is performed directly according to the stored path points. If it is external contour cutting, the geometric shape determined in step S05 is called to complete the final cutting using the multi-shape cutting algorithm.

[0087] Taking Unity as an example, Unity simulates CNC cutting by cutting a pre-set model, which cannot meet the need for real-time cutting of the target model according to actual requirements. Applying the method described in this invention to Unity, by creating a 3D model from a planar mesh, and then drawing the cutting shape and size according to the planar geometry to form the required target model, the need for real-time cutting of the target model can be achieved. Figure 3 As shown, this embodiment utilizes the Bala Vatti clipping algorithm to extend the rules, and the detailed steps for implementing 3D model cutting in Unity are as follows:

[0088] S01. Construct a planar mesh in the VR environment and combine and stitch it together to form a 3D model canvas of a specified size.

[0089] like Figure 4 As shown, first create a Unity project, then import the polygon clipping algorithm script needed later, and then instantiate the mesh canvas, entering the following definition:

[0090] (1) Define the size of the cell grid as blockSize using the float data type, define the length (With) and width (Height) of the cell grid using the int data type, define the depth of the composite model using the float data type, and define blockSizeScaled using the int64 data type. This gives the canvas width = blockSize * With and the canvas length = blockSize * Height. blockSizeScaled = (int64)(blockSize * VectorEx.float2int64); VectorEx.float2int64 is a global static float data set, defined here as 100000.0f.

[0091] (2) Define the edge list (edgesList) data type as List <List <vector2>>

[0092] (3) Define the vertices data of the cell, with the data type List. <vector2i>Vector2i is the ClipperLib.IntPoint constructor in the "Polygon Clipping Algorithm", which can convert two points on a plane into int64 data.

[0093] (4) Define the polygon data type as List <List <vector2i>>

[0094] (5) Define a block class, on which all unit meshes are attached, for initializing and updating the mesh. The method of updating the mesh by filling vertices is as follows: construct a planar mesh by receiving parameters of polygons, height, width, and depth. The planar mesh is divided into edge polygons and internal polygons.

[0095] (6) Using Unity's instantiation functions, construct a polyhedral mesh using vertices and triangles (e.g., Figure 5 As shown in (a), the vertex data of each mesh is stored, and then the meshes are stitched together to form a 3D model, as shown in (a). Figure 5 As shown in (b).

[0096] S02. Draw the circular cut size as the minimum cut size in the cut path.

[0097] Define the radius R of the circle, the number of segments N, and define a List. <vector2i>`vertices` is used to store vertices, and a float data type variable `Angle` is defined. The variable `Angle` is incremented by an integer data type `i` by looping from 0 to N. The angle `Angle` is calculated using the function `Mathf.Deg2Rad` (a constant for converting degrees to radians): `Mathf.Deg2Rad * (-90f - 360f / N * i)`. Then, the angle of the plane vertex is calculated as `new Vector2(R * Mathf.Cos(Angle), R * Mathf.Sin(Angle))`. Finally, the plane vertex is converted to `Vector2i` and stored in `vertices`.

[0098] S03. Generate path points: Cut according to the size of the circular cut to generate multiple path points until the object's trajectory formed by the path points forms a closed shape.

[0099] Constructing a coroutine function: Define a List within the function using a loop. <vector3>Used to store object position information. After the function yield return new WaitForEndOfFrame (meaning execution at the last stage of a frame) is executed, the object's position is stored (based on the object's basic property Transform's position, where position is Vector3 data and Transform is a common basic property for all objects).

[0100] To determine completion: iterate through all the location information of the stored path points. The process is complete when the first and last path points coincide or the error is less than the size of the circular cut. The List... <vector3>When storing the object's position information, the object's `position.z` property is ignored. In a specific application example, the resulting object motion trajectory is as follows: Figure 6 As shown in (a), Figure 6 In the middle (b), the path is cut at the smallest cutting unit during the motion.

[0101] S04. Convert the trajectory of an object's motion into the vertices of a planar geometric figure.

[0102] S401. Generate dividing extension lines: Obtain the maximum value of the Y-axis in all paths as the dividing line. If there are multiple maximum points, select any one of them. Calculate the shortest distance from the point to the grid boundary to form a closed geometry of the object's outer contour based on the object's motion trajectory. Calculate the path points of the line segments according to the specified intervals, and then use the Reverse() method of the list to get the points in the opposite direction.

[0103] In this embodiment, when calculating the spacing path points, the shortest distance is set to Y, and the spacing between each point is set to M. Then the number of path points is n = y / m. The path point data of the closed figure hypothesis is obtained by passing through these path points and the points in the opposite direction.

[0104] In this embodiment, when calculating the extension line segmentation, a variable maxY of data type float can be defined, and a list storing all paths can be iterated through in a loop. <vector3>The list can be obtained by using the Math.max function (which returns the larger of two integers), resulting in maxY = Math.Max(maxY, list collection element.y).

[0105] In a specific application example, the segmentation extension line is generated as follows: Figure 7 As shown, (a) corresponds to the effect of generating the extension line of the segment, and (b) corresponds to forming a closed shape through the extension line of the segment, where the arrow direction is the trajectory direction.

[0106] S402. Sort the trajectory of an object from the beginning to the end of the time position based on the object's motion trajectory.

[0107] Because of list <vector3>The list is stored according to the path, so it does not need to be sorted. However, the extensions need to be stored separately and then connected head to head to form a closed figure. Finally, the range of the geometric figure enclosed by the path points is calculated.

[0108] S05. Determine the cutting and trimming region based on the vertices of the transformed planar geometric figure.

[0109] Detection of cutting range:

[0110] In step S04, the boundary of the geometric area is defined with the lowest point H1 on the y-axis, the highest point H2, the minimum point X1 on the x-axis, and the maximum point X2. This is then obtained by iterating through all path points.

[0111] X1 = Math.Min(X1, path point.x);

[0112] X2 = Math.Max(maxx, pathpoint.x);

[0113] H1 = Math.Min(minY, pathpoint.y);

[0114] H2 = Math.Max(maxY, pathpoint.y);

[0115] By defining the lowest point (lowerPoint) and the highest point (upperPoint) of the data type vector2, we can derive:

[0116] lowerPoint=new Vector2(X1,H1);

[0117] upperPoint=new Vector2(X2,H2);

[0118] Define variables x1, x2, y1, and y2 of data type int;

[0119] x1=Mathf.Max(0,(int)(lowerPoint.x / blockSize));

[0120] x2 = Mathf.Min(grid canvas width - 1, (int)(upperPoint.x / blockSize));

[0121] y1=Mathf.Max(0,(int)(lowerPoint.y / blockSize));

[0122] y2 = Mathf.Min(grid height - 1, (int)(upperPoint.y / blockSize));

[0123] Use a double loop to traverse the canvas. The outermost loop traverses from x1 to x2 with an increment of x1, while the inner loop traverses from y1 to y2 with an increment of y1.

[0124] Define a one-dimensional array `blocks`, assign `blocks[x + width of grid canvas * y]` to a variable `newBlock` of data type `block`, resulting in: `newBlock = blocks[x + width of grid canvas * y]`; then call the `AddPolygons`, `AddPolygon`, and `Execute` functions in the polygon clipping algorithm, and finally call the `update grid` algorithm in `block` to complete the cutting.

[0125] S06. When performing internal shaping and cutting, cut on the 3D model drawing board according to the generated path points. When performing external contour cutting, cut on the 3D model drawing board according to the determined cutting and trimming area to complete the cutting of the final target model.

[0126] Define enumeration types OutCut (outline cutting) and InsideCut (internal shaping). For internal cutting, directly follow the list. <vector3>The list stores the cutting points. If it's an outer contour cutting, the geometry calculated in step S04 is used in the logic determined in step S05 to complete the final cutting. Then, the mesh is updated using method E, and the clipped model is rendered. In a specific application embodiment, the clipping effect based on the boundary detection of planar geometry is as follows: Figure 8 As shown.

[0127] In a specific application embodiment, the cutting effect obtained by the above method is as follows: Figures 9-12 As shown, a circular surface with a radius cuts continuously during the movement to mimic the motion trajectory of CNC cutting, resulting in the following effect. Figure 9 As shown in (a); the cutting trajectory can also be smoothed through Bézier curve motion during the cutting process, such as... Figure 9 As shown in (b), motion trajectory smoothing also applies to cutting smoothing. The shaping of the outer contour after the trajectory points are completed is as follows: Figure 10 , 11 As shown, where Figure 10 Images (a) through (c) show three different outer contour cutting effects. Figure 11 In the middle (a) and (b), the results correspond to two other more complex outer contour cutting effects. Figure 12 In Figures (a) and (b), the two effects of drawing and cutting the internal pattern based on trajectory points are shown respectively. As can be seen from the above cutting effects, this invention can effectively perform real-time cutting of various combined target models and complete the basic shaping of the model.

[0128] This embodiment also provides an automatic cutting system for 3D models in a VR environment, including a processor and a memory. The memory is used to store computer programs, and the processor is used to execute the computer programs to perform the methods described above.

[0129] This embodiment also provides a computer-readable storage medium storing a computer program, which, when executed, implements the method described above.

[0130] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Therefore, any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for automatic cutting of 3D models in a VR environment, characterized by the steps of The method comprises the following steps: constructing a plane grid in a VR environment and combining the grid to form a 3D model panel of a specified size; drawing a circular cutting size as the minimum cutting size in a cutting operation path; cutting according to the circular cutting size to generate a plurality of path points until the object movement trajectory formed by the path points forms a closed figure; converting the object movement trajectory into the vertices of a plane geometric figure; determining a cutting and clipping area according to the vertices of the converted plane geometric figure; when performing internal shaping cutting, cutting on the 3D model panel according to the generated path points; when performing external contour cutting, cutting on the 3D model panel according to the determined cutting and clipping area to complete the cutting of the final target model.

2. The method of claim 1, wherein, The cutting according to the circular cutting size to generate a plurality of path points until the object movement trajectory formed by the path points forms a closed figure comprises the following steps: configuring a coroutine function, and storing the object position information points corresponding to each frame as the path points when the coroutine function is cycled at the last stage of executing each frame during the cutting according to the circular cutting size; traversing the position information of the stored path points, and determining that the path point generation is completed and the closed object movement trajectory is formed if the first path point and the last path point coincide or the error is less than the circular cutting size.

3. The method of claim 1, wherein, The conversion of the object movement trajectory into the vertices of a plane geometric figure comprises the following steps: determining a split point according to the distance between all the path points of the object movement trajectory and the grid boundary, and constructing a plurality of path points from the split point to form a split extension line for forming a closed geometric figure from the cut figure; determining the vertices of the required plane geometric figure according to the geometric figure range enclosed by the path points on the object movement trajectory and the split extension line.

4. The method of claim 3, wherein, The step of forming the split extension line comprises the following steps: obtaining the path point with the maximum Y-axis in all the path points of the object movement trajectory as the split point; calculating the shortest distance from the split point to the grid boundary; calculating a plurality of path points according to a specified interval between the split point and the split point extended by the shortest distance in the positive direction of the Y-axis to obtain the path points in the positive direction of the split extension line; obtaining the path points in the reverse direction according to the path points in the positive direction of the split extension line to obtain the path points in the reverse direction of the split extension line; connecting the split extension line from the positive direction to the reverse direction to form a closed figure.

5. The method of claim 1, wherein, The determination of the cutting and clipping area according to the vertices of the converted plane geometric figure comprises the following steps: detecting the clipping range according to the vertices of the plane geometric figure, and calling a polygon clipping algorithm to determine the final cutting and clipping area.

6. The method of claim 5, wherein, When the polygon clipping algorithm is called, the positive winding rule is used, that is, only the area with a positive winding number is classified as the inside of the polygon, and the positive winding rule is used to clean up overlapping and / or self-intersecting polygons in the preprocessing step.

7. The method of claim 1-6, wherein, The drawing of the circular cutting size as the minimum cutting size in the cutting running path comprises: defining the radius R of the circle and the segment number N; calculating the angle using a predefined degree to radian function; calculating and storing the plane vertex according to the calculated angle, wherein the angle Angle of the i-th segment is calculated according to Angle = Mathf.Deg2Rad * (-90- 360 / N* i), wherein Mathf.Deg2Rad represents the degree to radian function, i = 0, 1,..., N, and the plane vertex is calculated according to Plane Vertex = new Vector2(R * Mathf.Cos(Angle), R * Mathf.Sin(Angle)), wherein Mathf.Cos represents the cosine function, Mathf.Sin represents the sine function, and Vector2 represents a two-dimensional vector.

8. The method of claim 1-6, wherein, The construction of the plane grid comprises: performing initialization definition, constructing a polyhedral grid through vertices and triangular faces using an instantiation function, and storing the vertex data of each grid, wherein the initialization definition comprises any multiple of the following: defining the size of a unit grid, an edge list, the vertex data type of a unit cell, a block class for initializing a grid, and a block class for updating a grid.

9. An automatic cutting system of a 3D model in a VR environment, comprising a processor and a memory, the memory being configured to store a computer program, characterized in that, The processor is configured to execute the computer program to perform the method of any one of claims 1-8.

10. A computer readable storage medium storing a computer program, characterized in that, The computer program, when executed, implements the method of any one of claims 1-8.

Citation Information

Patent Citations

  • Three-dimensional modeling method based on template

    CN105069226A

  • A triangular mesh model-based automatic surface patching algorithm for a sectioned contour

    CN109685914A