Method, device, storage medium and electronic device for smoothing curved surface
The proposed method automatically adjusts vertex normals in three-dimensional models by calculating weights based on neighboring vertices' distances and angles, addressing the inefficiencies of current smoothing techniques and achieving a more accurate and efficient visual smoothing of complex polygon surfaces.
Patent Information
- Application Number
- CN202111285144.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-01
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-11-01
AI Technical Summary
Current methods for smoothing three-dimensional surfaces in computer graphics are inefficient, requiring manual adjustment of vertex normals which is time-consuming and inaccurate, making it difficult to achieve a smooth visual effect on complex polygon surfaces.
A method that adjusts the vertex normals of a three-dimensional model by determining the weights of neighboring vertices based on their distances and angles to create a smooth transition, allowing for automatic optimization of vertex normals across the surface.
This method significantly improves the efficiency and accuracy of surface smoothing by automatically adjusting vertex normals, resulting in a more visually smooth and efficient rendering of complex polygon surfaces.
Smart Images

Figure CN113962896B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, storage medium and electronic device for smoothing a curved surface. Background Art
[0002] At present, in 3D models, continuous polygons are usually used to simulate smooth surfaces. When 3D software renders and displays the above 3D models, it usually inserts gradient normals with sufficient density in the middle of the polygons.
[0003] Whether the gradual transition of the normal is smooth will directly affect the visual smoothness of the 3D model surface. If the normal of a vertex has an obvious deviation, it will seriously affect the visual smoothness of the surface. The uneven surface can be visually concealed by properly setting the normal direction.
[0004] In the related art, the direction of the vertex normal can be adjusted manually. However, manually adjusting the direction of the vertex normal is time-consuming, labor-intensive and inaccurate, and it is impossible to make an overall adjustment on a multi-faceted polygonal surface and obtain a smooth surface effect, which makes the efficiency of smoothing the surface low.
[0005] With respect to the technical problem of low efficiency in smoothing curved surfaces in the prior art, no effective solution has been proposed yet. Summary of the invention
[0006] The main purpose of the present invention is to provide a method, device, storage medium and electronic device for smoothing a curved surface, so as to at least solve the technical problem of low efficiency in smoothing a curved surface.
[0007] In order to achieve the above-mentioned object, according to one aspect of the present invention, a method for surface smoothing is provided. The method may include: selecting a target surface to be smoothed on a three-dimensional model; determining a target vertex in the target surface, and determining a plurality of neighboring points of the target vertex, wherein each neighboring point is coplanar with the target vertex on the target surface; adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point, and obtaining a plurality of second normal vectors, wherein the weight of each neighboring point is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex; determining a third normal vector based on the plurality of second normal vectors, and smoothing the target surface based on the third normal vector.
[0008] Optionally, the method also includes: determining a first neighbor point corresponding to each neighbor point and a second neighbor point corresponding to each neighbor point among multiple neighbor points, wherein the first neighbor point is located on a first side of each neighbor point and the second neighbor point is located on a second side of each neighbor point; obtaining the distance between each neighbor point and the target vertex; and determining the weight of each neighbor point based on the first neighbor point, the second neighbor point and the distance.
[0009] Optionally, based on the first neighbor point, the second neighbor point and the distance, the weight of each neighbor point is determined, including: obtaining a first angle corresponding to each neighbor point and a second angle corresponding to each neighbor point, wherein the first angle is formed by the first neighbor point corresponding to each neighbor point, the target vertex and each neighbor point, and the second angle is formed by each neighbor point, the target vertex and the second neighbor point corresponding to each neighbor point; obtaining the sum of the first angle and the second angle; and determining the weight of each neighbor point based on the quotient between the sum and the distance.
[0010] Optionally, the method further includes: obtaining normal vectors of multiple vertices of each neighboring point; and determining an average value of the normal vectors of the multiple vertices as the first normal vector.
[0011] Optionally, adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point includes: determining the product of the weight of each neighboring point and the first normal vector as the second normal vector.
[0012] Optionally, determining the third normal vector based on the multiple second normal vectors includes: determining the sum of the multiple second normal vectors as the third normal vector.
[0013] Optionally, determining a target vertex in a target surface includes: identifying an edge vertex in the target surface; the method also includes: obtaining multiple adjacent edges of the edge vertex on an edge edge set of the target surface; obtaining third adjacent points other than the edge vertex on multiple adjacent edges; sorting the vertices and third adjacent points on a first continuous edge set to obtain a first vertex set, wherein the first continuous edge set includes edges formed by adjacent points of the edge vertex, the adjacent points of the edge vertex are coplanar with the edge vertex and are within the target surface; obtaining each adjacent first vertex and second vertex from the first vertex set; determining a third angle based on each adjacent first vertex and second vertex and the corresponding edge vertex to obtain multiple third angles.
[0014] Optionally, multiple neighboring points of the target vertex are determined, including: when the sum of the multiple third angles is within a first threshold range, determining the first-order vertex and the last-order vertex in the first vertex set as multiple neighboring points of the edge vertex; determining the third normal vector based on multiple second normal vectors, including: determining the fourth normal vector based on multiple second normal vectors corresponding to the multiple neighboring points of the edge vertex.
[0015] Optionally, the method also includes: when the sum of multiple third angles is within a first sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of multiple third angles, the lower limit value of the first sub-threshold range and the current normal vector of the edge vertex; smoothing the target surface based on the third normal vector, including: smoothing the target surface based on the adjusted fourth normal vector.
[0016] Optionally, the method also includes: when the sum of multiple third angles is within a second sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of the multiple third angles and a lower limit value of the second sub-threshold range; and smoothing the target surface based on the third normal vector, including: smoothing the target surface based on the adjusted fourth normal vector.
[0017] Optionally, determining multiple neighboring points of the target vertex includes: when the sum of multiple third angles is within a second threshold range, determining multiple vertices in the first vertex set as multiple neighboring points of the edge vertex in the target surface; determining a third normal vector based on multiple second normal vectors, including: determining a fifth normal vector based on multiple second normal vectors corresponding to the multiple neighboring points of the edge vertex in the target surface; and smoothing the target surface based on the third normal vector, including: smoothing the target surface based on the fifth normal vector.
[0018] Optionally, the method also includes: when the sum of multiple third angles is within a third threshold range, obtaining a target vector corresponding to the edge vertex, wherein the target vector is the average vector of multiple vectors of multiple vertex normals when the multiple vertex normals of the edge vertex are perpendicular to the polygon where the edge vertex is located, and the multiple vertex normals are vertex normals of the polygon on the edge of the target surface; and determining the target vector as the third normal vector.
[0019] Optionally, the method further includes: obtaining a polygon set of the target surface; and obtaining an edge set based on the polygon set.
[0020] Optionally, the method further includes: acquiring vertices passed by the edge set to obtain an edge vertex set; identifying edge vertices in the target surface, including: determining vertices in the edge vertex set as edge vertices.
[0021] Optionally, after determining a plurality of third normal vectors corresponding one-to-one to a plurality of edge vertices, current normal vectors of the corresponding plurality of edge vertices are corrected based on the plurality of third normal vectors respectively to obtain a plurality of first target normal vectors to smooth the target surface.
[0022] Optionally, determining a target vertex in a target surface includes: identifying an internal vertex in the target surface.
[0023] Optionally, the method also includes: obtaining a second continuous edge set based on internal vertices, wherein the second continuous edge set includes edges formed by neighboring points of the internal vertices, and the neighboring points of the internal vertices are coplanar with the internal vertices; sorting the vertices and internal vertices on the second continuous edge set to obtain a second vertex set; determining multiple neighboring points of the target vertex, including: determining multiple neighboring points of the internal vertex in the second vertex set.
[0024] Optionally, after determining a plurality of third normal vectors corresponding one-to-one to the plurality of internal vertices, current normal vectors of the corresponding plurality of internal vertices are corrected based on the plurality of third normal vectors respectively to obtain a plurality of second target normal vectors to smooth the target surface.
[0025] Optionally, the method further includes: rendering the smoothed three-dimensional model to obtain a target image; and displaying the target image on a graphical user interface.
[0026] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a device for smoothing a curved surface is provided. The device may include: a selection unit for selecting a target curved surface to be smoothed on a three-dimensional model; a determination unit for determining a target vertex in the target curved surface and determining a plurality of neighboring points of the target vertex, wherein each neighboring point is coplanar with the target vertex on the target curved surface; an adjustment unit for adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point to obtain a plurality of second normal vectors, wherein the weight of each neighboring point is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex; a smoothing unit for determining a third normal vector based on the plurality of second normal vectors, and smoothing the target curved surface based on the third normal vector.
[0027] To achieve the above object, according to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the surface smoothing method of the embodiment of the present invention.
[0028] To achieve the above object, according to another aspect of the present invention, an electronic device is provided, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the surface smoothing method of the present invention.
[0029] In this embodiment, by determining the weights and normal vectors corresponding to the neighboring points of the target vertex on the target surface, the normal vectors of the vertex normals of all vertices on the selected target surface can be optimized to achieve the purpose of smoothing the surface, thereby solving the technical problem of low efficiency in smoothing the surface and achieving the technical effect of improving the efficiency of smoothing the surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0031] Figure 1 is a hardware structure block diagram of a mobile terminal according to a method for smoothing a curved surface according to an embodiment of the present invention;
[0032] Figure 2 is a flow chart of a method for surface smoothing according to an embodiment of the present invention;
[0033] Figure 3 It is a schematic diagram of a model in which a vertex normal is perpendicular to the polygon in which the vertex is located according to the related art;
[0034] Figure 4 A schematic diagram of a model in which a vertex normal is perpendicular to a cut surface of a simulated curved surface according to an embodiment of the present invention;
[0035] Figure 5 is a schematic diagram comparing the effects of a normal defect and a wiring defect on a curved surface visual effect according to an embodiment of the present invention;
[0036] Figure 6 is a structural diagram of an automatic normal smoothing system according to an embodiment of the present invention;
[0037] Figure 7 is a flow chart of a relationship between modules and a method for data processing according to an embodiment of the present invention;
[0038] Figure 8 It is a schematic diagram of a typical three-dimensional model to be optimized in the related art, in which uneven surface vertex density causes uneven curved surface;
[0039] Fig. 9 is a schematic diagram of a topological structure of a curved surface wiring and the normal state of each vertex according to an embodiment of the present invention;
[0040] Fig.10 is a schematic diagram of a polygon to be optimized selected by a user according to an embodiment of the present invention;
[0041] Fig.11 is a schematic diagram of vertex distribution of a three-dimensional model according to an embodiment of the present invention;
[0042] Fig.12 A schematic diagram of the effect after completing three optimization iterations according to an embodiment of the present invention;
[0043] Fig.13 A schematic diagram of a vertex normal state after completing three optimization iterations according to an embodiment of the present invention;
[0044] Fig.14 is a schematic diagram of a curved surface smoothing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0046] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0047] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal according to a method for smoothing a curved surface according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0049] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a method for data processing in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0050] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0051] In this embodiment, a method for smoothing a curved surface running on the mobile terminal is provided, which is further described below.
[0052] Figure 2 FIG. 1 is a flow chart of a method for smoothing a curved surface according to an embodiment of the present invention. Figure 2 As shown, the method may include the following steps:
[0053] Step S202: Select a target surface to be smoothed on the three-dimensional model.
[0054] In the technical solution provided in the above step S202 of the present invention, the three-dimensional model can be a polygonal three-dimensional model (also referred to as a three-dimensional polygonal model, polygonal model), that is, a three-dimensional model that needs to simulate a smooth surface through a plurality of continuous polygons, wherein the polygons can be polygons with a low number of faces and similar curvatures (polygons with large curvature changes such as chamfered surfaces can be excluded). In this embodiment, a target surface to be smoothed can be selected on the three-dimensional model, and the target surface can be a surface whose visual effect of visual smoothness (smoothness) is affected, corresponding to the area selected on the three-dimensional model that needs to be optimized.
[0055] Step S204, determining a target vertex in the target surface, and determining a plurality of neighboring points of the target vertex.
[0056] In the technical solution provided in the above step S204 of the present invention, after selecting the target surface to be smoothed on the three-dimensional model, the target vertex can be determined in the target surface, and multiple neighboring points of the target vertex can be determined, wherein each neighboring point is coplanar with the target vertex on the target surface.
[0057] In this embodiment, the target surface includes multiple vertices, which can be used to form a polygon of the target surface. The vertex normals of the multiple vertices are not smoothly transitioned and need to be corrected. This embodiment determines the target vertex among the multiple vertices, which can be represented by V, and determines multiple neighboring points of the target vertex on the target surface that are coplanar and included in the calculation after being determined by the subsequent algorithm. The multiple neighboring points can be multiple normal vector reference neighboring points of the target vertex. For example, the multiple neighboring points can be V1, V2, . . . , V n .
[0058] Step S206: adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point, to obtain a plurality of second normal vectors.
[0059] In the technical solution provided in the above step S206 of the present invention, after the target vertex is determined in the target surface and multiple neighboring points of the target vertex are determined, the first normal vector of each neighboring point can be adjusted to a second normal vector based on the weight of each neighboring point to obtain multiple second normal vectors, wherein the weight of each neighboring point is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex.
[0060] In this embodiment, the vertex normal is the normal of a vertex on a neighboring face of a three-dimensional model. In a three-dimensional model, each vertex will extend a number of edges, and the polygon where every two adjacent edges and the vertex are located will generate a normal at the vertex, that is, if a vertex is adjacent to n polygons, there will be n vertex normals at the vertex, and these vertex normals can have the same vector at the same time, or they can be separated and have different vectors. Accordingly, each neighboring point of the target vertex of this embodiment can have multiple vertex normals, and a first normal vector can be determined based on the multiple vertex normals, and the first normal vector can be the same vector of multiple normals of the target vertex.
[0061] This embodiment can respectively obtain the weights of multiple neighboring points, which is also the added weight of the neighboring points, the weight coefficient, which is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex, wherein the third normal vector is a reference normal vector used to adjust the current normal vector of the target vertex, and the importance can be the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex.
[0062] After obtaining the first normal vector and the corresponding weight of each neighboring point, the first normal vector of each neighboring point can be adjusted to a second normal vector based on the weight of each neighboring point, so that each neighboring point corresponds to a second normal vector, and multiple second normal vectors correspond to multiple second normal vectors.
[0063] Step S208: determining a third normal vector based on the plurality of second normal vectors, and performing smoothing on the target surface based on the third normal vector.
[0064] In the technical solution provided in the above step S208 of the present invention, after the first normal vector of each neighboring point is adjusted to a second normal vector based on the weight of each neighboring point to obtain multiple second normal vectors, a third normal vector is determined based on the multiple second normal vectors, and the target surface is smoothed based on the third normal vector.
[0065] In this embodiment, since the weight of each neighboring point is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex, the first normal vector of each neighboring point is adjusted to the second normal vector based on the weight of each neighboring point. The third normal vector can be determined based on the second normal vector corresponding to each neighboring point. Multiple second normal vectors can be comprehensively processed, and then the current normal vector of the target vertex can be corrected based on the third normal vector to obtain the target normal vector. For example, the target normal vector can be obtained by It is represented to achieve the purpose of smoothing the target surface.
[0066] Optionally, this embodiment uses the above method to set the normal vectors of multiple vertices of the same target vertex to the same normal vector, so that the normal of each vertex of the polygon constituting the target surface is not perpendicular to the polygon where it is located, but perpendicular to the tangent plane of the surface simulated by all polygons adjacent to the target vertex, so as to simulate a smooth target surface through continuous polygons. If the vertex normals on each vertex are separated from each other and perpendicular to the polygon where it is located, hard edges will appear, resulting in poor surface smoothing effect. In the related art, the function of automatically smoothing normals can only make Figure 3 The hard surface shown becomes Figure 8 The degree shown. Figure 3 It is a schematic diagram of a model in which a vertex normal is perpendicular to the polygon in which the vertex is located according to the related art; Figure 8 It is a schematic diagram of a typical three-dimensional model to be optimized in the related art, in which uneven surface vertex density causes uneven surface.
[0067] Optionally, this embodiment adjusts the current normal vector of each vertex of the target surface according to the above method, wherein the normal vectors of different vertices on the same polygon may deviate within a certain range, and a gradient normal of sufficient density is inserted between two normal vectors with deviations, that is, a gradually transitioning value is inserted so that a gradual transition of the tangent plane angle is presented between two vertices at both ends of the same polygon, so as to improve the visual smoothness of the three-dimensional model surface, thereby achieving the purpose of smoothing the target surface, which not only improves the efficiency of surface smoothing, but also improves the effect of surface smoothing.
[0068] It should be noted that the above method of this embodiment is applicable to normal smoothing correction of three-dimensional models such as all planes, convex surfaces, concave surfaces, saddle surfaces, cylindrical surfaces, conical surfaces, surfaces with seam lines, etc.
[0069] Through the above steps S202 to S208 of the present application, a target surface to be smoothed is selected on the three-dimensional model; a target vertex is determined in the target surface, and multiple neighboring points of the target vertex are determined, wherein each neighboring point is coplanar with the target vertex on the target surface; the first normal vector of each neighboring point is adjusted to a second normal vector based on the weight of each neighboring point, and multiple second normal vectors are obtained, wherein the weight of each neighboring point is used to represent the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex; the third normal vector is determined based on the multiple second normal vectors, and the target surface is smoothed based on the third normal vector. In other words, the present application can optimize the normal vectors of the vertex normals of all vertices on the selected target surface by determining the weights and normal vectors corresponding to the neighboring points of the target vertex on the target surface, so as to achieve the purpose of smoothing the surface, solve the technical problem of low efficiency in smoothing the surface, and achieve the technical effect of improving the efficiency of smoothing the surface.
[0070] The above method of this embodiment is further illustrated below.
[0071] As an optional implementation, the method also includes: determining, among multiple neighboring points, a first neighboring point corresponding to each neighboring point and a second neighboring point corresponding to each neighboring point, wherein the first neighboring point is located on a first side of each neighboring point and the second neighboring point is located on a second side of each neighboring point; obtaining the distance between each neighboring point and the target vertex; and determining the weight of each neighboring point based on the first neighboring point, the second neighboring point and the distance.
[0072] In this embodiment, among the multiple neighboring points of the target vertex, each neighboring point has a corresponding first neighboring point and a second neighboring point. For example, the multiple neighboring points are V1, V2, . . . , V n , where for the neighboring point V1, its first neighboring point can be V n , the second neighboring point can be V2, for the neighboring point Vi For example, its first neighbor point can be V i-1 , the second neighbor point can be V i+1 , where i = 2 to n-1, for the neighboring point V n For example, its first neighbor point can be V n-1 , the second neighboring point may be V1. This embodiment may obtain the distance between each neighboring point and the target vertex. For example, for neighboring point V1, the distance between it and the target vertex may be For the neighboring point V i For , the distance between it and the target vertex can be For the neighboring point V n For , the distance between it and the target vertex can be in, That is, the distance weight.
[0073] After determining the first neighbor point corresponding to each neighbor point and the second neighbor point corresponding to each neighbor point, and obtaining the distance between each neighbor point and the target vertex, this embodiment can determine the weight of each neighbor point based on the first neighbor point, the second neighbor point and the distance between each of the above neighbor points and the target vertex.
[0074] Optionally, if one or at least two of the multiple neighboring points of the target vertex coincide with the target vertex so that the distance is zero, the calculation can be skipped and the average of the first normal vectors of all neighboring points with a distance of zero is directly output as the third normal vector of the target vertex, that is, the reference normal vector.
[0075] As an optional implementation, the weight of each neighbor point is determined based on the first neighbor point, the second neighbor point and the distance, including: obtaining a first angle corresponding to each neighbor point and a second angle corresponding to each neighbor point, wherein the first angle is formed by the first neighbor point corresponding to each neighbor point, the target vertex and each neighbor point, and the second angle is formed by each neighbor point, the target vertex and the second neighbor point corresponding to each neighbor point; obtaining the sum of the first angle and the second angle; and determining the weight of each neighbor point based on the quotient between the sum and the distance.
[0076] In this embodiment, when determining the weight of each neighboring point based on the first neighboring point, the second neighboring point and the distance, the first angle corresponding to each neighboring point and the second angle corresponding to each neighboring point can be obtained first, wherein the first angle and the second angle are the co-edge angles formed by the target vertex and the corresponding neighboring point and the first neighboring point and the second neighboring point on both sides thereof, for example, ∠V n VV1, ∠V1VV2 are the target vertex V and the corresponding neighboring point V1 and its neighboring points V on both sides n The angle between the edges of V2 and ∠V i-1 VV i , ∠Vi VV i+1 is the target vertex V and the corresponding neighboring vertex V i and its neighboring points V on both sides i-1 and V i+1 The angle between the two sides is ∠V n-1 VV n , ∠V n VV1 is the target vertex V and the corresponding neighboring vertex V n and its neighboring points V on both sides n-1 The common angle formed by V1 and V2.
[0077] This embodiment can obtain the sum of the first angle and the second angle, for example, to obtain ∠V n VV1+∠V1VV2,∠V i-1 VV i +∠V i VV i+1 , ∠V n-1 VV n ∠V n VV1 is the angle weight. After obtaining the sum of the first angle and the second angle, the weight of each neighboring point can be determined based on the quotient between the sum and the distance. For example, the quotient between the sum and the distance can be determined to be the initial weight of each neighboring point, and then normalized. For example, the sum of the initial weights of multiple neighboring points can be obtained. Then, the initial weight of each neighboring point is divided by the sum of the initial weights of multiple neighboring points to obtain the final weight of each neighboring point, which can be called the normal vector weight, or the normal vector addition weight, which can be represented by the following formula:
[0078]
[0079]
[0080]
[0081] From the above, it can be seen that in this embodiment, the closer the neighboring point of the target vertex is to the target vertex, the smaller the distance between the neighboring point and the target vertex, and the greater the weight corresponding to the neighboring point; among the multiple neighboring points of the target vertex, the greater the sum of the two common edge angles formed by the target vertex and the corresponding neighboring point and the first neighboring point and the second neighboring point on both sides, the greater the weight corresponding to the neighboring point.
[0082] The above-mentioned method of calculating the weight of each neighboring point of the target vertex in this embodiment can complete the weight calculation of each neighboring point only by detecting the distance between the neighboring point of the target vertex and the target vertex, and detecting the sum of the two common angles formed by the target vertex and the corresponding neighboring point and the first neighboring point and the second neighboring point on both sides. While saving computing resources, the obtained effect is very close to the result obtained by rigorous trigonometric function calculation on various types of surfaces. It has very strong universality and can be directly used for polygonal three-dimensional model surfaces such as planes, convex surfaces, concave surfaces, saddle surfaces, cylinders, cones, surfaces with seam lines, etc., and the calculation does not need to rely too much on smooth polygonal wiring, and can be used to cover up the uneven surface caused by surface wiring fluctuations and uneven vertex spacing.
[0083] It should be noted that in the above method, the reason why more rigorous trigonometric functions are not used to calculate the third normal vector of the target vertex is that in most cases, it is difficult to use a simple equation to describe the curvature of the target surface where the target vertex and its neighboring points are located. Even if it is to simulate an approximate surface, the calculation formula must also change with different surface types. In addition, the computing resources consumed by detecting the surface type of the target surface and subsequent calculations, using rigorous trigonometric functions to calculate the third normal vector will make each optimization of a multi-faceted three-dimensional model very slow.
[0084] As an optional implementation, the method further includes: obtaining normal vectors of multiple vertices of each neighboring point; and determining an average value of the normal vectors of the multiple vertices as the first normal vector.
[0085] In this embodiment, the first normal vector of each neighboring point is adjusted to a second normal vector based on the weight of each neighboring point, wherein the first normal vector can be determined based on the multiple vertex normals, and the normal vectors of multiple vertices of each neighboring point can be obtained, and then the normal vectors of the multiple vertices are averaged, that is, the vector average, and then determined as the first normal vector of each neighboring point. For example, the first normal vector can be
[0086] As an optional implementation, step S206, adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point, includes: determining the product of the weight of each neighboring point and the first normal vector as the second normal vector.
[0087] In this embodiment, when adjusting the first normal vector of each neighboring point to the second normal vector based on the weight of each neighboring point, the product between the weight of each neighboring point and the first normal vector may be obtained, for example, the following formula may be obtained:
[0088]
[0089]
[0090]
[0091] After obtaining the product between the weight of each neighboring point and the first normal vector, the product can be determined as the second normal vector of each neighboring point, thereby achieving the purpose of weighted calculation of the normal vector.
[0092] As an optional implementation, step S208, determining a third normal vector based on multiple second normal vectors, includes: determining the sum of the multiple second normal vectors as the third normal vector.
[0093] In this embodiment, when determining the third normal vector based on multiple second normal vectors, the multiple second normal vectors may be summed up, and the sum is then determined as the third normal vector of the target vertex. For example, the third normal vector Then, the current normal vector of the target vertex is adjusted based on the third normal vector to achieve smoothing of the target surface.
[0094] The following is an introduction to the method for correcting the normal lines of the selected edge vertices of the target surface of this embodiment.
[0095] As an optional implementation, step S204, determining the target vertex in the target surface, includes: identifying the edge vertex in the target surface; the method also includes: obtaining multiple adjacent edges of the edge vertex on the edge edge set of the target surface; obtaining third neighboring points other than the edge vertex on the multiple adjacent edges; sorting the vertices and third neighboring points on the first continuous edge set to obtain a first vertex set, wherein the first continuous edge set includes edges composed of neighboring points of the edge vertex, and the neighboring points of the edge vertex are coplanar with the edge vertex and are within the target surface; obtaining each adjacent first vertex and second vertex from the first vertex set; determining a third angle based on each adjacent first vertex and second vertex and the corresponding edge vertex to obtain multiple third angles.
[0096] In this embodiment, the target vertex may include an edge vertex, so that this embodiment may determine the edge vertex in the target surface. The edge vertex of this embodiment may be determined by V Bi To express.
[0097] In a three-dimensional polygon model, each edge vertex has only two adjacent edges on the edge and two adjacent points on the other side of the adjacent edge in the topological structure. This embodiment can obtain the two adjacent edges of the edge vertex on the edge set of the target surface, and then obtain the two third adjacent points on the other side of each adjacent edge. For example, the two third adjacent points can be V N1 、V NnIn this embodiment, a first continuous edge set is obtained, and the first continuous edge set may include edges formed by the neighboring points of the above edge vertices, which may be formed by E N The neighboring points of the edge vertex are coplanar with the edge vertex and are within the selected area corresponding to the target surface. After obtaining multiple adjacent edges and multiple third adjacent points on the first edge set, the vertex on the first continuous edge set and any third adjacent point among the multiple third adjacent points (for example, V N1 ) to obtain a first vertex set, which may be a vertex set starting from the third neighbor point and passing through the first continuous edge set E in order. N All vertices on the same node to another third neighboring point V Nn The final vertex set V N .
[0098] In this embodiment, each adjacent first vertex and second vertex can be obtained from the first vertex set, and then the angle of the third angle between the first vertex, the edge vertex and the second vertex can be calculated. For example, starting from i=1, the third angles of the first vertex set V can be obtained in sequence. N The first vertex V on Ni With the second vertex V N(i+1) The third angle formed, until the calculation of point i=n-1 is completed, all the angles are summarized to obtain multiple third angles, and the sum of multiple third angles can be further obtained, which can be recorded as A Bi , which will be used to determine how to calculate the target vertex V B Neighboring point V N The weight of is further described below.
[0099] As an optional implementation, step S204, determines multiple neighboring points of the target vertex, including: when the sum of multiple third angles is within a first threshold range, determines the first-order vertex and the last-order vertex in the first vertex set as multiple neighboring points of the edge vertex; determines the third normal vector based on multiple second normal vectors, including: determines the fourth normal vector based on multiple second normal vectors corresponding to the multiple neighboring points of the edge vertex.
[0100] In this embodiment, it can be determined whether the sum of the plurality of third angles is within a first threshold range, and the first threshold range can be (120°, 240°). In this embodiment, the vertex V that is ranked first in the first vertex set can be obtained. N1 and the last vertex V in the sorting Nn , which is determined as the edge vertex V Bi The two neighboring points of can be based on the first vertex V in the first vertex set. N1 , edge vertex V Bi , the last vertex V in the sortingNn Perform a weighted calculation of the normal vector to determine the edge vertex V Bi The third normal vector of . Optionally, because the two edges V N1 V Bi With V Bi V Nn The angle between the corresponding angle weights on both sides is ∠V N1 V Bi V Nn With ∠V Nn V Bi V N1 Therefore, this embodiment only needs to use two edges V N1 V Bi With V Bi V Nn The length of the distance weight is calculated, and then each neighboring point (V N1 、V Nn ) is adjusted to a second normal vector, a plurality of second normal vectors are obtained, and the edge vertex V is determined based on the plurality of second normal vectors. Bi That is, the third normal vector includes the fourth normal vector, which can be recorded as
[0101] Optionally, this embodiment may obtain a polygon set F of the optimization range corresponding to the target surface. S , get multiple adjacent edges and multiple adjacent faces of the edge vertex. Among them, multiple adjacent edges can be obtained through E T To express, for example, E T Including adjacent edge E1, adjacent edge E2, adjacent edge E3, etc., multiple adjacent faces can be T To express, for example, F T Including adjacent surface F1, adjacent surface F2, etc. Obtain the above multiple first adjacent surfaces F T With the polygon set F S The intersection of T That is, take F T With F S The intersection of T Among them, F T It contains the adjacent face of a certain edge vertex located in F S The surface on one side also includes the surface that does not belong to F S The face on the other side of the edge is within the range, so get F T With F S After the intersection of the edges, only the vertex adjacent to the edge and located in F S This embodiment can obtain the new set F T Multiple edges, and remove all adjacent edges E connected to the edge vertex from the multiple edges.T It should be noted that this refers to a single edge vertex, and cannot include its neighboring vertices on both sides of the edge. Otherwise, "eliminating all adjacent edges connected to the edge vertex" will also eliminate the edges connected to its neighboring vertices. The remaining edges after elimination in this embodiment are the first continuous edge set E that passes through all neighboring vertices. N This embodiment obtains E T With all edge sets E B The intersection between them, in order to obtain the edge set E B After the two adjacent edges connected to the edge vertex are obtained, they are then transformed to obtain the two adjacent points V at the other end of the adjacent edge. N1 、V Nn .
[0102] As an optional embodiment, the method also includes: when the sum of multiple third angles is within a first sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of multiple third angles, the lower limit value of the first sub-threshold range and the current normal vector of the edge vertex; smoothing the target surface based on the third normal vector, including: smoothing the target surface based on the adjusted fourth normal vector.
[0103] In this embodiment, the first threshold range may include a first sub-threshold range. For example, the first sub-threshold range may be A Bi ∈(120°, 180°], the fourth normal vector can be adjusted based on the sum of the multiple third angles, the lower limit value of the first sub-threshold range, and the current normal vector of the edge vertex. As the sum of the third angles exceeds the lower limit value (120°) of the first sub-threshold range, the reference normal vector of the edge vertex can gradually tend to the fourth normal vector calculated above. Optionally, in this embodiment, the reference normal vector of the edge vertex may be obtained by the following formula:
[0104] in, The current normal vector used to represent the edge vertex.
[0105] As an optional implementation, step S204, determining multiple neighboring points of the target vertex, includes: when the sum of multiple third angles is within a second threshold range, determining multiple vertices in the first vertex set as multiple neighboring points of the edge vertex in the target surface; determining the third normal vector based on multiple second normal vectors, including: determining the fifth normal vector based on multiple second normal vectors corresponding to the multiple neighboring points of the edge vertex in the target surface.
[0106] In this embodiment, it can be determined whether the plurality of third angles are within the second threshold range, which can be a range of ≥240°, and a neighbor point set V of the edge vertex in the selected area corresponding to the target surface is obtained. N , and then based on the neighboring point set V N The weight of each neighboring point in , the first normal vector of each neighboring point is adjusted to the second normal vector, multiple second normal vectors are obtained, and the fifth normal vector is determined based on the multiple second normal vectors, that is, the third normal vector can include the fifth normal vector, which can be recorded as
[0107] As an optional implementation, step S208, smoothing the target surface based on the third normal vector, includes: when the sum of the plurality of third angles is within a second threshold range, smoothing the target surface based on the fifth normal vector.
[0108] In this embodiment, when the sum of the plurality of third angles is within the second threshold range, for example, a range greater than or equal to 240°, since the third normal vector includes the fifth normal vector It can be used as a reference normal vector to correct the current normal vector of the edge vertex, so as to achieve smoothing of the target surface based on the third normal vector. It can be used to correct the current normal vector of the edge vertex based on the fifth normal vector to achieve smoothing of the target surface.
[0109] As an optional implementation, the method also includes: when the sum of multiple third angles is within the second sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of the multiple third angles and the lower limit value of the second sub-threshold range; step S208, smoothing the target surface based on the third normal vector, including: smoothing the target surface based on the adjusted fourth normal vector.
[0110] In this embodiment, the first threshold range may also include a second sub-threshold range, for example, the second sub-threshold range may be (180°, 240°), in which case the neighboring points of the edge vertex are no longer limited to being on one side of any adjacent edge of the selected area edge corresponding to the target surface. Bi When the lower limit of the second sub-threshold range is exceeded, the reference normal vector used to correct the current normal vector of the edge vertex can be gradually changed from the fourth normal vector Biased towards the fifth normal vector The fourth normal vector may be adjusted based on the sum of the plurality of third angles and the lower limit of the second sub-threshold range, or the fourth normal vector may be adjusted based on the sum of the plurality of third angles, the lower limit of the second sub-threshold range and the fifth normal vector, thereby obtaining a reference normal vector of the edge vertex. Optionally, this embodiment obtains the reference normal vector of the edge vertex by the following formula:
[0111]
[0112] As an optional implementation, the method also includes: when the sum of multiple third angles is within a third threshold range, obtaining a target vector corresponding to the edge vertex, wherein the target vector is an average vector of multiple vectors of multiple vertex normals when the multiple vertex normals of the edge vertex are perpendicular to the polygon where the edge vertex is located, and the multiple vertex normals are vertex normals of the polygon on the edge of the target surface; determining the target vector as the third normal vector.
[0113] In this embodiment, it can be determined whether the sum of the multiple third angles is within the third threshold range. For example, the third threshold range can be within a range of ≤120°. At this time, the edge vertex cannot obtain an ideal smooth surface result by only calculating the weights (weighted normal vectors) of adjacent vertices in a small range in one direction. This embodiment can directly obtain the normal vectors of multiple vertex normals on the edge vertex when they are perpendicular to the polygon where they are located, and can obtain multiple vertex normals N of the polygons on the edge of the target surface. VBS Corresponding multiple vectors, the average value of the multiple vectors is determined as the target vector corresponding to the edge vertex, and then the target vector can be used to determine the third normal vector to modify the current normal vector of the edge vertex to smooth the target surface.
[0114] Optionally, this embodiment may obtain polygons within the selected optimization range corresponding to the target surface, which are recorded as a polygon set F S , get all vertex normals of the polygon set and record it as set N VS , which may not contain edge vertices in the edge set E of the selected optimization range polygon B The vertex normals of the adjacent faces outside the selection range are used to exclude the vertex normals of the chamfered faces with inconsistent curvature outside the selection range. This embodiment can obtain all vertex normals adjacent to the edge set and record them as set N VB , get the above N VS With N VB The intersection of , thereby obtaining all the vertex normals of the polygons on the edge of the selected area, which belong to one side of the selected area, and recorded as the above N VBS .
[0115] It should be noted that the above threshold values of 120°, 180°, 240°, etc., which are used as the threshold range, are all empirical data and can be flexibly adjusted according to actual conditions if necessary.
[0116] As an optional implementation, the method further includes: obtaining a polygon set of the target surface; and obtaining an edge set based on the polygon set.
[0117] In this embodiment, the polygons in the selected optimization range corresponding to the target surface can be recorded as a polygon set F s , get the composition set F S The edges of the polygons in are recorded as set E s This embodiment can also obtain unselected faces and convert them into edges that constitute these faces, which can be recorded as a set E ns , get the edges on the edge of the entire 3D model and add them to the set E ns , then take the above E s With E ns The intersection between them is used to obtain the edge set E of the polygon within the selected optimization range. B .
[0118] As an optional implementation, the method further includes: acquiring vertices passed by the edge set to obtain an edge vertex set; identifying edge vertices in the target surface, including: determining vertices in the edge vertex set as edge vertices.
[0119] In this embodiment, the edge set of the target surface can be transformed to obtain all the vertices that the edge set passes through, thereby obtaining the above-mentioned edge vertex set V B , and then when identifying the edge vertices in the target surface, the vertices in the edge vertex set can be determined as edge vertices V Bi .
[0120] As an optional implementation, after determining multiple third normal vectors corresponding to multiple edge vertices one by one, the current normal vectors of the corresponding multiple edge vertices are corrected based on the multiple third normal vectors to obtain multiple first target normal vectors to smooth the target surface.
[0121] In this embodiment, for multiple edge vertices, the i-th edge vertex V in the edge vertex set can be selected one by one. Bi , edge set E B And the polygon set F selected within the optimization range S Calculate and obtain its third normal vector (reference normal vector) And get the edge vertex V Bi The current normal vector The current normal vector is adjusted by the third normal vector. The current normal vector of the edge vertex can be adjusted by the target parameter and the third normal vector to obtain the edge vertex V Bi The first target normal vector Optionally, in this embodiment, the optimized edge vertex V can be calculated by the following formula: Bi The first target normal vector
[0122] Among them, C n is the target parameter mentioned above.
[0123] This embodiment traverses the edge vertex set V by the above method. B All edge vertices in , obtain a first target vector sequence set N including the first target normal vector of each edge vertex V .
[0124] In this embodiment, the above target parameter can be an optimization bias setting coefficient, and its value range can be 0-1. This value can be used to determine whether the optimized first target normal vector is biased towards the original current normal vector or the third normal vector calculated in the current state. It can take a value of 0.5, and through multiple iterations, the first target normal vector of each edge vertex gradually tends to the theoretical optimal solution during the iteration. Optionally, if the value of the target parameter is too large, the first target normal vector may be overcorrected, and the first target normal vector may repeatedly swing around the optimal solution during multiple iterations.
[0125] After obtaining the first target vector sequence set N V After that, we can start from i=1 and sort the edge vertex set V one by one. B The i-th edge vertex V Bi All vertex normal vectors are uniformly corrected to the first target vector sequence set N V The first target normal vector at the i-th position Repeat the above steps until the edge vertex set V is traversed. B All vertices in .
[0126] It should be noted that the reason why this embodiment does not correct the current normal vector of a certain edge vertex immediately after calculating the first target normal vector of the edge vertex is because a certain edge vertex after the change may also be a neighboring point of another unoptimized edge vertex. The edge vertex that is changed first will cause deviations in subsequent optimization results.
[0127] Optionally, the embodiment can obtain the user's optimization settings from the interactive interface. Optionally. Obtain the option of whether to optimize the current normal vector of the edge vertex. If yes, the above-mentioned processing method for the edge vertex can be executed. If not, it can be executed. Optionally, the embodiment can also obtain the target parameter C from the interactive interface n .
[0128] The following is a further introduction to the method for selecting and correcting the normal lines of internal vertices of the target surface of this embodiment.
[0129] As an optional implementation, step S204, determining target vertices in the target surface, includes: identifying internal vertices in the target surface.
[0130] In this embodiment, when obtaining the edge set E B All edge vertices passed through, get the edge vertex set V B , and obtain the constituent polygons as a set F S After all the vertices of the polygon, the polygon can be recorded as a set F S Eliminate the edge vertex set V from all vertices B , thus obtaining the internal vertex set, which can be recorded as V I , and then determine the internal vertex in the internal vertex set, which can be recorded as V Ii .
[0131] Optionally, if the user chooses not to optimize the edge, calculation of the second target normal vector of the internal vertex may be performed to achieve the purpose of smoothing the target surface through the second target normal vector.
[0132] As an optional implementation, the method also includes: obtaining a second continuous edge set based on internal vertices, wherein the second continuous edge set includes edges formed by neighboring points of the internal vertices, and the neighboring points of the internal vertices are coplanar with the internal vertices; sorting the vertices and internal vertices on the second continuous edge set to obtain a second vertex set; step S204, determining multiple neighboring points of the target vertex, including: determining multiple neighboring points of the internal vertex in the second vertex set.
[0133] In this embodiment, for the internal vertex V Ii , you can get the internal vertex V Ii All adjacent edges E T and all adjacent surfaces E T , get the composition inside E T All edges of the internal vertex V are removed from them Ii All the adjacent edges E above are connected T , thereby obtaining connections with internal vertices V IiThe second continuous edge set E of all coplanar neighboring points N , and obtain the second continuous edge set E N Any vertex V I1 Optionally, this embodiment may sort the vertices and internal vertices on the second continuous edge set to obtain a second vertex set, which is composed of the vertices V on the second continuous edge set. I1 As the starting point, go through the second continuous edge set E in order N The internal vertex set of all vertices on the I , and thus this embodiment can determine multiple neighboring points of the above internal vertex in the second vertex set.
[0134] As an optional implementation, after determining multiple third normal vectors corresponding to multiple internal vertices, the current normal vectors of the corresponding multiple internal vertices are corrected based on the multiple third normal vectors to obtain multiple second target normal vectors to smooth the target surface.
[0135] In this embodiment, the internal vertex sets V can be obtained one by one. I The internal vertices in the grid are obtained, and the normal vectors of all the vertices of the internal vertices are obtained. After the normal vectors of all the vertices of the internal vertices are averaged, the average value is assigned to all the vertex normals on the internal vertex, so that all the vertex normal vectors on each internal vertex are consistent, which is convenient for subsequent optimization calculations.
[0136] Optionally, this embodiment may start from i=1 and convert the internal vertex set V I The i-th internal vertex V on Ii By determining multiple neighboring points of the internal vertex, adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point, obtaining multiple second normal vectors, and determining its reference normal vector (third normal vector) based on the multiple second normal vectors And get the internal vertex V Ii Current normal vector Can be Calculate the optimized vertex V Ii The second target normal vector
[0137] This embodiment traverses the internal vertex set V by the above method. I All internal vertices in , obtain a second target vector sequence set N including the second target normal vector of each internal vertex V .
[0138] In this embodiment, the second target vector sequence set N of all internal vertices can be obtained. VAfter that, we can start from i=1 and add the internal vertex set V I The i-th vertex V Ii All vertex normals are uniformly corrected to the second target vector sequence set N V The normal vector of the i-th position Repeat the above steps until the internal vertex set V is traversed I After all internal vertices in the selected area are calculated, the number of executed iterations plus one is recorded. If the number of executed iterations is less than the set number of iterations T, the above-mentioned calculation of the edge vertex normals of the selected area and the calculation of the internal vertex normals of the selected area can be re-executed while optimizing the edge vertex normals, or the above-mentioned calculation of the internal vertex normals of the selected area can be re-executed without optimizing the edge vertex normals. When the number of executed iterations is equal to T, the optimization ends. Optionally, this embodiment can also obtain the number of iterations T from the interactive interface.
[0139] As an optional implementation, the method further includes: rendering the smoothed three-dimensional model to obtain a target image; and displaying the target image on a graphical user interface.
[0140] In this embodiment, the target surface of the three-dimensional model is smoothed by the above method, thereby achieving the purpose of smoothing the three-dimensional model. The smoothed three-dimensional model can be further rendered to obtain a target image corresponding to the smoothed three-dimensional model.
[0141] Optionally, this embodiment can use a rendering program to render the smoothed three-dimensional model, wherein the rendering program can obtain the range of the smoothed three-dimensional model that needs to be rendered through the camera, and calculate the influence of each light source added to the scene on the smoothed three-dimensional model. Unlike the light sources in the real world, the rendering program can calculate a large number of auxiliary light sources. In this embodiment, it can also be determined whether to use depth map shadows or ray tracing shadows for the smoothed three-dimensional model based on the shadows cast by the light sources. In addition, after using area light sources, if the light sources in the scene use light source special effects, the rendering program will also calculate the results of the special effects, especially volumetric light (light fog), thereby achieving the purpose of rendering the smoothed three-dimensional model.
[0142] Optionally, in this embodiment, the above-mentioned rendering program can also calculate the color of the surface of the smoothed three-dimensional model based on the material of the smoothed three-dimensional model, wherein different types of materials, different properties, and different textures will produce various different effects, and this result does not exist independently, and it can be combined with the above-mentioned light source.
[0143] After rendering the smoothed three-dimensional model to obtain a target image, the target image can be displayed on a graphical user interface, thereby achieving the purpose of rendering and displaying the target image corresponding to the smoothed three-dimensional model on the graphical user interface.
[0144] In this embodiment, by determining the weights and normal vectors corresponding to the neighboring points of the target vertex on the target surface, the normal vectors of the vertex normals of all vertices on the selected target surface can be optimized to achieve the purpose of smoothing the surface, thereby solving the technical problem of low efficiency in smoothing the surface and achieving the technical effect of improving the efficiency of smoothing the surface.
[0145] The technical solution of the embodiment of the present invention is further illustrated below in conjunction with preferred implementation modes.
[0146] In a polygonal 3D model, in order to simulate a smooth surface with continuous polygons, the normal of each vertex of the polygon that makes up the surface is not perpendicular to the polygon itself, but to the tangent plane of the surface simulated by all polygons adjacent to the vertex. That is, at the same vertex in the smooth surface, the normal vectors of all vertices are the same.
[0147] If the vertex normals at each vertex are separated from each other and perpendicular to the polygon in which they are located, the following will appear: Figure 3 The hard edges shown. Figure 3 It is a schematic diagram of a model in which the vertex normal is perpendicular to the polygon in which it is located according to the related art. Therefore, on a polygonal surface model, multiple vertex normals of the same vertex are usually set to the same normal vector, and the normal angles of different vertices on the same polygon will have a certain deviation.
[0148] In 3D computer graphics, 3D software will insert a gradual transition value between two deviation normals when rendering polygons, so that the angle of the tangent plane between the two vertices at the two ends of the same polygon will show a gradual transition. Figure 4 As shown on the left. Figure 4 A schematic diagram of a model in which the vertex normal is perpendicular to the tangent plane of the simulated surface according to an embodiment of the present invention, a surface simulated by multiple polygons, the normal of each vertex of which is perpendicular to the tangent plane of the simulated surface, then when rendering and displaying, the 3D software will insert a gradient normal of sufficient density in the middle of the polygon, so that the normal of each vertex smoothly transitions, so that multiple planar polygons can be composed as follows Figure 4 A smoothly curved surface is shown on the right.
[0149] Whether the normal gradient transition is smooth will directly affect the visual smoothness of the 3D model surface. Figure 5 As shown on the left. Figure 5FIG. 1 is a schematic diagram comparing the effects of normal defects and wiring defects on the visual effect of a curved surface according to an embodiment of the present invention. If the normal of a vertex has an obvious deviation, the visual smoothness of the curved surface will be seriously affected. Figure 5 The wiring undulation artifact shown on the right can be visually masked by properly setting the normal direction to its uneven surface.
[0150] Therefore, the smooth transition of normals of each vertex on the surface of a three-dimensional model, especially a three-dimensional model with a low number of faces, has an important influence on the smoothness of the surface.
[0151] In the related art, there are three ways to achieve a smooth transition of normals: manually adjust the direction of vertex normals. However, manually adjusting the direction of vertex normals is time-consuming, labor-intensive and inaccurate, and it is impossible to make overall adjustments on a multi-faceted polygonal surface and achieve a smooth surface effect, so this solution is less practical.
[0152] In another related technology, the normal vectors of all vertices on each vertex on the surface can be directly obtained, and after averaging the normal vectors of all vertices, the average value is assigned to all vertex normals of the vertex, such as Figure 4 However, this method is only applicable to surfaces with smooth routing and no abnormal fluctuations, and evenly distributed vertices on the surface. When the vertex spacing must be close, the algorithm will inevitably make the surface uneven, resulting in poor surface smoothing effect, such as Figure 8 The surfaces shown in Fig. 9 The topological structure and normal direction shown in , so this method is less universal. Figure 8 It is a schematic diagram of a typical three-dimensional model to be optimized in the related art, in which uneven surface vertex density causes uneven curved surface. Fig. 9 It is a schematic diagram of a topological structure of a curved wiring and the normal state of each vertex according to an embodiment of the present invention.
[0153] In another related technology, a high-polygon model can be used as a normal source, and the interpolation vector of the closest point on the high-polygon model is taken as the normal vector source for each vertex on the surface to be optimized, and then the normals of all vertices on the target model are assigned after obtaining. However, this method must either make a high-polygon model with smooth surface wiring as a normal source for the low-polygon model, or manually delete the wiring on the surface based on the existing high-polygon model to reduce its number of faces and retain the normals of the high-polygon model. Both are time-consuming and labor-intensive, and the smoothness of the resulting surface is extremely dependent on the smoothness of the wiring on the model surface, so this solution is less easy to use.
[0154] However, this embodiment provides an algorithm for obtaining weighted normal vectors of neighboring points around a vertex. When calculating the normal of a vertex V on a surface, the weights (weight coefficient, normal vector weight, normal vector addition weight) of each coplanar neighboring point of the vertex V on the surface can be obtained; the weight is multiplied by the normal vector of the neighboring point to obtain the weighted normal vectors of all neighboring points; the weighted normal vectors of all neighboring points are combined; and the reference normal vector of the vertex that makes the surface look smoothest under the current neighboring point normal state is obtained. The algorithm is further introduced below.
[0155] When vertex V has n neighbors, the reference normal vector of vertex V can be:
[0156]
[0157] in, Used to represent the reference normal vector; V1, V2, ..., V n It is used to indicate the neighboring points of the vertex V on the surface that are coplanar with it and are included in the calculation after being determined by the subsequent algorithm; ∠V n VV1,∠V1VV2,...,∠V n-1 VV n , ∠V n VV1 is used to represent the vertex V and its corresponding neighboring points V1, V2, ..., V n and the angle of the two common side angles formed by the adjacent points on both sides; It is used to represent the distance between each neighboring point and the vertex V. Optionally, if a neighboring point or multiple neighboring points coincide with the vertex V so that L is zero, the calculation can be skipped and the average value of their normal vectors can be directly output as the reference normal vector. The average value of the normal vectors of all vertices corresponding to each neighboring point can be used.
[0158] The reason why this embodiment does not use more rigorous trigonometric functions to calculate the target vector value is that in most cases, it is difficult to use a simple equation to describe the curvature of the surface where the vertex V and its neighboring points are located. Even when simulating an approximate surface, the calculation formula must also change with different surface types. In addition, the computing resources consumed by detecting the surface type and subsequent calculations, using rigorous trigonometric functions to calculate the reference normal vector will make each optimization of the polyhedral model very slow.
[0159] The principle of the algorithm in this embodiment is: a) when a neighboring point is closer to the vertex V, the distance weight of its normal vector is ) is larger; b) among all the neighboring points of vertex V, the larger the sum of the two angles formed by the two neighboring points on both sides of each neighboring point and the neighboring point and vertex V is, the larger the angle weight of the normal vector of the neighboring point (∠V i-1 VVi +∠V i VV i+1 ) is larger.
[0160] The algorithm designed according to the above principles only needs to detect the angle and distance between vertices to complete the weight calculation, which saves computing resources. The obtained effect is very close to the result obtained by rigorous trigonometric function calculation on various surfaces. It has very strong universality and can be directly used for polygonal three-dimensional model surfaces such as planes, convex surfaces, concave surfaces, saddle surfaces, cylinders, cones, surfaces with seams, etc., and the calculation does not need to rely too much on smooth polygon wiring. It can be used to cover the uneven surface caused by surface wiring fluctuations and uneven vertex spacing (such as Figure 5 (shown as the right side surface in the figure).
[0161] This embodiment automatically determines the vertex topology of the selected area to be optimized based on a set of topology recognition logic, and can calculate the normal vector addition weights of its neighboring points in different methods for vertices in different positions and structures, ultimately achieving an ideal optimization effect.
[0162] Figure 6 is a structural diagram of an automatic normal smoothing system according to an embodiment of the present invention. Figure 6 As shown, the system may include: a program main control and structure identification module 101, a selection area edge vertex normal correction module 102, a selection area internal vertex normal correction module 103 and a continuous edge set related vertex sequence arrangement module 104.
[0163] The program main control and structure recognition module 101 is used to preliminarily determine the topological structure of the polygonal area to be optimized, and output the determination results to the selection edge vertex normal calculation module 102 and the selection internal vertex normal calculation module 103 for calculation of reference normal vectors, and record and summarize the returned results to correct the normals of each vertex of the surface to be optimized.
[0164] The selected area edge vertex normal calculation module 102 is used to determine the structure of the edge vertex set, adopt different weighting algorithms for different structures to calculate the reference normal vectors of the edge vertices, and return the results to the program main control and structure recognition module 101.
[0165] The module 103 for calculating normal lines of vertices inside the selected area is used to directly calculate the weighted vectors of normal lines of neighboring points around the vertices inside the selected area, and return the results to the program main control and structure recognition module 101 .
[0166] The continuous edge set related vertex sequence arrangement module 104 will be called by the selection area edge vertex normal calculation module 102 and the selection area internal vertex normal calculation module 103 during the calculation process to arrange all connected vertices on a continuous edge set in sequence.
[0167] For a more vivid explanation Figure 6 The working principle shown below will be Figure 7 The example analysis shown Figure 6 The functions and optimization processes of each module shown in the figure include the situation in a typical 3D model where the chamfered corners cause uneven distribution of surface vertices, which leads to unsatisfactory automatic normal calculation and abnormal highlight aggregation. Fig. 9 As shown in the figure, the polygonal topology of the surface and the normal state of each vertex before automatic normal smoothing are shown in the figure. Fig.12 As shown, Fig.12 1 is a schematic diagram of the effect after completing three optimization iterations according to an embodiment of the present invention, and 2 is a schematic diagram of the effect after completing the optimization Figure 8 The final effect of the case shown is as follows Fig.13 As shown, Fig.13 Schematic diagram of the vertex normal state after completing three optimization iterations according to an embodiment of the present invention.
[0168] Figure 7 FIG. 1 is a flow chart of a method for processing data and a relationship between modules according to an embodiment of the present invention. Figure 7 As shown, the data processing method in the program main control and structure recognition module 101 may include the following steps:
[0169] Step S201 ′, topology structure identification.
[0170] This embodiment can obtain the user's optimization settings from the UI interface: the option of whether to optimize the edge can be obtained, and the optimization bias setting coefficient C can be obtained. n and the number of iterations T.
[0171] In this embodiment, the polygons within the optimization range selected by the user can be recorded as a set F S ,like Fig.10 shown. Fig.10 is a schematic diagram of a polygon to be optimized selected by a user according to an embodiment of the present invention, wherein the set F S is the highlighted surface in the figure, including the highlighted areas in the second, third, and fourth quadrants on the right, where F S The surface has a little white dots as highlights, which are converted to form F S The edges of s , get all unselected faces and convert them into the edges that make up these faces, recorded as set E ns , get the edges on the edge of the entire object and add them to the set E ns , get E s With E ns The intersection between them obtains the edge set E of the selected optimization range polygon. B , convert it to obtain EB All the vertices passed are recorded as the edge vertex set V B , transform to obtain the composition F S All vertices of and remove the set V B , get the internal vertex set V I If the user chooses to optimize the edge, the set F S 、E B 、V B and V I Output to step S202', otherwise, it can be directly output to step S205'.
[0172] It should be noted that the above C of this embodiment n The value range of can be 0-1. This value determines whether the optimization result is biased towards the original normal or the reference weighted normal calculated in the current state in subsequent calculations. It is generally taken as 0.5, and through multiple iterations, the normal of each vertex gradually tends to the theoretical optimal solution during the iteration. If the value is too large, the optimization result may be overcorrected, and the normal will repeatedly swing around the optimal solution during multiple iterations.
[0173] Step S202 ′: averaging edge normals.
[0174] This embodiment can obtain the polygon set to be optimized F S All vertex normals within the range are recorded as set N VS , this set does not contain the edge set E B The vertex normals of the adjacent faces outside the selection range can be used to exclude the vertex normals of the chamfered faces with inconsistent curvature outside the selection range, and convert them to obtain all the vertex normals that are consistent with E B Adjacent vertex normals, denoted as set N VB , get N VS With N VB The intersection between them, get all the vertex normals of the polygons on the edge of the selected area, belonging to one side of the selected area range and record it as set N VBS , take the edge vertex set V one by one B The vertices in belong to the set N VBS The vertex normal of is obtained, and its average vector is obtained. The average is assigned to all vertex normals on the vertex, so as to unify all vertex normal vectors on each edge vertex, which is convenient for subsequent optimization calculations.
[0175] Step S203', edge normal target vector calculation.
[0176] This embodiment can start from i=1 and add the edge vertex set V B The i-th vertex V on Bi , edge set E BAnd the polygon set F selected within the optimization range S Output to the normal vector calculation module 102 of the edge vertex of the selected area to calculate and obtain its reference normal vector And get the vertex V Bi The current normal vector The optimized vertex V can be calculated by the following formula Bi The target normal vector
[0177]
[0178] Finally Record the target normal vector sequence set N V Repeat the above steps until the edge vertex set V is traversed B All vertices in .
[0179] Step S204 ′: adjusting the normals of edge vertices.
[0180] In this embodiment, the target vector sequence set N of all edge vertices is obtained. V After that, we can start from i=1 and add the edge vertex set V one by one B The i-th vertex V Bi All vertex normal vectors are uniformly corrected to set N V The normal vector of the i-th position
[0181] This embodiment can repeat the above steps until the set V is traversed. B The reason why the target normal vector is not corrected immediately after being calculated in step S203′ is that a certain vertex after being changed may also be a neighboring vertex of another unoptimized vertex, and the vertex changed first will cause deviation in the subsequent optimization results.
[0182] It should be noted that the above step S203′ only calculates the target normal vector of each vertex according to the normal state of the current neighboring points to obtain the target vector sequence set. In fact, the normal of each vertex still maintains the state before optimization. Only when the target normal vector calculation of all vertices is completed and the target vector sequence set N is obtained V Only then will the normal vector of each vertex be changed in step S204'. Otherwise, the calculation of the unoptimized vertex using the normal vector of the neighboring point that has been corrected will cause deviation in the result. The above-mentioned unified correction means that all vertex normals of the vertex (each neighboring face has a vertex normal) are uniformly modified to the target normal vector in the calculated set.
[0183] Step S205′, calculation of internal normal target vector.
[0184] This embodiment can obtain the internal vertex set V one by one I The vertices in the vertices are obtained and the normal vectors of all their vertices are obtained. After taking the average value, all the vertex normals on the vertex are assigned to the vertex, so that all the vertex normal vectors on each internal vertex are consistent, which is convenient for subsequent optimization calculations.
[0185] Optionally, this embodiment may start from i=1 and convert the set V I The i-th vertex V on Ii Output to the vertex normal vector calculation module 103 inside the selected area to calculate and obtain its reference normal vector And get V Ii Current normal vector The optimized vertex V is calculated by the following formula Ii The target normal vector
[0186]
[0187] Finally Record the target normal vector sequence set N V Repeat the above steps until the set V is traversed. I All vertices in .
[0188] Step S206 ′: adjusting internal vertex normals.
[0189] This embodiment can obtain the target vector sequence set N of all internal vertices. V After that, we can start from i=1 and add the set V I The i-th vertex V Ii All vertex normals are uniformly corrected to the target vector sequence set N V The normal vector of the i-th position Repeat the above steps until V is traversed. I After all vertices are in the optimization, the number of iterations executed is added by one. If the number of iterations executed is less than the set number of iterations T, steps S203′-S206′ can be re-executed according to the option of optimizing the edge vertex normals, or steps S205′-S206′ can be re-executed according to the option of not optimizing the edge vertex normals. When the number of iterations executed is equal to T, the optimization ends.
[0190] The following is an introduction to the data processing method in the selection area edge vertex normal vector calculation module 102 of this embodiment.
[0191] Step S301 ′, identifying the topological structure around the vertex.
[0192] This implementation can obtain the edge vertex set V from step S203′ BThe i-th edge vertex V Bi , edge set E B And the optimized range polygon set F S . The following Fig.11 Point H in the input vertex V Bi Herein, Fig.11 is a schematic diagram of vertex distribution of a three-dimensional model according to an embodiment of the present invention, including points A, B, C, D, E, F, G, H, I, J, K, L, and M. This embodiment can obtain vertex V Bi All adjacent edges E T and all adjacent faces F T , get F T With F S The intersection between them is recorded as the new set F T , F T Can include Fig.11 The polygons CGH, CHD and DHIE shown in Figure 1 are used to obtain the components of F T All edges of V are removed from them Bi All adjacent edges E connected T , get the connection with vertex V Bi (H) The continuous edge set E of all neighboring points that are coplanar and within the selected area N , where the E N Contains Fig.11 The edges GC, CD, DE and EI shown in E B With E T The intersection between them, in getting the vertex V Bi The edge set E of the selected optimization range polygon B After the adjacent edge on the first side, the two adjacent points at the other end of the adjacent edge are transformed and recorded as V N1 、V Nn ,like Fig.11 The vertices G and I shown in .
[0193] Step S302', sorting the neighbor point set.
[0194] In this embodiment, the continuous edge set E N With neighboring point V N1 、V Nn Any point in the N1 , for example, Fig.11 The point G shown in FIG. 1 is input into the continuous edge set related vertex sequence arrangement module 104 for sorting. After sorting, the vertex V N1 As the starting point, go through the continuous edge set E in order N All vertices on V N The final vertex set VN , where the vertex set V N In order it can include Fig.11 The vertices G, C, D, E, and I are shown.
[0195] Step S303 ′, calculating the edge angle.
[0196] This embodiment can start from i=1 and take V N The vertex V on Ni With V N(i+1) , calculated by V Ni 、V Bi With V N(i+1) The angles of the included angles, until the calculation of point i=n-1 is completed, all the included angles are summed up to obtain the vertex V Bi The total angle of the angle formed by all adjacent sides on one side of the selection range can be recorded as the edge adjacent angle A Bi , in such Fig.11 As shown, A Bi It can be the sum of the angles of ∠GHC, ∠CHD, and ∠DHI. Bi It will be used to determine how to calculate the vertex V in the future. Bi Neighboring point V N The normal vector weight of .
[0197] Alternatively, if A Bi ∈(120°, 240°), then jump to step S304′; if A Bi ≥240°, jump to step S305′; if A Bi ≤120°, jump to step S306′.
[0198] Step S304', weighted calculation A1 with reference to the normal vector.
[0199] This embodiment can obtain the vertex V N1 、V Bi With V Nn Three vertices and ignoring other neighboring points, for vertex V Bi Perform weighted calculation of the normal vector, because the two edges V N1 V Bi With V Bi V Nn Both sides are used for substitution The angle of the angle weight calculated by the formula is ∠V N1 V Bi V Nn With ∠V Nn V Bi V N1 Therefore, this embodiment only needs to use two edges V N1 V BiWith V Bi V Nn The length of the vertex V is calculated by calculating its distance weight. Bi The reference normal vector of Afterwards, if A Bi >180°, continue to execute step S305′, otherwise directly jump to step S306′.
[0200] Step S305', weighted calculation B1 with reference to the normal vector.
[0201] This embodiment can obtain the vertex V Bi And its neighboring point set V in the selected area N , its neighboring points that do not belong to the selected area can be ignored, for example, Fig.11 The vertices K, L, and M shown will not be included in the reference calculation. Bi Perform weighted calculation of normal vector to obtain vertex V Bi The reference normal vector of
[0202] Step S306 ′, weighted synthesis of reference normal vectors.
[0203] This embodiment can obtain the vertex V Bi The current normal vector of
[0204] Optionally, when the edge adjacent angle A Bi <120°, vertex V Bi It is not possible to obtain an ideal smooth surface result by only calculating the weighted normal vectors of a small range of adjacent vertices in one direction, for example, Fig.11 As shown in Bi If point C is the point, and the two adjacent edges of the edge of the selection area are BC and CD, then the adjacent vertices included in the calculation range are only B, G, H, and D, which are within a narrow angle range on one side of point C. Using them as references to calculate the target normal vector will cause the normal of vertex C to deviate toward these vertices. Therefore, this embodiment can directly obtain vertex V Bi The normal vectors of all vertices on the polygon when their normals are perpendicular to the polygon they are in (such as Figure 3 The state shown), can be taken from the set N VBS The vertex normal of , find its average vector, which can be recorded as It should be noted that this embodiment does not take the average value of all vertex normals because the vertex is located at the edge. If the average value of all vertex normals is obtained, vertex normals with inconsistent curvatures will be included in the calculation.
[0205] Optionally, when A Bi∈(120°, 180°], the reference normal vector can partially refer to the neighboring points on both sides of it that are on the edge, that is, as A Bi When the angle exceeds 120°, the reference normal vector may gradually be biased toward the result calculated in step S304′. In such Fig.11 As shown, assume that vertex V Bi is point B, and the two adjacent sides of the edge of the selection area are AB and BC. The adjacent vertices included in the calculation range include A, F, G, and C. If all of them are included in the reference range, the normal of point B will be biased towards point G. However, if only the normals of points A and C are calculated, a more ideal normal of point B can be obtained. Therefore, this embodiment can obtain the vector as follows:
[0206]
[0207] Among them, when A Bi ∈(180°, 240°), V Bi The neighboring points of are no longer limited to being on one side of any adjacent edge of the edge of the selected area, so the reference normal vector can be gradually changed from the one calculated in step S304′ to Biased towards the calculated value in step S305′ Therefore, the vector should be obtained as follows
[0208]
[0209] When A Bi ≥240°, V Bi The normal vectors of all neighboring points in the selection are sufficient as the source of the reference normal vector, so
[0210] Finally, the reference normal vector Return to the program main control and structure recognition module 101.
[0211] It should be noted that the angles of 120°, 180°, 240°, etc. described as the determination conditions in the above steps S303′-S306′ of this embodiment are all empirical data and can be adjusted according to actual conditions if necessary.
[0212] The data processing in the selection area internal vertex normal calculation module 103 can be divided into the following steps:
[0213] Step S401 ′, identifying the topological structure around the vertex.
[0214] This embodiment can obtain the vertex V from S205′ Ii , transform to get vertex V Ii All adjacent edges ET and all adjacent faces F T , transform to obtain the composition F T All edges of V are removed from it Ii All adjacent edges E connected T , get the connection with vertex V Ii The continuous edge set E of all coplanar neighboring points N , and transform to obtain E N Any vertex V I1 .
[0215] Step S402', sorting the neighbor point set.
[0216] This embodiment sets E N With V I1 The continuous edge set is input to the vertex sequence arrangement module 104 for sorting, and the vertex V is obtained after sorting. I1 As the starting point, go through the continuous edge set E in order N The vertex set V of all vertices on N .
[0217] Step S403', weighted calculation of reference normal vector.
[0218] The implementation can obtain the vertex V Ii and its neighboring point set V N , for the vertex V Ii Perform weighted calculation of normal vector to obtain vertex V Ii The reference normal vector is denoted as And return to the program main control and structure recognition module 101.
[0219] The following is an introduction to the data processing method in the continuous edge set related vertex sequence arrangement module 104 of this embodiment.
[0220] In this embodiment, the continuous edge set E is obtained from the selection area edge vertex normal correction module 102 and the selection area internal vertex normal correction module 103. N After the starting vertex V is obtained, the starting vertex V can be recorded as the vertex set V N The first position of the set V is obtained by repeating the following steps: N The last vertex, transform to get all its adjacent edges E T , get E T With E N The intersection of the vertex in the transformation is obtained in the set E N After finding the adjacent edge in the vertex, get the vertex V at the other end of the adjacent edge. T , in the T Eliminate set V N After the vertices already included in the set V TThe first vertex in the list is added to the current vertex set V N and put it at the end, repeat the above steps until it matches the set E N All connected vertices are recorded in the set V N , and finally V N Return to the selection area edge vertex normal correction module 102 and the selection area internal vertex normal correction module 103.
[0221] The above-mentioned method for smoothing surface normals of this embodiment can provide a convenient, efficient, and easy-to-use tool for smoothing polygonal model surface normals, and can optimize all vertex normals within the selected range with one click, that is, correct the uneven normal direction on the surface with one click. In practical applications, the method of this embodiment can be applied to smoothing normal correction of polygonal three-dimensional model surfaces such as planes, convex surfaces, concave surfaces, saddle surfaces, cylinders, cones, and surfaces with seam lines.
[0222] This embodiment only needs to select polygons with similar curvature on the surface to be optimized (excluding polygons with large curvature changes such as chamfered surfaces), and then multiple surface normal optimization iterations can be completed with one click, thereby improving the convenience of surface smoothing; this embodiment can adapt to various polygonal topological structures, and thus can be used for surface normal optimization of all three-dimensional models based on polygons, and can be applicable to all polygonal three-dimensional model surfaces such as planes, convex surfaces, concave surfaces, saddle surfaces, cylinders, cones, surfaces with seams, etc., which brings great efficiency to operations that require smooth surface normals in model production optimization, thereby improving the versatility of surface smoothing; this embodiment can use componentized and modular The design is based on thinking, which is not only conducive to improving the debugging efficiency of the code, but also can expand the single vertex normal optimization function with this tool as the core, or combine with the polygonal model chamfer surface selection tool to develop the overall normal automatic optimization function of the model, and it is very convenient for later code maintenance, thereby improving the scalability and maintainability of surface smoothing; this embodiment calculates the normal vector of each vertex on the surface of the selected area with a unique algorithm, and the effect is ideal and the practicability is high; this embodiment can select the area to be optimized and complete the normal optimization with one click, and the number of automatic iterations can be set to obtain the ideal effect through multiple iterations, simplify the operation process, increase the operation efficiency, and have high ease of use.
[0223] The embodiment of the present invention further provides a device for smoothing a curved surface. It should be noted that the device for smoothing a curved surface in this embodiment can be used to perform the embodiment of the present invention. Figure 2 The surface smoothing method shown.
[0224] Fig.14 Schematic diagram of a curved surface smoothing device according to an embodiment of the present invention. Fig.14As shown, the curved surface smoothing device 140 includes: a selection unit 141, a determination unit 142, an adjustment unit 143 and a smoothing unit 144.
[0225] The selection unit 141 is used to select a target surface to be smoothed on the three-dimensional model.
[0226] The determination unit 142 is used to determine a target vertex in the target surface and determine a plurality of neighboring points of the target vertex, wherein each neighboring point is coplanar with the target vertex on the target surface.
[0227] The adjustment unit 143 is used to adjust the first normal vector of each neighbor point to a second normal vector based on the weight of each neighbor point to obtain multiple second normal vectors, wherein the weight of each neighbor point is used to represent the importance of the first normal vector of each neighbor point to the third normal vector of the target vertex.
[0228] The smoothing unit 144 is configured to determine a third normal vector based on the plurality of second normal vectors, and to perform smoothing on the target surface based on the third normal vector.
[0229] In the surface smoothing device of this embodiment, by determining the weights and normal vectors corresponding to the neighboring points of the target vertex on the target surface, the normal vectors of the vertex normals of all vertices on the selected target surface can be optimized to achieve the purpose of smoothing the surface, thereby solving the technical problem of low efficiency in surface smoothing and achieving the technical effect of improving the efficiency of surface smoothing.
[0230] An embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the surface smoothing method of the embodiment of the present invention.
[0231] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0232] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0233] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0234] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0235] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for smoothing a curved surface, characterized in that: include: Select a target surface to be smoothed on the three-dimensional model; Determine a target vertex in the target curved surface, and determine a plurality of neighboring points of the target vertex, wherein each of the neighboring points is coplanar with the target vertex on the target curved surface; Adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point to obtain a plurality of second normal vectors, wherein the weight of each neighboring point is used to indicate the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex, and the first normal vector is an average value of the normal vectors of the plurality of vertices of each neighboring point; Determine the third normal vector based on the plurality of second normal vectors, and perform smoothing on the target surface based on the third normal vector; Wherein, adjusting the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point includes: determining the second normal vector as the product of the weight of each neighboring point and the first normal vector; determining the third normal vector based on the multiple second normal vectors includes: determining the sum of the multiple second normal vectors as the third normal vector; The method further includes: rendering the smoothed three-dimensional model to obtain a target image; and displaying the target image on a graphical user interface.
2. The method according to claim 1, characterized in that The method further comprises: Among the plurality of neighboring points, determine a first neighboring point corresponding to each of the neighboring points and a second neighboring point corresponding to each of the neighboring points, wherein the first neighboring point is located on a first side of each of the neighboring points, and the second neighboring point is located on a second side of each of the neighboring points; Obtain the distance between each of the neighboring points and the target vertex; A weight of each of the neighboring points is determined based on the first neighboring points, the second neighboring points, and the distance.
3. The method according to claim 2, characterized in that Determining a weight of each of the neighboring points based on the first neighboring point, the second neighboring point, and the distance includes: Obtain a first angle corresponding to each of the neighboring points and a second angle corresponding to each of the neighboring points, wherein the first angle is formed by the first neighboring point corresponding to each of the neighboring points, the target vertex, and each of the neighboring points, and the second angle is formed by each of the neighboring points, the target vertex, and the second neighboring point corresponding to each of the neighboring points; Obtaining the sum of the first angle and the second angle; The weight of each of the neighboring points is determined based on a quotient between the sum and the distance.
4. The method according to claim 1, characterized in that: Determining a target vertex in the target surface includes: identifying an edge vertex in the target surface; The method also includes: obtaining multiple adjacent edges of the edge vertex on the edge edge set of the target surface; obtaining third adjacent points on the multiple adjacent edges except the edge vertex; sorting the vertices and the third adjacent points on the first continuous edge set to obtain a first vertex set, wherein the first continuous edge set includes edges composed of adjacent points of the edge vertex, and the adjacent points of the edge vertex are coplanar with the edge vertex and within the target surface; obtaining each adjacent first vertex and second vertex from the first vertex set; determining a third angle based on each adjacent first vertex and second vertex and the corresponding edge vertex to obtain the multiple third angles.
5. The method according to claim 4, characterized in that Determining a plurality of neighboring points of the target vertex includes: when the sum of the plurality of third angles is within a first threshold range, determining a first-ranked vertex and a last-ranked vertex in the first vertex set as a plurality of neighboring points of the edge vertex; Determining the third normal vector based on the plurality of second normal vectors includes: determining a fourth normal vector based on the plurality of second normal vectors corresponding to a plurality of neighboring points of the edge vertex.
6. The method according to claim 5, characterized in that The method further includes: when the sum of the plurality of third angles is within a first sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of the plurality of third angles, a lower limit value of the first sub-threshold range, and a current normal vector of the edge vertex; The step of smoothing the target curved surface based on the third normal vector includes: smoothing the target curved surface based on the adjusted fourth normal vector.
7. The method according to claim 5, characterized in that The method further includes: when the sum of the plurality of third angles is within a second sub-threshold range of the first threshold range, adjusting the fourth normal vector based on the sum of the plurality of third angles and a lower limit value of the second sub-threshold range; The step of smoothing the target curved surface based on the third normal vector includes: smoothing the target curved surface based on the adjusted fourth normal vector.
8. The method according to claim 4, characterized in that Determining a plurality of neighboring points of the target vertex includes: determining a plurality of vertices in the first vertex set as a plurality of neighboring points of the edge vertex within the target surface when the sum of the plurality of third angles is within a second threshold range; Determining the third normal vector based on the plurality of second normal vectors includes: determining a fifth normal vector based on the plurality of second normal vectors corresponding to a plurality of neighboring points of the edge vertex within the target surface; The step of smoothing the target curved surface based on the third normal vector includes: smoothing the target curved surface based on the fifth normal vector.
9. The method according to claim 4, characterized in that The method further comprises: When the sum of the multiple third angles is within a third threshold range, obtaining a target vector corresponding to the edge vertex, wherein the target vector is an average vector of multiple vectors of the multiple vertex normals when the multiple vertex normals of the edge vertex are perpendicular to the polygon where the edge vertex is located, and the multiple vertex normals are vertex normals of the polygon on the edge of the target surface; The target vector is determined as the third normal vector.
10. The method according to claim 4, characterized in that The method further comprises: Obtaining a polygon set of the target surface; The edge set is obtained based on the polygon set.
11. The method according to claim 10, characterized in that The method further includes: acquiring vertices that the edge set passes through to obtain an edge vertex set; Identifying edge vertices in the target surface includes: determining vertices in the edge vertex set as the edge vertices.
12. The method according to claim 4, characterized in that After determining a plurality of the third normal vectors corresponding one-to-one to the plurality of edge vertices, the current normal vectors of the corresponding plurality of edge vertices are corrected based on the plurality of the third normal vectors respectively to obtain a plurality of first target normal vectors to smooth the target surface.
13. The method according to claim 1, characterized in that Determining a target vertex in the target surface includes: identifying an internal vertex in the target surface.
14. The method according to claim 13, characterized in that The method further includes: obtaining a second continuous edge set based on the internal vertex, wherein the second continuous edge set includes edges formed by neighboring points of the internal vertex, and the neighboring points of the internal vertex are coplanar with the internal vertex; sorting the vertices on the second continuous edge set and the internal vertex to obtain a second vertex set; Determining a plurality of neighboring points of the target vertex includes: determining a plurality of neighboring points of the internal vertex in the second vertex set.
15. The method according to claim 13, characterized in that After determining a plurality of the third normal vectors corresponding one-to-one to the plurality of the internal vertices, the current normal vectors of the corresponding plurality of the internal vertices are corrected based on the plurality of the third normal vectors respectively to obtain a plurality of second target normal vectors to smooth the target surface.
16. A device for smoothing curved surface, characterized in that: include: A selection unit, used for selecting a target surface to be smoothed on a three-dimensional model; A determination unit, configured to determine a target vertex in the target curved surface, and determine a plurality of neighboring points of the target vertex, wherein each of the neighboring points is coplanar with the target vertex on the target curved surface; an adjusting unit, configured to adjust the first normal vector of each neighboring point to a second normal vector based on the weight of each neighboring point, so as to obtain a plurality of second normal vectors, wherein the weight of each neighboring point is used to indicate the importance of the first normal vector of each neighboring point to the third normal vector of the target vertex, and the first normal vector is an average value of the normal vectors of the plurality of vertices of each neighboring point; a smoothing unit, configured to determine the third normal vector based on the plurality of second normal vectors, and perform smoothing processing on the target surface based on the third normal vector; The adjustment unit is further used to: determine the product between the weight of each neighboring point and the first normal vector as the second normal vector; the smoothing unit is used to determine the third normal vector based on the multiple second normal vectors, including: determining the sum of the multiple second normal vectors as the third normal vector; The device is also used for: rendering the smoothed three-dimensional model to obtain a target image; and displaying the target image on a graphical user interface.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of claims 1 to 15.
18. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the computer program to perform the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Vertex normal processing method and apparatus
CN107316337A
Method and device for snapping normals to create fair 3D surfaces from edge curves
US20130187913A1