Model generation method and device, storage medium and electronic equipment
By identifying ambient light occlusion areas in three-dimensional scenes and generating models, the problems of low efficiency and poor naturalness of manual model placement in existing technologies are solved, and automated, efficient and natural model generation is achieved.
Patent Information
- Application Number
- CN202510668710.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-23
AI Technical Summary
Existing technologies lack a systematic solution for automatically identifying ambient occlusion areas in three-dimensional space and automatically generating corresponding models, resulting in low efficiency in game scene production and unnatural model layout.
By acquiring the building model in the three-dimensional scene, determining the spatial range, generating multiple detection points, screening the effective detection points, performing multi-directional ray detection, identifying the ambient light occlusion area, and generating a preset model at the target detection point location.
It realizes automatic identification of ambient light occlusion areas and generates models, improves the efficiency of scene creation, ensures the naturalness and realism of the model, and conforms to the laws of nature.
Smart Images

Figure CN120689494A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game technology, and in particular to a model generation method and device, a storage medium, and an electronic device. Background Art
[0002] Ambient occlusion (AO) is a crucial visual effect in gaming and virtual reality scene creation, typically manifesting as dark corners at the intersections of objects due to light bouncing and absorbing at these interfaces. Traditionally, AO has primarily been applied as a two-dimensional texture to enhance realism. However, in nature, AO-blocked areas, such as building corners, the base of walls, or along roadsides, often feature vegetation or piles of garbage. This pattern needs to be mimicked in game scene creation. Currently, the placement of these models in game scenes relies primarily on manual effort by art engineers. For example, in a post-apocalyptic ruins scene, vegetation or debris must be placed one by one between buildings and around walls. This manual placement method is not only labor-intensive and time-consuming, but also makes it difficult to ensure a naturally random layout, severely impacting game development efficiency. Existing technologies lack a systematic solution that can automatically identify AO-blocked areas in three-dimensional space and generate corresponding models, limiting the efficiency and quality of game scene creation.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0004] The purpose of the present invention is to provide a model generation method and device, a storage medium, and an electronic device, thereby overcoming one or more problems caused by the limitations and defects of related technologies to at least a certain extent.
[0005] According to one aspect of the present disclosure, a model generation method is provided, the method further comprising:
[0006] Obtain the building model in the three-dimensional scene;
[0007] Determining a spatial range in the three-dimensional scene;
[0008] Generating a plurality of detection points within the spatial range according to a preset density;
[0009] Screening the plurality of detection points, eliminating detection points located inside the building model, and obtaining valid detection points;
[0010] Perform multi-directional ray detection on each of the effective detection points to obtain ray detection results;
[0011] Identifying a target detection point located in an ambient light shielding area based on the ray detection result; and
[0012] A preset model is generated at the target detection point position.
[0013] According to another aspect of the present disclosure,
[0014] An acquisition module is used to acquire a building model in a three-dimensional scene;
[0015] a range determination module, configured to determine a spatial range in the three-dimensional scene;
[0016] A detection point generation module, configured to generate a plurality of detection points within the spatial range according to a preset density;
[0017] A detection point screening module is used to screen the plurality of detection points, remove detection points located inside the building model, and obtain valid detection points;
[0018] A ray detection module is used to perform multi-directional ray detection on each of the effective detection points to obtain ray detection results;
[0019] an area recognition module, configured to recognize a target detection point located in an ambient light shielding area based on the ray detection result; and
[0020] The model generation module is used to generate a preset model at the target detection point position.
[0021] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the model generation method described in any one of the above is implemented.
[0022] According to another aspect of the present disclosure, there is provided an electronic device, including:
[0023] processor, display device; and
[0024] a memory for storing executable instructions of the processor;
[0025] The processor is configured to perform any one of the above model generation methods by executing the executable instructions.
[0026] The present application provides a model generation method, which comprises the following steps: obtaining a building model in a three-dimensional scene; determining a spatial range in the three-dimensional scene; generating a plurality of detection points within the spatial range according to a preset density; screening the plurality of detection points, eliminating detection points located inside the building model, and obtaining valid detection points; performing multi-directional ray detection on each of the valid detection points to obtain ray detection results; identifying a target detection point located in an ambient light shading area based on the ray detection results; and generating a preset model at the location of the target detection point. Therefore, the method provided in this embodiment enables automatic identification of ambient light shading areas based on the distribution characteristics of the building model in the three-dimensional scene and generation of models at appropriate locations, thereby eliminating the need for art engineers to manually place each small model, greatly improving scene creation efficiency, and at the same time ensuring the naturalness and realism of the generated model, in accordance with the distribution characteristics of objects in corner positions in natural laws. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The above and other features and advantages of the present disclosure will become more apparent by describing in detail exemplary embodiments thereof with reference to the accompanying drawings. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort. In the accompanying drawings:
[0028] Figure 1 is an architecture diagram of a cloud interaction system in an exemplary embodiment of the present disclosure;
[0029] Figure 2 is a flow chart of a model generation method in an exemplary embodiment of the present disclosure;
[0030] Figure 3 is a schematic diagram of a simplified model in an exemplary embodiment of the present disclosure;
[0031] Figure 4 is a schematic diagram of a ray detection result in an exemplary embodiment of the present disclosure;
[0032] Figure 5 is a schematic diagram of a generative model in an exemplary embodiment of the present disclosure;
[0033] Figure 6 is a composition diagram of a model generating device in an exemplary embodiment of the present disclosure;
[0034] Figure 7 A schematic diagram of the structure of a computer-readable storage medium in an exemplary embodiment of the present disclosure;
[0035] Figure 8 FIG. 1 is a diagram showing the composition of an electronic device in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0037] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0038] It should be noted that the information involved in this application (including but not limited to: information input by the user, for example, information entered by the user into the input box), data (including but not limited to data used for analysis, stored data, displayed data, etc., for example, context code, all codes of the current project, service pressure corresponding to operations on all codes of the current project, code development status of the current project) and signals are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards. For example, the context code, operations on all codes of the current project, and service pressure corresponding to the operations, code development status, etc. involved in this application are all obtained with full authorization.
[0039] It should be noted that the terms "first," "second," and the like in the specification and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate for the embodiments of the present invention described herein. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or apparatuses.
[0040] It should also be noted that the various triggering events disclosed in this specification can be preset, and different triggering events can trigger the execution of different functions.
[0041] In one embodiment of the present disclosure, a model generation method can be run on a terminal device or a server. The terminal device can be a local terminal device. When the model generation method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device. Figure 1 FIG. 1 is a diagram showing an architecture of a cloud interaction system provided by the present disclosure. As shown in the diagram, the cloud interaction system may include: a client device 10 and a server 20 , wherein the client device 10 may be connected to the server 20 via a network 30 .
[0042] In an optional embodiment, various cloud applications, such as cloud gaming, can be run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operation mode, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the model generation method are completed on the cloud gaming server. The role of the client device is to receive and send data and present the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, TV, computer, PDA, etc.; but the terminal device that performs information processing is the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation instructions to the cloud gaming server. The cloud gaming server runs the game according to the operation instructions, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0043] In an optional embodiment, the terminal device can be a local terminal device. Taking a game as an example, the local terminal device stores the game program and is used to present the game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, conventionally downloading and installing the game program through an electronic device and running it. The local terminal device can provide the graphical user interface to the player in various ways, for example, it can be rendered and displayed on the terminal display, or provided to the player through holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present the graphical user interface, the graphical user interface including the game screen, and the processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0044] Figure 2 In this embodiment, a model generation method is provided. Figure 2 is a flow chart of a model generation method according to an embodiment of the present disclosure, such as Figure 2 As shown, the process includes the following steps:
[0045] Step S1, obtaining a building model in a three-dimensional scene;
[0046] Step S2, determining a spatial range in the three-dimensional scene;
[0047] Step S3, generating a plurality of detection points within the spatial range according to a preset density;
[0048] Step S4, screening the plurality of detection points, eliminating detection points located inside the building model, and obtaining valid detection points;
[0049] Step S5, performing multi-directional ray detection on each of the effective detection points to obtain ray detection results;
[0050] Step S6, identifying a target detection point located in an ambient light shielding area based on the ray detection result; and
[0051] Step S7: generating a preset model at the target detection point position.
[0052] The method provided in this embodiment enables automatic identification of ambient light occlusion areas based on the distribution characteristics of building models in a three-dimensional scene and generation of models at appropriate locations, eliminating the need for art engineers to manually place each small model. This significantly improves scene creation efficiency while ensuring the naturalness and realism of the generated model, in line with the distribution characteristics of objects in corners in natural laws.
[0053] The above steps are described in detail below.
[0054] In step S1, a building model in a three-dimensional scene is obtained.
[0055] The building model is a 3D data model used to represent the building structure in a 3D scene. The building model is used to form the basic framework of the 3D scene and serves as a reference object and basis for subsequent model generation.
[0056] In an alternative embodiment, the building model can be model data created by a user using 3D modeling software and imported into the 3D scene, or it can be a simplified version of the building model automatically generated by the system according to predetermined rules. For example, the terminal device can receive a building model file created by a user using modeling software such as 3D Max, Maya, or Blender, and import it into the current 3D scene as the base environment.
[0057] In an alternative embodiment, the building model can be represented as a collection of geometric entities. These entities can be basic shapes such as cubes, cylinders, polyhedrons, or combinations thereof, used to simulate the appearance and structure of a real building. For example, a terminal device can use simplified geometric entities (such as cubes) to simulate the general structure of a building. These geometric entities serve as abstract representations of the building and can later be replaced by artists with more detailed and realistic building models.
[0058] In a specific application, the terminal device can import a pre-made building model through the asset import function of the game engine (such as the UE4 engine), or use the basic geometry tools provided by the engine to create a simplified building model. For example, several square box models are created to simulate the general structure of the building, including basic elements such as walls and ground, laying the foundation for subsequent ambient light occlusion area detection.
[0059] In step S2, a spatial range is determined in the three-dimensional scene.
[0060] The spatial extent is a specific area defined in a 3D scene that limits the computational scope of subsequent operations to improve processing efficiency. The spatial extent is usually represented by a bounding box with clear boundaries and volume.
[0061] In an optional embodiment, the spatial range can be defined by creating a bounding box that covers the building model and the area around it at a certain distance, thereby ensuring that any possible ambient occlusion areas are included. For example, the terminal device can automatically calculate a bounding box of appropriate size based on the outer contours of the building model, so that it completely contains the building model and leaves a certain amount of margin around the building.
[0062] In an optional embodiment, the size of the spatial range can be adjusted according to user needs to accommodate scenes of varying scales and model generation requirements of varying precision. For example, the terminal device can provide a parameter control interface that allows the user to input the size parameters of the bounding box (e.g., length, width, and height), or directly adjust the size and position of the bounding box using a visual editing tool.
[0063] In a specific application, when creating a blueprint (such as BP_SpawnInAO), the terminal device can add a volume component (Volume) and use the SetBoxExtent function to set the size of the volume. For example, you can set the parameter VolumeSize to 600 to create a cubic bounding box with a side length of 600 units. This will serve as the calculation range for subsequent detection point generation and ray detection, thus avoiding calculations in the entire infinite 3D space and effectively saving computing resources.
[0064] In step S3, a plurality of detection points are generated within the spatial range according to a preset density.
[0065] Detection points are three-dimensional coordinate points distributed across a spatial range and used for subsequent ray detection and model placement. The preset density determines the spacing and number of detection points, affecting the accuracy and computational efficiency of the resulting model.
[0066] In an optional embodiment, the preset density can be expressed as the number of points per unit length of space or the spacing between points. A higher density generates more detection points and a more refined model, but also increases the computational burden. For example, the terminal device can evenly divide the spatial range into multiple small blocks based on the density parameter set by the user, with the size of each block determined by the density value.
[0067] In an optional embodiment, detection points can be generated by evenly dividing the spatial range along the three coordinate axes and creating a detection point coordinate at each division point. For example, the terminal device can use three nested loops, one for each of the X, Y, and Z directions, to calculate the step length in each direction according to a preset density, and then generate a detection point at the intersection of each step length.
[0068] In a specific application, the terminal device can set the ProbeDensity parameter value to 10, evenly dividing the spatial range into 10×10×10=1000 small blocks, recording the 3D coordinates of the center point of each small block, and storing these coordinates in the Probes array. In this way, the entire spatial range is filled with 1000 evenly distributed detection points, providing basic sampling points for subsequent ray detection and ambient light occlusion area identification.
[0069] In step S4, the plurality of detection points are screened, and detection points located inside the building model are eliminated to obtain valid detection points.
[0070] Among them, the screening operation is to remove invalid detection points and improve the efficiency of subsequent processing. The detection points located inside the building model are considered invalid points because they cannot become ambient light occlusion areas and are not suitable for model placement.
[0071] In an optional embodiment, the screening process can be implemented by performing a collision check on each detected point to determine whether the point is located within the geometric body of the building model. For example, the terminal device can use techniques such as ray detection or overlap testing to determine the spatial relationship between the detected point and the building model.
[0072] In an optional embodiment, the screening results form a new set of valid detection points. These points are located in the space outside the building model and are valid candidate points for subsequent ray inspection. For example, the terminal device can create a new array to store only the coordinates of the detection points that pass the screening, thereby reducing the amount of data to be processed later.
[0073] In a specific application, the terminal device can traverse all detection points generated in step S3 and use the SphereOverlapActors function to check for overlap with the building model. If the detection point is located inside the building model, it is marked as invalid and removed from the candidate list. Otherwise, it is retained in the list of valid detection points and used as the starting point for subsequent raycasting. This avoids unnecessary raycasting of points inside the building and improves algorithm efficiency.
[0074] In step S5, multi-directional ray detection is performed on each of the effective detection points to obtain ray detection results.
[0075] Ray detection involves emitting rays from a valid detection point in different directions and detecting the intersection of the rays with the building model. The ray detection results include information such as the object hit by the ray, the location of the impact point, and the direction of the normal, which is used to determine whether the detection point is located in an ambient light occlusion area.
[0076] In an optional embodiment, multi-directional ray detection can be achieved by emitting rays from each valid detection point in multiple predefined directions. These directions can be a number of directional vectors evenly distributed in three-dimensional space. For example, the terminal device can pre-define multiple directional vectors, such as basic directions such as up, down, left, right, forward, and backward, or more detailed directional divisions.
[0077] In an optional embodiment, the ray detection results may include information such as whether the ray hit an object, the three-dimensional coordinates of the hit point, the surface normal vector of the hit point, and the material properties of the hit object. For example, the terminal device may record whether each ray hits a building model, and if so, the location of the hit point and the normal direction of the hit point. This information will be used to subsequently determine whether the detection point is located in an ambient light occlusion area.
[0078] In a specific application, the terminal device can randomly select five directions for each valid detection point, use LineTraceByChannel or a similar function to emit rays in these directions, and record the detection results of each ray, including information such as whether it hits an object, the location of the hit point, and the normal direction. These detection results are stored in arrays (such as the HitLocations and HitNormals arrays) to provide data support for subsequent ambient light occlusion area identification.
[0079] In step S6, a target detection point located in an ambient light shielding area is identified based on the ray detection result.
[0080] Ambient occlusion refers to the relatively dark areas around the building model, especially at the junction of walls and the ground, where light propagation is blocked by multiple surfaces. Target detection points are valid detection points identified as being within the ambient occlusion area.
[0081] In an optional embodiment, the identification of ambient light occlusion areas can be achieved by analyzing the pattern of ray detection results, such as examining factors such as the type of surface hit by the ray, the distance, and the normal direction. For example, the terminal device can check whether the ray at each detection point hits both the wall and the ground, and whether the normal direction of these hit points matches the characteristics of the wall-ground interface.
[0082] In an optional embodiment, the target detection point can be selected based on a combination of predefined conditions that effectively describe the characteristics of the ambient light occlusion area. For example, the terminal device can set multiple screening conditions, such as the ray must detect an object, the detection distance must be greater than a certain threshold, the detected object must have a valid physical material, and the ground must be detected. Only detection points that meet all of these conditions are identified as target detection points.
[0083] In a specific application, the terminal device can analyze the ray detection results for each valid detection point to check whether the following conditions are simultaneously met: 1) the ray detects an object; 2) the ray detection distance is greater than a preset threshold; 3) the detected object has a valid physical material; and 4) the ray detects the ground. Furthermore, the average normal of the ray impact point is calculated for each detection point and compared with the difference between this average and the normal of a single wall to determine whether the detection point is located at the intersection of the wall and the ground. Detection points that meet these conditions are marked as target detection points and used as the location basis for subsequent model generation.
[0084] In step S7, a preset model is generated at the target detection point position.
[0085] The target detection point refers to the valid detection point located in the ambient light occlusion area that is screened out by the previous processing steps. The preset model refers to the 3D model object that is pre-defined or provided by the user and needs to be automatically generated at a specific location.
[0086] In an optional embodiment, the target detection points are spatial points located at the intersections or corners of buildings and the ground, as determined after ambient occlusion analysis. These points typically simulate areas where objects tend to accumulate or plants tend to grow in natural environments. For example, in game scenes, areas such as the interface between buildings and the ground, corners of walls, and under bridges are typical areas of ambient occlusion; in the real world, these areas typically accumulate more debris or grow more vegetation.
[0087] In an optional embodiment, the preset models can be various types of 3D models, including but not limited to vegetation models, trash models, and decorative object models. These models can be selected by the user from a model library or directly imported into the system. For example, in constructing a post-apocalyptic ruins scene, the preset models might include weeds, shrubs, garbage piles, damaged objects, and other types of models. The system will select the appropriate model for generation based on the environmental characteristics of the target detection point.
[0088] The process of generating a preset model includes instantiating a three-dimensional model at the target detection point, and possibly performing transformation operations such as rotation and scaling on the model to make it better integrated into the environment.
[0089] In an optional implementation, random variations can be applied during model generation to give each instantiated model a unique appearance and orientation, thus avoiding noticeable repetition in the scene. For example, the system can apply random rotation angles, different scales, or even randomly select a model from multiple models of the same type for instantiation, thereby increasing the richness and naturalness of the scene.
[0090] In an optional embodiment, the system can generate models of different types or densities based on the environmental characteristics of different target detection points. For example, a denser model of debris or vegetation may be generated in a corner, while a sparser model may be generated in a more open area that is still within the ambient light occlusion zone.
[0091] In a specific application, when executing the model generation method, the terminal device first obtains a model list provided by the user, which contains various types of vegetation and debris models. The terminal device then randomly selects a suitable model for each identified target detection point (the ambient light occlusion area at the junction of the building and the ground). The terminal device then instantiates the selected model to the position of the target detection point and applies random rotation and scaling parameters to ensure that each generated model has a unique appearance. Ultimately, the terminal device generates naturally distributed vegetation and debris models around the buildings in the three-dimensional scene, making the scene appear more realistic and natural, while saving a lot of time in manually placing the models.
[0092] In a model generation method provided in an embodiment of the present application, obtaining a building model in a three-dimensional scene includes:
[0093] Receive user-provided building models; and / or
[0094] Generate a simplified building model.
[0095] Through the method provided in this embodiment, the terminal device can flexibly choose the method of obtaining the building model. It can not only directly utilize the user's existing model resources, but also automatically simplify the building structure as needed, reduce computing overhead, improve model generation efficiency, and at the same time ensure the accuracy and rationality of model generation.
[0096] The simplified building model is a building model data structure that has been geometrically simplified.
[0097] In an optional embodiment, the simplified building model is generated using voxelization, bounding box representation, or polygon reduction techniques. For example, the terminal device may employ a voxel-based simplification algorithm to discretize the original building model into a regular three-dimensional grid structure, then merge adjacent voxel units according to preset accuracy parameters to form a simplified building outline. Alternatively, the terminal device may employ a bounding box method to create simple geometric bounding volumes for major building components, such as walls and roofs, and use these bounding volumes to represent the overall building structure.
[0098] In an optional embodiment, receiving a user-provided building model and generating a simplified version of the building model can be combined to form a multi-layered building model representation. For example, a terminal device can first receive a user-provided detailed building model for final visual rendering, and then automatically generate a simplified building model based on the detailed model for spatial detection and calculation. This separation strategy can improve computational efficiency while maintaining visual quality.
[0099] In a specific application, the terminal device can provide a model import interface through which the user uploads a collection of detailed building models of a city block. After receiving these models, the terminal device automatically converts each building into a simplified geometric representation (such as a combination of cubes and rectangular parallelepipeds) and assigns these simplified models a spatial location and approximate size that matches the original building, such as Figure 3 In the subsequent model generation process, the terminal device uses these simplified building models for ray detection and space analysis, but the final rendering still displays the detailed building model provided by the user, thus achieving a balance between visual quality and computational efficiency.
[0100] In a model generation method provided in an embodiment of the present application, the method further includes:
[0101] A specific physical material identifier is assigned to the building model to distinguish different objects during ray detection.
[0102] Through the method provided in this embodiment, the terminal device can accurately identify building models and other objects during the X-ray detection process, improve the accuracy of object recognition, thereby ensuring the validity of the X-ray detection results, further improving the accuracy and rationality of model generation, and ultimately achieving a model distribution that is more in line with the characteristics of the real environment.
[0103] In an optional embodiment, the physical material identifier may include physical property parameters such as material type, material ID, reflectivity, and absorptivity. These parameters constitute the unique identifier of the object. For example, a terminal device may assign specific physical material ID values to a building model, such as assigning ID value 1 to walls and ID value 2 to the ground. This allows different object types to be distinguished by these ID values during radiographic detection.
[0104] In a specific application, when the terminal device needs to identify a target detection point located in an area shielded from ambient light, it will emit rays in multiple directions. At this time, the terminal device will first check whether the ray hits an object. If it hits an object, it will further read the physical material identification of the object. Through this physical material identification, the terminal device can determine whether the object is part of the building model (such as a wall or ground) or another object in the scene (such as existing furniture or decorations). Only when the ray hits a building model with a specific physical material identification will the detection point be further processed, thereby avoiding the erroneous generation of a preset model in a non-building model area.
[0105] In a model generation method provided in one embodiment of the present application, determining a spatial range in the three-dimensional scene includes:
[0106] Step S41, creating a bounding box as the spatial range;
[0107] Step S42: adjusting the size of the bounding box according to the volume size set by the user.
[0108] The method provided in this embodiment enables the calculation scope to be clearly limited during the model generation process, effectively avoiding unlimited consumption of computing resources, improving generation efficiency, and adapting to generation requirements of different scales by adjusting the size of the bounding box, thereby enhancing the flexibility and practicality of the method.
[0109] The above scheme is described in detail below.
[0110] In step S41, a bounding box is created as the spatial range.
[0111] A bounding box is a three-dimensional geometric structure used to define the boundaries of spatial calculations. It can be understood as a three-dimensional cube or cuboid whose boundaries define a closed spatial region, which is used to determine the effective range of model generation.
[0112] In an optional embodiment, a bounding box can define a closed three-dimensional space by specifying the coordinate values of six faces, and points within the space will be considered as the valid detection area. For example, before executing model generation, the terminal device can first create a bounding box of default size, centered at the coordinate origin, with the initial side length set to a predefined value, such as 500 units, to form an initial calculation space.
[0113] In an optional embodiment, the bounding box can be defined by determining the center point coordinates and the dimensions of the three dimensions. For example, at the beginning of the model generation process, the terminal device can set the center point of the bounding box to (0, 0, 0) and specify the half-length of the X, Y, and Z directions to be 300 units, thereby constructing a cubic space with a side length of 600 units as the working area for subsequent detection point generation and ray detection.
[0114] In a specific application, when executing the model generation method, the terminal device calls the dedicated function SetBoxExtent to create a bounding box component and uses it as the boundary definition of the spatial range. The bounding box forms a closed area with clear boundaries in the three-dimensional coordinate system. Subsequent detection point generation and ray detection operations are only performed within this area to ensure the rational use of computing resources.
[0115] In step S42, the size of the bounding box is adjusted according to the volume size set by the user.
[0116] The volume size is a parameter representing the size of the space. It can be a single value or a set of values that determines the specific length of the bounding box in each dimension, which in turn affects the size of the overall calculation range.
[0117] In an optional embodiment, the volume size can be received via a parameterized interface and applied to the bounding box adjustment process, allowing the bounding box size to be flexibly adjusted based on specific needs. For example, the terminal device can provide a parameter control interface named VolumeSize, which allows a specific value, such as 600, to be set before execution. This value is then used as the bounding box side length parameter, thereby adjusting the bounding box to form a 600×600×600 cubic space.
[0118] In an optional embodiment, the volume size can be adjusted for different dimensions of the bounding box, so that the bounding box forms a non-equilateral rectangular parallelepiped structure. For example, the terminal device can receive independent size values for the X, Y, and Z dimensions, such as X = 800, Y = 600, and Z = 400, and then adjust the bounding box to a rectangular parallelepiped of corresponding dimensions to meet the different dimensional distribution requirements of specific scenarios, such as horizontally extended street scenes or vertically extended canyon scenes.
[0119] In a specific application, after creating the bounding box, the SetBoxExtent function is called according to the preset VolumeSize parameter value (such as 600 in the example) to adjust the size of the bounding box to form a cubic space range with a side length of 600 units. This range covers the main model generation area, ensuring sufficient computing space and avoiding unnecessary waste of computing resources.
[0120] In a model generation method provided in an embodiment of the present application, generating a plurality of detection points according to a preset density within the spatial range includes:
[0121] Evenly dividing the spatial range into a plurality of small blocks according to a preset density value;
[0122] The three-dimensional coordinates of each small block are recorded as the detection point coordinates.
[0123] Through the method provided in this embodiment, the terminal device can systematically divide the specified area according to the preset density value to form a uniformly distributed detection grid, thereby providing reasonably distributed sampling points for subsequent ray detection, ensuring the comprehensiveness and uniformity of the detection, effectively avoiding the problem of uneven regional coverage that may be caused by random sampling, and improving the spatial distribution accuracy and computational efficiency of model generation.
[0124] Among them, uniform segmentation refers to the process of dividing the space into regular small blocks at equal intervals.
[0125] In an alternative embodiment, uniform segmentation can be achieved by using a grid partitioning algorithm to ensure that each block has the same size and shape. For example, for a 600×600×600 cubic space, if the preset density value is 10, then each block has a size of 60×60×60, forming a regular three-dimensional grid structure.
[0126] In an optional embodiment, the uniform segmentation process can be implemented using three nested loops, one for each of the X, Y, and Z coordinate axes, with the number of loops determined by a preset density value. For example, the terminal device can execute three loops: an outer loop increments the X coordinate from a minimum to a maximum value, a middle loop increments the Y coordinate, and an inner loop increments the Z coordinate. Each time the innermost loop completes, the position of a small block in space is determined.
[0127] In a specific application, the terminal device first receives a preset density value of 10 and then calculates a 600×600×600 unit space, with a 60 unit interval in each dimension. Next, the terminal device uses three nested loops, starting from the minimum coordinate in the space and recording a point position every 60 units until the entire space is traversed. This evenly divides the space into 1000 equal-sized cubes, laying the foundation for subsequent detection point generation.
[0128] Among them, a small block refers to each independent area unit obtained by evenly dividing the spatial range.
[0129] In an optional embodiment, a patch can be considered a basic sampling unit in space, with each patch having a unique spatial location and size. For example, in a partitioned space, each patch can be identified by an index triple (i, j, k), where i, j, and k represent the index position of the patch in the X, Y, and Z directions, respectively.
[0130] In an alternative embodiment, the shape of the tiles is generally a cube or a cuboid, with the side length determined by dividing the total size of the space by the preset density value. For example, for a cubic space, if the total side length is 900 units and the preset density value is 15, then the side length of each tile is 900 / 15 = 60 units, resulting in a cubic tile with a side length of 60 units.
[0131] The three-dimensional coordinates refer to the precise position of each small block in the three-dimensional space.
[0132] In an alternative embodiment, the three-dimensional coordinates can be represented by the location of the tile center point, obtained by calculating the actual spatial coordinate value corresponding to each tile index. For example, for a tile indexed by (i, j, k), its center coordinates can be calculated by multiplying the index value by the tile size, adding the starting coordinate of the spatial range and an offset of half a tile.
[0133] In one specific application, after evenly dividing the space, the terminal device calculates the center coordinates for each tile. For example, in a cubic space extending from (-300, -300, -300) to (300, 300, 300), with a preset density of 10, the terminal device calculates the center coordinates of the first tile (0, 0, 0) as (-270, -270, -270), the second tile (0, 0, 1) as (-270, -270, -210), and so on. These calculated center coordinates are stored in a three-dimensional vector array, serving as the starting position for subsequent ray detection, providing evenly distributed sampling points for identifying ambient light occlusion areas.
[0134] In a model generation method provided in an embodiment of the present application, the plurality of detection points are screened, and detection points located inside the building model are eliminated, and valid detection points are obtained, including:
[0135] Step S61, performing collision detection on each detection point to detect whether the detection point is located inside the building model;
[0136] Step S62: If the detection point is located inside the building model, the detection point is marked as an invalid detection point.
[0137] The method provided in this embodiment enables the terminal device to effectively filter out detection points located within the building model, avoiding subsequent processing at invalid locations and improving the accuracy and efficiency of model generation. The collision detection mechanism identifies and marks invalid detection points, ensuring that subsequent raycasting and model generation are performed only within the valid area, reducing the waste of computing resources.
[0138] The above scheme is described in detail below.
[0139] In step S61 , collision detection is performed on each detection point to detect whether the detection point is located inside the building model.
[0140] Collision detection is a spatial position determination mechanism used to determine whether a specific point in three-dimensional space is located inside a closed model. Detection points are points with three-dimensional coordinates generated according to pre-set rules within a specific spatial range. The interior of a building model refers to the internal space enclosed by the closed model.
[0141] In an optional embodiment, collision detection can be implemented using a ray casting method, which determines whether a point is inside the model by emitting a ray from the detection point in a specific direction and counting the number of times the ray intersects the model surface. For example, the terminal device can emit a ray from each detection point in each of the six principal axis directions (positive X, negative X, positive Y, negative Y, positive Z, and negative Z). If the number of intersections between the ray and the model surface is an odd number, the point is inside the model.
[0142] In a specific application, when performing collision detection, the terminal device can use the function interface provided by the physics engine to call the SphereOverlapActors function. This function sets a sphere with a very small radius (such as 0.1 units) with the detection point as the center, and detects whether the sphere overlaps with the building model. If overlap occurs, the detection point is determined to be inside the building model and needs to be eliminated.
[0143] In step S62, if the detection point is located inside the building model, the detection point is marked as an invalid detection point.
[0144] The marking operation refers to the process of recording the status of the detection point. Invalid detection points refer to detection points that do not meet the subsequent processing conditions and need to be excluded.
[0145] In an alternative embodiment, marking can be implemented by creating a Boolean flag array corresponding to the validity status of each detection point. For example, the terminal device can create a Boolean array with the same number of detection points, with all initial values set to true (valid). When a point is detected as being inside the building model, the value at the corresponding index is set to false (invalid).
[0146] In an optional embodiment, marking can also be achieved by directly removing invalid points from the detection point array, thereby reducing the amount of data to be processed subsequently. For example, the terminal device can maintain a list of valid detection points. When a detection point is determined to be invalid, it is not added to the list or is deleted from the existing list.
[0147] In one specific application, after completing collision detection, the terminal device can traverse all detection points, remove those located within the building model from the original detection point array, and construct a new valid detection point array. This allows subsequent multi-directional raycasting steps to process only valid detection points, significantly improving processing efficiency, especially in complex scenes where building models account for a large proportion.
[0148] In a model generation method provided in an embodiment of the present application, the method further includes:
[0149] Step S71, generating a random seed;
[0150] Step S72, randomly fine-tuning the position of the effective detection point according to the random seed to obtain a fine-tuned effective detection point;
[0151] The performing multi-directional ray detection on each of the effective detection points includes: performing multi-directional ray detection on the effective detection points after fine-tuning.
[0152] Through the method provided in this embodiment, the terminal device can fine-tune the effective detection points through random seeds, increase the randomness and naturalness of the generated model position, avoid the model distribution being too regular and mechanical, improve the visual realism and naturalness of the final generated effect, and at the same time ensure the difference of each generation result, meet the needs of different scenarios while improving the flexibility of the system.
[0153] The above scheme is described in detail below.
[0154] In step S71 , a random seed is generated.
[0155] The random seed is the initial value used to generate a random number sequence.
[0156] In an optional embodiment, the random seed can be a value automatically generated by the system to provide a random basis for subsequent random fine-tuning. For example, the terminal device can generate an integer between 0 and 99999 based on the current system time as the random seed.
[0157] In step S72, the position of the effective detection point is randomly fine-tuned according to the random seed to obtain a fine-tuned effective detection point.
[0158] Among them, random fine-tuning is the process of offsetting the original detection point position in a small range.
[0159] In an optional implementation, random fine-tuning can offset the coordinates of valid detection points in different directions. The offset is controlled by a random seed, ensuring randomness and diversity in the fine-tuning results. For example, the terminal device can generate three random offset values based on the random seed and apply them to the X, Y, and Z coordinate axes of the detection point, respectively, to achieve random position adjustment in three-dimensional space.
[0160] In an optional embodiment, the range of random fine-tuning can be limited to prevent excessive shifts in the positions of detection points after fine-tuning, which could distort detection results. For example, the terminal device can set the maximum offset range for fine-tuning to no more than half the distance between adjacent detection points, ensuring that the fine-tuned points remain within their original spatial distribution area and avoid biased detection results due to excessive shifts.
[0161] In step S73, multi-directional ray detection is performed on the effective detection points after fine-tuning.
[0162] Among them, multi-directional ray detection is the process of emitting rays from the detection point in multiple directions and recording the collision results.
[0163] In an optional embodiment, multi-directional ray detection can emit multiple rays from each fine-tuned detection point according to a preset set of directions, and record information about each ray's interaction with surrounding objects. For example, a terminal device can emit rays from a detection point in six cardinal directions: up, down, left, right, forward, and backward, to detect collisions with buildings or the ground.
[0164] In an optional embodiment, the ray detection result includes information such as whether the ray hits an object, the location coordinates of the impact point, the normal direction of the impact point, and the physical material of the impacted object, which is used to subsequently determine whether the detection point is located in an ambient light occlusion area. For example, the terminal device can record the distance from the collision point detected by each ray to the detection point, the surface normal direction of the object where the collision point is located, and the material properties of the object, and analyze this data to determine whether the point is located in an ambient light occlusion area such as a corner.
[0165] In one specific application, a terminal device performs multi-directional ray detection on a valid detection point fine-tuned to the coordinates (15.15, 28.78, 0.08). Rays are emitted in five directions: 45° upward, directly above, forward, 45° to the right, and 45° to the left. Three rays hit the wall, one hit the ground, and one did not hit anything. These detection results are stored as the ray detection data for the detection point.
[0166] In a specific application of this embodiment, the terminal device first randomly generates a random seed with a value of 25641, and then generates 1000 evenly distributed detection points in three-dimensional space, and screens out 782 valid detection points through collision detection. Subsequently, the terminal device uses the random seed to calculate the fine-tuning offset of each valid detection point, and fine-tunes the first valid detection point from the original position (10.0, 20.0, 0.0) to (10.13, 19.87, 0.05). The fine-tuned detection point is emitted in five different directions, and the collision points of two rays with the wall and one ray with the ground are recorded. Based on these ray detection results, the system determines that the point is located in the ambient light shielding area, and finally generates a moss model at this location.
[0167] In a model generation method provided in an embodiment of the present application, randomly fine-tuning the position of the effective detection point according to the random seed includes: randomly offsetting the position of each effective detection point within a range not exceeding the distance between adjacent detection points.
[0168] Through the method provided in this embodiment, the detection point positions can avoid the problem of the generated model being too uniform due to regular arrangement. At the same time, by limiting the random offset range, it is ensured that the fine-tuned detection points will not be too close to or far away from other detection points, maintaining an appropriate spatial distribution, so that the final generated model distribution is more natural and reasonable, improving the scene realism and maintaining stable and controllable detection accuracy.
[0169] The spacing between adjacent detection points is the distance between multiple detection points generated at a preset density within a spatial range. It is a physical quantity determined by both the spatial range and the preset density, representing the distance between two adjacent detection points in space. A smaller spacing indicates a denser distribution of detection points; a smaller spacing indicates a sparser distribution.
[0170] In an optional embodiment, the distance between adjacent detection points can be calculated by dividing the size of the spatial range by the preset density. For example, assuming the spatial range is a cube with a side length of 600 units and a preset density of 10, the space is divided into 10×10×10=1000 small blocks, and the distance between adjacent detection points is 600 / 10=60 units.
[0171] In a specific application, after the terminal device generates detection points with a preset density of 10 within the spatial range, it calculates that the distance between adjacent detection points is 60 units. For each valid detection point obtained by screening, the terminal device uses the previously generated random seed to ensure the randomness and repeatability of the offset. For each valid detection point, the terminal device generates random values in the range of [-30, 30] on the three coordinate axes of X, Y, and Z, such as (12, -18, 25), and adds these random values to the original coordinates of the detection point to obtain the fine-tuned detection point position. This random offset ensures that the detection points do not form an obvious grid arrangement, making the subsequent model distribution generated based on these detection points more natural.
[0172] In a model generation method provided in one embodiment of the present application, the multi-directional ray detection of each of the effective detection points includes: emitting rays from each effective detection point position to multiple preset directions; recording the impact point position and impact point normal of each ray; wherein the number of the multiple preset directions is at least three.
[0173] The method provided in this embodiment enables environmental information to be acquired from multiple directions, thereby improving the comprehensiveness and accuracy of detection, thereby enabling more accurate identification of locations suitable for generating preset models, improving the quality and rationality of model generation, and further optimizing resource utilization efficiency.
[0174] In a specific application, when performing ray detection on each valid point, the terminal device first generates five preset direction vectors, each pointing to a different location on the surface of the hemisphere to ensure wide coverage. Then, starting from each valid point, a ray is emitted along these five directions one by one, with the maximum detection distance of each ray set to 300 units to limit the detection range and improve efficiency.
[0175] The impact point position refers to the three-dimensional coordinates of the point where the ray intersects the object's surface. This coordinate information accurately describes a point on the object's surface. The impact point normal refers to the normal vector of the object's surface at the impact point. This vector is perpendicular to the object's surface and points outward from the object.
[0176] In an optional embodiment, the impact point location is obtained from the collision result returned by the ray detection function, which indicates the precise coordinates of the location where the ray first intersects the object. For example, when a ray is emitted from a valid point and intersects an object, the world coordinates (X, Y, Z) of the intersection point are recorded as the impact point location.
[0177] In an optional embodiment, the impact point normal is a perpendicular vector to the object's surface at the impact point, representing the orientation of the object's surface at that point. For example, for a flat wall, the normal vector is perpendicular to the wall; for the ground, the normal vector typically points upward. By analyzing the normal vector, it is possible to determine whether the ray hit the wall or the ground.
[0178] In one specific application, after performing ray detection, the terminal device stores the detection results of each ray in two arrays: one array stores the position coordinates of all hit points, and the other array stores the corresponding normal vectors. This data is used for subsequent analysis, specifically to calculate the average normal vector to determine whether the detection point is located at the intersection of two objects.
[0179] Wherein, the number of the multiple preset directions is at least three.
[0180] In an optional embodiment, the number of preset directions is set to at least three to ensure comprehensiveness and accuracy of detection. Multi-directional ray detection can obtain more complete environmental information. For example, five directions can be set, pointing to up, down, left, right, and front, respectively, to cover the main area of the hemisphere.
[0181] In an optional embodiment, the number of directions should be selected to balance detection accuracy and computational efficiency. The greater the number of directions, the more accurate the detection, but the greater the computational effort. For example, in actual applications, 3, 5, 8, or more directions can be selected for ray detection based on the required accuracy and available computing resources.
[0182] In a specific application of this embodiment, when the terminal device performs multi-directional ray detection, it will emit 5 rays from each valid point position. The directions of these rays are: (0, 0, 1), (1, 0, 0), (-1, 0, 0), (0, 1, 0) and (0, -1, 0), corresponding to the five directions of up, right, left, front and back respectively. When the ray hits the object, the position coordinates and normal information of the hitting point are recorded. By analyzing this information, especially the change in the normal vector, the terminal device can identify points at the intersection of objects. These points are usually areas with strong ambient light occlusion and are suitable for placing preset models.
[0183] In a model generation method provided in an embodiment of the present application, identifying a target detection point located in an ambient light shielding area based on the ray detection result includes:
[0184] Analyze the ray detection results of each effective detection point;
[0185] Identify detection points that meet the following conditions as target detection points:
[0186] The rays detect the object;
[0187] The ray detection distance is greater than the preset threshold;
[0188] The detected object has a valid physical material; and
[0189] The rays detected the ground.
[0190] The method provided in this embodiment enables the terminal device to accurately identify the ambient light occlusion area based on clearly defined multi-dimensional conditions, thereby improving the accuracy of model placement and scene realism. At the same time, it reduces computing resource consumption and improves generation efficiency through effectiveness screening.
[0191] Among them, the target detection points are valid detection points that meet specific conditions. These points are considered to be located in the ambient light occlusion area and are suitable for placing the preset model.
[0192] In an optional embodiment, detection points that simultaneously meet multiple conditions are identified by verifying whether the ray detection data of each valid detection point meets all specified conditions one by one. Only those that meet all conditions are marked as target detection points. For example, for each valid detection point, the terminal device can check whether the ray emitted by the point has a record of hitting an object and whether the hitting distance exceeds a minimum threshold preset by the system (e.g., 5 unit lengths). It can also verify whether the hit object has a pre-defined valid physical material identifier and whether any ray detected the ground.
[0193] In an optional embodiment, raycast detection of an object means that a raycast emitted from the detection point intersects an object in the scene, generating collision data. For example, the terminal device can determine whether a raycast successfully hits an object by checking whether the "collision success" flag in the raycast collision result is true. This is the first step in determining whether the detection point is likely located in an ambient light occlusion area.
[0194] In a specific application, the terminal device can evaluate a specific effective detection point. Assume that the point is located near the corner of a building, such as Figure 4The diagram below shows a ray detection result, showing that the ground around the building is completely covered with blocks. The terminal device first checks whether any of the five rays emitted from the point successfully hit an object, then confirms whether the hit distance is greater than the set 10-unit length threshold. Next, the terminal device verifies whether the hit object has a physical material identifier marked as "building" and finally confirms whether any rays hit an object marked as "ground." Only when all four conditions are met is the detection point marked as a target detection point for subsequent generation of the preset model at that location.
[0195] In a model generation method provided in an embodiment of the present application, identifying a target detection point located in an ambient light shielding area based on the ray detection result further includes:
[0196] Step 111, calculating the average value of the normal line of the ray hitting point of each detection point;
[0197] Step 112, comparing the difference between the normal average value and the normal of a single wall;
[0198] Step 113: Determine whether the detection point is located at the junction of the wall and the ground based on the difference.
[0199] Through the method provided in this embodiment, the terminal device can more accurately analyze and process the ray detection results, accurately identify the ambient light shading area located at the junction of the wall and the ground, thereby improving the accuracy of the model generation position, making the generated model more consistent with the distribution pattern of objects in the real environment, significantly improving the realism and naturalness of the scene, while also reducing the generation of invalid models and reducing system resource consumption.
[0200] The above scheme is described in detail below.
[0201] In step S111 , the average value of the ray impact point normal of each detection point is calculated.
[0202] The ray impact point normal is the normal vector of the object's surface at the point of detection during multi-directional ray detection. A normal vector is a direction vector perpendicular to the surface at that point and is used to indicate the orientation of the surface. The average normal value is the average of the sum of all the normal vectors of the impact points obtained from multiple rays emitted from the same detection point.
[0203] In an optional embodiment, the ray impact point normal refers to the normal vector of the object's surface at the intersection point where the ray intersects the object's surface. It reflects the orientation of the object's surface at that point. For example, the normal vector of a wall is typically horizontal, while the normal vector of the ground is typically vertical. The terminal device can record the impact point normals of all rays emitted from each detection point and store these normal vectors in an array for subsequent calculations.
[0204] In an optional embodiment, the process of calculating the average normal vector involves performing vector addition on the impact point normals of all rays emitted from the same detection point, then dividing the result by the number of rays to obtain a normalized average normal vector. For example, if five rays are emitted from a detection point, resulting in five impact point normal vectors, the terminal device performs vector addition on these five normal vectors and divides them by 5 to obtain the average normal vector for that detection point. This process can be implemented using a three-dimensional vector calculation library to ensure the accuracy of the calculation results.
[0205] In a specific application, a terminal device performs multi-directional ray detection on a detection point. Suppose that five rays are emitted, three of which hit the wall with normal vectors of (1, 0, 0), (0.98, 0.2, 0), and (0.95, 0.31, 0). The other two rays hit the ground with normal vectors of (0, 0, 1) and (0, 0.1, 0.99). The terminal device adds these five normal vectors and divides them by 5, obtaining an average normal value of (0.586, 0.122, 0.398). This value is used for subsequent difference comparison analysis.
[0206] In step S112 , the difference between the normal average value and the normal of a single wall is compared.
[0207] The single wall normal refers to the standard normal vector when only the wall surface is considered. The normal difference refers to the degree of difference between the average normal vector and the single wall normal, which can be measured by the angle or distance between the vectors.
[0208] In an optional embodiment, a single wall normal is typically a horizontal unit vector that represents the orientation of the wall surface. In three-dimensional space, walls facing different directions have different normal directions. For example, the normal of an east-facing wall might be (1, 0, 0), while the normal of a north-facing wall might be (0, 1, 0). The terminal device can determine the value of the single wall normal by analyzing the geometric information of the building model or using a preset method.
[0209] In an optional embodiment, the normal difference can be compared by calculating the dot product between the average normal value and a single wall normal, or by calculating the angle between two vectors. The closer the dot product result is to 1, the more similar the directions of the two vectors are; similarly, the smaller the angle, the more similar the directions of the two vectors are. The terminal device can set a threshold; when the normal difference exceeds this threshold, it is considered that the detection point is likely located at the junction of the wall and the ground.
[0210] In one specific application, the terminal device compared the calculated average normal value (0.586, 0.122, 0.398) with the standard normal of the east-facing wall (1, 0, 0). The dot product of the two vectors yielded 0.586, which is significantly less than 1, indicating a significant difference between the two vectors. The terminal device also calculated the angle between the two vectors, which was approximately 54 degrees. This significant angular difference further confirms that the detection point is likely located at the junction of the wall and the ground.
[0211] In step S113 , it is determined whether the detection point is located at the junction of the wall and the ground based on the difference.
[0212] The wall-ground interface refers to the area where a building wall intersects the ground, typically a location with significant ambient light occlusion. The process of determining the location of a detection point involves analyzing normal differences to determine whether the detection point meets specific conditions, thereby identifying locations with specific environmental characteristics.
[0213] In an optional embodiment, the terminal device can set a normal difference threshold. When the difference between the calculated average normal and a single wall normal exceeds the threshold, the detection point is determined to be at the intersection of the wall and the ground. This difference indicates that the ray from the detection point simultaneously hits different surfaces (such as the wall and the ground), resulting in a significant change in the average normal.
[0214] In an optional embodiment, in addition to the normal difference, the terminal device may also combine other parameters to enhance the accuracy of the judgment, such as the ray impact distance, the spatial distribution of the impact points, etc. For example, when the normal difference reaches a threshold, if the height distribution of the ray impact points includes both low points close to the ground and high points on the wall, it is more certain that the detection point is located at the intersection.
[0215] In a specific application, the terminal device compares the difference between the previously calculated average normal value and the normal of a single wall (the point product value is 0.586, and the angle is approximately 54 degrees) with a preset threshold (such as 0.7 or 45 degrees). Because the difference exceeds the threshold, the terminal device determines that the detection point is located at the intersection of the wall and the ground. At the same time, the terminal device also checks the height distribution of the ray impact points and confirms that some impact points are at ground height and some impact points are at wall height, further verifying the accuracy of the judgment. Therefore, the detection point is marked as a target detection point and will be used for model generation in subsequent steps.
[0216] In a model generation method provided in one embodiment of the present application, generating a preset model at the target detection point position includes:
[0217] Step 121, obtaining a model list provided by the user;
[0218] Step 122 , creating a hierarchical instanced Static Mesh instance for each model type;
[0219] Step 123: randomly select a model from the model list at each target detection point position to instantiate and generate it.
[0220] Through the method provided in this embodiment, the terminal device can efficiently organize and manage the model resources specified by the user, and dynamically generate a variety of model instances at the calculated target location, thereby greatly improving the model generation efficiency and scenario richness. At the same time, by adopting hierarchical instantiation technology, the system resource consumption is effectively reduced, ensuring good operating performance in large-scale model generation scenarios.
[0221] The above scheme is described in detail below.
[0222] In step S121 , a model list provided by the user is obtained.
[0223] The model list is a collection data structure containing one or more models.
[0224] In an optional embodiment, the model list is a collection of 3D model resources available for generation, selected and provided by the user through a graphical interface or configuration file. For example, the terminal device may provide a model selection interface, where the user can select multiple models from a model library that they wish to generate within the scene, such as plants, objects, and decorations. These selected models will be added to the model list for subsequent use.
[0225] In an optional embodiment, the model list can contain models of different categories, and each category can be assigned a different generation weight or probability distribution to control the distribution ratio of different models in the final scene. For example, in the model list, a generation weight of 60% can be set for plant models, 30% for garbage models, and 10% for other decorations. The terminal device will then perform probabilistic sampling based on these weights when randomly selecting models.
[0226] In step S122 , a hierarchical instanced Static Mesh instance is created for each model type.
[0227] Among them, hierarchical instanced static mesh instances are a technical structure that optimizes the rendering and management of three-dimensional models.
[0228] In an optional implementation, hierarchical instanced Static Mesh instances are container objects used to efficiently manage and render large numbers of identical models. By batching model instances of the same type together, draw calls can be significantly reduced. For example, the device creates a dedicated instanced Static Mesh instance for each model type in the model list. This allows all instances of the same model type to be rendered as a single drawing unit, significantly reducing the GPU load.
[0229] In an optional implementation, hierarchical instanced Static Mesh instances can be further grouped based on the model's material properties, size range, or functional category, allowing for more granular control over the rendering and interactive behavior of model instances at different levels. For example, a terminal device could create a separate instanced Static Mesh instance for a model with a transparent material and another instanced Static Mesh instance for a model with an opaque material to optimize rendering order and depth sorting.
[0230] In step S123, a model in the model list is randomly selected at each target detection point position for instantiation generation.
[0231] Among them, instantiation generation refers to the process of creating a model object at a certain three-dimensional coordinate.
[0232] In an optional embodiment, the instantiation generation process includes randomly selecting a suitable model from a model list, creating an instance of that model at the target detection point, and applying the necessary spatial transformations. For example, at each target detection point determined to be an ambient occlusion area, the terminal device selects a model from the model list based on a random algorithm, then creates an instance of the selected model at that coordinate point, making it part of the scene.
[0233] In an optional embodiment, instance generation can also apply additional random variations, such as scaling, rotation, or slight position offsets, to increase the naturalness and realism of the scene. For example, when generating model instances, the terminal device can apply a random scale variation of ±15% and a random rotation of 0-360 degrees to each instance. This ensures that even the same model in different positions will have a different appearance, avoiding visual repetition.
[0234] In a specific application, the terminal device first receives a set of decoration models uploaded by the user through the interface, including various plant, rock, and debris models. Subsequently, the terminal device creates a dedicated hierarchical instantiated static mesh instance for each type of model (such as all plant models, all rock models). After completing the previous target detection point identification, the terminal device traverses each target detection point and randomly selects a suitable model at each point position. For example, a small plant model may be generated at a target detection point near a corner of a wall; a pile of debris models may be generated at a target detection point at the edge of a building. This automated model generation method makes the scene decoration process efficient and natural.
[0235] In a model generation method provided in an embodiment of the present application, randomly selecting a model from the model list at each target detection point position for instantiation generation includes:
[0236] Step S131, applying random scaling and rotation transformations to the generated model;
[0237] Step S132, detecting whether there is any interpenetration between the generated models;
[0238] Step S133: remove the models that intersect with each other.
[0239] The method provided in this embodiment enables the generated model to have a more natural visual effect and layout rationality. The diversity and realism of the model are increased through random scaling and rotation transformations. At the same time, the physical rationality of the layout of objects in the scene is ensured by detecting and removing models that intersperse with each other, thereby improving the quality and usability of the automatically generated model and reducing the workload of manual adjustment.
[0240] The above scheme is described in detail below.
[0241] In step S131 , random scaling and rotation transformations are applied to the generated model.
[0242] Scaling is the process of adjusting the size of a generated model. Scaling can enlarge or reduce the model in three dimensions: x, y, and z, thereby changing the size and proportions of the model.
[0243] In an optional embodiment, the scaling transformation can be calculated based on random values within a preset scaling range, which can be a user-defined interval. For example, the terminal device can randomly generate three scaling factors within the range of 0.8 to 1.2 and apply them to the length, width, and height dimensions of the model, respectively, so that the model maintains its basic shape while having a certain size change.
[0244] In an optional embodiment, the scaling transformation can set different scaling ranges and scaling strategies based on the model type. For example, the terminal device can set a larger height scaling range (e.g., 0.7 to 1.5) for plant models while maintaining a smaller width scaling range (e.g., 0.9 to 1.1) to simulate the diversity of plant heights in the real world. For stone models, similar scaling ranges (e.g., 0.8 to 1.3) can be used in all three dimensions to maintain the consistency of their shapes.
[0245] A rotation transform is an operation that changes the spatial orientation of the generated model. Rotation transforms can rotate the model around the x-axis, y-axis, and z-axis at different angles, thereby changing the model's orientation and posture.
[0246] In an optional embodiment, the rotation transformation can be represented and calculated using Euler angles or quaternions, rotating the model at random angles in three dimensions. For example, the terminal device can generate three random angle values, representing the rotation angles around the x-axis, y-axis, and z-axis, respectively, and then apply these rotations to the model in sequence to randomize its orientation.
[0247] In an optional embodiment, the rotation transformation can be adjusted specifically based on the characteristics of the model and environmental constraints. For example, the terminal device can perform a small angle rotation (e.g., within a range of ±15 degrees) on a plant model primarily on the y-axis (the axis perpendicular to the ground) to maintain its roughly vertical growth characteristics, while performing completely random rotations (0 to 360 degrees) on the horizontal plane (x-axis and z-axis) to increase the variation in viewing angles. For miscellaneous models with no obvious orientation requirements, completely random rotations can be performed on all three axes.
[0248] In step S132 , it is detected whether the generated models are intertwined with each other.
[0249] Interpenetration refers to the unintended overlap or intersection of two or more 3D models in space. This can create visual artifacts and violate physical rules, impacting the realism and plausibility of the scene.
[0250] In an alternative embodiment, interpenetration detection can be implemented using a collision volume detection mechanism, which compares the collision boundaries of different models to determine whether they overlap. For example, the terminal device can create a simplified collision box or collision sphere for each generated model and then check whether there is overlap between these collision volumes. If there is overlap, the models are considered to be interpenetrating.
[0251] In an optional implementation, interpenetration detection can employ a multi-layered detection strategy to improve detection efficiency and accuracy. For example, the terminal device can first use a fast but rough bounding box check to initially screen for model pairs that may interpenetrate. It can then perform a more precise but computationally expensive mesh collision check on these potentially interpenetrating model pairs to determine if they are truly interpenetrating. This layered detection approach can significantly reduce computational effort while maintaining detection accuracy.
[0252] In step S133 , the interpenetrating models are removed.
[0253] Removing interpenetrating models involves determining which models to retain and which to remove based on specific rules when two or more models overlap or intersect. This step ensures that all models in the resulting scene conform to physical rules and avoid unnatural interpenetration.
[0254] In an optional implementation, the removal of interleaved models can be selectively performed based on priority rules, with less important models being removed. For example, the terminal device can assign a priority score to each model based on factors such as its size, type, and generation order. When two models are found to be interleaved, the higher-priority model is retained and the lower-priority model is removed. This ensures that the most important elements of the scene are preserved.
[0255] In an optional implementation, intersecting models can be removed by attempting to adjust their positions rather than directly deleting them. For example, if a terminal device discovers that two models are intersecting, it can attempt to fine-tune the position of one model within a small range, such as finding a new position near the original location that will prevent intersecting models. Only if intersecting models cannot be avoided after multiple attempts at repositioning is the model considered for removal. This approach maximizes the preservation of generated models and improves the richness of the scene.
[0256] In a specific application, after the terminal device generates a set of models simulating vegetation in the ambient light occlusion area, it applies a random scaling factor to each newly generated vegetation model. For example, a shrub may be scaled to 0.9 times the height and 1.1 times the width of its original size, and a 15-degree y-axis rotation is applied to make it appear to be growing naturally. Subsequently, the terminal device detects that the shrub has a 25% volume overlap with a previously generated stone model, indicating that they are intertwined. The terminal device attempts to find an alternative position within 0.3 meters of the original position, but the intertwining cannot be avoided. Finally, according to the priority rule (assuming that the stone has a higher priority), it decides to remove the shrub model to ensure that all retained models in the final scene conform to the physical distribution law.
[0257] In a model generation method provided in an embodiment of the present application, the method further includes:
[0258] Receive user adjustments to the following parameters: one or more of the following: detection point density, number of rays, and ambient occlusion threshold;
[0259] Re-execute the model generation process based on the adjusted parameters.
[0260] The method provided in this embodiment enables the terminal device to flexibly respond to the user's personalized needs and update the model generation results in real time by adjusting key parameters, which not only improves the accuracy of the model distribution but also enhances the interactivity and ease of use of the system, thereby obtaining the best model generation effect in different application scenarios.
[0261] Parameter adjustment refers to the modification of key variables in the control model generation process. These parameters directly affect the number, distribution and judgment accuracy of the final generated model.
[0262] In an optional embodiment, the detection point density parameter is used to control the number of detection points generated within a specified spatial range. For example, the terminal device may provide a slider interface element, allowing the user to adjust the density value from the initial setting of 10 to 20. This means that the space will be divided more finely, increasing the number of detection points from the original 10×10×10=1000 to 20×20×20=8000, thereby achieving a more refined model distribution effect.
[0263] In an optional embodiment, the detection point density parameter can be adjusted through the graphical user interface, and its value range can be set to an integer between 1 and 100. For example, when the detection point density is set to a low value such as 5, the terminal device will generate a sparse distribution of detection points in space, which is suitable for quick preview or low-configuration device operation; when it is set to a high value such as 50, a very dense detection point network will be generated, which is suitable for professional scene production that requires precise model placement.
[0264] In an optional embodiment, the ray count parameter determines the number of rays emitted from each detection point to detect the surrounding environment. For example, the terminal device can allow the user to adjust the default number of rays from 5 to 8. In this way, the system will emit rays from each valid detection point in 8 different directions, collecting more comprehensive environmental information and improving the accuracy of identifying ambient light occlusion areas.
[0265] In an optional embodiment, the number of rays parameter can be set via a numeric input box, with a valid range typically between 3 and 20. For example, when set to 3, the terminal device only performs the most basic environmental detection, resulting in faster processing but lower accuracy. When set to 12 or more, a full range of environmental sampling is possible, which, while increasing the computational effort, significantly improves the accuracy and naturalness of model placement.
[0266] In an optional embodiment, the ambient light occlusion threshold is a critical value used to determine whether a detection point is located in an ambient light occlusion area. For example, the terminal device may allow the user to adjust the default threshold of 0.5 to 0.7, which means that the system will adopt a stricter standard for determining ambient light occlusion areas. Only areas with light blocked to a degree of at least 70% will be considered valid model placement locations.
[0267] In an optional embodiment, the ambient occlusion threshold can be adjusted using a percentage slider, with a value ranging from 0 to 1. For example, when the threshold is set to a lower value, such as 0.3, the terminal device will identify more potential ambient occlusion areas and generate more models; when it is set to a higher value, such as 0.8, the terminal device will only generate models in obvious corners or deep occlusion areas, resulting in fewer models but more accurate locations.
[0268] Re-executing the model generation process means clearing the previous calculation results according to the newly adjusted parameter values of the user, and re-performing a complete calculation and generation operation according to the complete model generation process.
[0269] In an optional embodiment, re-executing the model generation process includes clearing the existing model and executing the generation process with the new parameters. For example, upon receiving a user instruction to increase the detection point density from 10 to 20, the terminal device would first remove all existing model instances in the scene, then use the new density value of 20 to partition the space, generate a new set of detection points, and then continue the subsequent screening, detection, and model generation steps based on these points.
[0270] In one specific application, the terminal device allows users to adjust parameters in real-time preview mode. The user first adjusts the detection point density from the default value of 10 to 15, at which point the system immediately regenerates the detection points and displays their distribution. Next, the user increases the number of rays from 5 to 8, at which point the system recalculates the environmental detection results for each detection point. Finally, the user adjusts the ambient occlusion threshold from 0.5 to 0.6, at which point the system updates the model's distribution position in real time. Throughout this process, the terminal device continuously renders the scene, allowing users to intuitively see the impact of each parameter adjustment on the final result, helping them quickly find the parameter combination that best meets their desired effect.
[0271] In a model generation method provided in an embodiment of the present application, the method further includes:
[0272] Calculate the ambient light occlusion intensity value of each target detection point;
[0273] Dividing the target detection points into multiple levels according to the ambient light shielding intensity value;
[0274] Different model generation strategies are set according to different levels, including model distribution density and model type.
[0275] Through the method provided in this embodiment, the terminal device can intelligently adjust the model generation strategy based on different levels of ambient light occlusion intensity, thereby achieving a model generation effect that is more in line with the real natural distribution law, improving the visual realism and diversity of the generated model, and at the same time making the generated results more delicate and layered through hierarchical processing.
[0276] Among them, the ambient light shielding intensity value is a numerical indicator that represents the degree to which the target detection point is shielded by the surrounding buildings.
[0277] In an optional embodiment, the ambient light obstruction intensity value can be calculated by analyzing the ray detection results around the target detection point, indicating the degree to which ambient light is blocked by surrounding objects at that point. For example, based on the ray detection results, the terminal device can calculate the percentage of rays blocked around the target detection point. A higher percentage of blocked rays indicates a higher ambient light obstruction intensity value for that point. Alternatively, the terminal device can calculate the average distance between the hit point and the target detection point in the ray detection results. A closer distance indicates more severe obstruction and a higher ambient light obstruction intensity value.
[0278] In an optional embodiment, the ambient light occlusion intensity value can be obtained by normalizing the multi-directional ray detection results to a value between 0 and 1, where 0 represents complete unobstructedness and 1 represents complete obstruction. For example, the terminal device can calculate the proportion of rays from multiple directional rays emitted from the target detection point that are obstructed by buildings and use this proportion as the ambient light occlusion intensity value; or the terminal device can calculate the ambient light occlusion intensity value using a specific formula based on the distance relationship between the hit point detected by the ray and the target detection point.
[0279] In an optional embodiment, the levels can be divided by setting multiple threshold intervals for the ambient light occlusion intensity value, with different intervals corresponding to different level categories. For example, the terminal device can divide the ambient light occlusion intensity value into three levels: high, medium, and low, where 0-0.3 is a low occlusion level, 0.3-0.7 is a medium occlusion level, and 0.7-1 is a high occlusion level. Alternatively, the terminal device can set more level divisions based on actual needs, such as five or ten levels, to achieve more refined model generation control.
[0280] Among them, the model generation strategy is the model layout rules and parameter settings adopted for areas with different ambient light occlusion levels.
[0281] In an optional embodiment, the model generation strategy includes adjusting the distribution density of the models, increasing the model generation density in areas with high ambient light occlusion intensity and reducing the model generation density in areas with low ambient light occlusion intensity. For example, the terminal device may set a higher model generation probability for areas with high occlusion levels, thereby generating more models in deeply occluded areas such as building corners; or the terminal device may set a lower model generation probability for areas with low occlusion levels, thereby generating fewer models in open areas, thereby conforming to the distribution patterns of objects in nature.
[0282] In an optional embodiment, the model generation strategy further includes selecting different types of models based on the shade level, such that certain types of models are more likely to appear in areas with a certain degree of shade. For example, the terminal device may generate more shade-loving plants such as mosses and ferns, or waste accumulations, in areas with high shade levels; or it may generate more adaptable plants such as shrubs in areas with medium shade levels; and more sun-loving plants or artificially placed objects in areas with low shade levels.
[0283] In a specific application, the terminal device implements a differentiated model generation strategy based on the four previously divided shading levels. For heavily shading areas (0.75-1), the terminal device sets the highest model density (such as 100%) and mainly generates models such as moss, garbage accumulation, and debris; for moderately shading areas (0.5-0.75), medium-high density (such as 70%) is used and shrubs and small vegetation are generated; for lightly shading areas (0.25-0.5), medium-low density (such as 40%) is used and more decorative elements are generated; for slightly shading areas (0-0.25), the lowest density (such as 10%) is used and models suitable for open areas are mainly generated. This hierarchical generation strategy makes the final generated scene more in line with natural laws and the visual effects are richer and more diverse.
[0284] In a model generation method provided in an embodiment of the present application, the method further includes:
[0285] Introducing environmental attributes, including one or more of temperature, humidity, and terrain type;
[0286] Establishing a mapping relationship between the environmental attributes and the adaptability of different models;
[0287] According to the environmental attributes of each target detection point location, a model subset suitable for the environmental attributes is screened from the model library for generation.
[0288] Among them, environmental attributes are a set of parameters that describe the environmental characteristics of a specific area or location, and are used to characterize the natural conditions or physical state of the area.
[0289] In an optional embodiment, the environmental attributes may be numerical or categorical indicators that characterize the environmental conditions of a specific area, and are used to describe natural factors such as the climate conditions, terrain characteristics, etc. of the area. For example, the environmental attributes may include numerical attributes such as temperature (in degrees Celsius, such as 25°C) and humidity percentage (such as 65%), as well as categorical attributes such as terrain type (plain, mountainous, desert, etc.).
[0290] The mapping relationship is a set of corresponding rules between environmental attribute parameters and model adaptability scores, which is used to determine the adaptability of different models under various environmental conditions.
[0291] In an alternative embodiment, the mapping relationship can be a set of rules or mathematical functions used to convert environmental attribute values into a model suitability score, thereby determining whether a model is suitable for generation in a specific environment. For example, for a "moss" model, a mapping rule can be established: the suitability score is high when the humidity is greater than 70%, the suitability score is high when the temperature is between 5°C and 25°C, and the suitability score is high when the terrain type is rocky or tree trunk.
[0292] Among them, the model subset is a group of models selected from the complete model library based on environmental adaptability. These models are suitable for generation under specific environmental conditions.
[0293] In an optional embodiment, the model subset selection process includes calculating the adaptability score of each model under the current environmental conditions and selecting models with scores above a threshold as candidates for generation, thereby ensuring that the generated models are compatible with the environment. For example, for an area with a temperature of 30°C and a humidity of 20%, the system calculates the adaptability score of each model in the model library and selects models with scores above 0.7 (out of a maximum score of 1) to form a model subset suitable for that environment.
[0294] In one specific application, when processing a target point near a water source, with a temperature of 22°C, a humidity of 75%, and hilly terrain, the terminal device first obtains the environmental attribute data for the point. Then, based on pre-established mapping relationships, it calculates the adaptability score of each model in the model library. The system finds that the "fern," "moss," and "mushroom" models have scores of 0.92, 0.88, and 0.85, respectively, significantly higher than the other models. Therefore, these three models are selected to form a model subset. Finally, the system randomly selects one of the three models and generates an instance of that model at the target point to ensure that the generated model is consistent with the environmental conditions.
[0295] like Figure 5 A schematic diagram of a generation model is shown. In a specific application of this embodiment, the terminal device first creates an environmental attribute distribution map for the scene area, which includes data in three dimensions: temperature, humidity, and terrain type. For each target point determined, the terminal device reads the environmental parameters of the location. For example, at a corner of a wall, the temperature is detected to be 18°C, the humidity is 82%, and the terrain type is a stone ground. Subsequently, the terminal device queries the mapping table of environmental attributes and model adaptability, and finds that under such environmental conditions, mosses, lichens, and small ferns have the highest adaptability scores. Finally, the terminal device randomly selects one of these highly adaptable models and generates a corresponding model at the target point location, so that the generated model distribution is more in line with natural laws, enhancing the realism and immersion of the scene.
[0296] This exemplary embodiment also discloses a model generating device, Figure 6 FIG. 1 is a composition diagram of a model generation device in an exemplary embodiment of the present disclosure. Figure 6 As shown, the device includes:
[0297] An acquisition module is used to acquire a building model in a three-dimensional scene;
[0298] a range determination module, configured to determine a spatial range in the three-dimensional scene;
[0299] A detection point generation module, configured to generate a plurality of detection points within the spatial range according to a preset density;
[0300] A detection point screening module is used to screen the plurality of detection points, remove detection points located inside the building model, and obtain valid detection points;
[0301] A ray detection module is used to perform multi-directional ray detection on each of the effective detection points to obtain ray detection results;
[0302] an area recognition module, configured to recognize a target detection point located in an ambient light shielding area based on the ray detection result; and
[0303] The model generation module is used to generate a preset model at the target detection point position.
[0304] Optionally, obtaining the building model in the three-dimensional scene includes:
[0305] Receive user-provided building models; and / or
[0306] Generate a simplified building model.
[0307] Optionally, the method further comprises:
[0308] Assign specific physical material identifiers to building models to distinguish different objects during ray detection.
[0309] Optionally, determining a spatial range in the three-dimensional scene includes:
[0310] Create a bounding box as the spatial range;
[0311] Resizes the bounding box based on the volume size specified by the user.
[0312] Optionally, generating a plurality of detection points according to a preset density within the spatial range includes:
[0313] Divide the spatial range into multiple small blocks evenly according to the preset density value;
[0314] The three-dimensional coordinates of each small block are recorded as the detection point coordinates.
[0315] Optionally, screening multiple detection points includes:
[0316] Perform collision detection on each detection point to detect whether the detection point is inside the building model;
[0317] If the detection point is located inside the building model, the detection point will be marked as an invalid detection point.
[0318] Optionally, the method further comprises:
[0319] Generate a random seed;
[0320] Randomly fine-tune the position of the effective detection point according to the random seed to obtain the effective detection point after fine-tuning;
[0321] Among them, multi-directional ray detection is performed on each effective detection point, including:
[0322] Perform multi-directional ray detection on the effective detection points after fine-tuning.
[0323] Optionally, randomly fine-tuning the position of the valid detection point according to the random seed includes:
[0324] The position of each valid detection point is randomly offset within the range not exceeding the distance between adjacent detection points.
[0325] Optionally, performing multi-directional ray detection on each valid detection point includes:
[0326] Emitting rays from each valid detection point position in multiple preset directions;
[0327] Record the impact point position and impact point normal of each ray;
[0328] The number of the multiple preset directions is at least three.
[0329] Optionally, identifying a target detection point located in an ambient light shading area based on the ray detection result includes:
[0330] Analyze the ray detection results of each effective detection point;
[0331] Identify detection points that meet the following conditions as target detection points:
[0332] The rays detect the object;
[0333] The ray detection distance is greater than the preset threshold;
[0334] The detected object has a valid physical material; and
[0335] The rays detected the ground.
[0336] Optionally, identifying a target detection point located in an ambient light shielding area based on the ray detection result further includes:
[0337] Calculate the average value of the ray hitting point normal for each detection point;
[0338] Compare the difference between the normal average and the normal of a single wall;
[0339] Based on the difference, determine whether the detection point is located at the junction of the wall and the ground.
[0340] Optionally, generating a preset model at the target detection point location includes:
[0341] Get the list of models provided by the user;
[0342] Create hierarchical instanced Static Mesh instances for each model type;
[0343] At each target detection point, a model from the model list is randomly selected for instantiation.
[0344] Optionally, randomly selecting a model from the model list at each target detection point location for instantiation generation includes:
[0345] Apply random scaling and rotation transformations to the generated model;
[0346] Detect whether there is any interpenetration between the generated models;
[0347] Remove interpenetrating models.
[0348] Optionally, the method further comprises:
[0349] Receive user adjustments to the following parameters: one or more of the following: detection point density, number of rays, and ambient occlusion threshold;
[0350] Re-execute the model generation process based on the adjusted parameters.
[0351] Optionally, the method further comprises:
[0352] Calculate the ambient light occlusion intensity value of each target detection point;
[0353] The target detection points are divided into multiple levels according to the ambient light occlusion intensity value;
[0354] Different model generation strategies are set according to different levels, including model distribution density and model type.
[0355] Optionally, the method further comprises:
[0356] Introducing environmental attributes, including one or more of temperature, humidity, and terrain type;
[0357] Establish a mapping relationship between environmental attributes and the adaptability of different models;
[0358] According to the environmental attributes of each target detection point location, a model subset suitable for the environmental attributes is screened from the model library for generation.
[0359] The method provided in this embodiment enables automatic identification of ambient light occlusion areas based on the distribution characteristics of building models in a three-dimensional scene and generation of models at appropriate locations, eliminating the need for art engineers to manually place each small model. This significantly improves scene creation efficiency while ensuring the naturalness and realism of the generated model, in line with the distribution characteristics of objects in corners in natural laws.
[0360] The specific details of each module unit in the above embodiment have been described in detail in the corresponding model generation method. In addition, the model generation device also includes other unit modules corresponding to the model generation method, so they will not be repeated here.
[0361] It should be noted that although several modules or units of the device for action execution are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0362] Figure 7 FIG. 1 is a schematic diagram of a computer-readable storage medium in an exemplary embodiment of the present disclosure. Figure 7 FIG. 1 illustrates a program product 1100 according to an embodiment of the present disclosure, which stores a computer program that, when executed by a processor, implements the steps of the aforementioned model generation method. The method provided by this embodiment automatically identifies ambient light occlusion areas based on the distribution characteristics of building models in a three-dimensional scene and generates models in appropriate locations. This eliminates the need for art engineers to manually position each small model, significantly improving scene creation efficiency while ensuring the naturalness and realism of the generated models, consistent with the natural distribution characteristics of objects in corners.
[0363] A computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable storage medium may transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0364] The program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency, etc., or any suitable combination of the foregoing.
[0365] The following combination Figure 8The electronic device 1000 in this exemplary embodiment is described. The electronic device 1000 is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0366] See also Figure 8 As shown, electronic device 1000 is implemented as a general-purpose computing device. Components of electronic device 1000 may include, but are not limited to, at least one processor 1010, at least one memory 1020, a bus 1030 connecting various system components (including processor 1010 and memory 1020), and a display unit 1040.
[0367] The memory 1020 stores program code that can be executed by the processor 1010, causing the processor 1010 to execute the specific steps of the above-mentioned model generation method by executing the executable instructions. The method provided in this embodiment enables automatic identification of ambient light occlusion areas based on the distribution characteristics of building models in a three-dimensional scene and generation of models in appropriate locations, eliminating the need for art engineers to manually place each small model. This significantly improves scene creation efficiency while ensuring the naturalness and realism of the generated model, conforming to the distribution characteristics of objects in corners in nature.
[0368] The electronic device may further include: a power supply component configured to manage power for executing the electronic device; a wired or wireless network interface configured to connect the electronic device to the network; and an input / output (I / O) interface. The electronic device may operate based on an operating system stored in the memory, such as Android, iOS, Windows, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0369] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, an electronic device, or a network device, etc.) to execute the method according to the embodiments of the present invention.
[0370] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow from the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0371] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A model generation method, characterized in that: The method comprises: Obtain the building model in the three-dimensional scene; Determining a spatial range in the three-dimensional scene; Generating a plurality of detection points within the spatial range according to a preset density; Screening the plurality of detection points, eliminating detection points located inside the building model, and obtaining valid detection points; Perform multi-directional ray detection on each of the effective detection points to obtain ray detection results; Identifying a target detection point located in an ambient light shielding area based on the ray detection result; and A preset model is generated at the target detection point position.
2. The model generation method according to claim 1, characterized in that The obtaining of the building model in the three-dimensional scene comprises: Receive user-provided building models; and / or Generate a simplified building model.
3. The model generation method according to claim 1, characterized in that The method further comprises: A specific physical material identifier is assigned to the building model to distinguish different objects during ray detection.
4. The model generation method according to claim 1, characterized in that Determining a spatial range in the three-dimensional scene includes: Create a bounding box as the spatial range; The size of the bounding box is adjusted according to the volume size set by the user.
5. The model generation method according to claim 1, characterized in that: Generating a plurality of detection points within the spatial range according to a preset density includes: Evenly dividing the spatial range into a plurality of small blocks according to a preset density value; The three-dimensional coordinates of each small block are recorded as the detection point coordinates.
6. The model generation method according to claim 1, characterized in that: The screening of the plurality of detection points comprises: Performing collision detection on each detection point to detect whether the detection point is located inside the building model; If the detection point is located inside the building model, the detection point is marked as an invalid detection point.
7. The model generation method according to claim 1, characterized in that: The method further comprises: Generate a random seed; Randomly fine-tune the position of the effective detection point according to the random seed to obtain a fine-tuned effective detection point; The performing of multi-directional ray detection on each of the effective detection points includes: Multi-directional ray detection is performed on the effective detection points after fine-tuning.
8. The model generation method according to claim 7, characterized in that: The randomly fine-tuning the position of the effective detection point according to the random seed includes: The position of each valid detection point is randomly offset within the range not exceeding the distance between adjacent detection points.
9. The model generation method according to claim 1, characterized in that: The performing multi-directional ray detection on each of the effective detection points comprises: Emitting rays from each valid detection point position in multiple preset directions; Record the impact point position and impact point normal of each ray; Wherein, the number of the multiple preset directions is at least three.
10. The model generation method according to claim 1, characterized in that: The identifying of a target detection point located in an ambient light shielding area based on the ray detection result includes: Analyze the ray detection results of each effective detection point; Identify detection points that meet the following conditions as target detection points: The rays detect the object; The ray detection distance is greater than the preset threshold; The detected object has a valid physical material; and The rays detected the ground.
11. The model generation method according to claim 10, characterized in that: The identifying of the target detection point located in the ambient light shielding area based on the ray detection result further includes: Calculate the average value of the ray hitting point normal for each detection point; comparing the difference between the normal average and a single wall normal; Based on the difference, it is determined whether the detection point is located at the junction of the wall and the ground.
12. The model generation method according to claim 1, characterized in that: Generating a preset model at the target detection point position includes: Get the list of models provided by the user; Create hierarchical instanced Static Mesh instances for each model type; At each target detection point, a model in the model list is randomly selected for instantiation and generation.
13. The model generation method according to claim 12, characterized in that: The randomly selecting a model from the model list at each target detection point position to instantiate and generate the model comprises: Apply random scaling and rotation transformations to the generated model; Detect whether there is any interpenetration between the generated models; Remove interpenetrating models.
14. The model generation method according to claim 1, characterized in that: The method further comprises: Receive user adjustments to the following parameters: one or more of the following: detection point density, number of rays, and ambient occlusion threshold; Re-execute the model generation process based on the adjusted parameters.
15. The model generation method according to claim 1, characterized in that: The method further comprises: Calculate the ambient light occlusion intensity value of each target detection point; Dividing the target detection points into multiple levels according to the ambient light shielding intensity value; Different model generation strategies are set according to different levels, including model distribution density and model type.
16. The model generation method according to claim 1, characterized in that: The method further comprises: Introducing environmental attributes, including one or more of temperature, humidity, and terrain type; Establishing a mapping relationship between the environmental attributes and the adaptability of different models; According to the environmental attributes of each target detection point location, a model subset suitable for the environmental attributes is screened from the model library for generation.
17. A model generation device, characterized in that: The device comprises: An acquisition module is used to acquire a building model in a three-dimensional scene; a range determination module, configured to determine a spatial range in the three-dimensional scene; A detection point generation module, configured to generate a plurality of detection points within the spatial range according to a preset density; A detection point screening module is used to screen the plurality of detection points, remove detection points located inside the building model, and obtain valid detection points; A ray detection module is used to perform multi-directional ray detection on each of the effective detection points to obtain ray detection results; an area recognition module, configured to recognize a target detection point located in an ambient light shielding area based on the ray detection result; and The model generation module is used to generate a preset model at the target detection point position.
18. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the model generation method according to any one of claims 1 to 16 are implemented.
19. An electronic device comprising a processor and a memory, characterized in that: The memory stores a computer program, and when the processor executes the computer program, the steps of the model generation method according to any one of claims 1 to 16 are implemented.