WO2022121525A1 - Method and device for rendering three-dimensional scene data, storage medium, and electronic device - Google Patents

Method and device for rendering three-dimensional scene data, storage medium, and electronic device Download PDF

Info

Publication number
WO2022121525A1
WO2022121525A1 PCT/CN2021/125315 CN2021125315W WO2022121525A1 WO 2022121525 A1 WO2022121525 A1 WO 2022121525A1 CN 2021125315 W CN2021125315 W CN 2021125315W WO 2022121525 A1 WO2022121525 A1 WO 2022121525A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
bounding box
modeling
node
scene data
Prior art date
Application number
PCT/CN2021/125315
Other languages
French (fr)
Chinese (zh)
Inventor
秦义明
黎宇航
朱方
施嘉理
盛斌
王依可
Original Assignee
中兴通讯股份有限公司
上海交通大学
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司, 上海交通大学 filed Critical 中兴通讯股份有限公司
Publication of WO2022121525A1 publication Critical patent/WO2022121525A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/005Tree description, e.g. octree, quadtree
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating 3D models or images for computer graphics
    • G06T19/20Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts

Definitions

  • the present disclosure mainly relates to the field of communications, and in particular, to a method and device for rendering three-dimensional scene data, a storage medium, and an electronic device.
  • the data processing methods for large-scale scenes are mainly: using a multi-level detail (Levels of Detail, LOD) model and a quadtree hierarchical structure to process the data of large-scale scenes and using an octree structure to process large-scale scene data.
  • the data of the scale scene is processed.
  • the LOD model and the quadtree hierarchy are used to process the data of large-scale scenes, and the LOD model is used to realize real-time visualization and the quadtree hierarchy to realize geographic information display, query and analysis, but this method needs to make different resolutions in advance.
  • rate LOD model which leads to poor adaptability and is not suitable for interactive scene rendering.
  • the octree structure is used to organize the scene model, and the spatial information and tree structure of the rendered 3D data are used to reduce the geometric nodes outside the view frustum in batches, quickly calculate the node sequence required for rendering, and reduce the number of input rendering channels.
  • the use of evenly divided octrees will lead to waste of resources.
  • Embodiments of the present disclosure provide a method and device, a storage medium, and an electronic device for rendering 3D scene data, so as to at least solve the problem in the related art that when a model of 3D scene data is processed through a hierarchical bounding box tree, the 3D scene data
  • the uneven distribution leads to uneven distribution of nodes in the hierarchical bounding box tree, which in turn causes problems such as waste of resources.
  • An embodiment of the present disclosure provides a method for rendering 3D scene data, including: determining a modeling model used for 3D scene data to be rendered, wherein different modeling models are used to indicate 3D scene data in different display modes;
  • the type of the modeling model performs block processing on the modeling model, and the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner, wherein,
  • the preset mode is used to indicate that the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold; to render.
  • determine the bounding box of the current model block in the modeling model determine the longest axis in the bounding box as the splitting axis, and determine the splitting point of the bounding box according to the splitting axis; All model blocks in the bounding box are determined according to the dividing point and stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  • determining the target node of the current model nugget to be stored in the hierarchical bounding box tree according to the splitting point includes: dividing the first model nugget whose coordinate value is greater than the splitting point into a left node and a right node In one node of ; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
  • the modeling model performs block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the hierarchical bounding box corresponding to the modeling model in a preset manner.
  • On the tree including: cyclically executing the following steps until all model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner: determining the number of blocks in the modeling model The bounding box of the current model block; the longest axis in the bounding box is used as the splitting axis, and the splitting point of the bounding box is determined according to the splitting circumference; all models in the bounding box are determined according to the splitting point
  • the block is stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  • the method further includes: when the modeling model is a triangular mesh model, And when the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, the current triangular patch is stored in the target node in a random manner.
  • rendering the three-dimensional scene data to be rendered according to the model blocks stored on the hierarchical bounding box tree includes: acquiring the model block to be rendered from the hierarchical bounding box tree in a parallel search manner. ; Render the three-dimensional scene data to be rendered according to the acquired model block to be rendered.
  • an apparatus for rendering three-dimensional scene data including: a determining module configured to determine a modeling model used for the three-dimensional scene data to be rendered, wherein different modeling models use the three-dimensional scene data indicating different display modes; the processing module is configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing according to a preset method On the hierarchical bounding box tree corresponding to the modeling model, wherein the preset manner is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold; the rendering module is set to according to The model block stored on the hierarchical bounding box tree renders the three-dimensional scene data to be rendered.
  • the processing module is further configured to determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the dividing axis, and determine the The dividing point of the bounding box; according to the dividing point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node .
  • a computer-readable storage medium is also provided, where a computer program is stored in the storage medium, wherein the computer program is configured to execute any one of the above method embodiments when running steps in .
  • an electronic device comprising a memory and a processor, wherein the memory stores a computer program, the processor is configured to run the computer program to execute any of the above Steps in Method Examples.
  • the modeling model used for the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are divided into blocks according to the types of the modeling models process, and save the model nuggets obtained after the block processing on the hierarchical bounding box tree corresponding to the modeling model according to a preset method, wherein the preset method is used to indicate the number of left and right nodes of the hierarchical bounding box tree The difference is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is stored in the hierarchical bounding box tree corresponding to the modeling model, and the level is guaranteed.
  • the difference between the number of left nodes and right nodes of the bounding box tree is less than the preset threshold.
  • FIG. 1 is a block diagram of a hardware structure of a computer terminal according to a method for rendering three-dimensional scene data according to an embodiment of the present disclosure
  • FIG. 2 is a flowchart of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure
  • FIG. 3 is a flowchart of a method for rendering three-dimensional scene data according to an optional embodiment of the present disclosure
  • FIG. 4 is a schematic diagram of a triangular mesh model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure
  • FIG. 5 is a schematic diagram of a point cloud model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure
  • FIG. 6 is a broken line chart of visual tracking query time change of the position of a moving camera in an optional embodiment of the present disclosure
  • FIG. 7 is a broken line graph of the time change of the viewing cone query by changing the viewing angle in an optional embodiment of the present disclosure
  • FIG. 8 is a line chart of the time change of the viewing cone query when the viewpoint position is changed in an optional embodiment of the present disclosure
  • FIG. 9 is a broken line graph of the time change of viewing cone query when the far plane distance is changed in an optional embodiment of the present disclosure.
  • FIG. 10 is a structural block diagram of an apparatus for rendering three-dimensional scene data according to an embodiment of the present disclosure.
  • FIG. 1 is a hardware structural block diagram of a computer terminal of a rendering method for three-dimensional scene data according to an embodiment of the present disclosure.
  • the computer terminal may include one or more (only one is shown in FIG.
  • processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.
  • the above-mentioned computer terminal may further include a transmission device 106 and an input/output device 108 configured as a communication function.
  • the structure shown in Fig. 1 is only for illustration, and it does not limit the structure of the above-mentioned computer terminal.
  • the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have a different configuration with equivalent or more functions than those shown in FIG. 1 .
  • the memory 104 may be configured to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the method for rendering three-dimensional scene data in the embodiments of the present disclosure.
  • the processor 102 executes the computer programs stored in the memory 104 , so as to perform various functional applications and data processing, that is, to implement the above method.
  • Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory located remotely from the processor 102, and these remote memories may be connected to the computer terminal through a network.
  • Transmission means 106 are arranged to receive or transmit data via a network.
  • the specific example of the above-mentioned network may include a wireless network provided by the communication provider of the computer terminal.
  • the transmission device 106 includes a network adapter (Network Interface Controller, NIC for short), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 may be a radio frequency (Radio Frequency, RF for short) module, which is configured to communicate with the Internet in a wireless manner.
  • RF Radio Frequency
  • FIG. 2 is a flowchart of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure, as shown in FIG. 2 , include:
  • Step S202 determining the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
  • Step S204 performing block processing on the modeling model according to the type of the modeling model, and saving the model blocks obtained after the block processing in a hierarchical bounding box tree corresponding to the modeling model in a preset manner.
  • the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
  • Step S206 rendering the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
  • the modeling model used for the 3D scene data to be rendered is determined, wherein different modeling models are used to indicate the 3D scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed.
  • the number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
  • the modeling model may include a point cloud model and a triangular mesh model, but is not limited to the point cloud model and the triangular mesh model, which is not limited in this embodiment of the present disclosure.
  • the modeling model perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the hierarchical bounding box corresponding to the modeling model in a preset manner.
  • the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget determine the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget, find and select the longest axis in the bounding box as the splitting axis, according to the center of all points in the splitting axis
  • the number of bits determines the dividing point of the bounding box, and all model blocks in the bounding box are determined according to the dividing point, and are respectively stored in the left node or the right node of the hierarchical bounding box tree.
  • the target node of the current model block stored in the hierarchical bounding box tree is determined according to the dividing point, and the first model block whose coordinate value is greater than the dividing point is divided into a left node and a right node. In one of the nodes; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
  • the model block whose coordinate value is greater than the coordinate value of the split point is used as the first model block, and the coordinate value of the model block is smaller than the split point.
  • the model nugget with the coordinate value of the In the left or right node of the hierarchical bounding box tree.
  • the data of the three-dimensional scene is very large, so the following steps need to be performed cyclically until all the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner: determining the bounding box of the current model block in the modeling model; taking the longest axis in the bounding box as the splitting axis, and determining the splitting point of the bounding box according to the splitting circumference; determining according to the splitting point All model blocks in the bounding box are stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  • the modeling model is a triangular mesh model and the current model block is a triangular patch
  • the current triangular patch is located at the edge of the dividing axis, the current triangular Slices are stored at the target node in a random manner.
  • the modeling model used for the 3D scene data to be rendered is a triangular mesh model
  • the internal primitives of the triangular mesh model are triangular patches
  • the triangular patch is at the edge of the dividing axis, some model blocks of the same triangular patch belong to the left node, and some model blocks belong to the right node.
  • the triangular patch is randomly stored in the left node or the right node, so as to ensure There is no resource conflict at the triangle patch level inside the bounding box, which is more conducive to query operations.
  • the three-dimensional scene data to be rendered is rendered according to the model blocks stored in the hierarchical bounding box tree, and the model block to be rendered is obtained from the hierarchical bounding box tree by means of parallel search;
  • the acquired model block to be rendered renders the three-dimensional scene data to be rendered.
  • the method of parallel search is used to obtain the model blocks to be rendered on the hierarchical bounding box tree, and then the 3D scene data to be rendered is rendered.
  • the parallel search method is used to speed up the search process and reduce the system delay.
  • a method for processing using an octree and the general steps are: (1) First, read large-scale three-dimensional scene data. Use the hierarchical scene graph to organize the scene, and get the rendering data hierarchy graph of the scene. For a graphics rendering engine, a very important part is to organize the primitive information in the scene.
  • the organization method needs to follow the following two principles: first, it is conducive to memory management when retrieving data; second, it can speed up the rendering process of the scene.
  • When using a hierarchy to organize render objects save common information in the parent node.
  • the hierarchical structure of a directed acyclic graph is generally used. This kind of scene graph contains a root node and has one or more child nodes. Each child node of the scene graph can also contain multiple child nodes.
  • nodes some are primitive objects that need to be rendered, and some are structures used to address rendering objects. For example, if a scene consists of many rooms, then a scene graph of this scene can be created, and the scene graph may contain nodes called room0, room1, room2, etc. The root node of these nodes is a node called building. Using the scene graph can make full use of hardware resources, which can greatly improve the performance of rendering.
  • (2) Establish and generate the octree structure of the scene, and record the relevant information.
  • An octree is a tree-like data structure that describes a three-dimensional space. Each node of the octree represents a volume element of a cube, and each node has eight child nodes.
  • the sum of the volume elements represented by these eight child nodes is equal to the volume of the parent node.
  • the center point of the model is used as the bifurcation center of the node.
  • the fast frustum culling is performed through the intersection detection algorithm between the frustum and the bounding box. Because the octree has already divided the space equally, it only needs to be based on whether the bounding box where the node is located is within the range of the view frustum. (4) Render objects in the view frustum.
  • This method uses the octree structure to organize the scene, utilizes the spatial information and tree structure of the rendered 3D data, reduces the geometric nodes outside the viewing frustum in batches, quickly calculates the node sequence required for rendering, and reduces the number of input The number of triangular patches for the render pass.
  • This method manages the scene by creating an octree, but since the distribution of the model may be uneven, using an evenly divided octree will lead to waste of resources and make the search process slower. At the same time, the method is carried out on a single machine, and the distributed rendering is not considered.
  • a method of 3D scene management and rendering based on LOD model and quadtree hierarchical structure uses LOD model to process data in layers and blocks to improve the browsing speed of 3D scene.
  • LOD model uses LOD model to process data in layers and blocks to improve the browsing speed of 3D scene.
  • the size of the visualized scene, the complexity and aggregation degree of the ground objects, the level standard of LOD modeling is determined, and the data is layered and divided into blocks. Small-scale scenes are processed as one piece during the roaming process. When the scene data scale increases, the data scale is processed into blocks.
  • the essence of LOD modeling is to reorganize the original model to obtain a data structure that is more convenient for real-time rendering.
  • the segmentation method of using quadtree to make LOD is like this.
  • the root node is also selected in the middle of the model. Take the entire model as the root node, and then start from the root node to determine whether the conditions for segmentation are met. If not, the segmentation will not be performed, and it will be saved as a leaf node; otherwise, the root node will be recursively divided into four equal sub-node areas. , until the position can no longer be divided, and finally all leaf nodes are drawn to form a simplified result.
  • the greater the depth of the segmentation the higher the resolution of the obtained LOD model, and the evaluation function and user requirements can also be used to judge each node during segmentation. If the accuracy of the point already meets the requirements, no further segmentation is performed; otherwise, the segmentation continues until the node meets the requirements.
  • the LOD model is used to realize real-time visualization, and the quadtree hierarchical structure is used to realize the display, query and analysis of geographic information.
  • this method needs to make LOD models of different resolutions in advance, which leads to poor adaptive ability and is not suitable for interactive scene rendering.
  • This method needs to specify different LOD models for each angle and different user needs.
  • the volume of the model is not very large, this method is still very practical, but when the scale of the model is large and the model is complex, the LOD needs to be produced. Consume a lot of time and computational rendering resources. And it requires more physical space for storage.
  • This method blocks the model when creating the LOD model and is not suitable for an interactive way.
  • the present disclosure firstly reads the point cloud model and the triangular mesh model to the main node, preprocesses the data using the structure of the octet hierarchical tree in the three-dimensional space, divides the model into blocks, and then saves the tree shape of the model structure.
  • the content to be rendered is determined according to the collision calculation between the view frustum and each node in the tree, and the parallelized search method of the octree is used to find the data to retrieve the model block to be used. Then render the data that needs to be rendered in the rendering node.
  • users can interactively change the area they want to see on the client side, and the master node will execute the query work again to schedule resources.
  • the present disclosure can quickly lock the part of the primitive model that needs to be rendered.
  • the present disclosure is applicable to large-scale point cloud models and triangular mesh models and scenarios where the models are orders of magnitude huge and cannot be rendered by a single machine.
  • the present disclosure handles scenarios with large differences in model distribution, the constructed tree is more reasonable. Using multiple tree structures for model preprocessing and parallel query processing can quickly obtain the primitive information that needs to be rendered.
  • FIG. 3 is a flowchart of a method for rendering 3D scene data according to an optional embodiment of the present disclosure; as shown in FIG. 3 , first, the point cloud model or grid model is split and managed by using a 3D space BVH tree, and then according to View cone information, query the geometric elements in the view cone according to the tree structure (equivalent to the model block in the above embodiment), then render these elements and display them on the window, modify the view cone information through the interaction of the keyboard and mouse, and render the different positions of the model, and then the cycle goes back and forth. Specifically, it can be divided into the following specific tasks:
  • FIG. 4 is a schematic diagram of a triangular mesh model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure
  • FIG. 5 is a rendering method for three-dimensional scene data according to an embodiment of the present disclosure. Schematic diagram of the point cloud model rendering interface.
  • An optional embodiment of the present disclosure utilizes an octagonal hierarchical bounding box in a three-dimensional space and a parallel search method, so that when a user performs an interactive operation, the search for rendering resources can be performed quickly.
  • the preprocessing of data is mainly to process the data into blocks.
  • the data segmentation only needs to be performed once, and the subsequent query stage can reuse the knowledge information obtained by preprocessing, that is, the result of the segmentation processing, thereby saving a lot of time.
  • There are many ways to partition data in space such as octree, k-dimensional tree (Kd-tree), Binary Space Partitioning (BSP) tree, etc.
  • Kd-tree k-dimensional tree
  • BSP Binary Space Partitioning
  • the octree is a uniform division of the scene.
  • the model is segmented based on the data distribution of the model, and a segmented tree structure is created, so that the data distribution of the created segmented tree is as balanced as possible.
  • Step 1 Given a root node, the root node contains the information of all objects in the scene. Calculates the bounding box of the current node along the axis. If the amount of primitive data in the bounding box is less than the given threshold, the division ends.
  • Step 2 Find and select the longest axis in the bounding box as the split axis.
  • Step 3 Calculate the median of all primitive information in the bounding box of the current node along the segmentation axis, and use it as the segmentation position.
  • Step 4 Traverse all the primitive information in the bounding box of the current node again, according to the segmentation position, divide the point whose coordinate value is greater than the segmentation position into one of the left node and the right node, and divide the coordinate value smaller than the segmentation position.
  • the point block of the location is divided into another one of the left node and the right node.
  • Step 5 Repeat operations 1-4 for the two child nodes to recursively build a tree. At the same time, the metadata stored in this node is cleared.
  • the biggest difference compared with the point cloud model is that the internal primitives of the triangular mesh model are triangular patches instead of points.
  • the internal primitives of the triangular mesh model are triangular patches instead of points.
  • two identical triangular patch return values may be sent to the working set, which requires de-duplication, but de-duplication is very complicated, which will waste a lot of time .
  • an optional embodiment of the present disclosure adopts a random allocation method to randomly allocate the triangular patch to one of the child nodes. In this way, although there will be spatial overlap conflicts between the bounding boxes of the child nodes, there will be no resource conflicts at the triangle patch level inside the bounding boxes, which is more conducive to query operations.
  • the pseudocode of the algorithm can be described as follows:
  • the input is the root node of a tree (the root node contains all model data) and the threshold to stop dividing.
  • the output is a tree with data only at the leaf nodes. Process it recursively.
  • Step 1 Get the bounding box of the node
  • Step 2 If the amount of scene data contained in the bounding box of the current node is less than the threshold, return to the node;
  • Step 3 If the amount of scene data contained in the bounding box of the current node is greater than the threshold, select the long side of the bounding box as the splitting edge for segmentation;
  • Step 4 Calculate the segmentation point of the scene on the segmentation edge
  • Step 5 Add two left and right child nodes to the node
  • Step 6 Split the node
  • Step 7 Traverse all the triangular faces in the node, divide them according to the dividing points, and place them in the left and right child nodes respectively;
  • Step 8 If there are no data elements in one of the nodes, stop the split operation for that node.
  • steps 1-8 are respectively performed on the left and right nodes that can still be divided, and the operations are performed recursively until the conditions in step 2 are reached.
  • the final time complexity of this partitioning method is O(NlogN).
  • the data structure and information of the split tree will be stored as a priori knowledge and model.
  • rendering 3D scene data similar to the way of octree query, it is only necessary to determine the orientation of the view cone according to the user's input, and then according to the relationship between the view cone and the constructed tree, the data nodes are processed. After determining, the recursive 3D scene data rendering is performed from the node, and this method can be parallelized.
  • the rendered portion of the 3D scene data requires a given view frustum.
  • the input of the frustum is seven parameters, camPos represents the position of the camera, camUp represents the upward direction of the camera, lookAt represents the viewpoint position of the camera, aspect represents the aspect ratio of the frustum, zNear and zFar represent the distance between the cropped far and near planes and the camera respectively.
  • the distance between, Fovy represents the field of view angle on the y-axis.
  • the patch is inside the view frustum.
  • the rendering of the three-dimensional scene data begins.
  • the specific process is as follows: Judging from the root node, if the eight vertices of the bounding box of the node are all outside a certain plane of the view frustum, then the bounding box is not in the view frustum at all, there is no need to recurse down, directly End return; if the eight vertices of the bounding box of the node are all inside the view frustum, then the bounding box is completely inside the view frustum, then a marker is given, no further judgment is required when recursing downward, and all nodes are returned directly; if If the bounding box intersects the view cone, recurse downwards, and a similar judgment is required when recursing downwards.
  • the input of the algorithm is the BVH tree of the root node, a boolean value representing the state of the node, and a view frustum.
  • the output is point or triangular mesh data in the view frustum.
  • Step 1 If the node is in the view frustum, perform the following steps;
  • Step 2 If the node is a leaf node, return the model data in the node and stop the operation;
  • Step 3 Divide the node to obtain the left and right nodes respectively;
  • Step 4 If the left and right nodes are leaf nodes, perform the following steps;
  • Step 5 Determine all the rendering data in the node
  • Step 6 If the data is in the frustum, add the data to the resulting queue;
  • Step 7 Recursively use steps 1-6 for the left and right nodes.
  • the parallel mode is used to accelerate the actual query, and the query time is related to the view frustum position and data distribution.
  • the specific analysis is as follows:
  • the present disclosure utilizes the octree BVH tree in three-dimensional space to solve the situation that the octree calculation consumes too much when the model distribution is not uniform.
  • a parallel search method is used in the search of the viewing cone model resources, which speeds up the search process and reduces the delay of the entire system.
  • the 3D scene data in the viewing cone is rendered, and the user can change the camera position, field of view angle, viewpoint position, and far and near planes to view the scene interactively.
  • Linear search refers to traversing the model to determine whether each point exists in the viewing frustum in turn;
  • the single-threaded three-dimensional space BVH tree search method is the search algorithm proposed by this group;
  • the parallel three-dimensional space BVH tree search method All the following examples are repeated 3 times and averaged to judge the speed of the query in the three ways, as follows:
  • FIG. 8 is a line chart of the time change of the viewing cone query when the viewpoint position is changed in an optional embodiment of the present disclosure. As shown in FIG. 8 , the overall trend is the same as before, and the BVH query time is very short, so when the amount of data is not large , the real-time performance of stand-alone rendering is high, the impact on the frame rate is small, and the rendering machine switches each frame smoothly.
  • FIG. 9 is a line chart of the time change of the viewing cone query for changing the distance of the far plane in an optional embodiment of the present disclosure.
  • the plane is relatively close, and no point is in the viewing cone.
  • the time consumed by multi-threading to create threads is not negligible compared to the time of querying, so it will take a little longer than single-threading at the beginning, but the advantages will become more obvious later.
  • the modeling model adopted by the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed.
  • the number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
  • This embodiment also provides an apparatus for rendering three-dimensional scene data.
  • the apparatus is configured to implement the above-mentioned embodiments and optional implementations, and what has already been described will not be described again.
  • the term "module” may be a combination of software and/or hardware that implements a predetermined function.
  • the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
  • FIG. 10 is a structural block diagram of an apparatus for rendering three-dimensional scene data according to an embodiment of the present disclosure. As shown in FIG. 10 , the apparatus includes:
  • the determining module 1002 is configured to determine the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
  • the processing module 1004 is configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing at the corresponding level of the modeling model in a preset manner On the bounding box tree, wherein the preset manner is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
  • the rendering module 1006 is configured to render the to-be-rendered three-dimensional scene data according to the model blocks stored in the hierarchical bounding box tree.
  • the modeling model adopted by the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed.
  • the number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
  • the modeling model may include a point cloud model and a triangular mesh model, but is not limited to a point cloud model and a triangular mesh model, which is not limited in the embodiment of the present disclosure.
  • the processing module is further configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the modeling model in a preset manner.
  • the dividing point of the bounding box; according to the dividing point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  • the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget determine the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget, find and select the longest axis in the bounding box as the splitting axis, according to the center of all points in the splitting axis
  • the number of bits determines the dividing point of the bounding box, and according to the dividing point, all model blocks in the bounding box are determined to be stored in the left node or the right node of the hierarchical bounding box tree.
  • the processing module is further configured to determine the target node of the current model block stored in the hierarchical bounding box tree according to the split point, and set the first model block whose coordinate value is greater than that of the split point Divide into one of the left node and the right node; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
  • the model block whose coordinate value is greater than the coordinate value of the split point is used as the first model block, and the coordinate value of the model block is smaller than the split point.
  • the model nugget of the coordinate value of is used as the second model nugget, and the first model nugget and the second model nugget are divided into two different nodes, the left node and the right node, respectively.
  • the processing module needs to perform the following steps cyclically until all the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner.
  • determine the bounding box of the current model block in the modeling model take the longest axis in the bounding box as the dividing axis, and determine the dividing point of the bounding box according to the dividing circle; according to the dividing The point determines that all model blocks in the bounding box are stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  • the processing module is configured to, when the modeling model is a triangular mesh model and the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, then The current triangular patch is stored in the target node in a random manner.
  • the modeling model used for the 3D scene data to be rendered is a triangular mesh model
  • the internal primitives of the triangular mesh model are triangular patches
  • the triangular patch is at the edge of the dividing axis, some model blocks of the same triangular patch belong to the left node, and some model blocks belong to the right node.
  • the triangular patch is randomly stored in the left node or the right node, so as to ensure There is no resource conflict at the triangle patch level inside the bounding box, which is more conducive to query operations.
  • the rendering module is further configured to render the three-dimensional scene data to be rendered according to the model blocks stored on the hierarchical bounding box tree, and obtain the to-be-rendered scene data from the hierarchical bounding box tree in a parallel search manner.
  • the rendered model block; the three-dimensional scene data to be rendered is rendered according to the obtained model block to be rendered.
  • the method of parallel search is used to obtain the model blocks to be rendered on the hierarchical bounding box tree, and then the 3D scene data to be rendered is rendered.
  • the parallel search method is used to speed up the search process and reduce the system delay.
  • the above modules can be implemented by software or hardware, and the latter can be implemented in the following ways, but not limited to this: the above modules are all located in the same processor; or, the above modules can be combined in any combination The forms are located in different processors.
  • An embodiment of the present disclosure further provides a storage medium, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
  • the above-mentioned storage medium may be configured to store a computer program for executing the following steps:
  • S3 Render the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
  • the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), Various media that can store computer programs, such as removable hard disks, magnetic disks, or optical disks.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • An embodiment of the present disclosure also provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
  • the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
  • the above-mentioned processor may be configured to execute the following steps through a computer program:
  • S3 Render the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
  • the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), Various media that can store program codes, such as removable hard disks, magnetic disks, or optical disks.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • modules or steps of the present disclosure can be implemented by a general-purpose computing device, and they can be centralized on a single computing device or distributed in a network composed of multiple computing devices Alternatively, they may be implemented in program code executable by a computing device, such that they may be stored in a storage device and executed by the computing device, and in some cases, in a different order than here
  • the steps shown or described are performed either by fabricating them separately into individual integrated circuit modules, or by fabricating multiple modules or steps of them into a single integrated circuit module.
  • the present disclosure is not limited to any particular combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Architecture (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Geometry (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

A method and device for rendering three-dimensional scene data, a storage medium, and an electronic device. The method comprises: determining a modeling model used by three-dimensional scene data to be rendered, wherein different modeling models are used for indicating three-dimensional scene data in different display modes (S202); performing block dividing processing on the modeling model according to the type of the modeling model, and storing, in a preset manner, model blocks obtained after the block dividing processing onto a hierarchical bounding box tree corresponding to the modeling model, wherein the preset manner is used for indicating that the difference between the number of left nodes and the number of right nodes of the hierarchical bounding box tree is less than a preset threshold (S204); and rendering said three-dimensional scene data according to the model blocks stored on the hierarchical bounding box tree (S206). The present invention solves the problem in the related art of waste of resources caused by uneven distribution of nodes of a hierarchical bounding box tree due to uneven distribution of three-dimensional scene data when performing processing on a model of the three-dimensional scene data by means of a hierarchical bounding box tree.

Description

三维场景数据的渲染方法及装置、存储介质、电子装置Rendering method and device, storage medium, and electronic device for three-dimensional scene data
本公开要求于2020年12月11日提交中国专利局、申请号为202011453443.8、发明名称“三维场景数据的渲染方法及装置、存储介质、电子装置”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of the Chinese patent application filed on December 11, 2020 with the Chinese Patent Office, the application number is 202011453443.8, and the invention title is "3D scene data rendering method and device, storage medium, electronic device", the entire content of which is provided by References are incorporated in this disclosure.
技术领域technical field
本公开主要涉及通信领域,具体而言,涉及一种三维场景数据的渲染方法及装置、存储介质、电子装置。The present disclosure mainly relates to the field of communications, and in particular, to a method and device for rendering three-dimensional scene data, a storage medium, and an electronic device.
背景技术Background technique
随着科技的不断发展,各种技术都在发展,由于三维大规模场景较为复杂,在对大规模场景进行实时渲染时,当前的图形渲染引擎会有一些不足,如无法完全载入资源、渲染量过大、无法实时显示等问题。因此需要对模型数据进行处理,进而克服当前图形渲染引擎的不足。With the continuous development of science and technology, various technologies are developing. Due to the complexity of 3D large-scale scenes, when rendering large-scale scenes in real time, the current graphics rendering engine will have some shortcomings, such as the inability to fully load resources, render The volume is too large and cannot be displayed in real time. Therefore, it is necessary to process the model data to overcome the deficiencies of the current graphics rendering engine.
相关技术中,对大规模场景的数据处理的方式主要是:使用多层次细节(Levels of Detail,LOD)模型和四叉树层次结构对大规模场景的数据进行处理和使用八叉树结构对大规模场景的数据进行处理。使用LOD模型和四叉树层次结构对大规模场景的数据进行处理的方式,利用LOD模型实现实时的可视化和四叉树层次结构实现地理信息显示、查询和分析,但是该方式需要提前制作不同分辨率的LOD模型,这会导致自适应能力较差,不适用于交互式的场景渲染。使用八叉树结构来组织场景模型,利用了渲染三维数据的空间信息和树形结构,来批量的削减视锥体外的几何节点,快速计算出渲染所需要的节点序列,减少了送入渲染通道的三角面片数量,但是由于场景模型的分布可能存在不均匀的情况,使用均匀分割的八叉树会导致资源的浪费。In the related art, the data processing methods for large-scale scenes are mainly: using a multi-level detail (Levels of Detail, LOD) model and a quadtree hierarchical structure to process the data of large-scale scenes and using an octree structure to process large-scale scene data. The data of the scale scene is processed. The LOD model and the quadtree hierarchy are used to process the data of large-scale scenes, and the LOD model is used to realize real-time visualization and the quadtree hierarchy to realize geographic information display, query and analysis, but this method needs to make different resolutions in advance. rate LOD model, which leads to poor adaptability and is not suitable for interactive scene rendering. The octree structure is used to organize the scene model, and the spatial information and tree structure of the rendered 3D data are used to reduce the geometric nodes outside the view frustum in batches, quickly calculate the node sequence required for rendering, and reduce the number of input rendering channels. However, due to the uneven distribution of the scene model, the use of evenly divided octrees will lead to waste of resources.
针对相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题,尚未提出有效的技术方案。In the related art, when the model of the 3D scene data is processed through the hierarchical bounding box tree, due to the uneven distribution of the 3D scene data, the nodes of the hierarchical bounding box tree are unevenly distributed, thereby causing the waste of resources and other problems. technical solution.
发明内容SUMMARY OF THE INVENTION
本公开实施例提供了一种三维场景数据的渲染方法及装置、存储介质、电子装置,以至少解决相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题。Embodiments of the present disclosure provide a method and device, a storage medium, and an electronic device for rendering 3D scene data, so as to at least solve the problem in the related art that when a model of 3D scene data is processed through a hierarchical bounding box tree, the 3D scene data The uneven distribution leads to uneven distribution of nodes in the hierarchical bounding box tree, which in turn causes problems such as waste of resources.
本公开实施例提供了一种三维场景数据的渲染方法,包括:确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。An embodiment of the present disclosure provides a method for rendering 3D scene data, including: determining a modeling model used for 3D scene data to be rendered, wherein different modeling models are used to indicate 3D scene data in different display modes; The type of the modeling model performs block processing on the modeling model, and the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner, wherein, The preset mode is used to indicate that the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold; to render.
可选地,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上的过程中:确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the hierarchical bounding box corresponding to the modeling model in a preset manner. During the process on the tree: determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the splitting axis, and determine the splitting point of the bounding box according to the splitting axis; All model blocks in the bounding box are determined according to the dividing point and stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
可选地,根据所述分割点确定所述当前模型块保存在所述层次包围盒树的目标节点,包括:将坐标值大于所述分割点的第一模型块划分到左节点和右节点中的一个节点中;将坐标值小于所述分割点的第二模型块划分到左节点和右节点中的另一个节点中。Optionally, determining the target node of the current model nugget to be stored in the hierarchical bounding box tree according to the splitting point includes: dividing the first model nugget whose coordinate value is greater than the splitting point into a left node and a right node In one node of ; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
可选地,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,包括:循环执行以下步骤,直至所述分块处理后所得到的所有模型块按照预设方式保存在所述建模模型对应的层次包围盒树上:确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割周确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the hierarchical bounding box corresponding to the modeling model in a preset manner. On the tree, including: cyclically executing the following steps until all model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner: determining the number of blocks in the modeling model The bounding box of the current model block; the longest axis in the bounding box is used as the splitting axis, and the splitting point of the bounding box is determined according to the splitting circumference; all models in the bounding box are determined according to the splitting point The block is stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
可选地,根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点之前,所述方法还包括:在所述建模模型为三角网格模型,且所述当前模型块为三角面片的情况下,如果当前三角面片位于所述分割轴的边缘,则将所述当前三角面片按照随机方式保存在所述目标节点。Optionally, it is determined according to the dividing point that all model blocks in the bounding box are stored before the target node of the hierarchical bounding box tree, and the method further includes: when the modeling model is a triangular mesh model, And when the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, the current triangular patch is stored in the target node in a random manner.
可选地,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染,包括:采用并行查找的方式从所述层次包围盒树上获取待渲染的模型块;根据获取的待渲染的模型块对所述待渲染的三维场景数据进行渲染。Optionally, rendering the three-dimensional scene data to be rendered according to the model blocks stored on the hierarchical bounding box tree includes: acquiring the model block to be rendered from the hierarchical bounding box tree in a parallel search manner. ; Render the three-dimensional scene data to be rendered according to the acquired model block to be rendered.
根据本公开的另一个实施例,还提供了一种三维场景数据的渲染装置,包括:确定模块,设置为确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;处理模块,设置为根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;渲染模块,设置为根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。According to another embodiment of the present disclosure, there is also provided an apparatus for rendering three-dimensional scene data, including: a determining module configured to determine a modeling model used for the three-dimensional scene data to be rendered, wherein different modeling models use the three-dimensional scene data indicating different display modes; the processing module is configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing according to a preset method On the hierarchical bounding box tree corresponding to the modeling model, wherein the preset manner is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold; the rendering module is set to according to The model block stored on the hierarchical bounding box tree renders the three-dimensional scene data to be rendered.
可选地,所述处理模块,还设置为确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, the processing module is further configured to determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the dividing axis, and determine the The dividing point of the bounding box; according to the dividing point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node .
根据本公开的又一个实施例,还提供了一种计算机可读的存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。According to yet another embodiment of the present disclosure, a computer-readable storage medium is also provided, where a computer program is stored in the storage medium, wherein the computer program is configured to execute any one of the above method embodiments when running steps in .
根据本公开的又一个实施例,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。According to yet another embodiment of the present disclosure, there is also provided an electronic device comprising a memory and a processor, wherein the memory stores a computer program, the processor is configured to run the computer program to execute any of the above Steps in Method Examples.
通过上述技术方案,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;根据建模模型的类型对建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在建模模型对应的层次包围盒树上,其中,预设方式用于指示层次包围盒树的左节点和右节点的数量差小于预设阈值;根据保存在层次包围盒树上的模型块对待渲染的三维场景数据进行渲染,即将分块处理后的模型块保存在建模模型对应的层次包围盒树上,并且保证层次包围盒树的左节点和右节点的数量差小于预设阈值,采用上述技术方案,解决了相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题。Through the above technical solution, the modeling model used for the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are divided into blocks according to the types of the modeling models process, and save the model nuggets obtained after the block processing on the hierarchical bounding box tree corresponding to the modeling model according to a preset method, wherein the preset method is used to indicate the number of left and right nodes of the hierarchical bounding box tree The difference is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is stored in the hierarchical bounding box tree corresponding to the modeling model, and the level is guaranteed. The difference between the number of left nodes and right nodes of the bounding box tree is less than the preset threshold. By adopting the above technical solution, it is solved in the related art that when the model of the three-dimensional scene data is processed through the hierarchical bounding box tree, the distribution of the three-dimensional scene data is not uniform. Evenly, resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
附图说明Description of drawings
此处所说明的附图用来提供对本公开的进一步理解,构成本申请的一部分,本公开的示意性实施例及其说明用于解释本公开,并不构成对本公开的不当限定。在附图中:The accompanying drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the attached image:
图1是本公开实施例的一种三维场景数据的渲染方法的计算机终端的硬件结构框图;1 is a block diagram of a hardware structure of a computer terminal according to a method for rendering three-dimensional scene data according to an embodiment of the present disclosure;
图2是根据本公开实施例的三维场景数据的渲染方法的流程图;2 is a flowchart of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure;
图3是根据本公开可选实施例的三维场景数据的渲染方法的流程图;3 is a flowchart of a method for rendering three-dimensional scene data according to an optional embodiment of the present disclosure;
图4是根据本公开实施例的三维场景数据的渲染方法的三角网格模型渲染界面示意图;4 is a schematic diagram of a triangular mesh model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure;
图5是根据本公开实施例的三维场景数据的渲染方法的点云模型渲染界面示意图;5 is a schematic diagram of a point cloud model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure;
图6是本公开可选实施例中的移动摄像机位置的视追查询时间变化折线图;FIG. 6 is a broken line chart of visual tracking query time change of the position of a moving camera in an optional embodiment of the present disclosure;
图7是本公开可选实施例中的改变视野角度的视锥查询时间变化折线图;FIG. 7 is a broken line graph of the time change of the viewing cone query by changing the viewing angle in an optional embodiment of the present disclosure;
图8是本公开可选实施例中的改变视点位置的视锥查询时间变化折线图;FIG. 8 is a line chart of the time change of the viewing cone query when the viewpoint position is changed in an optional embodiment of the present disclosure;
图9是本公开可选实施例中的改变远平面距离的视锥查询时间变化折线图;FIG. 9 is a broken line graph of the time change of viewing cone query when the far plane distance is changed in an optional embodiment of the present disclosure;
图10是根据本公开实施例的三维场景数据的渲染装置的结构框图。FIG. 10 is a structural block diagram of an apparatus for rendering three-dimensional scene data according to an embodiment of the present disclosure.
具体实施方式Detailed ways
下文中将参考附图并结合实施例来详细说明本公开。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。Hereinafter, the present disclosure will be described in detail in conjunction with the embodiments with reference to the accompanying drawings. It should be noted that the embodiments in the present application and the features of the embodiments may be combined with each other in the case of no conflict.
需要说明的是,本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、***、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second" and the like in the description and claims of the present disclosure and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances for the embodiments of the application described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
本申请实施例所提供的方法可以在移动终端、计算机终端或者类似的运算装置中执行。以运行在计算机终端上为例,图1是本公开实施例的一种三维场景数据的渲染方法的计算机终端的硬件结构框图。如图1所示,计算机终端可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和设置为存储数据的存储器104,可选地,上述计算机终端还可以包括设置为通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构 仅为示意,其并不对上述计算机终端的结构造成限定。例如,计算机终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示等同功能或比图1所示功能更多的不同的配置。存储器104可设置为存储计算机程序,例如,应用软件的软件程序以及模块,如本公开实施例中的三维场景数据的渲染方法对应的计算机程序,处理器102通过运行存储在存储器104内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。传输装置106设置为经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机终端的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,简称为RF)模块,设置为通过无线方式与互联网进行通讯。The methods provided by the embodiments of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking running on a computer terminal as an example, FIG. 1 is a hardware structural block diagram of a computer terminal of a rendering method for three-dimensional scene data according to an embodiment of the present disclosure. As shown in FIG. 1 , the computer terminal may include one or more (only one is shown in FIG. 1 ) processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 configured to store data, optionally, the above-mentioned computer terminal may further include a transmission device 106 and an input/output device 108 configured as a communication function. Those skilled in the art can understand that the structure shown in Fig. 1 is only for illustration, and it does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have a different configuration with equivalent or more functions than those shown in FIG. 1 . The memory 104 may be configured to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the method for rendering three-dimensional scene data in the embodiments of the present disclosure. The processor 102 executes the computer programs stored in the memory 104 , so as to perform various functional applications and data processing, that is, to implement the above method. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory located remotely from the processor 102, and these remote memories may be connected to the computer terminal through a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. Transmission means 106 are arranged to receive or transmit data via a network. The specific example of the above-mentioned network may include a wireless network provided by the communication provider of the computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC for short), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (Radio Frequency, RF for short) module, which is configured to communicate with the Internet in a wireless manner.
根据本公开的一个实施例,提供了一种三维场景数据的渲染方法,应用于上述计算机终端,图2是根据本公开实施例的三维场景数据的渲染方法的流程图,如图2所示,包括:According to an embodiment of the present disclosure, a method for rendering three-dimensional scene data is provided, which is applied to the above-mentioned computer terminal. FIG. 2 is a flowchart of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure, as shown in FIG. 2 , include:
步骤S202,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;Step S202, determining the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
步骤S204,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;Step S204, performing block processing on the modeling model according to the type of the modeling model, and saving the model blocks obtained after the block processing in a hierarchical bounding box tree corresponding to the modeling model in a preset manner. above, wherein the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
步骤S206,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。Step S206, rendering the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
通过上述步骤,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;根据建模模型的类型对建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在建模模型对应的层次包围盒树上,其中,预设方式用于指示层次包围盒树的左节点和右节点的数量差小于预设阈值;根据保存在层次包围盒树上的模型块对待渲染的三维场景数据进行渲染,即将分块处理后的模型块保存在建模模型对应的层次包围盒树上,并且保证层次包围盒树的左节点和右节点的数量差小于预设阈值,采用上述技术方案,解决了相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题。Through the above steps, the modeling model used for the 3D scene data to be rendered is determined, wherein different modeling models are used to indicate the 3D scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed. The number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
在步骤S202中,建模模型可以包括点云模型和三角网格模型,但是不限于点云模型和三角网格模型,本公开实施例对此不做限定。In step S202, the modeling model may include a point cloud model and a triangular mesh model, but is not limited to the point cloud model and the triangular mesh model, which is not limited in this embodiment of the present disclosure.
可选地,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上的过程中:还需要确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the hierarchical bounding box corresponding to the modeling model in a preset manner. During the process on the tree: it is also necessary to determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the splitting axis, and determine the splitting of the bounding box according to the splitting axis point; according to the split point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
也就是说,确定当前建模模型中存在的模型块,以及当前模型块对应的包围盒,寻找和选定包围盒中的最长的一根轴作为分割轴,根据分割轴中所有点的中位数确定所述包围盒的分割点,并根据分割点确定包围盒中的所有模型块分别保存在层次包围盒树的左节点或右节点。That is to say, determine the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget, find and select the longest axis in the bounding box as the splitting axis, according to the center of all points in the splitting axis The number of bits determines the dividing point of the bounding box, and all model blocks in the bounding box are determined according to the dividing point, and are respectively stored in the left node or the right node of the hierarchical bounding box tree.
在一个示例性实施例中,根据所述分割点确定所述当前模型块保存在所述层次包围盒树的目标节点,将坐标值大于所述分割点的第一模型块划分到左节点和右节点中的一个节点中;将坐标值小于所述分割点的第二模型块划分到左节点和右节点中的另一个节点中。In an exemplary embodiment, the target node of the current model block stored in the hierarchical bounding box tree is determined according to the dividing point, and the first model block whose coordinate value is greater than the dividing point is divided into a left node and a right node. In one of the nodes; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
也就是说,通过对分割点的坐标值和模型块的坐标值进行比较,将模型块的坐标值大于分割点的坐标值的模型块作为第一模型块,将模型块的坐标值小于分割点的坐标值的模型块作为第二模型块,将第一模型块和第二模型块分别划分在左节点和右节点两个不同的节点中,进而实现将包围盒中的所有模型块分别保存在层次包围盒树的左节点或右节点中。That is to say, by comparing the coordinate value of the split point with the coordinate value of the model block, the model block whose coordinate value is greater than the coordinate value of the split point is used as the first model block, and the coordinate value of the model block is smaller than the split point. The model nugget with the coordinate value of the In the left or right node of the hierarchical bounding box tree.
可选地,三维场景的数据很大,因此需要循环执行以下步骤,直至所述分块处理后所得到的所有模型块按照预设方式保存在所述建模模型对应的层次包围盒树上:确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割周确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, the data of the three-dimensional scene is very large, so the following steps need to be performed cyclically until all the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner: determining the bounding box of the current model block in the modeling model; taking the longest axis in the bounding box as the splitting axis, and determining the splitting point of the bounding box according to the splitting circumference; determining according to the splitting point All model blocks in the bounding box are stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
由于三维场景数据过大,执行一次上述步骤并不能完成根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,在模型块小于预定阈值的情况下,结束划分,完成对三维场景数据的分块处理。Since the 3D scene data is too large, executing the above steps once cannot complete the block processing of the modeling model according to the type of the modeling model, and the model blocks obtained after the block processing are stored in a preset manner in a preset manner. On the hierarchical bounding box tree corresponding to the modeling model, when the model block is smaller than the predetermined threshold, the division is ended, and the block processing of the three-dimensional scene data is completed.
可选地,在所述建模模型为三角网格模型,且所述当前模型块为三角面片的情况下,如果当前三角面片位于所述分割轴的边缘,则将所述当前三角面片按照随机方式保存在所述目标节点。Optionally, in the case where the modeling model is a triangular mesh model and the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, the current triangular Slices are stored at the target node in a random manner.
确定待渲染的三维场景数据所采用的建模模型为三角网格模型时,由于三角网格模型的内部图元为三角面片,所以在进行分割时,需要考虑如果三角面片处于分割轴的边缘的情况。在三角面片处于分割轴的边缘时,同一三角面片的部分模型块属于左节点,部分模型块属于右节点,此时,将该三角面片随机保存在左节点或者右节点中,这样保证了包围盒内部的三角形面片层次上不会发生资源的冲突,更有利于查询操作。When it is determined that the modeling model used for the 3D scene data to be rendered is a triangular mesh model, since the internal primitives of the triangular mesh model are triangular patches, when dividing, it is necessary to consider if the triangular patches are in the division axis. edge cases. When the triangular patch is at the edge of the dividing axis, some model blocks of the same triangular patch belong to the left node, and some model blocks belong to the right node. At this time, the triangular patch is randomly stored in the left node or the right node, so as to ensure There is no resource conflict at the triangle patch level inside the bounding box, which is more conducive to query operations.
可选地,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染,采用并行查找的方式从所述层次包围盒树上获取待渲染的模型块;根据获取的待渲染的模型块对所述待渲染的三维场景数据进行渲染。Optionally, the three-dimensional scene data to be rendered is rendered according to the model blocks stored in the hierarchical bounding box tree, and the model block to be rendered is obtained from the hierarchical bounding box tree by means of parallel search; The acquired model block to be rendered renders the three-dimensional scene data to be rendered.
在对三维场景数据进行渲染时,采用并行查找的方式,获取层次包围盒树上待渲染的模型块,进而对待渲染的三维场景数据进行渲染,采用并行查找的方式加速了查找的过程,降低了***的延迟。When rendering the 3D scene data, the method of parallel search is used to obtain the model blocks to be rendered on the hierarchical bounding box tree, and then the 3D scene data to be rendered is rendered. The parallel search method is used to speed up the search process and reduce the system delay.
以下结合几个可选实施例对上述三维场景数据的渲染方法的流程进行解释说明,但不用于限定本公开实施例的技术方案。The flow of the foregoing three-dimensional scene data rendering method is explained below with reference to several optional embodiments, but is not intended to limit the technical solutions of the embodiments of the present disclosure.
对于大规模场景的数据管理目前有以下两种常见的方式。There are currently two common methods for data management in large-scale scenarios.
1)使用八叉树进行处理的方法,其一般步骤为:(1)首先将大规模的三维场景数据进行读取。使用层次化的场景图来对场景进行组织,得到场景的渲染数据层次图。对于图形渲染 引擎来说,一个非常重要的部分就是对场景中的图元信息进行组织。组织方式需要遵循以下两个原则:第一,有利于调取数据时内存的管理;第二,能够加速场景的渲染过程。在使用层次结构组织渲染对象时,在父节点保存共同使用的信息。一般使用有向无环图的层次结构,这种场景图包含一个根节点,有一个或者多个孩子节点,它的每个孩子节点还可以包含多个孩子节点。在这些节点中,其中一些是需要进行渲染的图元对象,另外一些是用来住址渲染对象的结构。比如,一个场景有很多的房间组成,那么就可创建这个场景的场景图,该场景图就可能包含叫做room0,room1,room2等节点。这些节点的根节点就是一个叫做bu i ld ing的节点。使用场景图可以充分利用硬件资源,从而很大程度地提高渲染的性能。(2)建立并生成该场景的八叉树结构,记录相关的信息。八叉树是一种描述三维空间的树状数据结构。八叉树的每个节点表示一个正方体的体积元素,每个节点有八个子节点,这八个子节点所表示的体积元素加在一起就等于父节点的体积。一般使用模型的中心点作为节点的分叉中心。并且在建立八叉树的同时,为每个节点创建AABB包围盒。(3)利用八叉树的结构,通过视锥体与包围盒的相交检测算法进行快速的视锥剔除。因为八叉树已经对空间进行了均分,只需要根据节点所在的包围盒是否处在视锥体的范围内即可。(4)对于处于视锥中的物体进行渲染。1) A method for processing using an octree, and the general steps are: (1) First, read large-scale three-dimensional scene data. Use the hierarchical scene graph to organize the scene, and get the rendering data hierarchy graph of the scene. For a graphics rendering engine, a very important part is to organize the primitive information in the scene. The organization method needs to follow the following two principles: first, it is conducive to memory management when retrieving data; second, it can speed up the rendering process of the scene. When using a hierarchy to organize render objects, save common information in the parent node. The hierarchical structure of a directed acyclic graph is generally used. This kind of scene graph contains a root node and has one or more child nodes. Each child node of the scene graph can also contain multiple child nodes. Among these nodes, some are primitive objects that need to be rendered, and some are structures used to address rendering objects. For example, if a scene consists of many rooms, then a scene graph of this scene can be created, and the scene graph may contain nodes called room0, room1, room2, etc. The root node of these nodes is a node called building. Using the scene graph can make full use of hardware resources, which can greatly improve the performance of rendering. (2) Establish and generate the octree structure of the scene, and record the relevant information. An octree is a tree-like data structure that describes a three-dimensional space. Each node of the octree represents a volume element of a cube, and each node has eight child nodes. The sum of the volume elements represented by these eight child nodes is equal to the volume of the parent node. Generally, the center point of the model is used as the bifurcation center of the node. And while building the octree, create an AABB bounding box for each node. (3) Using the structure of the octree, the fast frustum culling is performed through the intersection detection algorithm between the frustum and the bounding box. Because the octree has already divided the space equally, it only needs to be based on whether the bounding box where the node is located is within the range of the view frustum. (4) Render objects in the view frustum.
该方法使用八叉树的结构来组织场景,利用了渲染三维数据的空间信息和树形结构,来批量的削减视锥体外的几何节点,快速计算出渲染所需要的节点序列,减少了送入渲染通道的三角面片数量。该方法是通过创建八叉树的方式进行场景的管理,但是由于模型的分布可能存在不均匀的情况,使用均匀分割的八叉树会导致资源的浪费,使得查找过程变慢。同时该方法是在单机上进行的,没有考虑分布式渲染的情况。This method uses the octree structure to organize the scene, utilizes the spatial information and tree structure of the rendered 3D data, reduces the geometric nodes outside the viewing frustum in batches, quickly calculates the node sequence required for rendering, and reduces the number of input The number of triangular patches for the render pass. This method manages the scene by creating an octree, but since the distribution of the model may be uneven, using an evenly divided octree will lead to waste of resources and make the search process slower. At the same time, the method is carried out on a single machine, and the distributed rendering is not considered.
2)基于LOD模型和四叉树层次结构的三维场景管理和渲染的方法,该方法使用了LOD模型对数据进行分层和分块处理来提高三维场景的浏览速度。首先根据应用需求精度、可视化场景的大小以及地物的复杂程度以及聚集程度,确定LOD建模的等级标准,进行数据分层,进行数据分块,小规模场景在漫游过程中作为一块来处理,当场景数据规模增大时,对数据规模作分块处理。LOD建模,其实质就是将原有的模型进行重组,得到一种更加便于实时绘制使用的数据结构。利用四叉树制作LOD的分割方式是这样的,从完整的模型出发,通常根节点也是选择在模型的中间。把整个模型作为根节点,然后从根节点出发判断是否满足分割的条件,若不满足则不进行分割,并作为叶子节点进行保存;否则把根节点进行不断递归地不断分成相等地四个子节点区域,直到不能再分割位置,最后将所有叶子节点绘制形成简化结果。分割的深度越大,得到的LOD模型的分辨率就越高,分割时同样可以结合评价函数和用户要求对每个节点进行判断。如果该点精度已经符合要求的话,则不再进行分割,否则,继续进行分割直到节点符合要求为止。2) A method of 3D scene management and rendering based on LOD model and quadtree hierarchical structure. This method uses LOD model to process data in layers and blocks to improve the browsing speed of 3D scene. First, according to the accuracy of application requirements, the size of the visualized scene, the complexity and aggregation degree of the ground objects, the level standard of LOD modeling is determined, and the data is layered and divided into blocks. Small-scale scenes are processed as one piece during the roaming process. When the scene data scale increases, the data scale is processed into blocks. The essence of LOD modeling is to reorganize the original model to obtain a data structure that is more convenient for real-time rendering. The segmentation method of using quadtree to make LOD is like this. Starting from the complete model, usually the root node is also selected in the middle of the model. Take the entire model as the root node, and then start from the root node to determine whether the conditions for segmentation are met. If not, the segmentation will not be performed, and it will be saved as a leaf node; otherwise, the root node will be recursively divided into four equal sub-node areas. , until the position can no longer be divided, and finally all leaf nodes are drawn to form a simplified result. The greater the depth of the segmentation, the higher the resolution of the obtained LOD model, and the evaluation function and user requirements can also be used to judge each node during segmentation. If the accuracy of the point already meets the requirements, no further segmentation is performed; otherwise, the segmentation continues until the node meets the requirements.
在上述方法中,利用LOD模型实现实时的可视化,利用四叉树层次结构实现地理信息显示、查询和分析。但是该方法需要提前制作不同分辨率的LOD模型,这会导致自适应能力较差,不适用于交互式的场景渲染。该方法需要针对每个角度和不同的用户需求指定不同的LOD模型,当模型的体量不是很大时,该方法还是很实用的,但是当模型的规模很大且模型复杂时,制作LOD需要消耗大量的时间和计算渲染资源。而且需要较多的物理空间进行存储。该方法在创建LOD模型时对模型进行了分块,不适合交互式的方式。In the above method, the LOD model is used to realize real-time visualization, and the quadtree hierarchical structure is used to realize the display, query and analysis of geographic information. However, this method needs to make LOD models of different resolutions in advance, which leads to poor adaptive ability and is not suitable for interactive scene rendering. This method needs to specify different LOD models for each angle and different user needs. When the volume of the model is not very large, this method is still very practical, but when the scale of the model is large and the model is complex, the LOD needs to be produced. Consume a lot of time and computational rendering resources. And it requires more physical space for storage. This method blocks the model when creating the LOD model and is not suitable for an interactive way.
对于大规模的无法在单机进行渲染的场景,需要在多机集群上进行分布式的渲染。进行 分布式渲染的一个重要点就是进行渲染资源的管理工作。本公开首先将点云模型和三角网格模型模型读取至主节点使用三维空间上的八叉层次结构树的结构对数据进行预处理,将模型进行分块处理,之后保存该模型的树形结构。在渲染时,依据视锥与树中各个节点进行碰撞计算确定需要渲染的内容,使用八叉树的并行化查找方式进行的查找数据的工作,调取需要使用的模型块。之后在渲染节点对需要渲染的数据进行渲染。同时用户可以在用户端交互式的改变想要看到的区域,主结点会再次执行查询工作进行资源的调度。本公开可以快速锁定需要渲染的图元模型部分。For large-scale scenes that cannot be rendered on a single machine, distributed rendering needs to be performed on a multi-machine cluster. An important point of distributed rendering is the management of rendering resources. The present disclosure firstly reads the point cloud model and the triangular mesh model to the main node, preprocesses the data using the structure of the octet hierarchical tree in the three-dimensional space, divides the model into blocks, and then saves the tree shape of the model structure. During rendering, the content to be rendered is determined according to the collision calculation between the view frustum and each node in the tree, and the parallelized search method of the octree is used to find the data to retrieve the model block to be used. Then render the data that needs to be rendered in the rendering node. At the same time, users can interactively change the area they want to see on the client side, and the master node will execute the query work again to schedule resources. The present disclosure can quickly lock the part of the primitive model that needs to be rendered.
本公开适用于大规模的点云模型和三角网格模型和模型数量级巨大无法进行单机渲染的场景。通过本公开处理模型分布差异较大的场景时,构建的树更加地合理。利用多种树形结构进行模型的预处理和并行查询处理,能够快速获得需要渲染的图元信息。The present disclosure is applicable to large-scale point cloud models and triangular mesh models and scenarios where the models are orders of magnitude huge and cannot be rendered by a single machine. When the present disclosure handles scenarios with large differences in model distribution, the constructed tree is more reasonable. Using multiple tree structures for model preprocessing and parallel query processing can quickly obtain the primitive information that needs to be rendered.
图3是根据本公开可选实施例的三维场景数据的渲染方法的流程图;如图3所示,首先将点云模型或网格模型使用三维空间BVH树的方法进行拆分管理,然后根据视锥信息,按照树的结构查询在视锥内的几何元素(相当于上述实施例中的模型块),然后将这些元素渲染出来并展现在窗口上,通过键鼠交互修改视锥信息,渲染模型的不同位置,然后循环往复。具体可以分为以下几个具体任务:3 is a flowchart of a method for rendering 3D scene data according to an optional embodiment of the present disclosure; as shown in FIG. 3 , first, the point cloud model or grid model is split and managed by using a 3D space BVH tree, and then according to View cone information, query the geometric elements in the view cone according to the tree structure (equivalent to the model block in the above embodiment), then render these elements and display them on the window, modify the view cone information through the interaction of the keyboard and mouse, and render the different positions of the model, and then the cycle goes back and forth. Specifically, it can be divided into the following specific tasks:
(1)读取点云模型或网格模型;(1) Read the point cloud model or grid model;
(2)对模型建立层次包围盒(Bounding Volume Hierarcy,BVH)树(相当于上述实施例中的层次包围盒树),进行分块存储;(2) establishing a hierarchical bounding box (Bounding Volume Hierarcy, BVH) tree (equivalent to the hierarchical bounding box tree in the above-mentioned embodiment) for the model, and storing in blocks;
(3)输入视锥信息,判断某个点是否在视锥内;(3) Input the viewing cone information to determine whether a certain point is within the viewing cone;
(4)根据BVH树逐层检测包围盒,判断哪些节点在视锥内部;(4) Detect the bounding box layer by layer according to the BVH tree, and determine which nodes are inside the view cone;
(5)使用多线程的方法,并行查找BVH树根节点的左儿子和右儿子;(5) Using the method of multi-threading, find the left son and right son of the root node of the BVH tree in parallel;
(6)将渲染结果显示在窗口上;(6) Display the rendering result on the window;
(7)添加仪表盘,显示每秒传输帧数(Frames Per Second,FPS)、平均渲染时延等信息;(7) Add a dashboard to display information such as frames per second (Frames Per Second, FPS), average rendering delay, etc.;
(8)添加键鼠交互,当视锥的参数(包括视锥的位置和属性)发生改变时,重新判断在视锥内的物体顶点,并渲染。(8) Add keyboard and mouse interaction. When the parameters of the view frustum (including the position and attributes of the view frustum) change, the vertices of the objects in the view frustum are re-determined and rendered.
渲染结果如图4和图5所示,图4是根据本公开实施例的三维场景数据的渲染方法的三角网格模型渲染界面示意图;图5是根据本公开实施例的三维场景数据的渲染方法的点云模型渲染界面示意图。Rendering results are shown in FIGS. 4 and 5 . FIG. 4 is a schematic diagram of a triangular mesh model rendering interface of a method for rendering three-dimensional scene data according to an embodiment of the present disclosure; FIG. 5 is a rendering method for three-dimensional scene data according to an embodiment of the present disclosure. Schematic diagram of the point cloud model rendering interface.
本公开可选实施例利用三维空间的八叉层次包围盒和并行查找的方式,当用户进行交互式的操作时,可以快速的进行渲染资源的查找。An optional embodiment of the present disclosure utilizes an octagonal hierarchical bounding box in a three-dimensional space and a parallel search method, so that when a user performs an interactive operation, the search for rendering resources can be performed quickly.
由于模型的数量级很大,首先对模型数据进行预处理工作。对数据的预处理主要是对数据进行分块的处理。对数据的分块只需要进行一次,随后的查询阶段可以重复使用预处理得到的知识信息,也就是分块处理的结果,进而节省大量的时间。在空间上对数据进行分块有多种方式,如八叉树、k-d树(k-dimensional tree,Kd-tree)、二叉空间分割(Binary Space Partitioning,BSP)树等,对于物体层面上有层次包围盒树的分割方法。八叉树是对场景进行的均匀的划分,当模型的数据分布较为均衡时,按照八叉树的情况进行划分是比较科学的,但是当模型的数据分布不均匀时,使用这种方法会导致八叉树的不平衡,会存在某些叶节点的深度过大或者某些叶节点含有的图元数据过多等情况。k-d树树在处理网格模型时具有较 大的劣势,因为当同一个三角面片处于不同的叶子节点时,会在三维场景数据的渲染阶段将该三角面片多次调入渲染工作集,这就需要在工作集上执行去重的操作。Since the magnitude of the model is large, the model data is first preprocessed. The preprocessing of data is mainly to process the data into blocks. The data segmentation only needs to be performed once, and the subsequent query stage can reuse the knowledge information obtained by preprocessing, that is, the result of the segmentation processing, thereby saving a lot of time. There are many ways to partition data in space, such as octree, k-dimensional tree (Kd-tree), Binary Space Partitioning (BSP) tree, etc. A segmentation method for hierarchical bounding box trees. The octree is a uniform division of the scene. When the data distribution of the model is relatively balanced, it is more scientific to divide according to the situation of the octree, but when the data distribution of the model is not uniform, using this method will lead to If the octree is unbalanced, the depth of some leaf nodes may be too large or some leaf nodes contain too much primitive data. The k-d tree has a great disadvantage when dealing with mesh models, because when the same triangular patch is in different leaf nodes, the triangular patch will be transferred into the rendering work set multiple times during the rendering stage of the 3D scene data. This requires deduplication on the working set.
在本公开可选实施例中,参考了物体层面的分割方法,基于模型的数据分布对模型进行分块,创建分块树结构,使得创建出来分块树的数据分布尽可能平衡。In an optional embodiment of the present disclosure, referring to the segmentation method at the object level, the model is segmented based on the data distribution of the model, and a segmented tree structure is created, so that the data distribution of the created segmented tree is as balanced as possible.
对于点云模型文件,格式采用(x,y,z,r,g,b),用来表示模型点的坐标与颜色值。算法流程如下:For point cloud model files, the format is (x, y, z, r, g, b) to represent the coordinates and color values of model points. The algorithm flow is as follows:
步骤1:给定根节点,此时该根节点包含场景中的全部物体的信息。计算当前节点沿坐标轴方向的包围盒。若包围盒内的图元数据数量小于给定的阈值,则结束划分。Step 1: Given a root node, the root node contains the information of all objects in the scene. Calculates the bounding box of the current node along the axis. If the amount of primitive data in the bounding box is less than the given threshold, the division ends.
步骤2:寻找和选定包围盒中最长的一根轴作为切分轴。Step 2: Find and select the longest axis in the bounding box as the split axis.
步骤3:沿着该切分轴计算当前节点的包围盒内的所有图元信息的中位数,以此作为切分的位置。Step 3: Calculate the median of all primitive information in the bounding box of the current node along the segmentation axis, and use it as the segmentation position.
步骤4:再次遍历当前节点的包围盒内的所有图元信息,根据切分位置,将坐标值大于切分位置的点划分到左节点和右节点中的一个节点中,将坐标值小于切分位置的点块划分到左节点和右节点中的另一个节点中。Step 4: Traverse all the primitive information in the bounding box of the current node again, according to the segmentation position, divide the point whose coordinate value is greater than the segmentation position into one of the left node and the right node, and divide the coordinate value smaller than the segmentation position. The point block of the location is divided into another one of the left node and the right node.
步骤5:对于两个子节点重复进行1-4操作,递归建树。同时清除该节点存储的图元数据。Step 5: Repeat operations 1-4 for the two child nodes to recursively build a tree. At the same time, the metadata stored in this node is cleared.
也就是说,只有子节点中存储图元数据,其他节点存储分割轴信息。That is to say, only the child nodes store the primitive data, and other nodes store the split axis information.
对于三角网格模型,与点云模型相比最大的不同在于三角网格模型内部图元为三角面片而不是点,在进行分割时需要考虑到如果三角形处在分割位置的边缘的情况,如果三角形正好处在边缘时,如部分点应该归属于左节点,部分点应该归属于右节点,此时需要着重考虑该三角形面片的归属问题。For the triangular mesh model, the biggest difference compared with the point cloud model is that the internal primitives of the triangular mesh model are triangular patches instead of points. When dividing, it is necessary to consider the situation if the triangle is at the edge of the dividing position. When the triangle is just on the edge, for example, some points should belong to the left node, and some points should belong to the right node. At this time, it is necessary to focus on the attribution of the triangle patch.
以下有两种方式解决三角形面片的归属问题:There are two ways to solve the problem of attribution of triangle patches:
第一种:将该三角面片同时放入两个子节点中。在进行基于视锥的需要渲染的元素的查询时,可能会将两个相同的三角面片返回值送到工作集中,这就需要去重复操作,但是去重复操作很复杂,这会浪费很多时间。The first: put the triangular patch into two child nodes at the same time. When querying the elements that need to be rendered based on the view frustum, two identical triangular patch return values may be sent to the working set, which requires de-duplication, but de-duplication is very complicated, which will waste a lot of time .
第二种:将该三角面片进行分割。使用这种方式会生成多余的图元信息,当较多的三角面片处于分割线上时会导致增加的图元信息过多,增加计算量。The second: divide the triangular patch. Using this method will generate redundant primitive information. When more triangular patches are on the dividing line, it will lead to too much additional primitive information and increase the amount of calculation.
因此,本公开可选实施例采用随机分配的方式,将该三角面片随机分配至其中一个子节点中。这样虽然子节点的包围盒之间会发生空间上的重叠冲突,但是包围盒内部的三角面片层次上不会发生资源的冲突,更有利于查询操作。Therefore, an optional embodiment of the present disclosure adopts a random allocation method to randomly allocate the triangular patch to one of the child nodes. In this way, although there will be spatial overlap conflicts between the bounding boxes of the child nodes, there will be no resource conflicts at the triangle patch level inside the bounding boxes, which is more conducive to query operations.
对于模型为点云模型或者三角网格模型时,算法的伪代码可以描述如下:When the model is a point cloud model or a triangular mesh model, the pseudocode of the algorithm can be described as follows:
输入为一棵树的根节点(该根节点包含全部的模型数据)和停止划分的阈值。输出为一个只在叶子节点存在数据的树。使用递归的方式进行处理。The input is the root node of a tree (the root node contains all model data) and the threshold to stop dividing. The output is a tree with data only at the leaf nodes. Process it recursively.
步骤1:获取节点的包围盒;Step 1: Get the bounding box of the node;
步骤2:如果当前节点的包围盒中所包含的场景数据量小于阈值,返回该节点;Step 2: If the amount of scene data contained in the bounding box of the current node is less than the threshold, return to the node;
步骤3:如果当前节点的包围盒中所包含的场景数据量大于阈值,选取该包围盒的长边作为分割边进行分割;Step 3: If the amount of scene data contained in the bounding box of the current node is greater than the threshold, select the long side of the bounding box as the splitting edge for segmentation;
步骤4:在该分割边上计算得到场景的分割点;Step 4: Calculate the segmentation point of the scene on the segmentation edge;
步骤5:为该节点添加上左右两个子结点;Step 5: Add two left and right child nodes to the node;
步骤6:对该节点进行分割;Step 6: Split the node;
步骤7:遍历该节点中的全部三角形片面,根据分割点进行划分,分别放置到左右子结点中;Step 7: Traverse all the triangular faces in the node, divide them according to the dividing points, and place them in the left and right child nodes respectively;
步骤8:如果其中的一个节点中没有数据元素,停止该节点的分割操作。Step 8: If there are no data elements in one of the nodes, stop the split operation for that node.
之后分别对还能够进行分割的左右节点进行步骤1-8的操作,一直递归进行,一直到达到步骤2中的条件。After that, the operations of steps 1-8 are respectively performed on the left and right nodes that can still be divided, and the operations are performed recursively until the conditions in step 2 are reached.
由于切分是以中位数为分割线进行切分的,除了分割线上的三角形面片无法做到均匀分到左右子节点上,其他位置的点都可以均匀的分到左右子节点中去,同时位于分割线上的三角形的数量并不会很多,因此该方法在划分时基本可以做到一分为二,那么整体的算法复杂度表示如下:Since the segmentation is based on the median as the dividing line, except for the triangular patches on the dividing line, which cannot be evenly divided into the left and right child nodes, points at other positions can be evenly divided into the left and right child nodes. , the number of triangles on the dividing line is not very large at the same time, so this method can basically be divided into two when dividing, then the overall algorithm complexity is expressed as follows:
Figure PCTCN2021125315-appb-000001
Figure PCTCN2021125315-appb-000001
根据主定理,该划分方法的最终时间复杂度为O(NlogN)。According to the master theorem, the final time complexity of this partitioning method is O(NlogN).
对于空间复杂度而言,只有在分割时采用了两个临时数组存储分割结果,空间复杂度为O(N)。而且在该节点成为非叶子节点时,都会释放存储的图元信息,只有叶子节点存储这些图元信息,这大大节约了对于模型数据的存储空间。In terms of space complexity, only two temporary arrays are used to store the division results during division, and the space complexity is O(N). Moreover, when the node becomes a non-leaf node, the stored primitive information will be released, and only the leaf node stores the primitive information, which greatly saves the storage space for model data.
在进行了大规模渲染数据的分块处理之后,会将分割树的数据结构和信息作为先验知识和模型进行配套的存储。在进行三维场景数据的渲染时,类似进行八叉树(Octree)进行查询的方式,只需要根据用户的输入确定视锥的方位,之后根据视锥与构建的树之间的关系进行数据节点的确定,之后从节点开始进行递归的三维场景数据的渲染,该方法可以进行并行化处理。After the block processing of large-scale rendering data, the data structure and information of the split tree will be stored as a priori knowledge and model. When rendering 3D scene data, similar to the way of octree query, it is only necessary to determine the orientation of the view cone according to the user's input, and then according to the relationship between the view cone and the constructed tree, the data nodes are processed. After determining, the recursive 3D scene data rendering is performed from the node, and this method can be parallelized.
三维场景数据的渲染部分需要给定视锥。视锥的输入是七个参数,camPos表示摄像机的位置,camUp表示摄像机的向上方向,lookAt表示摄像机的视点位置,aspect表示视锥的宽高比,zNear和zFar分别表示裁剪的远***面与摄像机之间的距离,Fovy表示y轴上的视野角度。通过这七个参数可以唯一确定一个视锥。判断某节点是否在视锥内,需要确定视锥六个平面的方程,也就需要确定八个顶点的坐标。使用叉乘的方法确定摄像机水平方向的单位方向向量camRight。之后利用下式(2)得到视锥的八个顶点的坐标。The rendered portion of the 3D scene data requires a given view frustum. The input of the frustum is seven parameters, camPos represents the position of the camera, camUp represents the upward direction of the camera, lookAt represents the viewpoint position of the camera, aspect represents the aspect ratio of the frustum, zNear and zFar represent the distance between the cropped far and near planes and the camera respectively. The distance between, Fovy represents the field of view angle on the y-axis. Through these seven parameters, a view cone can be uniquely determined. To judge whether a node is in the view cone, it is necessary to determine the equations of the six planes of the view cone, and also need to determine the coordinates of the eight vertices. Use the method of cross product to determine the unit direction vector camRight of the horizontal direction of the camera. Then, the coordinates of the eight vertices of the viewing cone are obtained by using the following formula (2).
Figure PCTCN2021125315-appb-000002
Figure PCTCN2021125315-appb-000002
之后取某个面上的三个顶点(x 1,y 1,z 1)、(x 2,y 2,z 2)、(x 3,y 3,z 3),这就可以利用公式(3)-(7)计算出这三个点所在面的平面方程。 Then take the three vertices (x 1 , y 1 , z 1 ), (x 2 , y 2 , z 2 ), (x 3 , y 3 , z 3 ) on a certain face, which can use formula (3 )-(7) Calculate the plane equation of the surface where the three points are located.
Ax+By+Cz+D=0   (3)Ax+By+Cz+D=0 (3)
A=(y 2-y 1)×(z 3-z 1)-(z 2-z 1)×(y 3-y 1)   (4) A=(y 2 -y 1 )×(z 3 -z 1 )-(z 2 -z 1 )×(y 3 -y 1 ) (4)
B=(x 3-x 1)×(z 2-z 1)-(x 2-x 1)×(z 3-z 1)   (5) B=(x 3 -x 1 )×(z 2 -z 1 )-(x 2 -x 1 )×(z 3 -z 1 ) (5)
C=(x 2-x 1)×(y 3-y 1)-(x 3-x 1)×(y 2-y 1)   (6) C=(x 2 -x 1 )×(y 3 -y 1 )-(x 3 -x 1 )×(y 2 -y 1 ) (6)
D=-(Ax 1+By 1+Cz 1)   (7) D=-(Ax 1 +By 1 +Cz 1 ) (7)
需要注意的是,因为zNear可以取0,这时视锥的棱台变成了棱锥,zNear所在的平面变 成了一个点,所以在其它面取顶点时,至多取一个zNear上的点,以防止取的三个点实际上是两个点。It should be noted that because zNear can take 0, then the frustum of the viewing cone becomes a pyramid, and the plane where zNear is located becomes a point, so when taking vertices on other faces, at most one point on zNear is taken, with The three points that are prevented from being taken are actually two points.
如果需要判断的点都在六个平面的内侧,那么该面片就在视锥内。在进行判断时,在所判断平面的对面上取一个顶点,将其带入平面方程的左侧,若结果大于0,则记为1;若小于0,则记为-1。显然对面平面上的一定位于该平面的内侧。然后将需要判断的点导入该方程中,并且乘以刚才获得的系数,大于0,则该点在该平面内侧,小于0,则在外侧。If the points to be judged are all inside the six planes, then the patch is inside the view frustum. When judging, take a vertex on the opposite side of the judged plane and bring it into the left side of the plane equation. If the result is greater than 0, it is recorded as 1; if it is less than 0, it is recorded as -1. Obviously the one on the opposite plane must be on the inside of that plane. Then import the point to be judged into the equation, and multiply it by the coefficient just obtained. If it is greater than 0, the point is inside the plane, and if it is less than 0, it is outside.
当有了判断点是否在视锥中的方法之后,开始进行三维场景数据的渲染的工作。具体的流程是这样的:从根节点开始判断,若该节点的包围盒的八个顶点全都在视锥某一个平面的外侧,那么这个包围盒完全不在视锥中,则无需往下递归,直接结束返回;若该节点的包围盒的八个顶点全都在视锥的内部,那么这个包围盒完全在视锥中,则给定一个标记,向下递归时无需继续判断,直接返回所有节点;若包围盒与视锥相交,则往下递归,向下递归时需要进行类似的判断。After there is a method for judging whether the point is in the viewing frustum, the rendering of the three-dimensional scene data begins. The specific process is as follows: Judging from the root node, if the eight vertices of the bounding box of the node are all outside a certain plane of the view frustum, then the bounding box is not in the view frustum at all, there is no need to recurse down, directly End return; if the eight vertices of the bounding box of the node are all inside the view frustum, then the bounding box is completely inside the view frustum, then a marker is given, no further judgment is required when recursing downward, and all nodes are returned directly; if If the bounding box intersects the view cone, recurse downwards, and a similar judgment is required when recursing downwards.
查询视锥中数据的具体算法如下所示:The specific algorithm for querying the data in the view frustum is as follows:
需要说明的是,算法的输入为根节点的BVH树,一个表示该节点状态的布尔值和一个视锥体。输出为在视锥中的点或者三角网格数据。It should be noted that the input of the algorithm is the BVH tree of the root node, a boolean value representing the state of the node, and a view frustum. The output is point or triangular mesh data in the view frustum.
步骤1:如果该节点位于视锥体中,进行下述步骤;Step 1: If the node is in the view frustum, perform the following steps;
步骤2:如果该节点是叶子节点,返回该节点中的模型数据,停止操作;Step 2: If the node is a leaf node, return the model data in the node and stop the operation;
步骤3:对该节点进行分割,分别得到左右节点;Step 3: Divide the node to obtain the left and right nodes respectively;
步骤4:如果该左右节点是叶子节点的话,执行下述步骤;Step 4: If the left and right nodes are leaf nodes, perform the following steps;
步骤5:判断全部在该节点中的渲染数据;Step 5: Determine all the rendering data in the node;
步骤6:如果该数据在视锥中,那么会将该数据添加到结果的队列中;Step 6: If the data is in the frustum, add the data to the resulting queue;
步骤7:对左右节点进行递归的使用步骤1-6操作。Step 7: Recursively use steps 1-6 for the left and right nodes.
在实际查询时使用并行方式加速,查询所用时间与视锥位置和数据分布均有关系。具体分析如下:The parallel mode is used to accelerate the actual query, and the query time is related to the view frustum position and data distribution. The specific analysis is as follows:
(1)当包围盒完全不在视锥内时可以直接返回,复杂度为O(1);(1) When the bounding box is completely outside the view frustum, it can be returned directly, and the complexity is O(1);
(2)当包围盒完全在视锥内时,仅需直接搜索到叶子结点然后返回,复杂度为树高。若模型在三个轴上能均匀分布,则建立的这棵树是一个满树,复杂度为O(logN);(2) When the bounding box is completely within the viewing frustum, it is only necessary to directly search for the leaf node and then return, and the complexity is the tree height. If the model can be evenly distributed on the three axes, the established tree is a full tree with a complexity of O(logN);
(3)当包围盒与视锥相交时,会继续向下递归,若以上述两种情况结束,则复杂度介于O(1)和O(logN)之间;若一直到叶子结点都仍需要遍历,则复杂度为O(N),退化为线性查找。(3) When the bounding box intersects with the view cone, it will continue to recurse downward. If it ends with the above two cases, the complexity is between O(1) and O(logN); if all the leaf nodes are reached If traversal is still required, the complexity is O(N), which degenerates into linear search.
本公开利用三维空间的八叉BVH树解决了当模型分布不均匀时,八叉树计算消耗过多的情况。同时在进行视锥模型资源查找时采用了并行的查找方式,加速了查找的过程,降低了整个***的延迟。The present disclosure utilizes the octree BVH tree in three-dimensional space to solve the situation that the octree calculation consumes too much when the model distribution is not uniform. At the same time, a parallel search method is used in the search of the viewing cone model resources, which speeds up the search process and reduces the delay of the entire system.
以下结合两个可选实施例对上述三维场景数据的渲染方法的流程进行解释说明,但不用于限定本公开实施例的技术方案。The flow of the foregoing three-dimensional scene data rendering method is explained below with reference to two optional embodiments, but is not used to limit the technical solutions of the embodiments of the present disclosure.
1)使用OGRE制作该平台的实例。分别在网格模型和点云模型上进行实验,包括模型的分块、视锥中渲染资源的查询和渲染工作。界面的左上方为六个滑动块,用来控制摄像机的参数,相对应的键盘操作也可以修改这些参数。当这些参数发生变化时,会触发函数进行视锥内数据的重新查询。界面的左下方为自定义的一些参数展示,包括视锥的Aspect、视点位置、每帧渲染事件、经查询后的渲染事件、渲染的图元数量等。这些参数可以供用户交互式 进行观察方式的变换。1) Use OGRE to make an instance of the platform. Experiments were performed on mesh models and point cloud models, including model partitioning, querying and rendering of rendering resources in the view frustum. There are six sliders on the upper left of the interface, which are used to control the parameters of the camera, and the corresponding keyboard operations can also modify these parameters. When these parameters change, the function will be triggered to re-query the data in the view frustum. The bottom left of the interface displays some customized parameters, including the Aspect of the view cone, the position of the viewpoint, the rendering event per frame, the rendering event after query, and the number of rendered primitives, etc. These parameters allow users to interactively change the viewing mode.
2)在模型分块之后,对视锥内三维场景数据进行了渲染,用户可以改变摄像机位置、视野角度、视点位置、远***面等方式进行交互式的场景查看。2) After the model is divided into blocks, the 3D scene data in the viewing cone is rendered, and the user can change the camera position, field of view angle, viewpoint position, and far and near planes to view the scene interactively.
使用了三种查询方法:线性查找、单线程BVH查找、多线程BVH查找。线性查找指遍历模型,依次判断每个点是否存在于视锥中;单线程三维空间BVH树查找方法即为本组提出的查找算法;并行三维空间BVH树查找方式。以下所有实施例都重复进行了3次并取平均,判断三种方式查询速度的快慢,具体如下:Three query methods are used: linear search, single-threaded BVH search, and multi-threaded BVH search. Linear search refers to traversing the model to determine whether each point exists in the viewing frustum in turn; the single-threaded three-dimensional space BVH tree search method is the search algorithm proposed by this group; the parallel three-dimensional space BVH tree search method. All the following examples are repeated 3 times and averaged to judge the speed of the query in the three ways, as follows:
(1)改变摄像机位置,其他参数不变。对摄像机的视野角度、***面、远平面、lookAt等参数都设定固定值,将摄像机的位置从移到(步长为2)进行实验,图6是本公开可选实施例中的移动摄像机位置的视追查询时间变化折线图,结果如图6所示。通过BVH分块,查询时间相比线性查询有了大幅度提高,单线程查询比线性查询时间约提高了82.8%,多线程查询比线性查询时间约提高了89.5%,而且BVH整体查询时间稳定,变化幅度不大。(1) Change the camera position, and other parameters remain unchanged. The camera's field of view angle, near plane, far plane, lookAt and other parameters are all set to fixed values, and the position of the camera is moved from to (with a step size of 2) to conduct experiments. Figure 6 is a moving camera in an optional embodiment of the present disclosure. The line chart of the time change of the position tracking query, the result is shown in Figure 6. Through BVH partitioning, the query time is greatly improved compared with linear query, single-threaded query is about 82.8% higher than linear query time, multi-threaded query is about 89.5% higher than linear query time, and the overall query time of BVH is stable, Not much change.
(2)改变摄像机视野角度,其他参数不变。将摄像机的fovY值从0.15增加到1.5(步长为0.15,即每次约增大8.6°)。由于线性查找时间与BVH查找差距较大,为了更好地展现多线程与单线程的比较,不予展示线性查找时间,此外还增加了柱形图展示查询到的点的个数,图7是本公开可选实施例中的改变视野角度的视锥查询时间变化折线图,如图7所示,单线程查询时间平均是多线程查询的0.59倍,除去创建线程的时间,基本能够实现线性加速比,体现出了并行查找的优势。(2) Change the viewing angle of the camera, and other parameters remain unchanged. Increase the camera's fovY value from 0.15 to 1.5 (0.15 steps, or about 8.6° increments each time). Due to the large gap between linear search time and BVH search, in order to better show the comparison between multi-threading and single-threading, the linear search time is not displayed. In addition, the number of points queried by the bar graph is also increased. Figure 7 is In an optional embodiment of the present disclosure, a line graph of the time change of the viewing cone query by changing the viewing angle, as shown in FIG. 7 , the single-threaded query time is 0.59 times that of the multi-threaded query on average, and the linear acceleration can be basically achieved except the time for creating a thread. ratio, reflecting the advantages of parallel search.
(3)改变摄像机视点位置(lookAt),其他参数不变。图8是本公开可选实施例中的改变视点位置的视锥查询时间变化折线图,如图8所示,整体走势与以前一致,BVH查询时间非常短暂,因此在数据量不是很大的时候,单机渲染时的实时性较高,对帧率影响较小,渲染机每帧切换流畅。(3) Change the camera viewpoint position (lookAt), and other parameters remain unchanged. FIG. 8 is a line chart of the time change of the viewing cone query when the viewpoint position is changed in an optional embodiment of the present disclosure. As shown in FIG. 8 , the overall trend is the same as before, and the BVH query time is very short, so when the amount of data is not large , the real-time performance of stand-alone rendering is high, the impact on the frame rate is small, and the rendering machine switches each frame smoothly.
(4)改变摄像机远平面距离(zFar),其他参数不变。图9是本公开可选实施例中的改变远平面距离的视锥查询时间变化折线图,如图9所示所示,在最开始的情况下,平面较近,没有点在视锥中,这种情况下多线程创建线程耗费的时间相比查询的时间不可忽略,因此在一开始的时候会比单线程耗时稍长一些,但越往后优势会越明显。(4) Change the camera far plane distance (zFar), and other parameters remain unchanged. FIG. 9 is a line chart of the time change of the viewing cone query for changing the distance of the far plane in an optional embodiment of the present disclosure. As shown in FIG. 9 , in the initial case, the plane is relatively close, and no point is in the viewing cone. In this case, the time consumed by multi-threading to create threads is not negligible compared to the time of querying, so it will take a little longer than single-threading at the beginning, but the advantages will become more obvious later.
通过本公开,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;根据建模模型的类型对建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在建模模型对应的层次包围盒树上,其中,预设方式用于指示层次包围盒树的左节点和右节点的数量差小于预设阈值;根据保存在层次包围盒树上的模型块对待渲染的三维场景数据进行渲染,即将分块处理后的模型块保存在建模模型对应的层次包围盒树上,并且保证层次包围盒树的左节点和右节点的数量差小于预设阈值,采用上述技术方案,解决了相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题。Through the present disclosure, the modeling model adopted by the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed. The number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如 ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本公开各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on this understanding, the technical solutions of the present disclosure essentially or the parts that contribute to the prior art can be embodied in the form of software products, and the computer software products are stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) execute the methods described in the various embodiments of the present disclosure.
在本实施例中还提供了一种三维场景数据的渲染装置,该装置设置为实现上述实施例及可选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。This embodiment also provides an apparatus for rendering three-dimensional scene data. The apparatus is configured to implement the above-mentioned embodiments and optional implementations, and what has already been described will not be described again. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
图10是根据本公开实施例的三维场景数据的渲染装置的结构框图,如图10所示,该装置包括:FIG. 10 is a structural block diagram of an apparatus for rendering three-dimensional scene data according to an embodiment of the present disclosure. As shown in FIG. 10 , the apparatus includes:
确定模块1002,设置为确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;The determining module 1002 is configured to determine the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
处理模块1004,设置为根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;The processing module 1004 is configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing at the corresponding level of the modeling model in a preset manner On the bounding box tree, wherein the preset manner is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
渲染模块1006,设置为根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。The rendering module 1006 is configured to render the to-be-rendered three-dimensional scene data according to the model blocks stored in the hierarchical bounding box tree.
通过本公开,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;根据建模模型的类型对建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在建模模型对应的层次包围盒树上,其中,预设方式用于指示层次包围盒树的左节点和右节点的数量差小于预设阈值;根据保存在层次包围盒树上的模型块对待渲染的三维场景数据进行渲染,即将分块处理后的模型块保存在建模模型对应的层次包围盒树上,并且保证层次包围盒树的左节点和右节点的数量差小于预设阈值,采用上述技术方案,解决了相关技术中,在通过层次包围盒树对三维场景数据的模型进行处理时,由于三维场景数据分布不均,导致层次包围盒树节点分布不均,进而造成资源的浪费等问题。Through the present disclosure, the modeling model adopted by the three-dimensional scene data to be rendered is determined, wherein different modeling models are used to indicate the three-dimensional scene data in different display modes; the modeling models are processed in blocks according to the types of the modeling models , and save the model block obtained after the block processing in the hierarchical bounding box tree corresponding to the modeling model according to the preset method, wherein the preset method is used to indicate the difference between the number of left nodes and right nodes of the hierarchical bounding box tree is less than the preset threshold; the 3D scene data to be rendered is rendered according to the model block stored in the hierarchical bounding box tree, that is, the model block after block processing is saved in the hierarchical bounding box tree corresponding to the modeling model, and the hierarchical bounding box tree is guaranteed. The number difference between the left node and the right node of the box tree is less than a preset threshold, and the above technical solution solves the problem of uneven distribution of the three-dimensional scene data in the related art when processing the model of the three-dimensional scene data through the hierarchical bounding box tree. , resulting in uneven distribution of nodes in the hierarchical bounding box tree, resulting in waste of resources and other problems.
需要说明的是,建模模型可以包括点云模型和三角网格模型,但是不限于点云模型和三角网格模型,本公开实施例对此不做限定。It should be noted that the modeling model may include a point cloud model and a triangular mesh model, but is not limited to a point cloud model and a triangular mesh model, which is not limited in the embodiment of the present disclosure.
可选地,处理模块,还设置为根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上的过程中:还需要确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, the processing module is further configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in the modeling model in a preset manner. In the process on the hierarchical bounding box tree corresponding to the model: it is also necessary to determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the splitting axis, and determine according to the splitting axis The dividing point of the bounding box; according to the dividing point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
也就是说,确定当前建模模型中存在的模型块,以及当前模型块对应的包围盒,寻找和选定包围盒中的最长的一根轴作为分割轴,根据分割轴中所有点的中位数确定所述包围盒的分割点,并根据分割点确定包围盒中的所有模型块保存在层次包围盒树的左节点或右节点。That is to say, determine the model nugget existing in the current modeling model and the bounding box corresponding to the current model nugget, find and select the longest axis in the bounding box as the splitting axis, according to the center of all points in the splitting axis The number of bits determines the dividing point of the bounding box, and according to the dividing point, all model blocks in the bounding box are determined to be stored in the left node or the right node of the hierarchical bounding box tree.
在一个示例性实施例中,处理模块,还设置为根据所述分割点确定所述当前模型块保存在所述层次包围盒树的目标节点,将坐标值大于所述分割点的第一模型块划分到左节点和右节点中的一个节点中;将坐标值小于所述分割点的第二模型块划分到左节点和右节点中的另一个节点中。In an exemplary embodiment, the processing module is further configured to determine the target node of the current model block stored in the hierarchical bounding box tree according to the split point, and set the first model block whose coordinate value is greater than that of the split point Divide into one of the left node and the right node; divide the second model block whose coordinate value is smaller than the dividing point into the other node of the left node and the right node.
也就是说,通过对分割点的坐标值和模型块的坐标值进行比较,将模型块的坐标值大于分割点的坐标值的模型块作为第一模型块,将模型块的坐标值小于分割点的坐标值的模型块作为第二模型块,将第一模型块和第二模型块分别划分在左节点和右节点两个不同的节点中。That is to say, by comparing the coordinate value of the split point with the coordinate value of the model block, the model block whose coordinate value is greater than the coordinate value of the split point is used as the first model block, and the coordinate value of the model block is smaller than the split point. The model nugget of the coordinate value of is used as the second model nugget, and the first model nugget and the second model nugget are divided into two different nodes, the left node and the right node, respectively.
可选地,因为三维场景的数据很大,处理模块需要循环执行以下步骤,直至所述分块处理后所得到的所有模型块按照预设方式保存在所述建模模型对应的层次包围盒树上:确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割周确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Optionally, because the data of the three-dimensional scene is very large, the processing module needs to perform the following steps cyclically until all the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner. Above: determine the bounding box of the current model block in the modeling model; take the longest axis in the bounding box as the dividing axis, and determine the dividing point of the bounding box according to the dividing circle; according to the dividing The point determines that all model blocks in the bounding box are stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
由于三维场景数据过大,执行一次上述步骤并不能完成根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,在模型块小于预定阈值的情况下,结束划分,完成对三维场景数据的分块处理。Since the 3D scene data is too large, executing the above steps once cannot complete the block processing of the modeling model according to the type of the modeling model, and the model blocks obtained after the block processing are stored in a preset manner in a preset manner. On the hierarchical bounding box tree corresponding to the modeling model, when the model block is smaller than the predetermined threshold, the division is ended, and the block processing of the three-dimensional scene data is completed.
可选地,处理模块,设置为在所述建模模型为三角网格模型,且所述当前模型块为三角面片的情况下,如果当前三角面片位于所述分割轴的边缘,则将所述当前三角面片按照随机方式保存在所述目标节点。Optionally, the processing module is configured to, when the modeling model is a triangular mesh model and the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, then The current triangular patch is stored in the target node in a random manner.
确定待渲染的三维场景数据所采用的建模模型为三角网格模型时,由于三角网格模型的内部图元为三角面片,所以在进行分割时,需要考虑如果三角面片处于分割轴的边缘的情况。在三角面片处于分割轴的边缘时,同一三角面片的部分模型块属于左节点,部分模型块属于右节点,此时,将该三角面片随机保存在左节点或者右节点中,这样保证了包围盒内部的三角形面片层次上不会发生资源的冲突,更有利于查询操作。When it is determined that the modeling model used for the 3D scene data to be rendered is a triangular mesh model, since the internal primitives of the triangular mesh model are triangular patches, when dividing, it is necessary to consider if the triangular patches are in the division axis. edge cases. When the triangular patch is at the edge of the dividing axis, some model blocks of the same triangular patch belong to the left node, and some model blocks belong to the right node. At this time, the triangular patch is randomly stored in the left node or the right node, so as to ensure There is no resource conflict at the triangle patch level inside the bounding box, which is more conducive to query operations.
可选地,渲染模块,还设置为根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染,采用并行查找的方式从所述层次包围盒树上获取待渲染的模型块;根据获取的待渲染的模型块对所述待渲染的三维场景数据进行渲染。Optionally, the rendering module is further configured to render the three-dimensional scene data to be rendered according to the model blocks stored on the hierarchical bounding box tree, and obtain the to-be-rendered scene data from the hierarchical bounding box tree in a parallel search manner. The rendered model block; the three-dimensional scene data to be rendered is rendered according to the obtained model block to be rendered.
在对三维场景数据进行渲染时,采用并行查找的方式,获取层次包围盒树上待渲染的模型块,进而对待渲染的三维场景数据进行渲染,采用并行查找的方式加速了查找的过程,降低了***的延迟。When rendering the 3D scene data, the method of parallel search is used to obtain the model blocks to be rendered on the hierarchical bounding box tree, and then the 3D scene data to be rendered is rendered. The parallel search method is used to speed up the search process and reduce the system delay.
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。It should be noted that the above modules can be implemented by software or hardware, and the latter can be implemented in the following ways, but not limited to this: the above modules are all located in the same processor; or, the above modules can be combined in any combination The forms are located in different processors.
本公开的实施例还提供了一种存储介质,该存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。An embodiment of the present disclosure further provides a storage medium, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:Optionally, in this embodiment, the above-mentioned storage medium may be configured to store a computer program for executing the following steps:
S1,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;S1, determining the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
S2,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;S2, performing block processing on the modeling model according to the type of the modeling model, and saving the model blocks obtained after the block processing on the hierarchical bounding box tree corresponding to the modeling model in a preset manner , wherein the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
S3,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。S3: Render the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), Various media that can store computer programs, such as removable hard disks, magnetic disks, or optical disks.
本公开的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。An embodiment of the present disclosure also provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。Optionally, the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:Optionally, in this embodiment, the above-mentioned processor may be configured to execute the following steps through a computer program:
S1,确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;S1, determining the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
S2,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;S2, performing block processing on the modeling model according to the type of the modeling model, and saving the model blocks obtained after the block processing on the hierarchical bounding box tree corresponding to the modeling model in a preset manner , wherein the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
S3,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。S3: Render the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), Various media that can store program codes, such as removable hard disks, magnetic disks, or optical disks.
可选地,本实施例中的具体示例可以参考上述实施例及可选实施方式中所描述的示例,本实施例在此不再赘述。Optionally, for specific examples in this embodiment, reference may be made to the examples described in the foregoing embodiments and optional implementation manners, and details are not described herein again in this embodiment.
显然,本领域的技术人员应该明白,上述的本公开的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本公开不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present disclosure can be implemented by a general-purpose computing device, and they can be centralized on a single computing device or distributed in a network composed of multiple computing devices Alternatively, they may be implemented in program code executable by a computing device, such that they may be stored in a storage device and executed by the computing device, and in some cases, in a different order than here The steps shown or described are performed either by fabricating them separately into individual integrated circuit modules, or by fabricating multiple modules or steps of them into a single integrated circuit module. As such, the present disclosure is not limited to any particular combination of hardware and software.
以上所述仅为本公开的可选实施例而已,并不用于限制本公开,对于本领域的技术人员来说,本公开可以有各种更改和变化。凡在本公开的原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。The above descriptions are only optional embodiments of the present disclosure, and are not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the principles of the present disclosure shall be included within the protection scope of the present disclosure.

Claims (10)

  1. 一种三维场景数据的渲染方法,包括:A rendering method for three-dimensional scene data, comprising:
    确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;determining the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
    根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;The modeling model is processed into blocks according to the type of the modeling model, and the model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner, wherein , the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
    根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。The to-be-rendered three-dimensional scene data is rendered according to the model block stored on the hierarchical bounding box tree.
  2. 根据权利要求1所述的方法,其中,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上的过程中:The method according to claim 1, wherein the modeling model is subjected to block processing according to the type of the modeling model, and the model blocks obtained after the block processing are stored in the model according to a preset method. During the process on the hierarchical bounding box tree corresponding to the modulo model:
    确定所述建模模型中的当前模型块的包围盒;determining the bounding box of the current model nugget in the modeling model;
    将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;Taking the longest axis in the bounding box as the dividing axis, and determining the dividing point of the bounding box according to the dividing axis;
    根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。All model blocks in the bounding box are determined according to the dividing point and stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  3. 根据权利要求2所述的方法,其中,根据所述分割点确定所述当前模型块保存在所述层次包围盒树的目标节点,包括:The method according to claim 2, wherein determining the target node of the current model nugget to be stored in the hierarchical bounding box tree according to the dividing point comprises:
    将坐标值大于所述分割点的第一模型块划分到左节点和右节点中的一个节点中;dividing the first model block whose coordinate value is greater than the dividing point into one of the left node and the right node;
    将坐标值小于所述分割点的第二模型块划分到左节点和右节点中的另一个节点中。The second model nugget whose coordinate value is smaller than the dividing point is divided into another node among the left node and the right node.
  4. 根据权利要求2所述的方法,其中,根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,包括:The method according to claim 2, wherein the modeling model is subjected to block processing according to the type of the modeling model, and the model blocks obtained after the block processing are stored in the model according to a preset method. On the hierarchical bounding box tree corresponding to the modular model, including:
    循环执行以下步骤,直至所述分块处理后所得到的所有模型块按照预设方式保存在所述建模模型对应的层次包围盒树上:确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割周确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。Execute the following steps cyclically until all model blocks obtained after the block processing are stored in the hierarchical bounding box tree corresponding to the modeling model in a preset manner: determine the bounding box of the current model block in the modeling model box; take the longest axis in the bounding box as the dividing axis, and determine the dividing point of the bounding box according to the dividing circle; determine all model blocks in the bounding box according to the dividing point and save them in the The target node of the hierarchical bounding box tree, wherein the target node includes: the left node or the right node.
  5. 根据权利要求2所述的方法,其中,根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点之前,所述方法还包括:The method according to claim 2, wherein it is determined that all model blocks in the bounding box are stored before the target node of the hierarchical bounding box tree according to the dividing point, and the method further comprises:
    在所述建模模型为三角网格模型,且所述当前模型块为三角面片的情况下,如果当前三角面片位于所述分割轴的边缘,则将所述当前三角面片按照随机方式保存在所述目标节点。When the modeling model is a triangular mesh model and the current model block is a triangular patch, if the current triangular patch is located at the edge of the dividing axis, the current triangular patch is randomly selected. saved in the target node.
  6. 根据权利要求1所述的方法,其中,根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染,包括:The method according to claim 1, wherein the rendering of the three-dimensional scene data to be rendered according to the model blocks stored on the hierarchical bounding box tree comprises:
    采用并行查找的方式从所述层次包围盒树上获取待渲染的模型块;Obtain the model block to be rendered from the hierarchical bounding box tree by means of parallel search;
    根据获取的待渲染的模型块对所述待渲染的三维场景数据进行渲染。The three-dimensional scene data to be rendered is rendered according to the acquired model block to be rendered.
  7. 一种三维场景数据的渲染装置,包括:A rendering device for three-dimensional scene data, comprising:
    确定模块,设置为确定待渲染的三维场景数据所采用的建模模型,其中,不同的建模模型用于指示不同显示方式的三维场景数据;a determining module, configured to determine the modeling model used by the three-dimensional scene data to be rendered, wherein different modeling models are used to indicate the three-dimensional scene data of different display modes;
    处理模块,设置为根据所述建模模型的类型对所述建模模型进行分块处理,并将分块处理后所得到的模型块按照预设方式保存在所述建模模型对应的层次包围盒树上,其中,所述预设方式用于指示所述层次包围盒树的左节点和右节点的数量差小于预设阈值;A processing module, configured to perform block processing on the modeling model according to the type of the modeling model, and save the model blocks obtained after the block processing in a preset manner in the corresponding hierarchical enclosure of the modeling model On a box tree, wherein the preset mode is used to indicate that the difference in the number of left nodes and right nodes of the hierarchical bounding box tree is less than a preset threshold;
    渲染模块,设置为根据保存在所述层次包围盒树上的模型块对所述待渲染的三维场景数据进行渲染。The rendering module is configured to render the three-dimensional scene data to be rendered according to the model blocks stored in the hierarchical bounding box tree.
  8. 根据权利要求7所述的装置,其中,所述处理模块,还设置为确定所述建模模型中的当前模型块的包围盒;将所述包围盒中的最长轴作为分割轴,并根据所述分割轴确定所述包围盒的分割点;根据所述分割点确定所述包围盒中的所有模型块保存在所述层次包围盒树的目标节点,其中,所述目标节点包括:所述左节点或所述右节点。The device according to claim 7, wherein the processing module is further configured to determine the bounding box of the current model nugget in the modeling model; take the longest axis in the bounding box as the dividing axis, and determine the bounding box of the current model block in the modeling model; The dividing axis determines the dividing point of the bounding box; according to the dividing point, all model blocks in the bounding box are determined to be stored in the target node of the hierarchical bounding box tree, wherein the target node includes: the the left node or the right node.
  9. 一种计算机可读的存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行所述权利要求1至6任一项中所述的方法。A computer-readable storage medium in which a computer program is stored, wherein the computer program is configured to execute the method of any one of claims 1 to 6 when run.
  10. 一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行所述权利要求1至6任一项中所述的方法。An electronic device comprising a memory and a processor with a computer program stored in the memory, the processor being arranged to run the computer program to perform the method of any one of claims 1 to 6.
PCT/CN2021/125315 2020-12-11 2021-10-21 Method and device for rendering three-dimensional scene data, storage medium, and electronic device WO2022121525A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011453443.8 2020-12-11
CN202011453443.8A CN114627219A (en) 2020-12-11 2020-12-11 Rendering method and device of three-dimensional scene data, storage medium and electronic device

Publications (1)

Publication Number Publication Date
WO2022121525A1 true WO2022121525A1 (en) 2022-06-16

Family

ID=81896120

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/125315 WO2022121525A1 (en) 2020-12-11 2021-10-21 Method and device for rendering three-dimensional scene data, storage medium, and electronic device

Country Status (2)

Country Link
CN (1) CN114627219A (en)
WO (1) WO2022121525A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115578538A (en) * 2022-10-17 2023-01-06 北京世冠金洋科技发展有限公司 Three-dimensional scene generation method and device, electronic equipment and storage medium
CN116049924A (en) * 2023-03-07 2023-05-02 武汉益模科技股份有限公司 Three-dimensional part difference analysis algorithm based on Cuda
CN116258840A (en) * 2023-05-16 2023-06-13 深圳大学 Hierarchical detail representation tree generation method, device, equipment and storage medium
CN116570925A (en) * 2023-05-19 2023-08-11 韶关学院 Resource management method based on AR development
CN116721187A (en) * 2023-06-15 2023-09-08 广州极尚网络技术有限公司 Animation dynamic loading and unloading method, device, equipment and medium based on scene cutting
CN117953181A (en) * 2024-03-27 2024-04-30 江苏狄诺尼信息技术有限责任公司 Vertex layering and incremental LOD method and system for WEB3D

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117635787A (en) * 2022-08-11 2024-03-01 华为云计算技术有限公司 Image rendering method, device and equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160292908A1 (en) * 2015-04-02 2016-10-06 Qualcomm Incorporated Efficient hierarchy traversal in ray tracing applications
CN106096082A (en) * 2016-05-24 2016-11-09 国网安徽省电力公司宿州供电公司 A kind of based on deblocking and the collision checking method of parallel processing
CN106776028A (en) * 2016-12-21 2017-05-31 东北大学 A kind of ray tracing method based on GPU
CN106875492A (en) * 2017-02-13 2017-06-20 华东师范大学 It is a kind of towards GPU bounding box collision checking methods
CN107689078A (en) * 2017-08-21 2018-02-13 哈尔滨工程大学 A kind of bounding volume hierarchy (BVH) tree constructing method based on chain list sorting balanced binary tree

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160292908A1 (en) * 2015-04-02 2016-10-06 Qualcomm Incorporated Efficient hierarchy traversal in ray tracing applications
CN106096082A (en) * 2016-05-24 2016-11-09 国网安徽省电力公司宿州供电公司 A kind of based on deblocking and the collision checking method of parallel processing
CN106776028A (en) * 2016-12-21 2017-05-31 东北大学 A kind of ray tracing method based on GPU
CN106875492A (en) * 2017-02-13 2017-06-20 华东师范大学 It is a kind of towards GPU bounding box collision checking methods
CN107689078A (en) * 2017-08-21 2018-02-13 哈尔滨工程大学 A kind of bounding volume hierarchy (BVH) tree constructing method based on chain list sorting balanced binary tree

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115578538A (en) * 2022-10-17 2023-01-06 北京世冠金洋科技发展有限公司 Three-dimensional scene generation method and device, electronic equipment and storage medium
CN116049924A (en) * 2023-03-07 2023-05-02 武汉益模科技股份有限公司 Three-dimensional part difference analysis algorithm based on Cuda
CN116258840A (en) * 2023-05-16 2023-06-13 深圳大学 Hierarchical detail representation tree generation method, device, equipment and storage medium
CN116258840B (en) * 2023-05-16 2023-08-11 深圳大学 Hierarchical detail representation tree generation method, device, equipment and storage medium
CN116570925A (en) * 2023-05-19 2023-08-11 韶关学院 Resource management method based on AR development
CN116721187A (en) * 2023-06-15 2023-09-08 广州极尚网络技术有限公司 Animation dynamic loading and unloading method, device, equipment and medium based on scene cutting
CN116721187B (en) * 2023-06-15 2024-01-30 广州极尚网络技术有限公司 Animation dynamic loading and unloading method, device, equipment and medium based on scene cutting
CN117953181A (en) * 2024-03-27 2024-04-30 江苏狄诺尼信息技术有限责任公司 Vertex layering and incremental LOD method and system for WEB3D

Also Published As

Publication number Publication date
CN114627219A (en) 2022-06-14

Similar Documents

Publication Publication Date Title
WO2022121525A1 (en) Method and device for rendering three-dimensional scene data, storage medium, and electronic device
CN108133044B (en) Spatial big data three-dimensional visualization method and platform based on attribute separation
CN102682103B (en) Three-dimensional space index method aiming at massive laser radar point cloud models
CN112347546A (en) BIM rendering method, device and computer-readable storage medium based on lightweight device
US7002571B2 (en) Grid-based loose octree for spatial partitioning
US7561156B2 (en) Adaptive quadtree-based scalable surface rendering
Ernst et al. Early split clipping for bounding volume hierarchies
CN113178014A (en) Scene model rendering method and device, electronic equipment and storage medium
CN109118588B (en) Automatic color LOD model generation method based on block decomposition
CN101119485A (en) Characteristic reservation based three-dimensional model progressive transmission method
CN115661374B (en) Rapid retrieval method based on space division and model voxelization
WO2023169095A1 (en) Data processing method and apparatus, device, and medium
CN113868476A (en) Octree point cloud preprocessing method based on local density
CN113094463A (en) Unstructured point cloud storage method, device, equipment and medium
CN112200906B (en) Entity extraction method and system for inclined three-dimensional model
CN116310060B (en) Method, device, equipment and storage medium for rendering data
EP4302847A1 (en) Object management method, apparatus and system, and device and storage medium
Hu et al. Parallel BVH construction using locally density clustering
Guérin et al. Efficient modeling of entangled details for natural scenes
CN112712581B (en) Ray tracing acceleration method
CN111275806A (en) Parallelization real-time rendering system and method based on points
Yin et al. Fast BVH construction and refit for ray tracing of dynamic scenes
CN109147032B (en) Distributed large-scale grid optimizing method
Yang et al. Dynamic Load Balancing Algorithm Based on Per-pixel Rendering Cost Estimation for Parallel Ray Tracing on PC Clusters
Ma et al. Research and application of personalized human body simplification and fusion method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21902232

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21902232

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.11.2023)