Methods, devices, computer equipment, and storage media for generating virtual scenes
By acquiring street block types and density distribution maps to generate street block models in virtual scenes, the problem of low efficiency in building street block models in existing technologies is solved, achieving the effect of rapid generation and flexible modification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2026-03-06
AI Technical Summary
The use of real map data to assist in street planning in existing technologies results in low efficiency in building street models and high difficulty in modification.
By acquiring the street type distribution map and street density distribution map, vector points are determined and street dividing lines are generated. Based on this information, a street model in the virtual scene is generated.
It can quickly generate street block models with different urban styles without relying on existing urban data, and flexibly modify the street block distribution plan, thus improving the efficiency of street block model generation.
Smart Images

Figure CN115554697B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to a method, apparatus, computer device, and computer-readable storage medium (hereinafter referred to as storage medium) for generating virtual scenes. Background Technology
[0002] With the development of information technology, the realism of virtual scenes, such as game scenes, is receiving increasing attention. Urban block planning is a crucial step in virtual city modeling. To improve the realism of urban modeling in virtual scenes, current technologies typically use real map data to assist in block planning and construct block models. However, using real map data to assist in block planning has significant limitations; modifying the planned distribution of blocks is difficult, resulting in low efficiency in constructing block models. Summary of the Invention
[0003] Therefore, it is necessary to provide a method, apparatus, computer equipment, and storage medium for generating virtual scenes to address the aforementioned technical problems, thereby improving the efficiency of constructing street models in virtual scenes.
[0004] In a first aspect, this application provides a method for generating a virtual scene, the method comprising:
[0005] Obtain a street block type distribution map and a street block density distribution map;
[0006] Obtain the street type of each coordinate point in the target area from the street type distribution map, and obtain the street density information of each coordinate point in the target area from the street density distribution map;
[0007] Based on the street type and street density information of each coordinate point, vector points are determined within the target area and street dividing lines are generated between the vector points;
[0008] A street model in a virtual scene is generated based on street boundary lines.
[0009] Secondly, this application provides a virtual scene generation apparatus, the apparatus comprising:
[0010] The distribution map acquisition module is used to acquire street block type distribution maps and street block density distribution maps;
[0011] The street information acquisition module is used to obtain the street type of each coordinate point in the target area from the street type distribution map, and to obtain the street density information of each coordinate point in the target area from the street density distribution map.
[0012] The grid line construction module is used to determine vector points within the target area and generate street dividing lines between vector points based on the street type and street density information of each coordinate point.
[0013] The street block generation module is used to generate street block models in a virtual scene based on street block division lines.
[0014] Thirdly, this application also provides a computer device, which includes:
[0015] One or more processors;
[0016] Memory; and
[0017] One or more applications, wherein the applications are stored in memory and configured to be executed by a processor to implement a method for generating virtual scenes.
[0018] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute steps in a method for generating a virtual scene.
[0019] Fifthly, embodiments of this application provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in the first aspect described above.
[0020] The aforementioned method, apparatus, computer equipment, and storage medium for generating virtual scenes involve acquiring street block type distribution maps and street block density distribution maps; obtaining the street block type of each coordinate point within the target area from the street block type distribution map, and obtaining the street block density information of each coordinate point within the target area from the street block density distribution map; determining vector points within the target area and generating street block dividing lines between vector points based on the street block type and density information of each coordinate point; and generating street block models in the virtual scene based on the vector points and street block dividing lines. By using street block type distribution maps and street block density distribution maps, street block models with different urban style types can be quickly generated without relying on existing urban data input. Furthermore, by changing or modifying the street block type distribution maps and street block density distribution maps, the street block distribution plan of the street block model can be flexibly modified, reducing the difficulty of modifying the street block model and improving the generation efficiency of street block models in virtual scenes. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating the method for generating virtual scenes in the embodiments of this application;
[0023] Figure 2 This is a schematic diagram showing the distribution of street dividing lines for different street types in the embodiments of this application;
[0024] Figure 3 This is a block density distribution map and a schematic diagram of the corresponding block division lines in the embodiments of this application;
[0025] Figure 4 This is a flowchart illustrating the steps for obtaining street boundary lines in an embodiment of this application;
[0026] Figure 5 This is a schematic diagram of the distribution of street division lines and its street model in the embodiments of this application;
[0027] Figure 6 This is a schematic diagram of the vector point selection direction in an embodiment of this application;
[0028] Figure 7 This is a schematic diagram of the street model generation page in an embodiment of this application;
[0029] Figure 8 This application includes a street block type distribution map, a street block density distribution map, and a corresponding street block dividing line distribution diagram in the embodiments of this application.
[0030] Figure 9 This is a schematic diagram of the structure of the virtual scene generation device in the embodiments of this application;
[0031] Figure 10 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0033] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0034] In the description of this application, the word "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0035] The virtual scene generation method provided in this application embodiment can run on a terminal device or a server. The terminal device can be a local terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Taking the virtual scene generation method provided in this application embodiment as an example of applying it to a virtual city in a video game, the video game server can generate street models in the virtual city based on this virtual scene generation method, thereby rendering the game world.
[0036] This application provides a method for generating a virtual scene, see embodiments thereof. Figure 1 The method includes steps S110 to S140, as follows:
[0037] S110, obtain the street block type distribution map and the street block density distribution map.
[0038] The street block type distribution map controls the street block type of the final generated street block model at different locations. It is understood that street block types include at least grid-type, circle-type, and natural-type street block types; for example, see... Figure 2 Figure a shows a grid-type street block, which refers to a street block layout mostly composed of perpendicular horizontal and vertical lines. This type can be used to simulate modern-style urban blocks; see also... Figure 2 Figure b in the diagram shows a circular block type, which refers to a block layout generated radially from a central point. This type can be used to simulate urban blocks that evolved from ancient towns. See also... Figure 2 Figure c in the diagram shows a natural-type street block, which is formed by the convergence of different curved line segments. It can be used to simulate urban blocks developed in conjunction with non-plain terrains such as mountains.
[0039] Specifically, the street type distribution map can control the street type at the corresponding coordinate point (or coordinate position) of each pixel by controlling the pixel value of each pixel. For example, a first pixel threshold and a second pixel threshold can be preset. If the pixel value of a certain pixel is less than the first pixel threshold, the street type at the corresponding coordinate point of the pixel is a grid street type. If the pixel value is greater than or equal to the first pixel threshold and less than the second pixel threshold, the street type at the corresponding coordinate point of the pixel is a circle street type. If the pixel value is greater than or equal to the second pixel threshold, the street type at the corresponding coordinate point of the pixel is a natural street type. The street type distribution map can also control the street type at the corresponding coordinate point of each pixel by the specific values of each pixel in different color channels; for example, the R channel corresponds to the grid street type, the G channel corresponds to the natural street type, and the B channel corresponds to the circle street type. If the value of a pixel in the R channel is not 0, but the value in the G channel and the B channel is 0, then the street type at the coordinate point of that pixel is the grid street type. If the value of a pixel in the R channel and the B channel is not 0, but the value in the G channel is 0, then the street type at the coordinate point of that pixel is a mixed street type of grid street type and circle street type.
[0040] Among them, the street density distribution map is used to control the density of street dividing lines in the final street model generated at different locations. Specifically, the street type distribution map can control the street density information at the corresponding coordinate point (or coordinate position) of each pixel through the gray value or brightness value of each pixel. For example, when the gray value of a pixel is closer to 255, the street density information at the corresponding coordinate point of the pixel is smaller, and the density of the street dividing line at the corresponding position is low. When the gray value of a pixel is closer to 0, the street density information at the corresponding coordinate point of the pixel is larger, and the density of the street dividing line at the corresponding position is large.
[0041] The street type distribution map and street density distribution map can be obtained through user input or by retrieving them from a database. Specifically, in one embodiment, a user input interface can be provided, and in response to an image upload operation on the user input interface, the user-uploaded street type distribution map and street density distribution map can be obtained. Furthermore, the user-uploaded street distribution map can also be obtained through the user input interface, and the street type distribution map can be obtained based on the values of each pixel in the street distribution map on different color channels, and the street density distribution map can be obtained based on the grayscale value or brightness value of each pixel in the street distribution map.
[0042] S120: Obtain the street type of each coordinate point in the target area from the street type distribution map, and obtain the street density information of each coordinate point in the target area from the street density distribution map.
[0043] The target area refers to a region in the virtual scene from which the street model to be generated can be the spatial region currently displayed by the view or the spatial region currently being processed by the server. Specifically, the target area can be a region in a two-dimensional plane in the virtual scene, and its size can be the same as the size of the street category distribution map or the street density distribution map.
[0044] After obtaining the street type distribution map and the street density distribution map, the street type at each coordinate position in the target area can be determined based on the values of different color channels at each coordinate point in the street type distribution map, and the street density information at each coordinate point in the target area can be determined based on the gray values at each coordinate point in the street density distribution map.
[0045] In one embodiment, the step of obtaining the street type of each coordinate point in the target area from the street type distribution map includes: obtaining the value of each pixel in the street type distribution map in different color channels; and determining the street type of each coordinate point in the target area based on the value of each pixel in different color channels.
[0046] As shown above, the street type distribution map controls the street type at each pixel's corresponding coordinate point by controlling the specific values of each pixel in different color channels. For example, the R channel can correspond to a grid-type street type, the G channel to a natural-type street type, and the B channel to a circle-type street type. For any pixel, the values of that pixel in different color channels in the street type distribution map can be read, and then the street type corresponding to the color channel with the largest value can be selected as the street type at the corresponding coordinate point of that pixel in the target area.
[0047] For example, if a pixel has the following values in each color channel: R channel value is 150, G channel value is 130, and B channel value is 0, then the street type corresponding to the R channel can be determined as the street type of the corresponding coordinate point of the pixel in the target area.
[0048] In one embodiment, the step of obtaining the street density information of each coordinate point in the target area from the street density distribution map includes: obtaining the gray value of each pixel in the street density distribution map; and determining the street density information of each coordinate point in the target area based on the gray value of each pixel.
[0049] Among them, the street density information is used to control the density of street dividing lines in the street model. Specifically, it can be the probability value of forming street dividing lines by connecting different points. As shown above, the street density distribution map can control the street density information at the corresponding coordinate point (or coordinate position) of each pixel through the gray value of each pixel. Therefore, for any pixel, the gray value of that pixel in the street density distribution map can be read, and then the street density information at the corresponding coordinate point of that pixel in the target area can be determined based on the gray value.
[0050] For example, when the grayscale value is closer to 255, the street density information of the corresponding coordinate point of the pixel in the target area is closer to 0, meaning the probability of that coordinate point forming a street dividing line is lower; when the grayscale value is closer to 0, the street density information of the corresponding coordinate point of the pixel in the target area is closer to 1, meaning the probability of that coordinate point forming a street dividing line is higher. See also Figure 3 , Figure 3 Figure a is a schematic diagram of the street block type distribution map in one embodiment, and Figure b is a schematic diagram of the street block division lines corresponding to the street block density distribution map.
[0051] S130: Based on the street type and street density information of each coordinate point, determine vector points within the target area and generate street dividing lines between vector points.
[0052] Among them, vector points are used to construct street dividing lines and are points selected within the target area; street dividing lines are used to divide the target area and are tangible marked data in the target area, such as line segments such as straight lines and curves; specifically, street dividing lines can be the main roads of the street model in the virtual scene, and the road network data in the street model in the virtual scene can be constructed through street dividing lines.
[0053] It is understandable that the street dividing lines are presented as part of the final generated street model, while vector points are marker data that helps generate the street model in the virtual scene and may not be presented as part of the final generated street model.
[0054] After obtaining the street type and street density information of each coordinate point in the target area, vector points can be obtained in the target area based on the street type of each coordinate point. Then, based on the street density information of each vector point, street dividing lines between the vector points can be constructed. Specifically, in one embodiment, such as... Figure 4 As shown, the steps for determining vector points and generating street dividing lines between vector points within the target area based on the street type and street density information of each coordinate point include:
[0055] S410, determine the first vector point, and obtain the starting street type of the first vector point based on the street type corresponding to each coordinate point.
[0056] S420: Obtain the second vector point corresponding to the first vector point within the target area based on the starting street type.
[0057] S430, determine the current street density information corresponding to each second vector point based on the street density information corresponding to each coordinate point.
[0058] S440: Connect the first vector point and the second vector point based on the current street density information to obtain the street dividing line.
[0059] In this process, multiple rounds of point sampling are required within the target area to determine the vector point. The first vector point refers to the starting point of each round of sampling, i.e., the initial position of each round. Specifically, the first vector point can be the initial vector point obtained by randomly scattering points in the target area, or it can be the vector point obtained in the previous round of sampling, meaning the starting position of this round of sampling is the location of the vector point obtained in the previous round. After determining the first vector point, the starting street type of the first vector point can be determined from the street types corresponding to each coordinate point in the target area based on the coordinate position of the first vector point.
[0060] Different street block types have different vector point selection rules. For example, taking the grid-type street block as an example, a grid-type street block is usually composed of mutually perpendicular horizontal and vertical lines. In the vector point selection rules for the grid-type street block, the direction of the second vector point corresponding to the first vector point includes a first direction that is the same as the vector direction between the first vector point and the previous vector point, and a second direction that is perpendicular to the first direction. As another example, taking the natural street block as an example, in the vector point selection rules for the natural street block, the direction of the second vector point corresponding to the first vector point includes a first direction that is the same as the vector direction between the first vector point and the previous vector point, and a second direction that is within 30 degrees of the first direction.
[0061] To facilitate the generation of street models of different street types, the generation method of street models of different street types can be declared using the vector point selection rules corresponding to different street types. After obtaining the starting street type of the first vector point, the second vector point corresponding to the first vector point can be obtained in the target area according to the vector point selection rules corresponding to the first vector point, so as to achieve rapid acquisition of vector points.
[0062] Specifically, in one embodiment, the step of obtaining the second vector point corresponding to the first vector point within the target area according to the starting street type includes: obtaining the vector point selection rules corresponding to the starting street type; obtaining the selection direction of the next vector point corresponding to the first vector point based on the pseudo-random function and the vector point selection rules corresponding to the starting street type; and obtaining the coordinate data of the second vector point according to the coordinate data of the first vector point and the selection direction.
[0063] The vector point selection rule can be used to control the proportion of the next vector point corresponding to the first vector point moving forward or turning left or right along the vector direction of the first vector point. Specifically, the vector point selection rule may include vector point configuration parameters, which may include, but are not limited to, the probability value of the next vector point corresponding to the first vector point in the first direction and the probability value in the second direction. The probability value in the first direction represents the probability value of the next vector point moving forward along the vector direction of the first vector point, and the probability value in the second direction represents the probability value of the next vector point turning left or right along the vector direction of the first vector point.
[0064] For example, taking the grid-type street block type as an example, in the vector point selection rules corresponding to the grid-type street block type, the vector direction of the first vector point refers to the vector direction between the first vector point and the previous vector point. The vector point configuration parameters corresponding to the grid-type street block type include the probability value that the selection direction of the next vector point is the same as the first vector point and the vector direction between the first vector point and the previous vector point, and the probability value that the selection direction of the next vector point is the second direction perpendicular to the vector direction between the first vector point and the previous vector point (that is, the angle of the next vector point turning left or right along the vector direction of the first vector point is 90 degrees).
[0065] For example, taking the natural type of street as an example, in the vector point selection rules corresponding to the natural type of street, the vector direction of the first vector point refers to the vector direction between the first vector point and the previous vector point. The vector point configuration parameters corresponding to the natural type of street include the probability value that the selection direction of the next vector point is the same as the first vector direction between the first vector point and the previous vector point, and the probability value that the selection direction of the next vector point is the second direction whose angle with the vector direction between the first vector point and the previous vector point is within ±30 degrees (that is, the angle range of the next vector point turning left and right along the vector direction of the first vector point is -30° to 30°).
[0066] For example, taking the circular block type as an example, in the vector point selection rules corresponding to the circular block type, the vector direction of the first vector point refers to the vector direction between the first vector point and the starting vector point. The vector point configuration parameters for the circular block type include the probability value that the selection direction of the next vector point is the same as the first vector point and the vector direction between the first and starting vector points (the first direction), and the probability value that the selection direction of the next vector point is the tangent direction of the circle with the first and starting vector points as radii (i.e., the second direction). It should be noted that in the circular block type model, when it is determined that the next vector point will turn left or right along the vector direction of the first vector point, a second vector point is added in the tangent direction of the circle.
[0067] After obtaining the vector point selection rules for the first vector point, a pseudo-random function can be used to determine whether to select the next vector point corresponding to the first vector point along the vector direction of the first vector point (i.e., the first direction), and whether to select the next vector point corresponding to the first vector point in the second direction after rotating left or right from the vector direction of the first vector point, thus determining the selection direction. Specifically, a first random number and a second random number can be obtained based on the pseudo-random function. If the first random number is within the probability value corresponding to the first direction, then the first direction is determined as the selection direction; if the first random number is not within the probability value of the first direction, then the first direction is not the selection direction. If the second random number is within the probability value of the second direction, then the second direction is determined as the selection direction; if the second random number is not within the probability value of the second direction, then the second direction is not the selection direction.
[0068] After determining the direction of point selection, the coordinates of the second vector point are obtained based on the coordinates of the first vector point and the direction of point selection. Further, after obtaining the second vector point, it can be used as a new first vector point, and the above steps are repeated to obtain the second vector point corresponding to the new first vector point. Then, the new first vector point and the new second vector point are connected according to the street density information corresponding to the new second vector point to obtain the street dividing line. This process is repeated until the obtained second vector point exceeds the range of the target area.
[0069] After obtaining the second vector point corresponding to the first vector point, for any given second vector point, the current street density information of that second vector point is determined based on its coordinate position. Then, based on the current street density information, it is determined whether to connect the second vector point to the first vector point to construct a street dividing line. Specifically, in one embodiment, the street density information includes connection probability values. Connecting the first and second vector points based on the current street density information yields the street dividing line. Specifically, this can be achieved by first calculating the probability value of connecting the second and first vector points using a pseudo-random function. If the probability value of connecting the second and first vector points is within the connection probability value corresponding to the current street density information, then the second and first vector points are connected to obtain the street dividing line. It is understood that if the probability value of connecting the second and first vector points is not within the connection probability value corresponding to the current street density information, then the second and first vector points are not connected.
[0070] S140 generates a street model in a virtual scene based on street dividing lines.
[0071] After obtaining the street boundary lines, a street model within the virtual scene is constructed based on the street boundary lines within the target area; for example, see Figure 5 , Figure 5The left image shows a schematic diagram of the street boundary lines within the target area, while the right image is a schematic diagram of the street model built based on these boundary lines. It is understandable that the generated street model can have various uses, such as for film and television special effects, game scene construction, and so on.
[0072] Furthermore, to increase the richness of road details in the street model, in one embodiment, before the step of generating the street model in the virtual scene based on the street dividing lines, the method further includes: obtaining the point selection direction of each vector point; using each vector point as a target vector point; if the point selection direction of the target vector point is the same as the point selection direction of the previous vector point corresponding to the target vector point, generating secondary vector points in the target area with the target vector point as the starting point; connecting the secondary vector points to obtain the road grid lines in the target area; the step of generating the street model in the virtual scene based on the street dividing lines includes: generating the street model in the virtual scene based on the street dividing lines and the road grid lines.
[0073] Here, the direction of a vector point refers to its position relative to the previous vector point; for example, see [link to relevant documentation]. Figure 6 , Figure 6 Vector point A is used as the first vector point. Vector point B can be determined based on vector point A. Vector point C and D can be determined based on vector point B. The direction of vector point B is direction 1, the direction of vector point C is direction 2, and the direction of vector point D is direction 3. It can be understood that the direction of vector point A as the starting vector point can be null.
[0074] After obtaining the selection direction of each vector point, each vector point is used as a target vector point. When the selection direction of a target vector point is the same as the selection direction of the previous vector point corresponding to the target vector point, a secondary vector point is generated within the target area, starting from the target vector point. Specifically, secondary vector points can be obtained by using the target vector point as the starting point and the direction perpendicular to the selection direction of the target vector point as the selection direction. Continuing with... Figure 6 For example, the direction of vector point B is direction 1, and the direction of vector point D is direction 3. Since direction 1 and direction 3 are the same, we can take vector point D as the starting point and obtain secondary vector points in the direction perpendicular to direction 3.
[0075] Furthermore, after obtaining a secondary vector point by taking the target vector point as the starting point and the direction perpendicular to the direction of taking the target vector point as the taking direction, a new secondary vector point can be obtained by taking the same secondary vector point as the starting point and the direction perpendicular to the direction of taking the secondary vector point as the new taking direction. The above steps are repeated to obtain multiple secondary vector points within the target area.
[0076] In this context, road grid lines refer to secondary roads in the street block model within the virtual scene. After obtaining secondary vector points, these points are sequentially connected to construct the road grid lines within the target area. Specifically, the street block density information corresponding to each secondary vector point can be determined based on the street block density information corresponding to each coordinate point within the target area. Then, based on the street block density information corresponding to each secondary vector point, these points are sequentially connected to construct the road grid lines. Finally, a street block model in the virtual scene is generated based on the street block division lines and the road grid lines.
[0077] The method for generating the aforementioned virtual scene involves obtaining a street block type distribution map and a street block density distribution map; extracting the street block type of each coordinate point within the target area from the street block type distribution map, and obtaining the street block density information of each coordinate point within the target area from the street block density distribution map; determining vector points within the target area based on the street block type and density information of each coordinate point, and generating street block dividing lines between the vector points; and generating a street block model in the virtual scene based on the vector points and street block dividing lines. By using the street block type distribution map and the street block density distribution map, street block models with different urban style types can be quickly generated without relying on existing urban data input. Furthermore, by changing or modifying the street block type distribution map and the street block density distribution map, the street block distribution plan of the street block model can be flexibly modified, reducing the difficulty of modifying the street block model and improving the generation efficiency of street block models in the virtual scene.
[0078] The method for generating virtual scenes provided in this application embodiment will be further explained below with reference to a specific application scenario. Specifically, the method for generating virtual scenes will be explained using a terminal as an example.
[0079] Step 1, the terminal provides information such as... through the display device. Figure 7 The interactive interface shown is used to display the street model generation page. The street model generation page includes a first image input control 701, a second image input control 702, a first vector point selection rule adjustment control 703 for grid-type streets, a second vector point selection rule adjustment control 704 for natural-type streets, a third vector point selection rule adjustment control 705 for center-type streets, a street model preview control 706, and a street model generation control 707.
[0080] The first image input control 701 is used to upload a street block type distribution map; the second image input control 702 is used to upload a street block density distribution map; the first vector point selection rule adjustment control 703, the second vector point selection rule adjustment control 704, and the third vector point selection rule adjustment control 705 are used to adjust the parameters in the vector point selection rules for different street block types, respectively. Specifically, the size parameter is the size of each street block type; the larger the value, the larger the street block per unit area. The turning parameter is the probability value of the next vector point corresponding to the first vector point turning left or right along the vector direction of the first vector point; the larger the value, the smaller the probability value. The street block model preview control 706 is used to generate a street block model preview image, and the street block model generation control 707 is used to generate a street block model.
[0081] Step 2: After receiving the street type distribution map selection instruction triggered by the user through the first image input control 701 on the street model generation page, the terminal can obtain the street type distribution map corresponding to the street type distribution map selection instruction; in addition, after receiving the street density distribution map selection instruction triggered by the user through the second image input control 702 on the street model generation page, the terminal can obtain the street density distribution map corresponding to the street density distribution map selection instruction.
[0082] Step 3: The terminal acquires the values of each pixel in the street type distribution map across different color channels; based on the values of each pixel in different color channels, the street type of each coordinate point within the target area is determined. Simultaneously, the grayscale value of each pixel in the street density distribution map is acquired; based on the grayscale value of each pixel, the street density information of each coordinate point within the target area is determined.
[0083] Step 4: After obtaining the street type and street density information of each coordinate point in the target area, the terminal determines vector points in the target area and generates street dividing lines between vector points based on the street type and street density information of each coordinate point.
[0084] Specifically, points can be randomly scattered within the target area, and the points obtained from this scattering can be used as starting vector points. Then, the starting vector points are used as the first vector points. After obtaining the starting street type of the first vector point based on the street type corresponding to each coordinate point, the second vector point corresponding to the first vector point is obtained within the target area according to the starting street type. It can be understood that after obtaining the second vector point corresponding to the starting vector point, the obtained second vector point can be used as the new first vector point, and the process of obtaining the second vector point corresponding to the new first vector point continues, realizing a new round of vector point selection. This process is repeated for multiple rounds of vector point selection until the obtained second vector point exceeds the range of the target area.
[0085] Taking a grid-type street block as an example, the vector between the first vector point and the previous vector point can be obtained based on the coordinate data of the first vector point, and the point selection parameters in the first direction and the second direction can be obtained based on the vector. Then, the probability value of the next vector point corresponding to the first vector point in the first direction and the probability value in the second direction can be obtained through a pseudo-random function. Here, the first direction refers to the same direction as the vector direction between the first vector point and the previous vector point, and the second direction refers to the direction perpendicular to the vector direction between the first vector point and the previous vector point.
[0086] If the first random number falls within the probability value corresponding to the first direction, then the first direction is determined as the point selection direction, and the coordinate data of the second vector point is obtained based on the coordinate data of the first vector point and the point selection parameters in the first direction; specifically, the coordinate data of the second vector point in the first direction can be obtained through the following pseudocode:
[0087] V=random(Min,Max)*previous_vertor
[0088] Random_number1=random(0,100)
[0089] ifRandom_number1 <pforward
[0090] k = vertex(vertex.coords + V)
[0091] Where V represents the point selection parameter in the first direction; Min and Max are preset parameters, and random(Min, Max) represents a random value between parameters Min and Max, used to adjust the distance between the second vector point and the first vector point; previous_vertor represents the vector between the first vector point and the previous vector point; it can be understood that V refers to adjusting the size of the vector between the first vector point and the previous vector point based on a random value between parameters Min and Max. Random_number1 represents the first random number; pforward represents the probability value corresponding to the first direction; k represents the coordinate data of the second vector point; vertex.coords represents the coordinate data of the first vector point.
[0092] Similarly, if the second random number falls within the probability value of the second direction, then the second direction is determined as the point-taking direction. Based on the coordinate data of the first vector point and the point-taking parameters in the second direction, the coordinate data of the second vector point is obtained. Specifically, the coordinate data of the second vector point in the second direction can be obtained through the following pseudocode:
[0093] N=np.array(previous_vertor[1], previous_vertor[0])
[0094] Random_number2=random(0,100)
[0095] ifRandom_number1 <pturn
[0096] k1 = vertex(vertex.coords + N)
[0097] k2 = vertex(vertex.coords - N)
[0098] Where N represents the point selection parameter in the second direction, previous_vertor represents the vector between the first vector point and the previous vector point, Random_number2 represents the second random number, pturn represents the probability value corresponding to the second direction, k1 and k2 represent the coordinate data of two different second vector points respectively; vertex.coords represents the coordinate data of the first vector point.
[0099] For the center-type street block, the method for obtaining the second vector point is similar to that for the grid-type street block. The difference is that the first direction refers to the direction of the vector between the first vector point and the starting vector point, while the second direction refers to the tangent direction of the circle with the first vector point and the starting vector point as its radii. Specifically, the coordinate data of the second vector point in the second direction can be obtained through the following pseudocode:
[0100] k1=vertex(vertex.coords+rotate(30,V))
[0101] k2=vertex(vertex.coords-rotate(30,V))
[0102] Where V = random(Min, Max) * previous_vertor, V represents the point selection parameter in the first direction; Min and Max are preset parameters used to adjust the distance between the second vector point and the first vector point; previous_vertor represents the vector between the first vector point and the previous vector point, k1 and k2 represent the coordinate data of two different second vector points; vertex.coords represents the coordinate data of the first vector point.
[0103] For the natural block type, the method for obtaining the second vector point is similar to that for the grid block type, the only difference being the second direction. In the natural block type, the second direction refers to the direction that is the same as the vector direction between the first vector point and the starting vector point. The second direction refers to the direction whose angle with the vector direction between the first vector point and the previous vector point is within ±30 degrees. Specifically, each time the second vector point in the second direction is calculated, the target direction can be determined by a pseudo-random function within ±30 degrees of the vector direction between the first vector point and the previous vector point, and this target direction is used as the selection direction for the second vector point in this round of vector point selection.
[0104] After obtaining all vector points in the target area, for the first and second vector points in each round of vector point acquisition, the current street density information corresponding to each second vector point can be determined based on the street density information corresponding to each coordinate point. Then, the first and second vector points are connected according to the current street density information to obtain the street dividing line.
[0105] Step 5: Take each vector point as the target vector point and obtain the direction of the target vector point; if the direction of the target vector point is the same as the direction of the previous vector point corresponding to the target vector point, generate secondary vector points in the target area starting from the target vector point; connect the secondary vector points to obtain the road grid lines in the target area.
[0106] Specifically, if a vector point is located in the first direction of the previous vector point, then that vector point serves as the starting point for the growth of secondary roads (i.e., road grid lines). Taking a grid-type street block as an example, during the vector point selection process for the grid-type street block, the second vector point selected in the first direction corresponding to the first vector point is added to a target queue. After the vector point selection is completed, the vector points in the target queue are used as starting points to generate secondary vector points within the target area.
[0107] Step 6: The terminal responds to the user's touch operation on the street model preview control 706 on the street model generation page and outputs the street model preview image through the display device.
[0108] See Figure 8 , Figure 8 Figure a shows the distribution of street types input by the user, Figure b shows the distribution of street density input by the user, and Figure c shows a preview of the street model corresponding to Figure a and Figure b.
[0109] Step 7: The terminal responds to the user's touch operation on the street model generation control 707 on the street model generation page, and generates a street model in the virtual scene based on the street division lines and road grid lines.
[0110] After obtaining a preview image of the street model that meets the expected results, the corresponding street model can be generated directly. See [link / reference]. Figure 5 , Figure 5 The diagram shows a schematic of the street block model.
[0111] In the aforementioned method for generating virtual scenes, the generation of different street types is controlled by a street type distribution map, and the distribution density of streets is controlled by a street density distribution map. A preview image of the street model can be displayed intuitively, such as a schematic diagram of street boundary lines, facilitating rapid modification and iteration. After obtaining a preview image of the street model that meets the expected effect, the corresponding street model can be directly generated, making it convenient for use in other graphics production software and improving the efficiency of street model generation. Furthermore, the street type distribution map and street density distribution map can be overlaid with other data in the virtual scene, such as terrain height maps and vegetation distribution density maps, to accurately generate the corresponding street model.
[0112] To better implement the virtual scene generation method provided in the embodiments of this application, based on the virtual scene generation method proposed in the embodiments of this application, the embodiments of this application also provide a virtual scene generation apparatus, such as... Figure 9 As shown, the virtual scene generation device 900 includes:
[0113] The distribution map acquisition module 910 is used to acquire the street block type distribution map and the street block density distribution map;
[0114] The street information acquisition module 920 is used to obtain the street type of each coordinate point in the target area from the street type distribution map, and to obtain the street density information of each coordinate point in the target area from the street density distribution map;
[0115] The grid line construction module 930 is used to determine vector points within the target area and generate street dividing lines between vector points based on the street type and street density information of each coordinate point.
[0116] The street block generation module 940 is used to generate street block models in a virtual scene based on street block division lines.
[0117] In some embodiments of this application, the street information acquisition module 920 is specifically used to acquire the values of each pixel in the street type distribution map in different color channels; and to determine the street type of each coordinate point in the target area based on the values of each pixel in different color channels.
[0118] In some embodiments of this application, the street information acquisition module 920 is specifically used to acquire the grayscale value of each pixel in the street density distribution map; and to determine the street density information of each coordinate point in the target area based on the grayscale value of each pixel.
[0119] In some embodiments of this application, the grid line construction module 930 is specifically used to determine a first vector point and obtain the starting street type of the first vector point based on the street type corresponding to each coordinate point; obtain a second vector point corresponding to the first vector point in the target area according to the starting street type; determine the current street density information corresponding to each second vector point based on the street density information corresponding to each coordinate point; and connect the first vector point and the second vector point according to the current street density information to obtain the street dividing line.
[0120] In some embodiments of this application, the grid line construction module 930 is specifically used to obtain the vector point selection rules corresponding to the starting street type; based on the pseudo-random function and the vector point selection rules corresponding to the starting street type, obtain the selection direction of the next vector point corresponding to the first vector point; and obtain the coordinate data of the second vector point according to the coordinate data of the first vector point and the selection direction.
[0121] In some embodiments of this application, the street density information includes connection probability values; the grid line construction module 930 is specifically used to calculate the probability value of the connection between the second vector point and the first vector point based on a pseudo-random function; if the probability value of the connection between the second vector point and the first vector point is within the connection probability value corresponding to the current street density information, then the second vector point and the first vector point are connected to obtain the street dividing line.
[0122] In some embodiments of this application, the grid line construction module 930 is further configured to obtain the point selection direction of each target vector point using each vector point as a target vector point; if the point selection direction of the target vector point is the same as the point selection direction of the previous vector point corresponding to the target vector point, generate secondary vector points in the target area starting from the target vector point; connect the secondary vector points to obtain the road grid lines in the target area; and the street block module generation module is configured to generate a street block model in the virtual scene based on the street block division lines and the road grid lines.
[0123] Specific limitations regarding the virtual scene generation device can be found in the limitations on the virtual scene generation method described above, and will not be repeated here. Each module in the aforementioned virtual scene generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0124] In some embodiments of this application, the virtual scene generation apparatus 900 can be implemented as a computer program, which can be implemented in, for example... Figure 10 The computer device shown is running the program. The computer device's memory can store the various program modules that make up the virtual scene generation device 900, for example, Figure 9 The diagram shows a distribution map acquisition module 910, a street information acquisition module 920, a grid line construction module 930, and a street module generation module 940. The computer program comprised of these modules causes the processor to execute the steps in the virtual scene generation methods of the various embodiments of this application described in this specification.
[0125] For example, Figure 10 The computer device shown can be used as follows Figure 9 The distribution map acquisition module 910 in the virtual scene generation apparatus 900 executes step S110. The computer device can execute step S120 via the street information acquisition module 920. The computer device can execute step S130 via the grid line construction module 930. The computer device can execute step S140 via the street module generation module 940. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with external computer devices via a network connection. When the computer program is executed by the processor, it implements a method for generating a virtual scene.
[0126] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0127] In some embodiments of this application, a computer device is provided, including one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor as follows:
[0128] Obtain a street block type distribution map and a street block density distribution map;
[0129] Obtain the street type of each coordinate point in the target area from the street type distribution map, and obtain the street density information of each coordinate point in the target area from the street density distribution map;
[0130] Based on the street type and street density information of each coordinate point, vector points are determined within the target area and street dividing lines are generated between the vector points;
[0131] A street model in a virtual scene is generated based on street boundary lines.
[0132] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: obtaining the values of each pixel in the street type distribution map in different color channels; and determining the street type of each coordinate point in the target area based on the values of each pixel in different color channels.
[0133] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: obtaining the grayscale value of each pixel in the street density distribution map; and determining the street density information of each coordinate point in the target area based on the grayscale value of each pixel.
[0134] In some embodiments of this application, when the processor executes the computer program, it further implements the following steps: determining a first vector point and obtaining the starting street type of the first vector point based on the street type corresponding to each coordinate point; obtaining a second vector point corresponding to the first vector point in the target area according to the starting street type; determining the current street density information corresponding to each second vector point based on the street density information corresponding to each coordinate point; and connecting the first vector point and the second vector point according to the current street density information to obtain the street dividing line.
[0135] In some embodiments of this application, when the processor executes the computer program, it further implements the following steps: obtaining the vector point selection rules corresponding to the starting street type; obtaining the selection direction of the next vector point corresponding to the first vector point based on the pseudo-random function and the vector point selection rules corresponding to the starting street type; and obtaining the coordinate data of the second vector point according to the coordinate data of the first vector point and the selection direction.
[0136] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: calculating the probability value of the connection between the second vector point and the first vector point based on a pseudo-random function; if the probability value of the connection between the second vector point and the first vector point is within the connection probability value corresponding to the current street density information, then connecting the second vector point and the first vector point to obtain the street dividing line.
[0137] In some embodiments of this application, when the processor executes the computer program, it further implements the following steps: taking each vector point as a target vector point and obtaining the point selection direction of the target vector point; if the point selection direction of the target vector point is the same as the point selection direction of the previous vector point corresponding to the target vector point, generating a secondary vector point in the target area with the target vector point as the starting point; connecting the secondary vector points to obtain the road grid lines in the target area; and generating a street model in the virtual scene based on the street division lines and the road grid lines.
[0138] In some embodiments of this application, a computer-readable storage medium is provided, storing a computer program that is loaded by a processor, causing the processor to perform the following steps:
[0139] Obtain a street block type distribution map and a street block density distribution map;
[0140] Obtain the street type of each coordinate point in the target area from the street type distribution map, and obtain the street density information of each coordinate point in the target area from the street density distribution map;
[0141] Based on the street type and street density information of each coordinate point, vector points are determined within the target area and street dividing lines are generated between the vector points;
[0142] A street model in a virtual scene is generated based on street boundary lines.
[0143] In some embodiments of this application, when the computer program is executed by the processor, it further performs the following steps: obtaining the values of each pixel in the street type distribution map in different color channels; and determining the street type of each coordinate point in the target area based on the values of each pixel in different color channels.
[0144] In some embodiments of this application, when the computer program is executed by the processor, it also performs the following steps: obtaining the grayscale value of each pixel in the street density distribution map; and determining the street density information of each coordinate point in the target area based on the grayscale value of each pixel.
[0145] In some embodiments of this application, when the computer program is executed by the processor, it further performs the following steps: determining a first vector point and obtaining the starting street type of the first vector point based on the street type corresponding to each coordinate point; obtaining a second vector point corresponding to the first vector point in the target area according to the starting street type; determining the current street density information corresponding to each second vector point based on the street density information corresponding to each coordinate point; and connecting the first vector point and the second vector point according to the current street density information to obtain the street division line.
[0146] In some embodiments of this application, when the computer program is executed by the processor, it further implements the following steps: obtaining the vector point selection rules corresponding to the starting street type; obtaining the selection direction of the next vector point corresponding to the first vector point based on the pseudo-random function and the vector point selection rules corresponding to the starting street type; and obtaining the coordinate data of the second vector point according to the coordinate data of the first vector point and the selection direction.
[0147] In some embodiments of this application, when the computer program is executed by the processor, it further implements the following steps: calculating the probability value of the connection between the second vector point and the first vector point based on a pseudo-random function; if the probability value of the connection between the second vector point and the first vector point is within the connection probability value corresponding to the current street density information, then connecting the second vector point and the first vector point to obtain the street dividing line.
[0148] In some embodiments of this application, when the computer program is executed by the processor, it further implements the following steps: taking each vector point as a target vector point and obtaining the point selection direction of the target vector point; if the point selection direction of the target vector point is the same as the point selection direction of the previous vector point corresponding to the target vector point, generating secondary vector points in the target area with the target vector point as the starting point; connecting the secondary vector points to obtain the road grid lines in the target area; and generating a street model in the virtual scene based on the street division lines and the road grid lines.
[0149] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0150] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0151] The foregoing has provided a detailed description of a method, apparatus, computer device, and storage medium for generating a virtual scene according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method of generating a virtual scene, characterized by, The method comprises the following steps: obtaining a block type distribution map and a block density distribution map; obtaining the block type of each coordinate point in a target area from the block type distribution map and obtaining the block density information of each coordinate point in the target area from the block density distribution map; determining a vector point in the target area and generating a block division line between the vector points based on the block type and the block density information of each coordinate point; generating a block model in a virtual scene based on the block division line; wherein the step of obtaining the block type of each coordinate point in the target area from the block type distribution map comprises: obtaining the value of each pixel point in the block type distribution map on different color channels; determining the block type of each coordinate point in the target area according to the value of each pixel point on different color channels; alternatively, the step of obtaining the block type of each coordinate point in the target area from the block type distribution map comprises: determining the block type of each coordinate point in the target area through the pixel value corresponding to each pixel point in the block type distribution map; wherein the step of obtaining the block density information of each coordinate point in the target area from the block density distribution map comprises: obtaining the gray value or brightness value of each pixel point in the block density distribution map; determining the block density information of each coordinate point in the target area according to the gray value or brightness value of each pixel point; wherein the step of determining a vector point in the target area and generating a block division line between the vector points based on the block type and the block density information of each coordinate point comprises: determining a first vector point and obtaining the starting block type of the first vector point based on the block type corresponding to each coordinate point; obtaining a second vector point corresponding to the first vector point in the target area according to the starting block type; determining the current block density information corresponding to each second vector point based on the block density information corresponding to each coordinate point; connecting the first vector point and the second vector point according to the current block density information to obtain a block division line.
2. The method of claim 1, wherein, The step of obtaining a second vector point corresponding to the first vector point in the target area according to the starting block type comprises: obtaining a vector point taking point rule corresponding to the starting block type; obtaining a taking point direction of a next vector point corresponding to the first vector point based on a pseudo-random function and the vector point taking point rule corresponding to the starting block type; obtaining the coordinate data of the second vector point according to the coordinate data of the first vector point and the taking point direction.
3. The method of claim 1, wherein, The block density information comprises a connection probability value; the step of connecting the first vector point and the second vector point according to the current block density information to obtain a block division line comprises: calculating the probability value of the connection between the second vector point and the first vector point based on a pseudo-random function; if the probability value of the connection between the second vector point and the first vector point is within the connection probability value corresponding to the current block density information, connecting the second vector point and the first vector point to obtain a block division line.
4. The method of claim 1, wherein, The step of generating the block model in the virtual scene based on the block division line further comprises: respectively taking each of the vector points as a target vector point, and obtaining a point-taking direction of the target vector point; if the point-taking direction of the target vector point is the same as a point-taking direction of a previous vector point corresponding to the target vector point, generating a secondary vector point in the target region with the target vector point as a starting point; connecting the secondary vector points to obtain a road grid line in the target region; the step of generating the block model in the virtual scene based on the block division line comprises: generating the block model in the virtual scene based on the block division line and the road grid line.
5. A device for generating virtual scenes, characterized in that, The device comprises: a distribution map acquisition module configured to acquire a block type distribution map and a block density distribution map; a block information acquisition module configured to acquire a block type of each coordinate point in a target region from the block type distribution map, and acquire block density information of each coordinate point in the target region from the block density distribution map; a grid line construction module configured to determine a vector point in the target region and generate a block division line between the vector points based on the block type and the block density information of each coordinate point; a block model generation module configured to generate a block model in a virtual scene based on the block division line; wherein the block information acquisition module is configured to perform: acquiring a value of each pixel point in different color channels in the block type distribution map; determining a block type of each coordinate point in a target region according to the value of each pixel point in different color channels; or, determining a block type of each coordinate point in a target region through a pixel value corresponding to each pixel point in the block type distribution map; wherein the block information acquisition module is configured to perform: acquiring a gray value or brightness value of each pixel point in the block density distribution map; determining block density information of each coordinate point in a target region according to the gray value or brightness value of each pixel point; wherein the grid line construction module is configured to perform: determining a first vector point, and acquiring a starting block type of the first vector point based on the block type corresponding to each coordinate point; acquiring a second vector point corresponding to the first vector point in the target region according to the starting block type; determining current block density information corresponding to each second vector point based on the block density information corresponding to each coordinate point; connecting the first vector point and the second vector point according to the current block density information to obtain a block division line.
6. A computer device, comprising: The computer device comprises: one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the virtual scene generation method of any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the virtual scene generation method of any one of claims 1 to 4.
Citation Information
Patent Citations
GDP spatialization method based on remote sensing data and POI data
CN111914137A
Three-dimensional virtual scene generation method and device
CN112396688A