Large-scale scene blanking algorithm based on heterogeneous computing power acceleration
By segmenting the three-dimensional model into blocks and utilizing the computing resources of the CPU and GPU, the blanking algorithm is optimized, and the problems of slow blanking speed and poor effect in large scenarios are solved, and fast, accurate blanking and efficient drawing are achieved.
Patent Information
- Application Number
- CN202411826303.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-12-12
AI Technical Summary
The existing blanking function has problems such as slow blanking speed, poor results, and large computing resources when dealing with large scenarios, making it difficult to achieve fast and accurate blanking, which affects the drawing efficiency and quality.
Using a large-scene blanking algorithm based on heterogeneous computing power, the three-dimensional model is divided into multiple blocks and the computing resources of the CPU and GPU are used to manage and render in depth, so as to realize parallel computing and efficient occlusion testing, and optimize disinfection. Hidden process.
It significantly improves the speed and accuracy of large-scene blanking, reduces blanking time, improves drawing efficiency and quality, and allows real-time viewing of two-dimensional projections during blanking.
Smart Images

Figure CN119295639A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics, and in particular to a large scene hidden layering algorithm based on heterogeneous computing power acceleration. Background Art
[0002] At present, in the process of 2D CAD drawing, the hidden processing of large scenes is usually achieved through the hidden function of the software. Hiding refers to hiding unnecessary lines and blocked parts during the drawing process to show the design drawings more clearly. The hidden function can improve drawing efficiency and readability, which is especially important when dealing with large scenes.
[0003] CN114154223A discloses a method, system, storage medium and device for generating two-dimensional engineering drawings from three-dimensional models, which include: performing lightweight processing on the three-dimensional model; determining the insertion base point of the three-dimensional model after the lightweight processing; using the insertion base point as a positioning point, obtaining the three-dimensional model in various directions and storing it in a database; sectioning the three-dimensional model and selecting the spatial range to be drawn; performing two-dimensional replacement on the selected three-dimensional model after sectioning according to the selected view direction and printing the drawing.
[0004] CN118505949A discloses a method, device and electronic device for processing virtual-real occlusion relationship, the method comprising determining a virtual avatar of a real target object based on a preset template matching rule; hiding the virtual avatar; obtaining the depth value and color value of the virtual object that occludes the real target object in the occlusion area and the depth value and color value of the virtual avatar in the corresponding occlusion area; determining the virtual-real occlusion relationship between the virtual object and the real target object based on the depth values of the two; and drawing a virtual-real fusion scene for the hidden real target object based on the virtual-real occlusion relationship and the color value.
[0005] CN111467801A discloses a model hiding method and device, a computer-readable storage medium and an electronic device, the method comprising: providing a graphical user interface through a terminal device, the graphical user interface comprising a game screen provided at least in part through a virtual camera, the game screen comprising at least part of a game model and at least part of a virtual object, obtaining an initial game model, wherein the initial game model comprises a hidden model and a physical model; controlling and adjusting the transparency of the hidden model that blocks the virtual object according to the position information of the virtual camera, the position information of the virtual object and the position information of the hidden model.
[0006] In the process of converting a three-dimensional model into a two-dimensional drawing, the following steps are required: projecting the three-dimensional model along a predetermined direction to form a two-dimensional plane, wherein some lines need to be eliminated during the projection process, wherein these lines are originally used to display predetermined objects in the three-dimensional image, but in the projection process from three-dimensional to two-dimensional, these lines will be blocked and invisible due to the conversion of viewing angles. However, when hiding lines, the existing hiding function has the disadvantages of slow hiding speed, unsatisfactory effect, and occupying a large amount of computing resources when processing large scenes. Especially when processing complex large scenes, the hiding process may take a lot of time and affect the drawing efficiency. If there are a large number of three-dimensional models, such as a chemical plant scene with a large number of equipment and pipelines, the hiding process itself takes several minutes or even dozens of minutes or even hours. And it is often only possible to achieve the hidden CAD output of a certain area or even a certain equipment, and it is difficult to achieve detailed and accurate CAD drawing generation of the overall scene. In addition, it is necessary to wait until the end of the hiding process before viewing the final two-dimensional plane, so the hiding process cannot be monitored, which makes the flexibility and controllability of the software operation worse. The reason why it is so difficult for a large number of 3D models is that when performing the hidden calculation, the relationship between multiple 3D models needs to be considered, and it is difficult to implement an optimization algorithm to perform parallel calculations while maintaining a high fault tolerance rate. Therefore, how to significantly reduce the time required for the hidden process and view the 3D to 2D projection process in real time during the hidden process is a technical problem that urgently needs to be solved in this field.
[0007] In addition, on the one hand, there are differences in understanding among those skilled in the art; on the other hand, the applicant studied a large number of documents and patents when making the present invention, but due to space limitations, not all details and contents are listed in detail. However, this does not mean that the present invention does not have the characteristics of these prior arts. On the contrary, the present invention already has all the characteristics of the prior art, and the applicant reserves the right to add relevant prior art to the background technology. Summary of the invention
[0008] The problems existing in the prior art are mainly caused by the defects of the existing hidden function such as algorithm complexity, computing resource consumption, and low efficiency when processing large scenes. Large scenes contain a large number of lines and graphics. The hidden function needs to calculate and process each line. The hidden algorithm is highly complex and consumes a lot of computing resources, resulting in slow hidden speed and poor effect. At the same time, the existing hidden function is not optimized for the characteristics of large scenes, and cannot effectively handle the occlusion relationship in large scenes, resulting in inaccurate hidden effect. In view of the shortcomings of the prior art, the present invention provides a large scene hidden algorithm based on heterogeneous computing power acceleration, aiming to solve the problems of slow hidden speed, poor effect, and high computing resource consumption in the process of large scene hidden two-dimensional CAD drawing in the prior art. The present invention optimizes the hidden algorithm and combines CPU and GPU computing resources to achieve rapid hidden of large scenes and improve drawing efficiency and quality.
[0009] The present invention divides the large scene to be drawn into multiple independent blocks perpendicular to the projection plane, and each block is assigned an independent CPU process for hidden processing to form a list of feature lines to be hidden. In this way, the large scene can be decomposed into small blocks, the calculation amount of each block can be reduced, and the hidden efficiency can be improved. The present invention adopts GPU deep rendering technology, and performs collision testing during the hidden process. By detecting the depth information of each pixel in the rendering image, it can quickly determine which lines or graphics are blocked, thereby achieving fast and accurate hidden processing. The parallel computing capability of the GPU can accelerate the occlusion test process and improve the hidden efficiency. The present invention makes full use of the computing resources of the CPU and GPU during the hidden process, and reasonably allocates and coordinates the hidden algorithm between the two. Among them, the CPU is responsible for managing scene segmentation and task allocation, and the GPU is responsible for deep rendering and occlusion testing. The two cooperate with each other to achieve efficient hidden of large scenes. Through the implementation of the above technical solutions, the present invention can effectively solve the problems existing in the process of large scene hidden two-dimensional CAD drawing in the prior art, achieve fast and accurate hidden of large scenes, and improve drawing efficiency and quality.
[0010] Specifically, the present invention discloses a large scene hidden algorithm based on heterogeneous computing power acceleration, which includes the following steps: S1. When loading a three-dimensional file, first partition the three-dimensional models in the three-dimensional file according to their locations, wherein each partition includes at least one three-dimensional model, and each three-dimensional model is assigned to at least one partition; S2, assigning each partition with at least one three-dimensional model to at least one CPU for calculation, and converting each three-dimensional model contained in the three-dimensional file into a two-dimensional plane object in a partition calculation manner, wherein in the process of converting the three-dimensional model of each partition into the two-dimensional plane object, calculating and determining in each partition respectively the lines that are blocked when projecting along the projection direction; S3. Merge all the converted two-dimensional plane objects, wherein for the three-dimensional models respectively assigned to two or more partitions, connect the line segments of the converted two-dimensional plane objects belonging to different partitions.
[0011] According to a preferred embodiment, when performing the partition calculation of step S2, the partition calculation process includes constructing a scene octree, wherein the step of constructing the scene octree includes: Loading a scene file corresponding to the three-dimensional file, wherein when loading the scene file, obtaining all entities in the scene defined by the scene file; Calculate the bounding box in the scene, traverse each entity list in the scene, merge the bounding boxes of all entities, and get the bounding box of the entire scene; Use the bounding box of the entire scene to generate the octree root node; Determine the octree depth; Bind entities to octree nodes; When all entities are correctly bound to the octree nodes, the octree is built.
[0012] According to a preferred embodiment, when performing the partition calculation of step S2, the partition calculation process includes extracting characteristic lines, wherein the step of extracting characteristic lines includes: Traversing the scene octree nodes within the field of view determined by the projection direction, wherein when traversing all nodes of the scene octree, identifying the nodes within the current field of view; Visit each entity on the node, where in each node in the field of view, visit the entities bound to it one by one; Extracting three-dimensional feature lines according to entity types, and converting the three-dimensional feature lines into two-dimensional feature lines, which include axis lines, contour lines or outer contour lines; The identified primitive feature lines and non-primitive feature lines are stored to form a feature line list.
[0013] According to a preferred embodiment, when executing the step of extracting feature lines, for the feature lines of the basic body, the feature lines of different basic bodies are separately constructed through an interpolation algorithm, each polyline is stored as an element in a feature line list, and then the intersecting polylines in the list are subjected to Boolean operations to generate feature lines such as outer contour lines.
[0014] According to a preferred embodiment, when executing the step of extracting feature lines, for non-basic body feature lines, mesh data of entities that are not basic geometric shapes are loaded; a list of common edges of adjacent triangles is constructed based on the coordinates of the triangle vertices; the common edges are traversed to determine whether they are feature lines based on the normals of the two triangles on them; and finally, all identified feature lines are merged.
[0015] According to a preferred embodiment, when performing the partition calculation of step S2, the partition calculation process includes generating a hidden line, wherein the step of generating a hidden line includes: Traverse the list of hidden entities; Calculate the traversal step length according to the entity size; Iterate through the feature line list of each entity; For each line segment of each feature line of each entity, traverse it according to the determined step size; Perform a preliminary judgment on the visibility of the feature line endpoints, wherein the "invisible feature line" is stored in a list of feature lines to be hidden; Taking the endpoint of the line segment obtained by dividing the feature line according to the step length as the starting point, a ray for scene collision test is formed in the opposite direction of the projection direction; By using the scene collision test to determine the visible or invisible state of each line segment endpoint "as the starting point of the ray used for the scene collision test"; According to the state of the endpoint of "the starting point of the ray used for scene collision test", the state of the line segment is determined and stored in the corresponding list, wherein the line segments in the invisible list are all stored in the list of feature lines to be hidden.
[0016] According to a preferred embodiment, when determining the visible or invisible state of each line segment endpoint, it is determined by iteratively judging whether there is an intersection between the ray starting from each line segment endpoint and other entities in the scene, thereby determining the intersection between the entity feature lines observed in the projection direction.
[0017] According to a preferred embodiment, when determining the state of a line segment, a line segment whose endpoints are all visible is determined to be in a visible state and stored in a visible list, a line segment whose endpoints are all invisible is determined to be in an invisible state and stored in an invisible list, and for a partially visible line segment "a line segment in which one endpoint is visible and the other is invisible", the morning and evening division point of the partially visible line segment is determined by determining the intersection between the partially visible line segment and the outer contour line of an entity having a collision relationship, and the partially visible line segment is split into visible line segments and invisible line segments with the morning and evening division point as the boundary, and the segments are stored in the corresponding state list.
[0018] According to a preferred embodiment, step S1 includes the following sub-steps: Setting hidden parameters: after or before each 3D model is partitioned, setting hidden parameters, wherein the hidden parameters include projection direction, number of partitions, and ID of the partitions; Generate scene quadtree: Generate a quadtree corresponding to the scene of the 3D file according to the number of partitions; Based on the quadtree segmentation scene: determine the range of the partition and the three-dimensional model contained therein according to the quadtree; Storing the divided scene: storing the number of partitions, the determined partition range, the partition ID, and the three-dimensional model contained in each partition using the partition ID as an index.
[0019] According to a preferred embodiment, during the scene collision test, GPU acceleration is completed through the following steps: Load the required mesh model data and use the GPU graphics API (such as OpenGL) to render the depth information into a depth map according to the hidden projection direction and record the memory; In the scene where the collision test between the ray and the mesh model is required, the depth value of the pixel point on the depth map corresponding to the ray is directly queried to perform a depth test to determine the occlusion relationship. The corresponding depth map is used to read the depth information of the corresponding pixel point, and the depth value of the starting point of the ray is compared to determine whether it is blocked. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a step diagram of a large scene hidden algorithm of a preferred embodiment provided by the present invention; Figure 2 It is a flowchart of a large scene hidden algorithm of a preferred implementation mode provided by the present invention; Figure 3 It is a schematic diagram of a process of constructing a scene octree according to a preferred embodiment of the present invention; Figure 4 It is a schematic diagram of a flow chart of extracting characteristic lines according to a preferred embodiment of the present invention; Figure 5 is an explanatory diagram of generating an outer contour line according to a preferred embodiment of the present invention; Figure 6 It is a schematic diagram of a process of generating hidden lines according to a preferred embodiment of the present invention; Figure 7 is a schematic diagram of two entities in a hidden entity list of a preferred embodiment provided by the present invention; Figure 8 It is an explanatory example diagram of performing a preliminary judgment on the visibility of the endpoints of a feature line according to a preferred embodiment of the present invention; Fig. 9It is a flowchart of a GPU acceleration method according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0021] The following is a detailed description with reference to the accompanying drawings.
[0022] The terms used in this invention are defined as follows: Hiding: In the projection process from 3D to 2D, there will be lines that are blocked due to viewing angles. These lines need to be hidden when displayed on the computer. This hiding process is called hiding. Hiding only makes the lines invisible at the display level, but these lines actually exist in the 2D drawing and their geometric position relationship is preserved. Therefore, these hidden lines can be displayed again under set conditions.
[0023] Hidden parameters: at least include projection direction, number of partitions, and partition ID.
[0024] Projection direction: In the projection process from 3D to 2D, it is necessary to determine the projection direction from 3D to 2D based on the viewing angle of the 2D view, such as a top view, bottom view, side view or axial view. The projection direction is, for example, pre-specified by the user of the 2D drawing.
[0025] like Figure 1 As shown, the present invention discloses a large scene hidden algorithm or large scene hidden method based on heterogeneous computing power acceleration, which performs the following efficient hidden steps when converting a three-dimensional file with a large number of three-dimensional models into a two-dimensional plane map: S1. When loading a three-dimensional file, first partition the three-dimensional models in the three-dimensional file according to their locations, wherein each partition includes at least one three-dimensional model, and each three-dimensional model is assigned to at least one partition; S2, assigning each partition with at least one three-dimensional model to at least one CPU for calculation, and converting each three-dimensional model contained in the three-dimensional file into a two-dimensional plane object in a partition calculation manner, wherein in the process of converting the three-dimensional model of each partition into the two-dimensional plane object, calculating and determining in each partition respectively the lines that are blocked when projecting along the projection direction; S3. Merge all the converted two-dimensional plane objects, wherein for the three-dimensional models respectively assigned to two or more partitions, connect the line segments of the converted two-dimensional plane objects belonging to different partitions.
[0026] Preferably, if Figure 2 As shown, step S1 may include the following sub-steps: S11. Setting hidden parameters: After each 3D model is partitioned, the hidden parameters can be set; or before each 3D model is completed, the hidden parameters can be set, wherein the hidden parameters may include projection direction, number of partitions, and partition ID.
[0027] S12, generating a scene quadtree: generating a quadtree (including a number of leaf nodes) corresponding to the scene of the three-dimensional file according to the number of partitions.
[0028] S13, segmenting the scene based on a quadtree: determining the range of the partition and the three-dimensional model contained therein according to the quadtree.
[0029] S14, storing the segmented scene: storing the number of partitions, the determined partition range, the partition ID, and the three-dimensional model contained in each partition using the partition ID as an index, thereby completing the segmentation and storage of the scene of the three-dimensional file.
[0030] Figure 2 The "DGECore" in it refers to the "Dynamic Graphics Engine Core", which is a core library or engine component for developing computer graphics applications and provides basic graphics processing functions.
[0031] Preferably, when performing the partition calculation of step S2, the partition calculation process includes: S21, constructing a scene octree, wherein, Figure 3 As shown, the steps of constructing a scene octree may include: Loading a scene file corresponding to the three-dimensional file, wherein when loading the scene file, obtaining all entities in the scene defined by the scene file, the entities can be filled with the three-dimensional model of the three-dimensional file; Calculate the bounding box in the scene, traverse each entity list in the scene, merge the bounding boxes of all entities, and get the bounding box of the entire scene. The bounding box of the scene contains the bounding boxes of all entities in the scene; Use the bounding box of the entire scene to generate the octree root node, that is, create the octree root node based on the scene bounding box obtained in the previous step; Determine the depth of the octree, where the required depth of the octree is calculated using the scene bounding box and the bounding box of the smallest entity among all entities; Binding entities to octree nodes, wherein entity objects in the scene can be bound to corresponding octree nodes (e.g., the octree can be recursively traversed to assign entities to appropriate leaf nodes); When all entities are correctly bound to the octree nodes, the octree is built.
[0032] Through the above steps, the octree can be effectively used to organize and manage entities in the scene, thereby achieving efficient collision detection, frustum culling and other operations. This method is particularly suitable for processing large-scale three-dimensional scenes because it can greatly reduce unnecessary calculations and improve the performance of the overall system.
[0033] Preferably, when performing the partition calculation of step S2, the partition calculation process includes: S22, extracting feature lines, wherein, Figure 4 As shown, the step of extracting feature lines may include: Traversing the scene octree nodes within the field of view determined by the projection direction, wherein when traversing all nodes of the scene octree, identifying the nodes within the current field of view; Visit each entity on the node, where in each node in the field of view, visit the entities bound to it one by one; Extracting three-dimensional feature lines according to entity types, and converting the three-dimensional feature lines into two-dimensional feature lines, which include axis lines, contour lines or outer contour lines, etc.; The identified primitive feature lines and non-primitive feature lines are stored to form a feature line list.
[0034] Preferably, after generating a three-dimensional file (such as dwg) through design software such as AutoCAD, when these three-dimensional files need to be transferred to other software for processing, they need to be converted into an exchange data format such as obj format in advance. The three-dimensional file in obj format will lose the parameters defined by the original design software, so that when other software subsequently uses the obj format file, the three-dimensional file in the exchange data format (standard exchange format file, such as stl, obj, step, etc.) will have the defect of incomplete information, causing the subsequent software to need to identify the geometric bodies therein. Further, it is mainly to identify the basic body and the non-basic body. The definition of the two is: the basic body is described by parameters in the standard exchange format file; and the non-basic body is composed of triangles in the standard exchange format file. Therefore, in the above-mentioned step of extracting feature lines, the basic body feature lines and the non-basic body feature lines can be extracted and identified respectively.
[0035] Preferably, for the basic body feature lines, if the entity is a basic geometric shape (such as a cube, a sphere, a cylinder, etc.), its feature lines can be directly identified or generated.
[0036] Optionally, when identifying the basic body feature lines, a model coordinate system can be constructed and projected to the local coordinate system, which may specifically include steps such as determining the model coordinate system, obtaining the transformation matrix, and applying the transformation. Preferably, in the step of determining the model coordinate system, the origin can be defined first, that is, a reasonable point is selected as the origin of the model. Usually, this point may be the geometric center of the model or a reference point specified during design; then the axis is determined, that is, the directions of the three main axes (X axis, Y axis, and Z axis) of the model coordinate system are defined. These axes can reflect the actual orientation of the model (for example, for a building model, the X axis may be along the length of the building, the Y axis along the width, and the Z axis represents the height); finally, ensure that the direction of each axis is a unit vector, which means that their length is 1 and they are perpendicular to each other. Preferably, in the step of obtaining the transformation matrix, a translation transformation matrix can be first calculated according to the position of the model origin relative to the local coordinate system to move the model to the corresponding position in the local coordinate system; then, for the model that is not placed according to the standard axis of the local coordinate system, a rotation transformation matrix is calculated to adjust the posture of the model so that its axis is aligned with the local coordinate system; finally, for the model whose size is different from the ratio of the local coordinate system, a scaling transformation matrix is calculated to make the size of the model adapt to the local coordinate system. Preferably, in the step of applying the transformation, the translation, rotation and scaling transformation matrices can be first combined into a total transformation matrix. Usually, these transformations are applied in sequence, that is, scaling first, then rotation, and finally translation; then, for each vertex in the model, the total transformation matrix is used to convert it from the model coordinate system to the local coordinate system, wherein this step can be achieved by matrix multiplication, that is, the vertex coordinates are represented as column vectors and then multiplied by the total transformation matrix.
[0037] Through the above steps, the model can be successfully converted from its own coordinate system to the local coordinate system, which is very necessary for subsequent rendering, collision detection and other spatial operations. This ensures that the model interacts with other scene elements in the same coordinate system and avoids errors caused by inconsistent coordinate systems.
[0038] Preferably, the feature lines of different basic bodies can be constructed separately through interpolation algorithms, and each polyline is stored as an element in the feature line list, wherein the constructed feature lines may include outer contour lines. Exemplarily, the outer contour line of a cube can be constructed through the following steps: define vertices: a cube has 8 vertices, which can be defined according to the size and position of the cube; define edges: a cube has 12 edges, each of which connects two vertices; interpolation algorithm: for a cube, no complex interpolation algorithm is required, because its edges are all straight line segments, that is, each edge can be directly regarded as an outer contour line segment and added to the feature line list; store results: store the 12 edges as independent polylines in the feature line list. Exemplarily, the outer contour of a sphere can be constructed by the following steps: define parameters: a sphere can be defined by a radius and a center point; sampling points: in order to construct the outer contour of a sphere, a series of sampling points need to be selected on the sphere. These points can be defined by a latitude and longitude system, such as selecting a point at a certain angle; interpolation algorithm: use spline curves (such as Bézier curves or B-splines) to connect adjacent sampling points. Spline curves can smoothly pass through or approach given points to form a smooth outer contour line; store results: store each segment of the spline curve obtained by the interpolation algorithm as an independent polyline in the feature line list. Note that the outer contour of a sphere may require multiple closed curves to fully depict. Exemplarily, the outer contour line of a cylinder can be constructed by the following steps: define parameters: the cylinder can be defined by radius, height and bottom center point; the circumference of the bottom and top surfaces: the cylinder has two parallel circular bottom surfaces, and for each circumference, the sampling points can be defined using a polar coordinate system; interpolation algorithm: similar to a sphere, spline curves can be used to smoothly connect the sampling points on the bottom and top circumferences; side: the side of the cylinder consists of straight line segments between the two circular bottom surfaces, which can also be regarded as part of the outer contour line; store results: the circular curves of the bottom and top surfaces, and the straight line segments of the side surfaces, are stored as independent polylines in the feature line list.
[0039] Preferably, after being stored as independent polylines in the feature line list, the following steps may be performed: merging and simplification: merging some continuous polylines into a single polyline to simplify the data structure; optimization: certain optimization strategies may be adopted, such as reducing redundant points, simplifying curves, etc., to improve rendering efficiency; projection: if the outer contour line needs to be projected onto a different perspective or plane, a projection transformation may be applied.
[0040] Preferably, after the polylines are stored in the feature line list, the intersecting polylines in the list can be subjected to directed polyline Boolean operations to generate feature lines such as outer contour lines. In this embodiment, these polylines are, for example, two-dimensional feature lines converted from three-dimensional feature lines. Figure 5As shown, for the closed first polyline a (0', 1', 2', 3', 4', 5', 6') and the second polyline b (0, 1, 2, 3, 4, 5), the addition of Boolean operations is performed. The first polyline a is selected, and the vertices are traversed starting from 0', marked as visited, and recorded in the output array out. Furthermore, when traversing the vertices, it is necessary to determine whether the line connecting it and the subsequent point intersects with the second polyline b. If they do not intersect, the traversed corresponding vertices of the first polyline a are recorded in the output array out; if they intersect, the intersection point p' of the first polyline a and the second polyline b is calculated and determined, and the determined intersection point is recorded in the output array out; in response to the determination of the first intersection point p', the traversal object is replaced with the second polyline b that intersects with the first polyline a, and traversed along the same direction ( Figure 5 In the example, the traversal direction of the two polylines is counterclockwise, and the second polyline b is traversed until the second intersection point p between the second polyline b and the first polyline a is encountered; in response to the determination of the second intersection point p, the traversal object is replaced with the first polyline a intersecting with the second polyline b, and the first polyline a is traversed in the same traversal direction until the vertex 0' that has been traversed is encountered. For example, in Figure 5 When traversing from vertex 0' to vertex 4', the output array out is (0', 1', 2', 3', 4'). At this time, it is also necessary to calculate the intersection p' between edge 4'-5' and edge 2-3 of the second polyline b, and record it in the output array out to update it to (0', 1', 2', 3', 4', p'). When the intersection p' is determined, the traversal target is changed to the second polyline b. Then traverse the vertices of the second polyline b, starting from the next vertex 3 in the counterclockwise direction until vertex 1, and record it in the output array out to update it to (0', 1', 2', 3', 4', p', 3, 4, 5, 0, 1). Calculate the intersection point p of edge 1-2 and 5'-6' of the first polyline a, and record it in the output array out to update it to (0', 1', 2', 3', 4', p', 3, 4, 5, 0, 1, p), and then exchange the traversal object to the first polyline a. Then traverse the vertices of the first polyline a, starting from the next vertex 6' in the counterclockwise direction until vertex 0', but 0' has been visited, so jump out of the iteration and terminate the traversal. The final output is out (0', 1', 2', 3', 4', p', 3, 4, 5, 0, 1, p, 6') as the outer contour of the entity.
[0041] Preferably, to increase the traversal speed, in the initialization phase, the traversal is started from a polygon vertex that is farther away from another polyline. For example, when traversing the first polyline a, as long as it does not start from point 5', it is a good starting point.
[0042] Preferably, for non-basic feature lines, if the entity is not a basic geometric shape, its mesh data needs to be loaded; secondly, a list of common edges of adjacent triangles is constructed based on the coordinates of the triangle vertices; then the common edges are traversed to determine whether they are feature lines based on the normals of the two triangles on them; finally, all identified feature lines are merged.
[0043] Preferably, when performing the partition calculation of step S2, the partition calculation process includes: S23, generating hidden lines. After step S22 generates the feature line list, step S23 can be performed, wherein, Figure 6 As shown, the steps of generating hidden lines may include: a. Traverse the hidden entity list, including traversing all entities that need to participate in the hidden test, see Figure 7 Entities in (En1, En2); b. Calculate the traversal step size based on the entity size, where for each entity, an appropriate traversal step size is calculated based on its size. For example, En2 requires more traversal steps, which helps to process larger entities more efficiently in subsequent tests; c. Traverse the feature line list of each entity, wherein, for each entity, traverse its feature line list, wherein the feature line refers to the edge of the object surface or a significant line such as a contour line, an outer contour line or an axis line; d. For each feature line of each entity (stored in the form of polylines), traverse each line segment of each feature line in the feature line list according to the step size determined in the above step b. If the line segment is long, it may be divided into multiple steps for processing. That is, if a line segment of the feature line is too long, especially longer than the step size, the traversal process will be divided into corresponding multiple steps. For example, the long side of En2 may need to be divided into multiple steps; e. As a preferred step, traverse each line segment, wherein it is determined whether there are missing multi-segment lines; f. Perform a preliminary judgment on the visibility of the endpoints of the feature lines, wherein the visibility of the corresponding feature line endpoints is distinguished by determining whether the feature line endpoints exist on the outer contour line of the entity after two-dimensional projection, wherein all the endpoints on the two-dimensional outer contour line are visible, and vice versa, thereby being able to efficiently remove the invisible feature lines to reduce the workload of the scene collision test in the subsequent steps, wherein the "invisible feature lines" are stored in the list of feature lines to be hidden; g. Taking the endpoint of the line segment obtained by dividing the feature line according to the step length as the starting point, a ray for scene collision test is formed in the reverse direction of the projection direction; h. Determine the visible or invisible state of each line segment endpoint "as the starting point of the ray for scene collision test" by using scene collision test. Therefore, after executing the collision test, not only the collision relationship between the ray starting from the line segment endpoint and the entity can be determined, but also the visible or invisible state of the corresponding endpoint can be determined; i. According to the status of the endpoints of "the starting points of the rays used for scene collision test", the line segments whose endpoints are all visible are determined to be in a visible state and stored in the Out_Poly (visible) list, and the line segments whose endpoints are all invisible are determined to be in an invisible state and stored in the In_Poly (invisible) list. For the partially visible line segments "where one endpoint is visible and the other is invisible", the morning and evening segmentation point of the partially visible line segments is determined by determining the intersection between the partially visible line segments and the outer contour line of the entity with a collision relationship, and the partially visible line segments are split into visible line segments and invisible line segments with the morning and evening segmentation point as the boundary, and stored in the corresponding state lists, wherein the line segments in the In_Poly (invisible) list are all stored in the list of feature lines to be hidden.
[0044] Preferably, if Figure 8 As shown, the three planes where point A is located have three normals, some of which are facing away from the projection direction, while all normals of point G are facing away from the projection direction. In order to determine whether points A and G are visible, in the above step f, it can be determined whether the normals of the two points contain at least part of the normals facing the projection direction, or it can be distinguished by the outer contour line after two-dimensional projection. All points on the two-dimensional outer contour line are visible. Furthermore, it can also be determined whether it is facing away from the projection direction based on the angle between the normal of the solid surface where each line segment vertex of each feature line is located and the projection direction, wherein the angle between the normal of the surface where the line segment is located and the observer's line of sight (projection direction) is calculated. If the angle exceeds a certain threshold, it indicates that the surface is facing away from the observer, so the line segment will not be seen.
[0045] Preferably, in the above step h, it is determined by iteratively determining whether there are intersections between the rays starting from the endpoints of each line segment and other entities in the scene, so as to determine the intersections between the entity feature lines observed in the projection direction. Figure 7 The intersection point P1 or P2 of the characteristic line in the scene. For example, the ray starting from the endpoint e of entity En1 has an intersection with entity En2. By constructing the ray with the endpoint of the line segment and the reverse direction along the projection direction, and then performing a scene collision test, the purpose is to find the intersection point between the ray and other entities in the scene. The significance of using the step size is that if all points are judged, it will cause too much calculation, and judging one by one according to the step size can reduce the amount of calculation.
[0046] For example, for the above step i, Figure 7In the figure, line segment fe is divided into line segment f-P2 and line segment P2-e based on the intersection point P2, and is classified into In_Poly and Out_Poly lists according to their states and saved in a special data structure for subsequent processing.
[0047] Preferably, after forming a list of feature lines to be hidden for each partition, for example, another CPU working in parallel can achieve real-time hiding of the partition by loading the list of feature lines to be hidden, thereby completing step S2. Thus, the present invention can view the converted two-dimensional graphics or at least a part of the converted two-dimensional graphics in real time during the process of converting the three-dimensional graphics to the two-dimensional graphics, without waiting for the analysis of the entire three-dimensional graphics to be completed.
[0048] Preferably, in step S2, each partition is assigned to an independent CPU for calculation, so that the calculation can be completed in parallel and efficiently; and because the number of models in each partition is different, the hidden situation in the partition with a smaller number and thus faster calculation can be checked first. In each partition, it is calculated and determined that the lines that are blocked when projecting along the projection direction are, for example, feature lines such as outer contour lines, contour lines and axis lines.
[0049] Preferably, when the partitioned three-dimensional model is projected, the endpoints of the line segments belonging to different partitions are added to the two-dimensional plane object lines corresponding to the three-dimensional model lines at the boundary positions where the three-dimensional model lines cross the zones. In other words, when such endpoints are projected to form a two-dimensional plane object, they are generated at the corresponding two-dimensional boundary positions and are two endpoints that overlap. Therefore, in step S3, when "connecting the line segments belonging to different partitions", the two endpoints that overlap need to be removed, thereby restoring the two-dimensional plane object lines corresponding to the three-dimensional model lines.
[0050] According to a preferred embodiment, in the process of scene collision testing, processing large mesh models may lead to inefficiency. Therefore, the present invention adopts a GPU acceleration method to optimize the collision test between rays and mesh models, thereby significantly improving the overall performance. Fig. 9 As shown, the following steps may be specifically included: Load the required mesh model data and use the GPU graphics API (such as OpenGL) to render the depth information into a depth map according to the hidden projection direction and record the memory; In the scene where the collision test between the ray and the mesh model is required, the depth value of the pixel point on the depth map corresponding to the ray is directly queried, and the depth test is quickly performed to determine the occlusion relationship.
[0051] Preferably, the corresponding depth map can be used to read the depth information of the corresponding pixel point, and the depth value of the starting point of the ray can be compared to determine whether it is blocked. According to the obtained blocking relationship information, the subsequent processing steps can be completed.
[0052] Furthermore, the collected points are classified according to their source information in an attempt to restore them to a parametric expression. For example, for an arc from a cylinder, these discrete points can be replaced with the arc's parameter description, and the specific parameters can be calculated based on the source information. After the restoration step is completed, the final hidden information is saved as a binary file by type. When multiple cores are calculating and generating at the same time, these binary files can be stored in a database for storage, or the hidden effect of the completed part can be viewed in real time during the calculation process, so as to detect potential problems early.
[0053] Suppose there is a complex scene with a large number of geometric shapes, including a large number of triangular patches. First, the data of this scene needs to be loaded and converted into a form suitable for GPU processing. Then, using the parallel computing power of the GPU, the depth information of each triangular patch is rendered to a pre-prepared depth map. Next, in the actual culling process, whenever a ray needs to be tested for collision with an object in the scene, instead of checking each triangular patch one by one, the depth value of the corresponding position is directly found from the depth map and compared with the position of the current ray. This can greatly reduce the amount of unnecessary calculations, thereby significantly improving the speed and efficiency of culling.
[0054] By adopting the method provided by the present invention, the time overhead required for blanking can be greatly reduced without sacrificing image quality. This is particularly important for applications that require real-time rendering of a large number of complex scenes, such as virtual reality, augmented reality, and game development. In addition, since the workload of the CPU is reduced, system resources can be further released, allowing other tasks to run more smoothly.
[0055] It should be noted that the above-mentioned specific embodiments are exemplary, and those skilled in the art can come up with various solutions inspired by the disclosure of the present invention, and these solutions also belong to the disclosure scope of the present invention and fall within the protection scope of the present invention. Those skilled in the art should understand that the present invention specification and its drawings are illustrative and do not constitute a limitation of the claims. The scope of protection of the present invention is defined by the claims and their equivalents. The present invention specification contains multiple inventive concepts, such as "preferably" or "according to a preferred embodiment", which means that the corresponding paragraph discloses an independent concept, and the applicant reserves the right to file a divisional application based on each inventive concept. Throughout the text, the features guided by "preferably" are only an optional method and should not be understood as a must-have setting. Therefore, the applicant reserves the right to abandon or delete the relevant preferred features at any time.
Claims
1. A large scene hidden algorithm based on heterogeneous computing power acceleration, characterized in that: It includes the following steps: S1. When loading a three-dimensional file, first partition the three-dimensional models in the three-dimensional file according to their locations, wherein each partition includes at least one three-dimensional model, and each three-dimensional model is assigned to at least one partition; S2, assigning each partition with at least one three-dimensional model to at least one CPU for calculation, and converting each three-dimensional model contained in the three-dimensional file into a two-dimensional plane object in a partition calculation manner, wherein in the process of converting the three-dimensional model of each partition into the two-dimensional plane object, calculating and determining in each partition respectively the lines that are blocked when projecting along the projection direction; S3. Merge all the converted two-dimensional plane objects, wherein for the three-dimensional models respectively assigned to two or more partitions, connect the line segments of the converted two-dimensional plane objects belonging to different partitions.
2. The large scene hidden algorithm according to claim 1, characterized in that: When performing the partition calculation of step S2, the partition calculation process includes constructing a scene octree, wherein the step of constructing the scene octree includes: Loading a scene file corresponding to the three-dimensional file, wherein when loading the scene file, obtaining all entities in the scene defined by the scene file; Calculate the bounding box in the scene, traverse each entity list in the scene, merge the bounding boxes of all entities, and get the bounding box of the entire scene; Use the bounding box of the entire scene to generate the octree root node; Determine the octree depth; Bind entities to octree nodes; When all entities are correctly bound to the octree nodes, the octree is built.
3. The large scene hidden algorithm according to claim 2, characterized in that: When performing the partition calculation of step S2, the partition calculation process includes extracting feature lines, wherein the step of extracting feature lines includes: Traversing the scene octree nodes within the field of view determined by the projection direction, wherein when traversing all nodes of the scene octree, identifying the nodes within the current field of view; Visit each entity on the node, where in each node in the field of view, visit the entities bound to it one by one; Extracting three-dimensional feature lines according to entity types, and converting the three-dimensional feature lines into two-dimensional feature lines, which include axis lines, contour lines or outer contour lines; The identified primitive feature lines and non-primitive feature lines are stored to form a feature line list.
4. The large scene hidden algorithm according to claim 3, characterized in that: When executing the step of extracting feature lines, for the feature lines of the basic bodies, the feature lines of different basic bodies are constructed separately through the interpolation algorithm, and each polyline is stored as an element in the feature line list. Then, the intersecting polylines in the list are subjected to Boolean operations to generate feature lines such as outer contour lines.
5. The large scene hidden algorithm according to claim 3, characterized in that: When executing the step of extracting feature lines, for non-basic feature lines, load the mesh data of entities that are not basic geometric shapes; build a list of common edges of adjacent triangles based on the coordinates of triangle vertices; traverse the common edges and determine whether they are feature lines based on the normals of the two triangles on them; Finally, all identified feature lines are merged.
6. The large scene hidden algorithm according to claim 3, characterized in that: When performing the partition calculation of step S2, the partition calculation process includes generating hidden lines, wherein the step of generating hidden lines includes: Traverse the list of hidden entities; Calculate the traversal step length according to the entity size; Iterate through the feature line list of each entity; For each line segment of each feature line of each entity, traverse it according to the determined step size; Perform a preliminary check on the visibility of feature line endpoints, where "invisible feature lines" are stored in a list of feature lines to be hidden; Taking the endpoint of the line segment obtained by dividing the feature line according to the step length as the starting point, a ray for scene collision test is formed in the opposite direction of the projection direction; By using the scene collision test to determine the visible or invisible state of each line segment endpoint "as the starting point of the ray used for the scene collision test"; According to the state of the endpoint "as the starting point of the ray for scene collision test", the state of the line segment is determined and stored in the corresponding list, wherein the line segments in the invisible list are stored in the list of feature lines to be hidden.
7. The large scene hidden algorithm according to claim 6, characterized in that: When determining the visible or invisible state of each line segment endpoint, it is determined by iteratively determining whether there is an intersection between the ray starting from each line segment endpoint and other entities in the scene, thereby determining the intersection between the entity feature lines observed in the projection direction.
8. The large scene hidden algorithm according to claim 7, characterized in that: When determining the state of a line segment, a line segment whose endpoints are all visible is determined to be in a visible state and stored in a visible list, a line segment whose endpoints are all invisible is determined to be in an invisible state and stored in an invisible list, and for a partially visible line segment "a line segment in which one endpoint is visible and the other is invisible", the morning and evening division point of the partially visible line segment is determined by determining the intersection between the partially visible line segment and the outer contour line of the entity having a collision relationship, and the partially visible line segment is split into visible line segments and invisible line segments with the morning and evening division point as the boundary, and the two segments are stored in the corresponding state list.
9. The large scene hidden algorithm according to claim 1, characterized in that: Step S1 includes the following sub-steps: Setting hidden parameters: after or before each 3D model is partitioned, setting hidden parameters, wherein the hidden parameters include projection direction, number of partitions, and ID of the partitions; Generate scene quadtree: Generate a quadtree corresponding to the scene of the 3D file according to the number of partitions; Based on the quadtree segmentation scene: determine the range of the partition and the three-dimensional model contained therein according to the quadtree; Storing the divided scene: storing the number of partitions, the determined partition range, the partition ID, and the three-dimensional model contained in each partition using the partition ID as an index.
10. The large scene hidden algorithm according to claim 6, characterized in that: During the scene collision test, GPU acceleration is completed through the following steps: Load the required mesh model data and use the GPU graphics API to render the depth information into a depth map according to the hidden projection direction and record the memory; In the scene where the collision test between the ray and the mesh model is required, the depth value of the pixel point on the depth map corresponding to the ray is directly queried to perform a depth test to determine the occlusion relationship. The corresponding depth map is used to read the depth information of the corresponding pixel point, and the depth value of the starting point of the ray is compared to determine whether it is blocked.
Citation Information
Patent Citations
3D virtual set ray tracking method for accelerating back light source irradiation
CN101982838A
object space blanking line calculation acceleration method using OPENGL
CN109829962A
Three-dimensional scene rendering acceleration method and system based on video geometric analysis
CN110738721A
Three-dimensional visual edge generation method and system, computer and readable storage medium
CN113902887A
Image processing method and apparatus
CN1802668A