Method and device for dynamic flattening of local area of three-dimensional scene based on flattened view cone
By using the method of flattening the visual cone in a three-dimensional scene, dynamically flattening the local area, solving the problem of low-quality model flattening that requires professional operation and irreversible in the prior art, realizing user-friendly interactiveness and efficient calculations, maintaining Consistency of the scene.
Patent Information
- Application Number
- CN202110178974.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-08
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-02-08
AI Technical Summary
The existing three-dimensional model repair software requires professional operation when flattening low-quality models, and the operation is irreversible, resulting in inconsistent with the virtual scene and the actual scene, which is not feasible for ordinary users, and physical damage is present, affecting the application effect.
Using the three-dimensional scene local area dynamic flattening method based on the flattening view cone, by defining the flattening view cone in the user coordinate system, creating a flattening camera and setting a projection matrix and observation matrix, passing it into the GPU programmable pipeline, and coloring it at the vertex The inclusion relationship of vertices is judged in the device, the displacement and flattening of vertices are realized, and the visual cone parameters are dynamically adjusted to adapt to various shapes.
It realizes dynamic flattening and restoring local areas without modifying the three-dimensional model, which is interactive and suitable for ordinary users, improves computing efficiency and availability, avoids physical damage, and maintains the consistency of the scene.
Smart Images

Figure CN112837430B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of spatial information, and in particular relates to a method and device for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone. Background Art
[0002] The 3D model is an important data foundation for 3D visualization. Its accuracy is closely related to the visualization effect of the 3D scene. A fine model can improve the quality of 3D visualization, while the existence of a low-quality model will hinder the perception and even affect the application effect. Fine models are generally modeled manually or by lidar, but due to the high production cost, they are generally only used for modeling key targets. Oblique photography is suitable for batch modeling of large scenes. It has low production costs and fast production speeds. It can achieve 3D reconstruction including geometric structures and textures. However, due to the limitations of current technology, the modeling effect of small and scattered targets such as trees and electric poles is poor, which easily leads to the generation of a large number of low-quality models.
[0003] Using professional modeling software to remove low-quality models can improve the visualization effect. The removal operation is essentially a secondary modeling of the original model, and data (such as texture images) need to be re-collected to achieve three-dimensional reconstruction of the removed area. At present, some modeling software such as MeshMixer and wish3D provide a local flattening function for the model. There is no need to re-collect data. Low-quality models (such as trees) can be directly flattened to the ground, which indirectly achieves the requirement of removing low-quality models. However, this method has the following problems: (1) Flattening requires professional user operation and professional modeling software support. In addition to increasing the extra workload, it is basically not feasible for ordinary users. (2) Modeling software flattening is essentially a physical destruction of the three-dimensional model, resulting in new inconsistencies between the virtual scene and the actual scene. Since its operation is irreversible, it is unacceptable in some applications. Summary of the invention
[0004] Purpose of the invention: The present invention proposes a method and device for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone. The method and device do not require modification of the three-dimensional model and can dynamically flatten and restore the local area according to user needs, with strong interactivity.
[0005] Technical solution: The present invention proposes a method for dynamically flattening a local area of a three-dimensional scene based on a flattened view cone, which specifically includes the following steps:
[0006] (1) Define a flattening frustum in the user coordinate system to determine the flattening range: First, determine the flattening plane according to the shape of the local area to be flattened, and then determine the optimal position and posture of the flattening frustum, so that the flattening frustum completely contains the target to be flattened, and the near plane or far plane of the flattening frustum coincides with the flattening plane;
[0007] (2) Create a flattened camera based on the flattened view frustum and set the projection matrix V and observation matrix P;
[0008] (3) The projection matrix V and observation matrix P of the flattened camera are passed into the GPU programmable pipeline;
[0009] (4) In the vertex shader of the GPU, the inclusion relationship between the viewing cone and the vertex is determined, and the vertices inside the flattened viewing cone are shifted and flattened.
[0010] Furthermore, the flattening camera described in step (2) is a virtual camera used to transform vertex coordinates from a user coordinate system to an observation coordinate system or a projection coordinate system.
[0011] Furthermore, the step (2) comprises the following steps:
[0012] (21) Setting the projection matrix of the flattened camera: setting the projection type of the flattened camera to perspective projection, setting the flattened view cone as the observation space of the flattened camera, and setting the projection matrix of the flattened camera according to the observation space of the flattened camera;
[0013] (22) Setting the observation matrix of the applanation camera: Taking the convergence point of the ridges of the flattened viewing cone as the origin of the observation coordinate system and the central axis of the flattened viewing cone as the line of sight, construct the observation coordinate system and set the observation matrix of the applanation camera according to the observation coordinate system.
[0014] Furthermore, the step (4) comprises the following steps:
[0015] (41) According to the observation matrix V and projection matrix P of the flattening camera, the vertex coordinates V0(x0, y0, z0, 1) in the user coordinate system are transformed to the flattening camera projection space. Let the transformed coordinates be V1(x1, y1, z1, w), where w is the dummy coordinate. The transformation process is:
[0016] V1=P*V*V0;
[0017] (42) If w>0 and the absolute values of x1, y1, and z1 are all less than or equal to w, then it is determined that the vertex needs to be flattened, and flattening is performed in the homogeneous space: if the near plane is the flattening plane, the coordinates of V1 are modified to (x1, y1, -w, w); if the far plane is the flattening plane, the coordinates of V1 are modified to (x1, y1, w, w); according to the observation matrix and projection matrix of the flattening camera, V1 is inversely transformed to the user coordinate system to obtain V2:
[0018] V2=V -1 *P -1 *V1
[0019] Among them, V -1 is the inverse matrix of the observation matrix V, P -1is the inverse of the projection matrix; reset V0 with the normalized value of V2:
[0020] V0=V2 / w;
[0021] (43) The reset V0 participates in the normal rendering process.
[0022] Based on the same inventive concept, the present invention also provides a device for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the method for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone is implemented.
[0023] Beneficial effects: Compared with the prior art, the present invention has the following beneficial effects: Compared with the traditional flattening method that requires modification of the model file, the present invention does not require modification of the three-dimensional model, can dynamically flatten and restore local areas according to user needs, has strong interactivity, and can conveniently view the actual flattening effect and make dynamic adjustments; at the same time, the present invention can appropriately adjust the parameters of the viewing cone according to the shape of the model, and is suitable for areas of various shapes, and the present invention can realize the flattening function with only a small number of parameters, has high computational efficiency, and strong usability. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a flow chart of the present invention;
[0025] Figure 2 This is a schematic diagram of the pole before it is flattened;
[0026] Figure 3 A diagram of a flattened view frustum for interactive definition;
[0027] Figure 4 This is a visualization of the effect after the pole is flattened. DETAILED DESCRIPTION
[0028] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0029] The present invention provides a method for dynamically flattening a local area of a three-dimensional scene based on a flattened bounding sphere. Figure 1 As shown, the specific steps include:
[0030] Step 1: Define the flattening frustum in the user coordinate system to determine the flattening range: According to the shape of the local area to be flattened, first determine the flattening plane, and then determine the optimal position and posture of the flattening frustum, so that the flattening frustum completely contains the area to be flattened, and the near plane or far plane of the flattening frustum coincides with the flattening plane.
[0031] The flattening plane is the plane onto which the flattened area is projected. The flattening frustum is a tetrahedron, which is exactly the same as the definition of the perspective projection frustum in computer graphics, including the near plane, far plane, left plane, right plane, top plane and bottom plane, of which the near plane and far plane can be used as the flattening planes. Figure 2 This is a schematic diagram of the pole before it is flattened. Figure 3 As shown, users can define the frustum by adjusting parameters such as far, near, fovy, aspect ratio of near and far planes, so that the near or far plane of the frustum coincides with the flattening plane of the target to be flattened, and the frustum completely contains the area to be flattened. The area to be flattened is part of the scene and can be defined arbitrarily, such as a tree, a pole, or even half of a stone can be used as the area to be flattened.
[0032] Step 2: Create a flattened camera based on the flattened frustum and set the projection matrix V and observation matrix P.
[0033] A flattened camera is a virtual camera that transforms vertex coordinates from the user coordinate system to the view coordinate system or projection coordinate system, and its characteristics are fully defined by the view matrix and the projection matrix.
[0034] Set the projection matrix of the flattened camera: Set the projection type of the flattened camera to perspective projection, set the flattened view cone as the observation space of the flattened camera, and set the projection matrix of the flattened camera according to the observation space of the flattened camera. Users can use the gluPerspective function in the 3D rendering engine library OpenGL to construct the projection matrix P of the flattened camera through the near and far parameters of the view cone and the fovy and aspect parameters of the view cone.
[0035] Set the observation matrix of the flattened camera: Take the convergence point of the flattened frustum ridges as the origin of the observation coordinate system, and the central axis of the flattened frustum as the line of sight to construct the observation coordinate system, and set the observation matrix of the flattened camera according to the observation coordinate system. Based on the origin of the observation coordinate system and the line of sight direction component, the gluLookAt function can be used in the 3D rendering engine library OpenGL to automatically construct the observation matrix V of the flattened camera.
[0036] Step 3: Pass the flattened camera’s projection matrix P and observation matrix V into the GPU programmable pipeline.
[0037] Step 4: In the vertex shader of the GPU, determine the inclusion relationship between the viewing cone and the vertices, and shift and flatten the vertices inside the flattened viewing cone.
[0038] (4.1) Normally render the 3D scene. According to the observation matrix V and projection matrix P of the flattened camera, transform the vertex coordinates V0(x0, y0, z0, 1) in the user coordinate system to the flattened camera projection space. Let the transformed coordinates be V1(x1, y1, z1, w), where w is the dummy coordinate. Then the transformation process is:
[0039] V1=P*V*V0;
[0040] (4.2) If w>0 and the absolute values of x1, y1, z1 are all less than or equal to w, then it is determined that the vertex needs to be flattened, and flattening is performed in the homogeneous space:
[0041] 1) If the near plane is a pressure plane, modify the V1 coordinates to (x1, y1, -w, w);
[0042] 2) Otherwise, the far plane is the pressure plane, and the V1 coordinates are modified to (x1, y1, w, w);
[0043] 3) According to the observation matrix and projection matrix of the flattened camera, V1 is inversely transformed to the user coordinate system to obtain V2:
[0044] V2=V -1 *P -1 *V1
[0045] Where V -1 is the inverse matrix of the observation matrix V, P -1 is the inverse of the projection matrix.
[0046] 4) Reset V0 with the normalized value of V2:
[0047] V0=V2 / w
[0048] (4.3) Use V0 to participate in the normal rendering process. The rendering effect is as follows Figure 4 shown.
[0049] The flattened view frustum is defined in the user coordinate system, and the inclusion relationship judgment between the flattened view frustum and the vertices and the vertex flattening operation are all implemented in the vertex shader of the graphics processor GPU.
[0050] Based on the same inventive concept, the present invention also provides a device for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the method for dynamically flattening a local area of a three-dimensional scene based on a flattened viewing cone is implemented.
Claims
1. A method for dynamic flattening of local areas of three-dimensional scenes based on flattened view cones. It is characterized in that The following steps are involved: (1) Define a flattening frustum in the user coordinate system to determine the flattening range: First, determine the flattening plane according to the shape of the local area to be flattened, and then determine the optimal position and posture of the flattening frustum, so that the flattening frustum completely contains the target to be flattened, and the near plane or far plane of the flattening frustum coincides with the flattening plane; (2) Create a flattened camera based on the flattened view frustum and set the projection matrix V and observation matrix P; (3) The projection matrix V and observation matrix P of the flattened camera are passed into the GPU programmable pipeline; (4) In the vertex shader of the GPU, the inclusion relationship between the viewing cone and the vertex is determined, and the vertices inside the flattened viewing cone are shifted and flattened; The step (4) comprises the following steps: (41) According to the observation matrix V and projection matrix P of the flattening camera, the vertex coordinates V0(x0, y0, z0, 1) in the user coordinate system are transformed to the flattening camera projection space. Let the transformed coordinates be V1(x1, y1, z1, w), where w is the dummy coordinate. The transformation process is: V1=P*V*V0; (42) If w>0 and the absolute values of x1, y1, and z1 are all less than or equal to w, then it is determined that the vertex needs to be flattened, and flattening is performed in the homogeneous space: if the near plane is the flattening plane, the coordinates of V1 are modified to (x1, y1, -w, w); if the far plane is the flattening plane, the coordinates of V1 are modified to (x1, y1, w, w); according to the observation matrix and projection matrix of the flattening camera, V1 is inversely transformed to the user coordinate system to obtain V2: V2=V -1 *P -1 *V1 Among them, V -1 is the inverse matrix of the observation matrix V, P -1 is the inverse of the projection matrix; reset V0 with the normalized value of V2: V0=V2 / w; (43) The reset V0 participates in the normal rendering process.
2. The method for dynamically flattening a local area of a three-dimensional scene based on a flattened view cone according to claim 1, It is characterized in that The flattening camera described in step (2) is a virtual camera used to transform vertex coordinates from a user coordinate system to an observation coordinate system or a projection coordinate system.
3. The method for dynamically flattening a local area of a three-dimensional scene based on a flattened view cone according to claim 1, It is characterized in that The step (2) comprises the following steps: (21) Setting the projection matrix of the flattened camera: setting the projection type of the flattened camera to perspective projection, setting the flattened view cone as the observation space of the flattened camera, and setting the projection matrix of the flattened camera according to the observation space of the flattened camera; (22) Setting the observation matrix of the applanation camera: Taking the convergence point of the ridges of the flattened viewing cone as the origin of the observation coordinate system and the central axis of the flattened viewing cone as the line of sight, construct the observation coordinate system and set the observation matrix of the applanation camera according to the observation coordinate system.
4. A device for dynamically flattening a local area of a three-dimensional scene based on a flattened view cone, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the computer program is loaded into a processor, the method for dynamic flattening of a local area of a three-dimensional scene based on a flattened viewing cone according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Topographical flattening method for three-dimensional scenes
CN107845136A
Three-dimensional graph automatic simplification generation method
CN107945258A
Embedded city design scene simulation method and system
CN109934914A
Indoor target object 6D attitude estimation method based on enhanced auto-encoder
CN110533721A
Three-dimensional fabricating system, information processing apparatus, three-dimensional fabricating model arrangement method, and three-dimensional fabricating model arrangement program
US20160371398A1
