Methods, apparatus, electronic devices and storage media for extracting model edges
By determining the normal direction and connecting direction of the model's position points in three-dimensional space, the edge position points of the three-dimensional model are extracted, solving the problem of monotonous rendering effects in existing technologies and achieving richer rendering effects.
Patent Information
- Application Number
- CN202211552193.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-05
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-12-05
AI Technical Summary
In existing technologies, the rendering effect of the edges of 3D models is relatively simple and difficult to adjust flexibly, resulting in insufficient rendering effect.
By setting up a 3D target model and reference points in a preset 3D space, determining the normal direction and connecting direction of the model's position points, and extracting edge position points from multiple model position points based on the directional relationship, the model edges of the 3D target model are formed.
It achieves more flexible model rendering effects, making the rendering effects related to model edges richer and more diverse.
Smart Images

Figure CN116245898B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model rendering technology, and in particular to a method, apparatus, electronic device, and storage medium for extracting model edges. Background Technology
[0002] In related technologies, pre-packaged functional modules can be used to render 3D models, obtaining rendering effects related to the edges of the 3D model; for example, cartoon material rendering can be applied to a 3D model to obtain an edge-sweeping rendering effect. However, the above methods cannot extract the edges of the 3D model, resulting in relatively simple rendering effects related to the edges of the 3D model. Summary of the Invention
[0003] In view of this, the present invention provides a method, apparatus, electronic device and storage medium for extracting model edges, so as to extract the model edges of a three-dimensional model, realize more flexible model rendering, and make the rendering effects related to model edges richer.
[0004] In a first aspect, embodiments of the present invention provide a method for extracting model edges, the method comprising: setting a three-dimensional target model and reference position points in a preset three-dimensional space; determining multiple model position points on the model surface of the three-dimensional target model and determining the normal direction of the position points; determining the direction of the line connecting the model position points and the reference position points; and determining edge position points of the three-dimensional target model from the multiple model position points based on the directional relationship between the direction of the line and the normal direction of the position points; wherein the edge position points constitute the model edge of the three-dimensional target model.
[0005] Secondly, embodiments of the present invention provide a model edge extraction device, the device comprising: a setting module for setting a three-dimensional target model and reference position points in a preset three-dimensional space; a first direction determination module for determining multiple model position points on the model surface of the three-dimensional target model and determining the position point normal direction of the model position points; a second direction determination module for determining the direction of the line connecting the model position points and the reference position points; and a position point determination module for determining edge position points of the three-dimensional target model from the multiple model position points based on the directional relationship between the line direction and the position point normal direction; wherein the edge position points constitute the model edge of the three-dimensional target model.
[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described method for extracting model edges.
[0007] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for extracting model edges.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] The aforementioned method, apparatus, electronic device, and storage medium for extracting model edges involves setting a 3D target model and reference points in a preset 3D space; determining multiple model position points on the surface of the 3D target model and defining the normal directions of these position points; determining the direction of the line connecting the model position points and the reference position points; and determining the edge position points of the 3D target model from the multiple model position points based on the directional relationship between the connecting line direction and the normal direction of the position point. These edge position points constitute the model edges of the 3D target model. In this method, multiple model position points are determined on the surface of the 3D model. Based on the directional relationship between the line direction connecting the model position points and the reference position points, and the normal direction of the model position points, edge position points can be obtained from the multiple model position points, thereby extracting the 3D model edges. The extracted 3D model edges enable more flexible model rendering, resulting in richer rendering effects related to the model edges.
[0010] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0011] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0012] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating a method for extracting model edges according to an embodiment of the present invention;
[0014] Figure 2 A schematic diagram of the three-dimensional target model and reference position points provided in the embodiments of the present invention;
[0015] Figure 3 A schematic diagram of the three-dimensional target model and vertex normals provided in an embodiment of the present invention;
[0016] Figure 4 A schematic diagram of the model location points provided in the embodiments of the present invention;
[0017] Figure 5 A schematic diagram of the position point normal provided in an embodiment of the present invention;
[0018] Figure 6 A schematic diagram of the connecting direction and reference position points provided in an embodiment of the present invention;
[0019] Figure 7 A schematic diagram of the connection direction and position point normal provided in an embodiment of the present invention;
[0020] Figure 8 A schematic diagram of model position points on the model surface inside the model provided in an embodiment of the present invention;
[0021] Figure 9 A schematic diagram illustrating the effect of deleting model position points inside the model only from the first direction, as provided in an embodiment of the present invention;
[0022] Figure 10 A schematic diagram illustrating the effect of deleting model position points inside the model only from the second direction, as provided in an embodiment of the present invention;
[0023] Figure 11 This is a schematic diagram illustrating the effect of deleting model position points inside the model from two directions, as provided in an embodiment of the present invention.
[0024] Figure 12 A schematic diagram of a model edge extraction device provided in an embodiment of the present invention;
[0025] Figure 13 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] In related technologies, the main approach is to use pre-packaged functional modules to render model-related effects and edge effects. However, the types of effects provided by these modules are limited, making it difficult for users to adjust them. This results in poor rendering flexibility and a rather monotonous rendering effect.
[0028] Based on this, embodiments of the present invention provide a method, apparatus, electronic device and storage medium for extracting model edges. This technology can be applied to 3D model rendering. For example, it can be used to extract model edges from a 3D model and then perform subsequent rendering processing based on the model edges.
[0029] To facilitate understanding of this embodiment, a method for extracting model edges disclosed in this invention will first be described in detail, such as... Figure 1 As shown, the method includes the following steps:
[0030] Step S102: Set the three-dimensional target model and reference position points in the preset three-dimensional space;
[0031] The 3D target model is typically a 3D model, which can be static or dynamic. For dynamic 3D models, the shape, orientation, and position of the 3D model in each frame can be captured. Then, the model edges are extracted for each frame using the method described in this embodiment. The reference position point can be a coordinate point in 3D space, which can be preset. Alternatively, a 3D object can be set in 3D space, and the position of the 3D object can be used as the reference position point. For example, the 3D object can be a virtual camera.
[0032] Step S104: Determine multiple model position points on the model surface of the 3D target model, and determine the normal direction of the position points;
[0033] The model location points here are used to filter out edge location points located on the edges of the 3D target model from the available model location points. These edge location points are then used to obtain the model edges of the 3D target model. It's understandable that the more model location points there are, the more accurate the model edges indicated by the final edge location points will be. In practical implementation, model location points can be randomly determined from the model surface of the 3D target model by scattering points. For example, the number or density of scattering points can be preset, and then model location points can be randomly determined from the model surface of the target model based on these parameters. Alternatively, the selection method for model location points can be set to determine multiple model location points. For example, model vertices of the 3D target model can be used as model location points, or the location points at the center of the model surface can be used as model location points, etc.
[0034] The location point normal direction of a model's position point can be obtained from the vertex normals or face normals of the 3D target model. For example, the vertex positions of the 3D target model can store the vertex normal direction corresponding to each vertex. If the model position point is a model vertex, the vertex normal direction can be directly determined as the location point normal direction. If the model position point is not a model vertex but lies on a model surface, the location point normal direction can be obtained by weighted calculation based on the vertex normal directions of multiple model vertices on that model surface. Alternatively, the 3D target model can also store face normals. If the model position point lies on a model surface, the face normal corresponding to that model surface can be used as the location point normal direction. If the model position point is a model vertex, the face normals of multiple model surfaces connected to that vertex can be weighted to obtain the location point normal direction.
[0035] Step S106: Determine the direction of the line connecting the model position point and the reference position point;
[0036] For each model location point, the direction of the line connecting that model location point and the aforementioned reference location point can be calculated. In actual implementation, the coordinates of the model location point and the reference location point in 3D space can be obtained. The vector between the model location point and the reference location point is calculated using these coordinates, and the direction of this vector is determined as the direction of the line. Alternatively, a line can be generated between the model location point and the reference location point, and then the direction of this line can be calculated to obtain the direction of the line.
[0037] Step S108: Based on the directional relationship between the connecting line direction and the normal direction of the position point, determine the edge position point of the three-dimensional target model from multiple model position points; wherein, the edge position point constitutes the model edge of the three-dimensional target model.
[0038] In this embodiment, the edge points are located on the outline of the 3D target model as viewed from the reference point. It is understood that the closer a model point is to the edge, the larger the angle between the direction of the connecting line and the normal direction of the point. Based on this directional relationship, edge points can be extracted from the model points. For example, an angle threshold can be set, and model points with angles greater than this threshold can be identified as edge points. Since edge points are scattered, the more edge points there are, the clearer and more accurate the edges of the 3D target model formed by these edge points will be. In actual implementation, the edge points can be further processed, such as by connecting lines and smoothing, to obtain the edge lines of the model.
[0039] The aforementioned method for extracting model edges involves setting up a 3D target model and reference points in a preset 3D space; determining multiple model position points on the surface of the 3D target model and defining the normal directions of these position points; determining the direction of the line connecting the model position points and the reference position points; and, based on the directional relationship between the connecting line direction and the normal direction of the position point, determining the edge position points of the 3D target model from these multiple model position points. These edge position points constitute the model edges of the 3D target model. In this method, multiple model position points are determined on the surface of the 3D model. Based on the directional relationship between the line direction connecting the model position point and the reference position point, and the normal direction of the model position point, edge position points can be obtained from these multiple model position points, thereby extracting the 3D model edges. The extracted 3D model edges enable more flexible model rendering, resulting in richer rendering effects related to the model edges.
[0040] In practical implementation, the first step is to determine the reference position point. Specifically, a 3D target model and a virtual camera are set up in a preset 3D space; the camera position of the virtual camera is then determined as the reference position point. For example... Figure 2 In this embodiment, the 3D target model and the virtual camera can have a certain distance, with the location of the virtual camera serving as a reference point. This 3D space can be generated using 3D computer graphics software, such as Houdini; the method described in this embodiment is implemented using software to obtain the model edges.
[0041] In one specific implementation, the position point normal direction of a model's location point can be determined by the vertex normal direction. Specifically, the vertices of the 3D target model have preset vertex normal directions; these directions can be stored within the vertices of the 3D target model or stored through a normal map. For example... Figure 3 The image shows the vertex normals of the three-dimensional target model.
[0042] If the model location point is a model vertex, the vertex normal direction of the model vertex is determined as the location point normal direction; if the model location point is not a model vertex, the 3D target model vertices within a specified range of the model location point are determined; based on the vertex normal directions of the 3D target model vertices, the location point normal direction of the model location point is determined.
[0043] If the model location point is not a model vertex, it is typically located on a model surface with multiple vertices. These vertices are used as vertices of the 3D target model. The normal direction of the model location point is calculated using the vertex normal directions defined by the 3D target model. For example, the aforementioned specified range can be the model vertices of the model surface where the model location point is located.
[0044] For example, the average of the vertex normal directions of a 3D target model can be calculated to obtain the position point normal direction. The position point normal direction can be linked to a specified attribute in the software, allowing you to view the position point normal direction for each model point.
[0045] exist Figure 4 In this process, points are scattered across the surface of the 3D target model to obtain multiple model position points. The denser the model position points, the more edge position points are obtained, resulting in smoother and more accurate model edges. Using the method described in the previous embodiment, the normal direction of each model position point can be obtained. Figure 5 The location point normal of the model is shown. Figure 6 The diagram shows the line connecting the model position point on the 3D target model to the virtual camera, where the camera position of the virtual camera is the aforementioned reference position point.
[0046] This embodiment provides multiple ways to determine edge location points.
[0047] In one approach, the angle between the direction of the connecting line and the normal direction of the location point is determined; from the model location points whose angle falls within a preset range, the edge location points of the 3D target model are determined. It can be understood that the larger the angle, the closer the model location point is to the edge of the 3D target model; when the angle is 90 degrees or close to 90 degrees, the model location point is considered an edge location point. Figure 7 As can be seen in the example, at model locations on the edge, the angle between the normal direction of the location point and the direction of the connecting line is relatively large, close to 90 degrees. The aforementioned preset angle range can be preset, for example, it can be set to 89-90 degrees, or 80-90 degrees, etc.
[0048] In practical implementation, edge points can be calculated and filtered using trigonometric functions. Specifically, the cosine value of the directional angle is determined; model points whose absolute cosine value is less than a preset cosine threshold are identified as edge points of the 3D target model. This preset cosine threshold matches the aforementioned preset angle range.
[0049] In one specific implementation, the model position point with a right angle is determined as the edge position point of the 3D target model. That is, the direction of the line connecting the final edge position point and the reference position point has a 90-degree angle with the direction of the normal to the position point.
[0050] Understandably, the smaller the aforementioned preset angle range, the fewer the number of edge points, and the thinner the edge lines of the model formed by these edge points. For example, when the preset angle range is small, such as 89-90 degrees, the final number of edge points will be relatively small, resulting in a thinner model edge; conversely, when the preset angle range is large, such as 70-90 degrees, the final number of edge points will be relatively large, resulting in a thicker model edge line. The angle threshold can be set according to actual needs to control the thickness of the final model edge.
[0051] In another approach, the cosine value of the directional angle can be calculated. When the directional angle is close to 90 degrees, the cosine value will be close to zero. Based on this, a cosine value threshold can be set, and model position points whose absolute cosine value is less than the threshold can be identified as model position points whose directional angle is greater than the preset angle threshold.
[0052] After filtering out model location points from multiple location points whose directional angle is greater than a preset threshold, these model location points can be directly identified as edge location points. For example, for models with relatively simple structures, model location points with directional angles greater than the preset threshold can be used as edge location points. However, for models with relatively complex structures, there may be model location points among those with directional angles greater than the preset threshold that are not located at the model edge. For example, if the model surface of the 3D target model has large undulations or contains internal surfaces located inside the model, then there will be model location points among those with directional angles greater than the preset threshold that are not located at the model edge.
[0053] Figure 8 As an example, the 3D target model is a pig's head model. This model contains internal surfaces, such as the model surface inside the pig's mouth. Model points on these surfaces are not located at the model edges, but they still satisfy the condition that the directional angle is greater than a preset threshold. Therefore, it is necessary to further filter the model points with directional angles greater than the preset threshold to obtain edge points.
[0054] In one approach, model position points whose directional angles fall within a preset range are identified as candidate position points. These candidate position points are then offset along the connecting line to obtain offset position points. A line is generated connecting the offset position points and a reference position point. Based on the positional relationship between the connecting line and the model surface on the 3D target model, edge position points of the 3D target model are determined from the candidate position points. The connecting line between the candidate position points and the reference position point typically has two opposing directions. This connecting direction can be understood as one of the two directions of the connecting line, for example, the direction pointing to the reference position point; alternatively, the connecting direction can be either of the two directions.
[0055] Specifically, the candidate position points can be offset along the first direction of the connecting line to obtain the first position point; the candidate position points can also be offset along the second direction of the connecting line to obtain the second position point; wherein the second direction is opposite to the first direction; the first and second position points are then determined as the offset position points. This method can also be understood as deleting candidate position points located inside the model from both directions, thereby making the final edge position points more accurate.
[0056] As an example, Figure 9 The diagram shows the final edge position points obtained after offsetting the candidate position points only along the first direction. Figure 10 This shows the final edge position points obtained after offsetting the candidate position points only along the second direction; observe... Figure 9 and Figure 10 It can be seen that if the offset is made in only one direction, there will be some edge points that are not located at the edge of the model, resulting in low accuracy of the edge points. Figure 11 The diagram shows the final edge locations obtained after offsetting the candidate locations in two directions. These edge locations are all located at the edge of the model and have high accuracy.
[0057] In one specific implementation, after offsetting the candidate position point along the aforementioned first direction, the second position point can be obtained in the following manner: Specifically, the difference vector between the candidate position point and the first position point is determined; based on this difference vector, the candidate position point is offset to obtain the second position point; wherein, the second position point and the first position point are located on opposite sides of the candidate position point along the line direction of the difference vector. It can be understood that the difference vector is obtained by subtracting the first position point from the candidate position point. The direction indicated by this difference vector is opposite to the offset direction of the first position point relative to the candidate position point, but the length of the difference vector is the same as the distance between the first position point and the candidate position point. Based on this, using the candidate position point as a reference, the second position point is obtained by offsetting according to the direction and length indicated by the difference vector; the second position point and the first position point are on opposite sides of the candidate position point, that is, the offset direction of the second position point is opposite to that of the first position point, but the distance between the second position point and the first position point is the same as that between the first position point and the candidate position point.
[0058] In practice, the distance between the first position point and the candidate position point is called the first distance, and the distance between the second position point and the candidate position point is called the second distance. The first distance and the second distance can be the same or different. However, usually the distance values of the first distance and the second distance are both small, that is, the candidate position point is offset by a very small distance in both directions to obtain the aforementioned first position point and second position point.
[0059] After offsetting the candidate point along the connecting line, the resulting offset point will be away from the model surface. Then, a line is generated connecting the offset point and the reference point. Since the offset point is away from the model surface of the 3D target model, extending this line can bring the line closer to the 3D target model. The offset distance between the offset point and the corresponding candidate point is usually set to a small value. In this case, the positional relationship between the connecting line and the model surface of the 3D target model will have several possibilities, such as the line passing through the model surface, being tangent to the model surface, or being separated from the model surface, i.e., having no intersection point. Based on this positional relationship, edge points can be determined from the aforementioned candidate points.
[0060] In one scenario, if the connecting line crosses the model surface of the 3D target model, the corresponding candidate point is deleted, and the remaining candidate points are designated as edge points. For model surfaces recessed within the model, if candidate points lie on these surfaces, the connecting line between the candidate point and the reference point will cross the model surface where the candidate point is located, and may also cross other model surfaces. Therefore, candidate points whose connecting lines cross the model surface are not considered edge points and need to be deleted. After deleting these candidate points, the remaining candidate points are obtained. These remaining candidate points can be used as edge points.
[0061] The lines connecting the remaining candidate points do not pass through the model surface, but are tangent to it. Understandably, on the edge of the model, the lines connecting the edge points to the reference points are tangent to the model. Therefore, this method allows for the selection of more accurate edge points. However, it also results in a smaller number of edge points, leading to finer final model edges.
[0062] Besides determining candidate location points using the aforementioned directional angle method, other methods can also be used. Specifically, obtain the absolute value of the cosine of the line direction and the normal direction of the location point; delete model location points whose absolute cosine value is greater than a preset absolute value threshold, and determine the remaining model location points as candidate location points. When the model location point is located at the edge of the model, the absolute value of the cosine is very small, approaching zero. Therefore, an absolute value threshold can be preset, such as 1 or 0.5, to delete model location points with large absolute cosine values, and determine the remaining model location points as candidate location points.
[0063] The above method can be used to obtain edge position points distributed along the edges of the model. When the model is dynamic, the edge position points in each frame can be obtained in real time using this method. After obtaining the edge position points, they can be further processed. The processing methods include at least one of the following: using the edge position points as the emission source of the target effect and rendering and adding the target effect; generating the model edge line model of the 3D target model based on the edge position points; setting the rendering attribute information of each edge position point, rendering the edge position points based on the rendering attribute information, and obtaining the edge rendering result corresponding to the rendering attribute information.
[0064] In this embodiment, since the edge position points of the model are extracted, the edge position points can be used as the emission source of special effects. Users can edit various types of special effects. For example, the edge position points can be divided into multiple regions, and different special effects can be attached to the edge position points of each region, thereby increasing the richness of the special effects.
[0065] You can also connect and smooth the edge points to obtain the model edge lines, generate the model edge line model, and control the model individually, such as controlling the movement of the edge line model, to obtain the edge line model associated with the 3D target model. You can also set different special effects for the edge line model than the 3D target model.
[0066] Alternatively, different rendering attribute information can be set for each edge location point. This rendering attribute information can be, for example, the size attribute, material attribute, displacement attribute, etc. of the edge location point. Based on these rendering attribute information, each edge location point is rendered to obtain the edge rendering effect of the 3D target model. This edge rendering effect can also be a sweeping edge effect, thereby making the sweeping edge rendering effect richer.
[0067] For the corresponding method embodiments described above, see [link to relevant documentation]. Figure 12 The diagram shows a structural schematic of a model edge extraction device, which includes:
[0068] Setting module 120 is used to set the three-dimensional target model and reference position points in a preset three-dimensional space;
[0069] The first direction determination module 122 is used to determine multiple model position points on the model surface of the three-dimensional target model and determine the position point normal direction of the model position points;
[0070] The second direction determination module 124 is used to determine the direction of the line connecting the model position point and the reference position point;
[0071] The location point determination module 126 is used to determine the edge location points of the three-dimensional target model from multiple model location points based on the directional relationship between the connecting line direction and the normal direction of the location point; wherein, the edge location points constitute the model edge of the three-dimensional target model.
[0072] The aforementioned model edge extraction device sets up a 3D target model and reference points in a preset 3D space; determines multiple model position points on the model surface of the 3D target model, and determines the normal direction of each model position point; determines the direction of the line connecting the model position points and the reference position points; and, based on the directional relationship between the connecting line direction and the normal direction of the position point, determines the edge position points of the 3D target model from the multiple model position points; wherein, the edge position points constitute the model edge of the 3D target model. In this method, multiple model position points are determined on the surface of the 3D model. Based on the directional relationship between the line direction connecting the model position point and the reference position point, and the normal direction of the model position point, edge position points can be obtained from the multiple model position points, thereby extracting the 3D model edge. The extracted 3D model edge enables more flexible model rendering, resulting in richer rendering effects related to the model edge.
[0073] The aforementioned first direction determination module is further configured to: if the model position point is a model vertex, determine the vertex normal direction of the model vertex as the position point normal direction; if the model position point is not a model vertex, determine the three-dimensional target model vertices within a specified range of the model position point; and determine the position point normal direction of the model position point based on the vertex normal direction of the three-dimensional target model vertices.
[0074] The aforementioned location point determination module is also used to: determine the directional angle between the connecting line direction and the normal direction of the location point; and determine the edge location points of the three-dimensional target model from the model location points whose directional angle is within a preset directional angle range.
[0075] The aforementioned location point determination module is also used to: determine the cosine value of the directional angle; and determine the model location points whose absolute value of the cosine value is less than a preset cosine threshold as edge location points of the three-dimensional target model.
[0076] The aforementioned location point determination module is also used to: determine the model location points with a right angle between their directions as the edge location points of the three-dimensional target model.
[0077] The aforementioned location point determination module is also used to: determine model location points whose directional angles are within a preset range as candidate location points; offset the candidate location points along the connecting line to obtain offset location points; generate a connecting line between the offset location points and the reference location points; and determine the edge location points of the three-dimensional target model from the candidate location points based on the positional relationship between the connecting line and the model surface on the three-dimensional target model.
[0078] The aforementioned location point determination module is also used to: obtain the absolute value of the cosine of the connection direction and the normal direction of the location point; delete model location points whose absolute cosine value is greater than a preset absolute value threshold, and determine the remaining model location points as candidate location points.
[0079] The aforementioned location point determination module is also used to: if the connecting line passes through the surface of the 3D target model, delete the candidate location point corresponding to the connecting line, and determine the remaining candidate location point as the edge location point.
[0080] The aforementioned location point determination module is also used to: determine the remaining candidate location points that are tangent to any model surface on the three-dimensional target model as edge location points.
[0081] The aforementioned position point determination module is further configured to: offset the candidate position point along a first direction of the connecting line to obtain a first position point; offset the candidate position point along a second direction of the connecting line to obtain a second position point; wherein the second direction is opposite to the first direction; and determine the first position point and the second position point as offset position points.
[0082] The aforementioned position point determination module is further configured to: determine the difference vector between the candidate position point and the first position point; and offset the candidate position point based on the difference vector to obtain a second position point; wherein the second position point and the first position point are located on opposite sides of the candidate position point along the straight line of the difference vector.
[0083] The smaller the aforementioned preset angle range, the fewer the number of edge position points, and the finer the edge lines of the model formed by the edge position points.
[0084] The aforementioned settings module is also used to: set a three-dimensional target model and a virtual camera in a preset three-dimensional space; and determine the camera position of the virtual camera as a reference position point.
[0085] The aforementioned device further includes an edge location point processing module, used to perform at least one of the following: using the edge location points as emission sources of target effects, rendering and adding target effects; generating model edge line models of the three-dimensional target model based on the edge location points; setting rendering attribute information for each edge location point, rendering the edge location points based on the rendering attribute information of the edge location points, and obtaining the edge rendering result corresponding to the rendering attribute information.
[0086] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the above-described method for extracting model edges. This electronic device can be a server or a terminal device.
[0087] See Figure 13As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described model edge extraction method.
[0088] Furthermore, Figure 13 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.
[0089] The memory 101 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 13 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0090] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0091] The processor in the aforementioned electronic device, by executing machine-executable instructions, can perform the following operations in the above-mentioned model edge extraction method:
[0092] In a preset 3D space, a 3D target model and reference position points are set; multiple model position points are determined on the model surface of the 3D target model, and the normal direction of the model position points is determined; the direction of the line connecting the model position points and the reference position points is determined; based on the directional relationship between the line direction and the normal direction of the position points, the edge position points of the 3D target model are determined from the multiple model position points; wherein, the edge position points constitute the model edge of the 3D target model.
[0093] If the model location point is a model vertex, the vertex normal direction of the model vertex is determined as the location point normal direction; if the model location point is not a model vertex, the target model vertex within the specified range of the model location point is determined; based on the vertex normal direction of the target model vertex, the location point normal direction of the model location point is determined.
[0094] Determine the angle between the direction of the connecting line and the direction of the normal to the position point; determine the edge position points of the 3D target model from the model position points whose angle is within the preset angle range.
[0095] Determine the cosine value of the directional angle; identify the model position points whose absolute value of the cosine value is less than the preset cosine threshold as the edge position points of the 3D target model.
[0096] The model location points with right angles are determined as the edge locations of the 3D target model.
[0097] Model position points whose directional angles fall within a preset range are identified as candidate position points; the candidate position points are offset along the connecting line to obtain offset position points; a connecting line is generated between the offset position points and the reference position points; based on the positional relationship between the connecting line and the model surface on the 3D target model, the edge position points of the 3D target model are determined from the candidate position points.
[0098] Obtain the absolute value of the cosine of the connection direction and the normal direction of the location point; delete model location points whose absolute cosine value is greater than a preset absolute value threshold, and determine the remaining model location points as candidate location points.
[0099] If the connecting line passes through the surface of the 3D target model, delete the corresponding candidate location point and determine the remaining candidate location point as the edge location point.
[0100] Offset the candidate position point along the first direction of the connecting line to obtain the first position point; offset the candidate position point along the second direction of the connecting line to obtain the second position point; wherein the second direction is opposite to the first direction; the first position point and the second position point are determined as the offset position points.
[0101] Determine the difference vector between the candidate position point and the first position point; based on the difference vector, offset the candidate position point to obtain the second position point; wherein the second position point and the first position point are located on both sides of the candidate position point along the line direction of the difference vector.
[0102] The smaller the preset angle range, the fewer the number of edge points, and the thinner the edge lines of the model formed by the edge points.
[0103] Set up a 3D target model and a virtual camera in a preset 3D space; determine the camera position of the virtual camera as a reference position point.
[0104] Use edge location points as emission sources for target effects and render and add target effects; and / or, based on edge location points, generate model edge line models of 3D target models; and / or, set rendering attribute information for each edge location point, render the edge location points based on the rendering attribute information, and obtain the edge rendering results corresponding to the rendering attribute information.
[0105] In the above method, multiple model position points are determined on the surface of the 3D model. Based on the directional relationship between the line direction connecting the model position point and the reference position point, and the normal direction of the model position point, edge position points can be obtained from the multiple model position points, thereby extracting the edges of the 3D model. The extracted 3D model edges enable more flexible model rendering, resulting in richer rendering effects related to the model edges.
[0106] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for extracting model edges.
[0107] The machine-executable instructions stored in the aforementioned machine-readable storage medium can be executed to perform the following operations in the above-mentioned model edge extraction method:
[0108] In a preset 3D space, a 3D target model and reference position points are set; multiple model position points are determined on the model surface of the 3D target model, and the normal direction of the model position points is determined; the direction of the line connecting the model position points and the reference position points is determined; based on the directional relationship between the line direction and the normal direction of the position points, the edge position points of the 3D target model are determined from the multiple model position points; wherein, the edge position points constitute the model edge of the 3D target model.
[0109] If the model location point is a model vertex, the vertex normal direction of the model vertex is determined as the location point normal direction; if the model location point is not a model vertex, the target model vertex within the specified range of the model location point is determined; based on the vertex normal direction of the target model vertex, the location point normal direction of the model location point is determined.
[0110] Determine the angle between the direction of the connecting line and the direction of the normal to the position point; determine the edge position points of the 3D target model from the model position points whose angle is within the preset angle range.
[0111] Determine the cosine value of the directional angle; identify the model position points whose absolute value of the cosine value is less than the preset cosine threshold as the edge position points of the 3D target model.
[0112] The model location points with right angles are determined as the edge locations of the 3D target model.
[0113] Model position points whose directional angles fall within a preset range are identified as candidate position points; the candidate position points are offset along the connecting line to obtain offset position points; a connecting line is generated between the offset position points and the reference position points; based on the positional relationship between the connecting line and the model surface on the 3D target model, the edge position points of the 3D target model are determined from the candidate position points.
[0114] Obtain the absolute value of the cosine of the connection direction and the normal direction of the location point; delete model location points whose absolute cosine value is greater than a preset absolute value threshold, and determine the remaining model location points as candidate location points.
[0115] If the connecting line passes through the surface of the 3D target model, delete the corresponding candidate location point and determine the remaining candidate location point as the edge location point.
[0116] Offset the candidate position point along the first direction of the connecting line to obtain the first position point; offset the candidate position point along the second direction of the connecting line to obtain the second position point; wherein the second direction is opposite to the first direction; the first position point and the second position point are determined as the offset position points.
[0117] Determine the difference vector between the candidate position point and the first position point; based on the difference vector, offset the candidate position point to obtain the second position point; wherein the second position point and the first position point are located on both sides of the candidate position point along the line direction of the difference vector.
[0118] The smaller the preset angle range, the fewer the number of edge points, and the thinner the edge lines of the model formed by the edge points.
[0119] Set up a 3D target model and a virtual camera in a preset 3D space; determine the camera position of the virtual camera as a reference position point.
[0120] Use edge location points as emission sources for target effects and render and add target effects; and / or, based on edge location points, generate model edge line models of 3D target models; and / or, set rendering attribute information for each edge location point, render the edge location points based on the rendering attribute information, and obtain the edge rendering results corresponding to the rendering attribute information.
[0121] In the above method, multiple model position points are determined on the surface of the 3D model. Based on the directional relationship between the line direction connecting the model position point and the reference position point, and the normal direction of the model position point, edge position points can be obtained from the multiple model position points, thereby extracting the edges of the 3D model. The extracted 3D model edges enable more flexible model rendering, resulting in richer rendering effects related to the model edges.
[0122] The computer program product of the model edge extraction method, apparatus, electronic device and storage medium provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.
[0123] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0124] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0125] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0126] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0127] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method of extracting a model edge, characterized by, The method comprises: setting a three-dimensional target model and a reference position point in a preset three-dimensional space; determining a plurality of model position points on a model surface of the three-dimensional target model, and determining a position point normal direction of the model position points; determining a line direction of the model position points and the reference position point; determining an edge position point of the three-dimensional target model from the plurality of model position points based on a directional relationship between the line direction and the position point normal direction; wherein the edge position point constitutes a model edge of the three-dimensional target model; The step of determining an edge position point of the three-dimensional target model from the plurality of model position points based on a directional relationship between the line direction and the position point normal direction comprises: determining a directional included angle between the line direction and the position point normal direction; determining the edge position point of the three-dimensional target model from the model position points whose directional included angles are within a preset included angle range; The step of determining the edge position point of the three-dimensional target model from the model position points whose directional included angles are within a preset included angle range comprises: determining the model position points whose directional included angles are within a preset included angle range as candidate position points; offsetting the candidate position points along the line direction to obtain offset position points; and generating a line between the offset position points and the reference position point; determining the edge position point of the three-dimensional target model from the candidate position points based on a positional relationship between the line and the model surface of the three-dimensional target model.
2. The method of claim 1, wherein, The model vertex of the three-dimensional target model is preset with a vertex normal direction; the step of determining the position point normal direction of the model position point comprises: if the model position point is a model vertex, determining the vertex normal direction of the model vertex as the position point normal direction; if the model position point is not a model vertex, determining a target model vertex within a specified range of the model position point; and determining the position point normal direction of the model position point based on the vertex normal direction of the target model vertex.
3. The method of claim 1, wherein, The step of determining the edge position point of the three-dimensional target model from the model position points whose directional included angles are within a preset included angle range comprises: determining a cosine value of the directional included angle; determining the model position points whose absolute values of the cosine values are less than a preset cosine threshold value as the edge position points of the three-dimensional target model.
4. The method of claim 1, wherein, The step of determining the edge position point of the three-dimensional target model from the model position points whose directional included angles are within a preset included angle range comprises: determining the model position points whose directional included angles are right angles as the edge position points of the three-dimensional target model.
5. The method of claim 1, wherein, The step of determining the model position points whose directional included angles are within a preset included angle range as candidate position points comprises: obtaining an absolute value of a cosine value of the line direction and the position point normal direction; deleting the model position points whose absolute values of the cosine values are greater than a preset absolute value threshold value, and determining the remaining model position points as candidate position points.
6. The method of claim 1, wherein, The step of determining the edge position point of the three-dimensional target model from the candidate position points based on the positional relationship between the line and the position of the model surface on the three-dimensional target model comprises: If the line passes through the model surface of the three-dimensional target model, the candidate position point corresponding to the line is deleted, and the remaining candidate position points are determined as the edge position points.
7. The method of claim 1, wherein, The step of performing offset processing on the candidate position points along the direction of the line to obtain offset position points comprises: performing offset processing on the candidate position points along a first direction of the direction of the line to obtain first position points; performing offset processing on the candidate position points along a second direction of the direction of the line to obtain second position points; wherein the second direction is opposite to the first direction; determining the first position points and the second position points as offset position points.
8. The method of claim 7, wherein, The step of performing offset processing on the candidate position points along a second direction of the direction of the line to obtain second position points comprises: determining a difference vector between the candidate position point and the first position point; based on the difference vector, offsetting the candidate position point to obtain a second position point; wherein the second position point and the first position point are located on two sides of the candidate position point along the direction of the line of the difference vector.
9. The method of claim 1, wherein, The smaller the preset angle range is, the fewer the edge position points are, and the thinner the edge lines of the model edge composed of the edge position points are.
10. The method of claim 1, wherein, The step of setting a three-dimensional target model and a reference position point in a preset three-dimensional space comprises: setting a three-dimensional target model and a virtual camera in a preset three-dimensional space; determining the camera position of the virtual camera as a reference position point.
11. The method of claim 1, wherein, After the step of determining the edge position point of the three-dimensional target model from the plurality of model position points based on the directional relationship between the direction of the line and the position point normal direction, the method further comprises: adding a target special effect by rendering the edge position points as the emission source of the target special effect; and / or; generating a model edge line model of the three-dimensional target model based on the edge position points; and / or; setting rendering attribute information of each edge position point, and rendering the edge position points based on the rendering attribute information of the edge position points to obtain an edge rendering result corresponding to the rendering attribute information.
12. An apparatus for extracting a model edge, characterized by comprising: The device comprises: a setting module configured to set a three-dimensional target model and a reference position point in a preset three-dimensional space; a first direction determination module configured to determine a plurality of model position points on a model surface of the three-dimensional target model and determine a position point normal direction of the model position points; a second direction determination module configured to determine a line direction of the model position points and the reference position point; a position point determination module configured to determine an edge position point of the three-dimensional target model from the plurality of model position points based on a directional relationship between the line direction and the position point normal direction; wherein the edge position point constitutes a model edge of the three-dimensional target model. The position point determination module is configured to determine a direction included angle between the connecting line direction and the normal direction of the position point; and determine an edge position point of the three-dimensional target model from the model position points whose direction included angles are within a preset included angle range. The position point determination module is configured to determine a model position point whose direction included angle is within a preset included angle range as a candidate position point; offset the candidate position point along the connecting line direction to obtain an offset position point; generate a connecting line between the offset position point and the reference position point; and determine an edge position point of the three-dimensional target model from the candidate position points based on the position relationship between the connecting line and a model surface of the three-dimensional target model.
13. An electronic device, comprising: The processor executes the machine executable instructions to implement the method for extracting a model edge according to any one of claims 1-11.
14. A machine-readable storage medium, characterized in that, The machine readable storage medium stores machine executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for extracting a model edge according to any one of claims 1-11.