A block loading method and terminal for 3D scenes

The placeholder and resource prefabricated body are generated through the clustering algorithm and the AP neighbor propagation clustering algorithm, which solves the problems of complex resource management and unreasonable segmentation in 3D scene block loading, and achieves more efficient resource management and loading speed.

CN114788954BActive Publication Date: 2025-08-22FUJIAN TIANYI WEBSOFT TECH LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110100635.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-26
Publication Date
2025-08-22
Estimated Expiration
2041-01-26

AI Technical Summary

Technical Problem

The existing 3D scene chunking loading methods have complex resource management, unreasonable segmentation of scene elements, and possible misleading problems, resulting in excessive system resource consumption and slow loading speed.

Method used

The clustering algorithm is used to block the 3D scene, generate the placeholder and resource prefabricated body, dynamically load and unload according to the camera's field of view, avoid scene elements segmentation and trade-offs, and use the AP nearest neighbor propagation clustering algorithm for resource management.

Benefits of technology

It realizes simplified and reasonable blocking of resource management, avoids misleading problems during element unloading, and improves loading speed and resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114788954B_ABST
    Figure CN114788954B_ABST
Patent Text Reader

Abstract

The present invention discloses a block loading method and terminal for a 3D scene. The present invention traverses all model elements in the scene and takes the model elements whose element bounding box sizes exceed a preset maximum block size as separate blocks. A clustering algorithm is used to cluster all the remaining model elements, and blocks are generated by dividing them according to the clustering results. A corresponding placeholder and a resource prefab corresponding to the placeholder are generated for each block, and the model elements in the scene are removed, leaving only the placeholder. The resource prefab of the placeholder is loaded and unloaded according to the camera field of view. The present invention dynamically classifies and blocks scene resources according to size through a clustering algorithm, and does not require segmentation and selection of scene elements, thereby avoiding the problem of possible exposure when elements are unloaded, which is more reasonable. In addition, no segmentation is required for large scene elements, and resource management is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a block loading method and terminal for a 3D scene. Background Art

[0002] As competition in the gaming industry becomes increasingly fierce, the visual performance requirements for games are becoming increasingly demanding, and the design of game scenes is becoming increasingly rich. However, operating systems have a limit on the maximum memory capacity of each app. Loading a complete scene will inevitably lead to excessive consumption of system resources, resulting in slow loading speeds, game lags, and even crashes. Therefore, game scenes must be processed in blocks, with each block having relatively small resources. This allows scene elements to be loaded on demand, improving game loading speeds and reducing resource consumption.

[0003] Traditional scene segmentation schemes typically divide the entire scene into evenly spaced M*N blocks. After the game starts, the character's grid is used as the center, and the surrounding 8 grids are loaded. As the field of view moves, the 8 unloaded grids around the newly entered grid are loaded, and the resources in all but 9 grids are unloaded, so that the scene is always segmented and dynamically loaded in a nine-grid manner.

[0004] This approach has the following drawbacks:

[0005] 1. For scene elements between two blocks, it is necessary to make a division and choose which block they belong to; when the block containing the element is unloaded, there may be problems with the appearance of the scene, which is not reasonable.

[0006] 2. For large scene elements that can span multiple blocks (such as mountains, etc.), they are usually cut into multiple blocks, which increases the complexity of resource management. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a block loading method and terminal for a 3D scene, which improves the simplicity of resource management and makes the block division of the scene more reasonable.

[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0009] A block loading method for a 3D scene, comprising:

[0010] S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks;

[0011] S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results;

[0012] S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder;

[0013] S4. Load and unload the resource prefab of the placeholder according to the camera field of view.

[0014] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0015] A terminal for loading blocks of 3D scenes includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0016] S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks;

[0017] S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results;

[0018] S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder;

[0019] S4. Load and unload the resource prefab of the placeholder according to the camera field of view.

[0020] The beneficial effects of the present invention are as follows: the present invention dynamically classifies and blocks scene resources according to size through clustering calculation, and does not need to split or select scene elements, thus avoiding the problem of possible exposure when elements are unloaded, which is more reasonable; and large scene elements do not need to be split, which facilitates resource management. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a flowchart of a block loading method for a 3D scene according to an embodiment of the present invention;

[0022] Figure 2 This is a structural diagram of a terminal for loading blocks of a 3D scene according to an embodiment of the present invention;

[0023] Figure 3 A flowchart of the block-by-block steps of a method for loading a 3D scene in blocks according to an embodiment of the present invention;

[0024] Figure 4 A flowchart of loading steps of a block loading method for a 3D scene according to an embodiment of the present invention;

[0025] Figure 5 This is a first actual display diagram of a block loading method for a 3D scene according to an embodiment of the present invention;

[0026] Figure 6 This is a second actual display diagram of a block loading method for a 3D scene according to an embodiment of the present invention;

[0027] Description of labels:

[0028] 1. A block loading terminal for a 3D scene; 2. A processor; 3. A memory. DETAILED DESCRIPTION

[0029] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.

[0030] Please refer to Figure 1 、 Figure 3 and Figure 4 , a block loading method for a 3D scene, comprising:

[0031] S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks;

[0032] S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results;

[0033] S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder;

[0034] S4. Load and unload the resource prefab of the placeholder according to the camera field of view.

[0035] From the above description, it can be seen that the beneficial effects of the present invention are: the present invention dynamically classifies and blocks scene resources according to size through clustering calculation, and does not need to split and select scene elements, avoiding the problem of possible exposure when elements are unloaded, which is more reasonable; and there is no need to split large scene elements, and it is convenient to manage resources.

[0036] Furthermore, the clustering algorithm is an AP nearest neighbor propagation clustering algorithm.

[0037] From the above description, it can be seen that the present invention uses the AP clustering algorithm. The results of the scene segmentation by the AP clustering algorithm are stable, that is, the results of each clustering are consistent. This is of great benefit for the modification of scene resources, program performance optimization, and bug location. When it is found that a certain scene has a large resource in a certain block, resulting in frame drops during loading, it can be optimized by optimizing the layout of scene elements, etc., and then the block can be re-divided to verify whether the problem is solved, and it will not be unable to reproduce due to the instability of the block algorithm.

[0038] Furthermore, the step S3 is specifically as follows:

[0039] S31, calculating the center point and bounding box of each block as attributes of the block, and creating a placeholder with a size of the bounding box at the center point of each block in the scene;

[0040] S32: Create an empty object with the same name as each placeholder as a child node of the placeholder, and place the model element of the block corresponding to the placeholder into the child node;

[0041] S33: Export the child nodes of each placeholder to a project-specified directory as resource prefabs with the same name, and unload all the model elements in the scene and the child nodes under the placeholders.

[0042] As can be seen from the above description, the present invention sets a placeholder at the position of each block and creates a corresponding resource prefab, which makes it easier to load the scene and determine the position, collision, etc.

[0043] Furthermore, the step S4 is specifically as follows:

[0044] Determine whether the block enters the camera field of view of the character; if so, determine whether the resource prefab of the block has been loaded; if so, change the resource prefab from a hidden state to a visible state before displaying it; if the resource prefab of the block has not been loaded, automatically load the resource prefab with the same name as the placeholder of the block, add the resource prefab to the center point of the block, set it to a visible state, and then display it;

[0045] When the block is not within the camera's field of view, the resource prefab of the block is set to a hidden state and added to a resource recycling list. The resource recycling list is checked regularly. When the distance between the resource prefab in the resource recycling list and the character exceeds a preset threshold, the resource prefab is destroyed.

[0046] From the above description, it can be seen that the present invention does not directly destroy the environmental resources when the scene resources leave the character's field of vision, but hides them and puts them into the resource recycling list. When they need to be displayed again, there is no need to reload the environmental resources, which reduces the use of video memory. The scene resources are only destroyed when the distance between the character and the scene resources exceeds the preset distance.

[0047] Furthermore, the determination of whether the block enters the camera field of view of the character is specifically as follows:

[0048] It is determined whether the bounding box of the block intersects with the viewing cone of the camera. If the bounding box of the block intersects with the viewing cone, the block enters the camera field of view; otherwise, the block is not in the camera field of view.

[0049] From the above description, it can be seen that the present invention determines whether a character is in view by whether the bounding box of the block intersects with the camera's viewing cone, making the judgment more objective and direct.

[0050] Please refer to Figure 1 、 Figure 3 and Figure 4 , embodiment 1 of the present invention is:

[0051] A block loading method for a 3D scene, comprising:

[0052] S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks;

[0053] S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results;

[0054] The clustering algorithm is an AP nearest neighbor propagation clustering algorithm;

[0055] In this embodiment, taking the Unity3D game engine as an example, the model elements whose element bounding box size exceeds the preset maximum block size are separately treated as blocks, and the remaining model elements use the AP neighbor propagation clustering algorithm (AffinityPropagation) to cluster the scene resources and converge the blocks. The final block result reference format is: {Model 1: [Model a, Model b, Model c], Model 2: [Model aa, Model bb, Model cc], ...}, which means that Model 1 is the center and the three models of Model a, Model b, and Model c are aggregated.

[0056] The core of the AP proximity propagation clustering algorithm lies in the similarity algorithm. In this solution, the similarity algorithm is the negative Euclidean distance and the size of their bounding boxes. The closer the distance, the higher the similarity. When the combined bounding box of two objects exceeds the maximum bounding box, the similarity tends to a large negative number.

[0057] S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder;

[0058] In this embodiment, if Figure 3 As shown, the step S3 is specifically as follows:

[0059] S31, calculating the center point and bounding box of each block as attributes of the block, and creating a placeholder with a size of the bounding box at the center point of each block in the scene;

[0060] S32: Create an empty object with the same name as each placeholder as a child node of the placeholder, and place the model element of the block corresponding to the placeholder into the child node;

[0061] S33: Export the child nodes of each placeholder to a project-specified directory as resource prefabs with the same name, and unload all the model elements in the scene and the child nodes under the placeholders.

[0062] In this embodiment, the center point and bounding box of each block are calculated as follows: for block 1 composed of "model 1: [model a, model b, model c]", the center point and bounding box generated by the four models, model 1, model a, model b, and model c, are calculated as the attributes of block 1.

[0063] According to the attribute data of each block, a Cube placeholder object is created in the scene, the useless component MeshRenderer is removed, and the position is set to the center point of the block and the size (Scale) is set to the bounding box of the block. The Cube placeholder object is used as a substitute for the block during scene loading.

[0064] like Figure 5 As shown, based on the Cube placeholder object created in the previous step, create an empty object in each child node of the Cube placeholder, and name the Cube placeholder object and the empty object with the same name, such as Figure 5"SceneName_Model_1" and "SceneName_Model_2" are shown on the right, and then the resource models in each block are placed in the empty object. For example, "Model 1, Model a, Model b, Model c" are set as child nodes of SceneName_Model_1, and "Model 2, Model aa, Model bb, Model cc" are set as child nodes of SceneName_Model_2.

[0065] like Figure 6 As shown, all sub-objects under the Cube placeholder are exported as resource prefabs with the same name, such as "SceneName_Model_1" and "SceneName_Model_2". They are exported as resource prefabs to the specified directory of the project, and all sub-objects under the Cube placeholder in the scene are deleted, leaving only the initial root node (that is, the Cube placeholder).

[0066] S4, loading and unloading the resource prefab of the placeholder according to the camera field of view;

[0067] In this embodiment, if Figure 4 As shown, the step S4 is specifically as follows:

[0068] Determine whether the block enters the camera field of view of the character; if so, determine whether the resource prefab of the block has been loaded; if so, change the resource prefab from a hidden state to a visible state before displaying it; if the resource prefab of the block has not been loaded, automatically load the resource prefab with the same name as the placeholder of the block, add the resource prefab to the center point of the block, set it to a visible state, and then display it;

[0069] When the block is not within the camera's field of view, the resource prefab of the block is set to a hidden state and added to a resource recycling list. The resource recycling list is checked regularly. When the distance between the resource prefab in the resource recycling list and the character exceeds a preset threshold, the resource prefab is destroyed.

[0070] The method of determining whether the block enters the camera field of view of the character is as follows:

[0071] It is determined whether the bounding box of the block intersects with the viewing cone of the camera. If the bounding box of the block intersects with the viewing cone, the block enters the camera field of view; otherwise, the block is not in the camera field of view.

[0072] In this embodiment, when a block enters the camera's field of view, the corresponding prefab resource is automatically loaded according to the name of the block placeholder, including setting the hidden resource to the visible state and loading the resource prefab from the project directory. After loading, it is added to the center point of the corresponding block for display;

[0073] When a block is out of view, the resource is unloaded, which includes hiding and destroying it. When a block goes from being in view to being out of view, the block's resources are hidden and added to the resource recycling list. The resource unloading module regularly checks the resource recycling list, but destroys the resource when the distance between the resource and the character exceeds a threshold.

[0074] In this embodiment, the judgment of whether it is within the field of view is achieved by judging whether the bounding box of the block intersects with the camera's viewing cone. In other equivalent embodiments, the field of view judgment method provided by the game engine can also be used.

[0075] In addition, this embodiment presets a preloaded field of view, which is larger than the actual visible field of view. When a block enters the preloaded field of view, resources are loaded, and when it enters the real field of view, it is displayed immediately, which can increase the smoothness of resource display.

[0076] Please refer to Figure 2 , the second embodiment of the present invention is:

[0077] A terminal 1 for loading blocks of 3D scenes includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, the steps of the above embodiment are implemented.

[0078] In summary, the present invention provides a block loading method and terminal for 3D scenes, which dynamically classify and block scene resources according to size through clustering calculation, and do not need to split and select scene elements, avoiding the problem of possible exposure when elements are unloaded, which is more reasonable; and no segmentation is required for large scene elements, and it is convenient to manage resources; the neighbor propagation clustering algorithm is used, and when segmenting the 3D scene, the size of the scene and the number of model elements do not matter, only the size of the blocks to be segmented need to be paid attention to, and the AP clustering algorithm has stable results for scene segmentation, and the results of each clustering are consistent, which is of great benefit for modifying scene resources, optimizing program performance, and locating bugs.

[0079] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's description and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A block loading method for a 3D scene, characterized in that: include: S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks; S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results; S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder; Step S3 is specifically as follows: S31, calculating the center point and bounding box of each block as attributes of the block, and creating a placeholder with a size of the bounding box at the center point of each block in the scene; S32: Create an empty object with the same name as each placeholder as a child node of the placeholder, and place the model element of the block corresponding to the placeholder into the child node; S33, exporting the child nodes of each placeholder to a project-specified directory as resource prefabs with the same name, and unloading all the model elements in the scene and the child nodes under the placeholders; S4. Load and unload the resource prefab of the placeholder according to the camera field of view.

2. The block loading method of a 3D scene according to claim 1, characterized in that: The clustering algorithm is an AP nearest neighbor propagation clustering algorithm.

3. The block loading method of a 3D scene according to claim 1, characterized in that: The step S4 is specifically as follows: Determine whether the block enters the camera field of view of the character; if so, determine whether the resource prefab of the block has been loaded; if so, change the resource prefab from a hidden state to a visible state before displaying it; if the resource prefab of the block has not been loaded, automatically load the resource prefab with the same name as the placeholder of the block, add the resource prefab to the center point of the block, set it to a visible state, and then display it; When the block is not within the camera's field of view, the resource prefab of the block is set to a hidden state and added to a resource recycling list. The resource recycling list is checked regularly. When the distance between the resource prefab in the resource recycling list and the character exceeds a preset threshold, the resource prefab is destroyed.

4. The block loading method of a 3D scene according to claim 3, characterized in that: The determination of whether the block enters the camera field of view of the character is specifically as follows: It is determined whether the bounding box of the block intersects with the viewing cone of the camera. If the bounding box of the block intersects with the viewing cone, the block enters the camera field of view; otherwise, the block is not in the camera field of view.

5. A terminal for loading blocks of 3D scenes, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Traverse all model elements in the scene and take the model elements whose bounding box size exceeds the preset maximum block size as separate blocks; S2. Clustering all the remaining model elements using a clustering algorithm, and dividing them into blocks according to the clustering results; S3. Generate a corresponding placeholder and a resource prefab corresponding to the placeholder for each block, and remove the model elements in the scene, leaving only the placeholder; Step S3 is specifically as follows: S31, calculating the center point and bounding box of each block as attributes of the block, and creating a placeholder with a size of the bounding box at the center point of each block in the scene; S32: Create an empty object with the same name as each placeholder as a child node of the placeholder, and place the model element of the block corresponding to the placeholder into the child node; S33, exporting the child nodes of each placeholder to a project-specified directory as resource prefabs with the same name, and unloading all the model elements in the scene and the child nodes under the placeholders; S4. Load and unload the resource prefab of the placeholder according to the camera field of view.

6. The terminal for loading blocks of a 3D scene according to claim 5, characterized in that: The clustering algorithm is an AP nearest neighbor propagation clustering algorithm.

7. The terminal for loading blocks of 3D scenes according to claim 5, characterized in that: The step S4 is specifically as follows: Determine whether the block enters the camera field of view of the character; if so, determine whether the resource prefab of the block has been loaded; if so, change the resource prefab from a hidden state to a visible state before displaying it; if the resource prefab of the block has not been loaded, automatically load the resource prefab with the same name as the placeholder of the block, add the resource prefab to the center point of the block, set it to a visible state, and then display it; When the block is not within the camera's field of view, the resource prefab of the block is set to a hidden state and added to a resource recycling list. The resource recycling list is checked regularly. When the distance between the resource prefab in the resource recycling list and the character exceeds a preset threshold, the resource prefab is destroyed.

8. The terminal for loading blocks of 3D scenes according to claim 7, characterized in that: The determination of whether the block enters the camera field of view of the character is specifically as follows: It is determined whether the bounding box of the block intersects with the viewing cone of the camera. If the bounding box of the block intersects with the viewing cone, the block enters the camera field of view; otherwise, the block is not in the camera field of view.

Citation Information

Patent Citations

  • Lightweight visualization method of building information model based on Web3D

    CN109145366A