Virtual terrain generation method and device, computer equipment and storage medium

By acquiring the terrain shape of the initial virtual landform and adjusting the position of the collision point, the target virtual landform is generated, which solves the problems of low efficiency in landform model construction and poor display effect in the existing technology, and achieves efficient virtual landform generation and optimized display effect.

CN115518376BActive Publication Date: 2026-05-05NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETEASE (HANGZHOU) NETWORK CO LTD
Filing Date
2022-10-12
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing technologies, the construction efficiency of game scene terrain models is low and the display effect is poor, requiring manual splicing, which is time-consuming and labor-intensive.

Method used

By acquiring the terrain shape of the initial virtual landform, determining the preset rays and collision points, adjusting the position of the collision points to generate surface location points, and then generating the target virtual landform.

Benefits of technology

It improves the efficiency of virtual terrain generation and optimizes the display effect, making the generated target virtual terrain highly compatible with the virtual scene of the initial virtual terrain, and directly mapped in the virtual scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115518376B_ABST
    Figure CN115518376B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a virtual terrain generation method and device, computer equipment and a storage medium. Embodiments of the present application obtain a topographic shape of an initial virtual terrain, determine a collision point of a preset ray and the initial virtual terrain, the preset ray passes through a target point, and the target point includes a preset point of the topographic shape. According to a preset direction, the position of the collision point is adjusted to obtain a ground position point, and the preset direction is related to the height of the initial virtual terrain. According to the ground position point, a target virtual terrain is generated. In the embodiments of the present application, the target virtual terrain with high adaptability to the virtual scene in which the initial virtual terrain is located can be automatically generated from the initial virtual terrain, can be directly mapped in the virtual scene, and not only has high generation efficiency, but also can optimize the display effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and specifically to methods, apparatus, computer devices, and storage media for generating virtual terrain. Background Technology

[0002] In recent years, with the development of computer technology, more and more users are experiencing various games through electronic devices. In game design, the design of game scenes is a crucial element; complex and diverse game scenes can provide users with an immersive gaming experience.

[0003] In existing technologies, terrain models for game scenes are typically constructed manually and then pieced together into the game scene. However, this method requires manual terrain piecing, which is time-consuming, labor-intensive, and prone to problems such as unevenness. It is not only inefficient but also produces poor display results. Summary of the Invention

[0004] This application provides a method, apparatus, computer equipment, and storage medium for generating virtual terrain, which not only has high generation efficiency but also optimizes display effects.

[0005] This application provides a method for generating virtual terrain, comprising: acquiring the terrain shape of an initial virtual terrain; determining a collision point between a preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; adjusting the position of the collision point according to a preset direction to obtain a surface location point, wherein the preset direction is related to the height of the initial virtual terrain; and generating a target virtual terrain based on the surface location point.

[0006] This application embodiment also provides a method and apparatus for generating virtual terrain, comprising: a shape generation unit for acquiring the terrain shape of an initial virtual terrain; a determination unit for determining a collision point between a preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; an adjustment unit for adjusting the position of the collision point according to a preset direction to obtain a surface position point, wherein the preset direction is related to the height of the initial virtual terrain; and a terrain generation unit for generating a target virtual terrain based on the surface position point.

[0007] This application also provides a computer device, including a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in any of the virtual terrain generation methods provided in this application.

[0008] This application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the virtual terrain generation methods provided in this application.

[0009] This application embodiment can obtain the terrain shape of an initial virtual terrain; determine the collision point between a preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; adjust the position of the collision point according to a preset direction to obtain a surface position point, wherein the preset direction is related to the height of the initial virtual terrain; and generate a target virtual terrain based on the surface position point.

[0010] In this application, collision points on the initial virtual terrain can be determined based on preset rays passing through preset points of the terrain shape. By adjusting the collision points, the surface location points of the target virtual terrain can be obtained. Thus, corresponding surface location points can be determined based on the terrain shape of the initial virtual terrain, making the generated target virtual terrain related to the terrain shape of the initial virtual terrain. By adjusting the collision points, the surface height of the virtual terrain can be adjusted differentially. Therefore, a target virtual terrain with high adaptability to the virtual scene in which the initial virtual terrain is located can be automatically generated from the initial virtual terrain, and can be directly mapped into the virtual scene, resulting in high generation efficiency and optimized display effects. Attached Figure Description

[0011] 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.

[0012] Figure 1a This is a scene diagram of the virtual terrain generation system provided in the embodiments of this application;

[0013] Figure 1b This is a flowchart illustrating the method for generating virtual terrain provided in an embodiment of this application;

[0014] Figure 1c This is a schematic diagram illustrating the determination of the initial virtual terrain provided in an embodiment of this application;

[0015] Figure 1d This is a schematic diagram of the terrain shape for obtaining the initial virtual landform provided in an embodiment of this application;

[0016] Figure 1e This is a schematic diagram of the sheet assembly provided in an embodiment of this application;

[0017] Figure 1f This is a schematic diagram of the cyclic process provided in the embodiments of this application;

[0018] Figure 1g This is a schematic diagram of a patch model of the upper surface of the target virtual terrain provided in an embodiment of this application;

[0019] Figure 1h This is a schematic diagram of blurring the terrain of the first scene provided in an embodiment of this application;

[0020] Figure 1i This is a schematic diagram of blurring the terrain of the second scene provided in an embodiment of this application;

[0021] Figure 1j This is a schematic diagram of the scene terrain obtained by subtracting the processed first scene terrain from the processed second scene terrain, provided in an embodiment of this application.

[0022] Figure 1k This is a schematic diagram of the target scene terrain provided in the embodiments of this application;

[0023] Figure 11 This is a schematic diagram of the linear features of the scene terrain data before and after processing, as provided in the embodiments of this application.

[0024] Figure 2 This is a flowchart illustrating a method for generating virtual terrain according to another embodiment of this application;

[0025] Figure 3 This is a schematic diagram of the structure of the virtual terrain generation device provided in the embodiments of this application;

[0026] Figure 4 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation

[0027] 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.

[0028] Before providing a detailed explanation of the embodiments of this application, some terms involved in the embodiments of this application will be explained.

[0029] The terms "first," "second," etc., used in this application may be used to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are used only to distinguish one concept from another. "At least one" means one or more; for example, at least one user can be one user, two users, three users, or any integer greater than or equal to one. "Multiple" means two or more; for example, multiple users can be two users, three users, or any integer greater than or equal to two users.

[0030] In this context, a virtual scene is a virtual environment displayed (or provided) by an application running on a terminal. This virtual scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. The virtual scene can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual scene; this application does not limit the dimension of the virtual scene. For example, a virtual scene may include the sky, land, and ocean, and the land may include environmental elements such as deserts and cities. Users can control virtual characters to move within this virtual scene.

[0031] Virtual terrain can be objects formed based on the shape of the terrain in a virtual scene. For example, virtual terrain can be mountains, plains, forests, deserts, water bodies, swamps, or customized terrain such as cliffs. After rendering the virtual terrain, it can be displayed in the game screen on the terminal with a visual appearance similar to the terrain in the real world.

[0032] In this context, a patch model refers to a model comprising multiple patches. Typically, the model to be rendered is a 3D model, which can be defined as a model represented mathematically in three dimensions. A 3D model exists within a control corresponding to a coordinate system composed of three mutually perpendicular vectors (X, Y, Z). The patches within a patch model can be divided into multiple patch components. For example, a tree model can include patches corresponding to leaves, and patches located on the same branch constitute one patch component.

[0033] This application provides a method, apparatus, computer equipment, and storage medium for generating virtual terrain.

[0034] Specifically, the device for generating the virtual terrain can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.

[0035] In some embodiments, the virtual terrain generation apparatus may also be integrated into multiple electronic devices. For example, the virtual terrain generation apparatus may be integrated into multiple servers, and the virtual terrain generation method of this application may be implemented by multiple servers.

[0036] In some embodiments, the server may also be implemented as a terminal.

[0037] For example, refer to Figure 1a In some embodiments, a schematic diagram of a virtual terrain generation system is provided, which can implement a method for generating virtual terrain. This scenario may include a server and a terminal.

[0038] The server can obtain the terrain shape of the initial virtual terrain; determine the collision point between the preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; adjust the position of the collision point according to a preset direction to obtain a surface location point, wherein the preset direction is related to the height of the initial virtual terrain; and generate a target virtual terrain based on the surface location point.

[0039] The following sections will provide detailed explanations.

[0040] In this embodiment, a method for generating virtual terrain is provided, such as... Figure 1b As shown, the specific process of generating this virtual terrain can be described as follows:

[0041] 110. Obtain the terrain shape of the initial virtual landform.

[0042] The initial virtual terrain can refer to the original virtual terrain in the virtual scene, or it can refer to the preset virtual terrain. For example, the original virtual terrain such as mountains and plains in the virtual scene can be obtained as the initial virtual terrain, or the initial virtual terrain can be pre-constructed in the virtual scene.

[0043] In some implementations, an initial virtual terrain can be arbitrarily selected within the virtual scene, thereby enabling the autonomous generation of diverse virtual terrains. Specifically, before obtaining the terrain shape of the initial virtual terrain, the following steps may be included:

[0044] In response to a selection operation of at least one terrain region in a virtual scene, the virtual terrain corresponding to at least one terrain region is determined as the initial virtual terrain.

[0045] For example, such as Figure 1c As shown in (1), two areas can be defined in the virtual scene as terrain areas. When these two areas are selected, they are displayed in black. The virtual mountains displayed in these two areas are the initial virtual terrain.

[0046] In some implementations, to improve the efficiency and accuracy of converting the initial virtual terrain into a terrain shape, the initial virtual terrain can be blurred first to simplify its features. Specifically, determining the virtual terrain corresponding to at least one terrain region as the initial virtual terrain may further include: blurring the virtual terrain corresponding to at least one terrain region to obtain the initial virtual terrain.

[0047] For example, after selecting a virtual terrain in a virtual scene, and then blurring that virtual terrain, as shown... Figure 1c As shown, for Figure 1c After blurring the middle (1), we can obtain Figure 1c The virtual terrain shown in (2) has a blurred effect. It can be adjusted based on terrain height. Figure 1c The virtual scene shown in (2) is converted into a grid-like height field. The initial virtual terrain is then set to be visible, and the areas in the virtual scene other than the initial virtual terrain are set to be invisible. In this way, we can obtain Figure 1c The initial virtual terrain extracted from the virtual scene is shown in (3).

[0048] Blur processing refers to methods that create a blurred effect on images, 3D models, etc. Blur processing can be achieved through methods such as mean blur, median blur, and Gaussian blur. For example, Gaussian blur can be used on voxels (volume elements) of a 3D model, taking the average value of the points surrounding the voxel to make the voxel lose detail, thus converting a 3D virtual terrain with various terrain details into a simple and concise outline model.

[0049] In some implementations, the terrain shape can be a shape line, thereby constructing a target virtual terrain using lines representing the shape of the initial virtual terrain. This ensures that the generated target virtual terrain is related to the terrain shape of the initial virtual terrain, improving the fit between the target virtual terrain and the virtual scene containing the initial virtual terrain, and optimizing the display effect. Specifically, obtaining the terrain shape of the initial virtual terrain may include:

[0050] The initial virtual terrain is converted into shape lines to obtain the terrain shape.

[0051] In this context, shape lines refer to lines used to represent the shape of the initial virtual terrain. Shape lines can be lines representing the boundaries of the initial virtual terrain or lines representing the skeleton lines of the initial virtual terrain. Skeleton lines refer to lines used to represent the topographical features of the area to be processed. Skeleton lines can be extracted by extracting the centerline of the initial virtual terrain, scaling the initial virtual terrain, etc. For example, the initial virtual terrain can be converted into a 3D model, and the surface of the 3D model can be pushed inward at a constant speed, merging the vertices in the 3D model, i.e., shrinking the volume of the 3D model, until the 3D model shrinks into a polygon. Then, the polygon is pushed inward again, merging adjacent vertices in the polygon, until lines are obtained.

[0052] In some implementations, to improve the accuracy of converting the initial virtual terrain into terrain shapes, skeleton lines can be used as the shape lines of the initial virtual terrain. Specifically, converting the initial virtual terrain into shape lines can include:

[0053] Extract the skeleton lines of the initial virtual terrain to obtain shape lines.

[0054] For example, by extracting Figure 1c The skeleton lines of the initial virtual terrain shown in (3) can be used to obtain the following: Figure 1d The shape lines shown in (1) are as follows. It can be understood that the process of generating shape lines from the initial virtual terrain is essentially a process of extracting vertices located along the centerline from the initial virtual terrain or a process of merging vertices of the initial virtual terrain for scaling. Therefore, the resulting shape lines are composed of a portion of the vertices of the initial virtual terrain. For example, as shown in (1) Figure 1d The shape shown in (1) includes multiple vertices.

[0055] In some implementations, the terrain shape can be a patch model, thereby constructing a target virtual terrain using a patch model that represents the shape of the initial virtual terrain. This ensures that the generated target virtual terrain is related to the terrain shape of the initial virtual terrain, improving the fit between the target virtual terrain and the virtual scene in which the initial virtual terrain resides, and thus optimizing the display effect. Specifically, obtaining the terrain shape of the initial virtual terrain may include:

[0056] Convert the initial virtual terrain into shape lines;

[0057] Based on the shape lines, generate a patch model that conforms to the shape lines to obtain the terrain shape. The patch model includes at least one patch component.

[0058] Among these methods, surface models can be generated from shape lines through stretching, lofting, and other techniques. For example, shape lines can be stretched or lofted to generate surface models parallel to the shape lines. The direction of stretching or lofting can be arbitrary.

[0059] In this context, when the shape lines include multiple branches, a patch component in the patch model can refer to any one of the branches. For example, by referring to... Figure 1d After lofting the shape and lines shown in (1), the following can be obtained: Figure 1d The patch model shown in (3) may include 9 patch components, and each patch component may include at least one patch.

[0060] For example, after obtaining the shape lines using the aforementioned method, the cross-section for lofting the shape lines can be set to a preset shape, which can be a line or a surface. If the preset shape is a line, the shape lines can be lofted along this line to obtain a surface model. It is understood that two adjacent vertices in the shape lines can form a surface in the surface model after lofting. In practical applications, if the shape lines include multiple branches, each branch can be lofted separately; that is, the lofting direction or preset shape of different branches can be different.

[0061] In some implementations, vertex numbers can be stored in a preset set for immediate retrieval when generating the patch model. Specifically, after generating a patch model that conforms to the shape lines and obtaining the terrain shape, the process may further include:

[0062] Store the vertex numbers in the patch model in a preset set.

[0063] The preset set can refer to a pre-defined set used to store vertex IDs. For example, the vertex IDs of vertices in a patch model can be stored in the attribute file of the idd file.

[0064] In some implementations, to increase the smoothness of the generated patch model, the vertices on the shape lines can be normalized and remapped. Specifically, generating a patch model that conforms to the shape lines can include:

[0065] Based on the vertex numbers of the vertices in the shape lines, the vertices are normalized to obtain the normalized values ​​of the vertices.

[0066] The normalized values ​​are remapped to obtain the processed lines.

[0067] Based on the processed lines, generate a patch model that matches the shape of the lines.

[0068] The normalization process can include dividing the vertex number of any vertex in the shape line by the largest vertex number in the shape line, or it can include a combination of dividing the vertex number of any vertex in the shape line by the vertex numbers in the shape line. When the shape line includes multiple branches, the vertex numbers of vertices within each branch can also be normalized separately.

[0069] Remapping refers to remapping a value between 0 and 1. For example, remapping can remap values ​​greater than 0.8 to 1. Remapping can also smooth the transition between points on a line, increasing the smoothness of the line.

[0070] For example, when a shape line includes multiple branches, the number of any vertex in each branch can be divided by the numbers of all vertices in that branch to obtain the normalized value of that vertex. This value ranges from 0 to 1. The normalized value can then be remapped from 0 to 1 onto a line with values ​​from 0 to 1. By adjusting the line from 0 to 1 and then back to 0, the following can be obtained: Figure 1d The processed lines are shown in (2). Then, through stretching, lofting, and other methods, lines are generated from the processed lines to form lines like... Figure 1d The patch model shown in (3) is shown in the middle.

[0071] 120. Determine the collision point between the preset ray and the initial virtual terrain. The preset ray passes through the target point.

[0072] In mathematics, a ray can refer to a straight line formed by extending one end of a line segment infinitely. A ray has only one endpoint and its length cannot be measured (it is infinitely long). In the embodiments of this application, the ray can be determined by virtual ray detection technology, which can be Unity ray detection. Ray detection refers to a method of emitting a ray from a fixed point along a specific direction, and returning collision information after a collision with an object. The collision information may include information related to the object.

[0073] Here, a preset ray can refer to a ray emitted in a specific direction. This specific direction is the direction of the preset ray, which can be set according to actual needs or application scenarios, or determined according to the terrain shape. In practical applications, there can be multiple preset rays, and the target points traversed by each preset ray and the direction can be the same or different. Optionally, the endpoint of the preset ray is the target point.

[0074] The collision point can refer to the point where the preset ray collides with the initial virtual terrain, or it can refer to the point determined by the location of the collision point.

[0075] The target point can include a preset point of the terrain shape. The preset point can be a point set in the terrain shape according to actual needs or application scenarios, or a point randomly determined from the terrain shape, or a point randomly determined from the terrain shape according to a preset direction.

[0076] In practical applications, if the terrain shape is a line shape, the direction of the preset ray can be set according to actual needs or application scenarios. If the terrain shape is a patch model, the preset direction can be set according to the direction of the vertices in the patch component.

[0077] In some implementations, the direction of a preset ray can be quickly determined based on vertices at different heights in the patch component. Specifically, the process of acquiring the terrain shape of the initial virtual terrain and determining the collision point between the preset ray and the initial virtual terrain may further include:

[0078] The first vertex and the second vertex are determined from the vertices of the patch component, and the first vertex and the second vertex have different heights along a preset direction;

[0079] Determine the direction of the preset ray based on the first and second vertices.

[0080] Here, the first vertex and the second vertex can refer to vertices located at different heights of the panel component. For example, the first vertex and the second vertex can refer to vertices located on the sides or ends of the panel component. For instance, the panel component can be divided into upper and lower sides along a preset direction, with the first vertex and the second vertex located on the upper and lower sides, respectively. As another example, if the panel component is higher at one end and lower at the other along a preset direction, the vertex at the relatively higher end of the panel component can be designated as the first vertex, and the vertex at the relatively lower end as the second vertex.

[0081] The preset direction can refer to a direction related to the height of the initial virtual terrain. For example, the preset direction can be a direction related to height in the virtual scene, such as a direction from top to bottom or from bottom to top in the virtual scene, which can be set according to actual needs.

[0082] The preset ray direction can be either the direction from the location of the first vertex to the location of the second vertex, or the direction from the location of the second vertex to the location of the first vertex.

[0083] In practical applications, the direction of a preset ray can be set according to the terrain of the target virtual landform to be generated. For example, if the target virtual landform is to be generated downwards from the location of the terrain shape, the preset ray direction can be from the relatively higher first vertex to the relatively lower second vertex; conversely, if the target virtual landform is to be generated upwards from the location of the terrain shape, the preset ray direction can be from the relatively lower second vertex to the relatively higher first vertex. For example, to generate a cliff wall upwards from the location of the terrain shape, the preset ray direction can be as follows: Figure 1e As shown, the top vertex of the patch component can be... Figure 1e The vertex with an even-numbered midpoint is designated as the first vertex, and the vertex located to the bottom is... Figure 1e The vertex with an odd number is designated as the second vertex, and the default ray direction can be from the second vertex to the first vertex.

[0084] In some implementations, before determining the direction of the preset ray, the relatively higher and lower sides of the face assembly can be quickly distinguished based on the sum of the heights of the vertices on both sides of the face assembly, improving the efficiency of determining the direction of the preset ray. Specifically, determining the first vertex and the second vertex from the vertices of the face assembly based on the height of the vertices of the face assembly along the preset direction includes:

[0085] Obtain the height values ​​of all first-side vertices and all second-side vertices in the face component, respectively, to obtain the first height sum and the second height sum. The first-side vertices and the second-side vertices are located on both sides of the face component.

[0086] The vertex corresponding to the larger of the two sums of heights is designated as the first vertex, and the vertex corresponding to the smaller of the two sums is designated as the second vertex.

[0087] The first side vertex and the second side vertex can refer to the vertices located on both sides of the face assembly.

[0088] The height value can refer to the height of the vertex along a preset direction.

[0089] In practical applications, the vertex number can be used to distinguish which side a vertex is located on. For example, as Figure 1e As shown, the patch component consists of multiple quadrilateral patches. When generating the patch model, the vertices of each patch are numbered sequentially from top to bottom, resulting in... Figure 1e The vertex numbers in the array. Clearly, Figure 1eIn this context, vertices numbered odd and even are located on different sides of the face component. Therefore, vertices numbered odd can be designated as first-side vertices, and vertices numbered even can be designated as second-side vertices. The sum of the heights of all first-side vertices in any face component (first height sum) and the sum of the heights of all second-side vertices in any face component (second height sum) are calculated. The first height sum and the second height sum are compared, and the side of the face component corresponding to the larger sum is determined as the higher side, and the side of the face component corresponding to the smaller sum is determined as the lower side. Thus, the vertex on the higher side of the face component can be designated as the first vertex, and the vertex on the lower side can be designated as the second vertex.

[0090] In some implementations, to quickly identify vertices located on the higher or lower side of the patch assembly, they can be stored as the maximum or minimum height. Specifically, determining the first and second vertices from the vertices of the patch assembly based on the heights of the vertices along a preset direction may further include:

[0091] Store the vertex number of the first vertex as the maximum height or store the vertex number of the second vertex as the minimum height.

[0092] For example, the sum of the heights of vertices with odd-numbered vertices can be stored as height0 (first total height), and the sum of the heights of vertices with even-numbered vertices can be stored as height1 (second total height). Compare the sizes of height0 and height1, and store the vertex numbers of the vertices corresponding to the smaller one in the heightmin group (minimum height). In this way, we can directly distinguish which side of the face component is shorter based on the vertex numbers stored in the heightmin group, and we can also distinguish which side of the face component is taller based on the vertex numbers of vertices not stored in the heightmin group.

[0093] In some implementations, the directions of multiple preset rays can be determined by multiple pairs of associated first and second vertices in the patch component. This allows for the generation of multiple preset rays based on different directions, resulting in multiple collision points and multiple surface location points. The more surface location points, the higher the detail of the generated virtual terrain, thereby improving the surface stretching of the generated virtual terrain. Specifically, the patch component includes at least one patch. Determining the direction of the preset rays based on the first and second vertices can include:

[0094] Determine the direction of any preset ray based on any associated first vertex and any associated second vertex.

[0095] Among them, association can refer to relationships such as being connected or located on the same facet.

[0096] For example, such as Figure 1e As shown, for each facet in each facet assembly, there may be at least one first vertex and at least one second vertex. A preset ray direction can be determined based on the connected first and second vertices, and the endpoint of the preset ray can be either the first or the second vertex. That is, for any connected first and second vertex in the facet assembly, a preset ray direction can be determined.

[0097] In some implementations, the target point can be moved to the collision location of the initial virtual terrain to obtain the collision point, thereby moving the target point to generate a surface location point. Specifically, determining the collision point between the preset ray and the initial virtual terrain may include:

[0098] Determine the collision point between the preset ray and the initial virtual terrain;

[0099] Move the target point to the collision location of the initial virtual terrain to obtain the collision point.

[0100] For example, a virtual ray can be emitted along the direction of a preset ray corresponding to the second vertex, with the second vertex as the endpoint of the ray. If the virtual ray hits the initial virtual terrain, the second vertex can be moved to the position where the virtual ray hits the initial virtual terrain, i.e., the collision position, to obtain the collision point.

[0101] 130. Adjust the position of the collision point according to the preset direction to obtain the ground position point.

[0102] The preset direction is highly correlated with the height of the initial virtual terrain. For example, the preset direction can be a top-down direction or a bottom-up direction in the 3D virtual scene.

[0103] Among them, the surface location point can refer to a point located on the surface of the virtual terrain. For example, if the virtual terrain is a mountain, the surface location point can be a point on the surface of the mountain; if the virtual terrain is a cliff, the surface location point can be a point on the cliff face, and so on.

[0104] For example, the position of the collision point can be adjusted along a preset direction, or it can be adjusted along a direction related to the preset direction, such as the opposite direction.

[0105] It is understandable that, since the collision point is a point located on the initial virtual terrain, if the target virtual terrain is obtained directly based on the collision point, the target virtual terrain will be identical to the terrain of the initial virtual terrain. Therefore, by adjusting the position of the collision point, this embodiment of the application can generate a target virtual terrain that is associated with the initial virtual terrain but different from it.

[0106] In practical applications, by setting different preset directions, preset ray directions, and collision point adjustment directions in the embodiments of this application, various different terrains, such as slopes and cliffs, can be constructed based on the initial virtual terrain. For example, if the preset ray direction points from the second vertex to the first vertex, the preset direction can be from bottom to top. By setting the upward displacement of the collision point position, a new surface position point higher than the initial virtual terrain can be generated, thereby raising the surface position of the initial virtual terrain and generating a new virtual terrain. Since the new terrain is generated based on the original virtual terrain (initial virtual terrain), it has a high degree of compatibility with the virtual scene where the original virtual terrain is located and can be directly mapped into the virtual scene, resulting in high efficiency and good stitching effect.

[0107] Optionally, different collision points can be adjusted in the same direction. For example, adjusting all collision points in the same direction allows them to move synchronously, thus changing their positions simultaneously. This allows for the rapid generation of new virtual terrain (target virtual terrain).

[0108] In some implementations, multiple candidate location points can be determined through a loop. As the loop repeats, the positions of these candidate locations can be gradually adjusted along a preset direction, either from bottom to top or from top to bottom, to improve the compatibility between the target virtual terrain and the virtual scene containing the original virtual terrain, thereby optimizing the display effect. Specifically, adjusting the position of the collision point according to the preset direction to obtain the surface location point can include:

[0109] Based on the preset direction, adjust the position of the collision point to obtain candidate position points;

[0110] Using candidate location points as target points, repeat the steps to perform collision detection on the initial virtual terrain based on preset rays and target points to determine collision points. Then, adjust the position of the collision points according to preset directions to obtain surface location points until there are no more collision points. The surface location points are the location points determined by the candidate location points.

[0111] Among them, the candidate position point can refer to the point obtained by adjusting the collision point.

[0112] For example, at the start of the loop, any second vertex on the terrain shape, such as vertex A, can be used as the target point. A virtual ray A is emitted from vertex A, with its direction corresponding to the second vertex. If virtual ray A hits the initial virtual terrain, vertex A is moved to the point where it hits the initial virtual terrain (the collision point), and then adjusted upwards to obtain a candidate point A. This candidate point can then be used as the target point to execute the next loop. Specifically, a virtual ray B is emitted from vertex A, with its direction parallel to the initial virtual terrain. If virtual ray B hits the initial virtual terrain, the candidate point is moved to the point where it hits the initial virtual terrain (the collision point), and then adjusted upwards to obtain a new candidate point B. The next loop then executes. If virtual ray B does not hit the initial virtual terrain (i.e., there is no collision point), the loop ends. Figure 1f As shown, through the above cyclic process, the vertices on the terrain shape can be continuously moved upward to generate candidate location points until the highest point (the surface location point) is reached, at which point the process stops.

[0113] Optionally, the surface location point is the candidate location point obtained in the last loop, i.e., the highest point. For example, if the displacement of the collision point is adjusted upward during the loop, multiple surface location points located above the initial virtual terrain can be obtained after the loop ends. In this way, the target virtual terrain located above the initial virtual terrain can be constructed from the surface location points.

[0114] Optionally, the surface location points include all candidate location points. In this way, multiple surface location points can be determined in a loop. As the loop is repeated, the surface location on the target virtual terrain can be determined step by step along a preset direction from bottom to top or from top to bottom. For example, all candidate location points in the loop, such as candidate location point A, candidate location point B, etc., can be used as surface location points to form a slope.

[0115] 140. Generate the target virtual terrain based on the location points on the ground.

[0116] The target virtual terrain can be different virtual terrains such as mountains and cliffs.

[0117] The surface of a target virtual terrain can be constructed from surface location points to generate the target virtual terrain. For example, after obtaining a patch model, the patch model can be converted from a surface to a volume through stretching, filling, or other methods to obtain a three-dimensional target virtual terrain. For example, if the target virtual terrain is a cliff, the displacement of the collision point position can be adjusted upwards to connect the obtained surface location points to form the upper surface of the cliff, and then the upper surface can be extruded downwards to form a volume (that is, the patch model of the upper surface is filled downwards) to obtain the target virtual terrain. For example, if the target virtual terrain is a mountain, as mentioned above, all candidate location points in the process of determining surface location points can be used as surface location points to obtain a patch model that constitutes the slope of the mountain, and then the patch model can be filled to obtain the target virtual terrain.

[0118] In some implementations, the heights of other vertices can be adjusted based on the height of the surface location points to form a surface of the target virtual terrain. This allows the target virtual terrain to be directly applied to the virtual scene, increasing the adaptability between the target virtual terrain and the virtual scene. This not only improves efficiency but also results in better stitching effects. Specifically, generating the target virtual terrain based on surface location points can include:

[0119] When the preset point includes the second vertex, adjust the height of the first vertex according to the height of the ground location point to obtain the target location point;

[0120] Generate a virtual terrain based on the location points on the ground and the target location points.

[0121] For example, if the surface location point is a candidate location point obtained in the last iteration, the first vertex can be moved up to the same height as the corresponding surface location point to generate the target virtual terrain. Figure 1g As shown, Figure 1g In the middle (1), the face model is obtained by lofting the shape lines. Figure 1g (2) represents a patch model consisting of a surface location point and the first vertex. Obviously, since the second vertex has moved upwards to the surface location point, the height of the second vertex is higher than that of the first vertex. Therefore, it can be... Figure 1g In the face model represented by (2), the vertex (first vertex) on the shorter side along a preset direction is moved to the same height as the vertex (ground position point) on the other side, resulting in the following: Figure 1g The surface model of the upper surface of the target virtual terrain shown in (3) can be squeezed downwards to form a volume to obtain the target virtual terrain.

[0122] For example, if the surface location points include all candidate location points, and the second vertex is used as the endpoint of the preset ray, then the surface location points can be considered as points obtained by moving the second vertex upwards. That is, the surface location points can form the slope of the target virtual terrain. In this case, the first vertex can be moved upwards to the same height as the surface location point obtained in the last iteration. Thus, the first vertex after being moved upwards and the surface location point obtained in the last iteration can form a plane. This slope and plane can form a closed-shaped target virtual terrain.

[0123] In some implementations, adjusting the height of the first vertex based on the height of the surface location point to obtain the target location point may include: adjusting the height of the first target vertex based on the height of the surface location point corresponding to the second target vertex to obtain the target location point. Here, the second target vertex can refer to any second vertex, the second target vertex can refer to a second vertex associated with the first target vertex, and the surface location point corresponding to the second target vertex can refer to the surface location point obtained by moving the second target vertex upwards.

[0124] In some implementations, if the first vertex is used as the endpoint of a preset ray, the height of the second vertex can be adjusted accordingly to form the surface of the target virtual terrain. Specifically, generating the target virtual terrain based on surface location points can include:

[0125] When the preset point includes the first vertex, the height of the first vertex can be adjusted according to the height of the ground location point to obtain the target location point;

[0126] Generate a virtual terrain based on the location points on the ground and the target location points.

[0127] In some implementations, to prevent excessive stretching of the generated target virtual terrain surface, which could lead to virtual terrain deformation, the excessively offset surface location points can be adjusted. Specifically, after adjusting the position of the collision point according to a preset direction to obtain the surface location points, the implementation may further include:

[0128] If the distance between the target point and the ground location point is greater than the preset value, the target direction is determined based on the target point and the ground location point;

[0129] Adjust the position of the target point along the target direction to update the position of the surface location point.

[0130] The preset value can refer to a preset distance value, which can be the distance of the point in a two-dimensional coordinate system or a three-dimensional coordinate system, or the distance of the point along at least one coordinate axis in the coordinate system.

[0131] The target direction can refer to the direction from the target point to the location point on the ground.

[0132] For example, if the distance between the target point and the surface location point is greater than a preset value, the position of the target point can be subtracted from the position of the surface location point in the coordinate system to obtain a vector representing the target direction. Then, the target point is moved a preset distance, such as 10 unit vectors, along this vector to obtain a new location point, which is then updated as the surface location point. It should be noted that during the loop, if the surface location point is updated according to the preset value, the previous surface location point can be deleted, and only the updated surface location point is used to construct the target virtual terrain.

[0133] In some implementations, to enrich the details of the target virtual terrain in the virtual scene, the height field of the target virtual terrain can be adjusted based on the height field of the initial virtual terrain in the virtual scene. Specifically, after generating the target virtual terrain based on the surface location points, the process may further include:

[0134] The first scene terrain and the second scene terrain are obtained by mapping the target virtual terrain and the initial virtual terrain onto the virtual scene, respectively.

[0135] Based on the height field of the second scene's terrain, adjust the height field of the second scene's terrain to obtain the target scene's terrain.

[0136] Among them, scene terrain can refer to the terrain presented in a virtual scene.

[0137] Mapping can refer to stitching or drawing virtual terrain onto a virtual scene. For example, virtual terrain can be moved to a terrain area in a virtual scene to generate scene terrain; alternatively, the height value of virtual terrain can be identified to adjust the terrain in the virtual scene and obtain scene terrain.

[0138] The height field can refer to the bounding box of the effective area of ​​a virtual scene (the region containing data). For example, in a 3D virtual scene, the height field can refer to the bounding box of the effective area of ​​the scene in the xz coordinate system; the height field is essentially a two-dimensional array.

[0139] For example, the target virtual terrain can be mapped onto a virtual scene to obtain, such as Figure 1h The first scene terrain shown in (1) is where the black area represents the region corresponding to the target virtual terrain. It is possible to obtain, for example... Figure 1i The virtual scene shown in (1) is the second scene terrain. The initial virtual terrain has been mapped in the virtual scene, and the black area is the area corresponding to the initial virtual terrain.

[0140] In some implementations, to improve processing efficiency and the rendering effect of the terrain, the scene terrain can be blurred to simplify its features, and then the height field of the second scene terrain can be adjusted. Adjusting the height field of the second scene terrain based on its height field to obtain the target scene terrain can include:

[0141] The first scene terrain and the second scene terrain are blurred respectively to obtain the processed first scene terrain and the processed second scene terrain;

[0142] The target scene terrain is obtained by subtracting the height field of the processed first scene terrain from the height field of the processed second scene terrain.

[0143] The method for blurring the terrain of the first scene and the terrain of the second scene can be the same as the method for blurring the initial virtual terrain described above.

[0144] For example, it can be done separately for Figure 1h The first scene terrain in (1) and Figure 1i The second scene terrain in (1) is blurred to obtain the following result: Figure 1h The processed terrain of the first scene shown in (2) and as shown in the figure Figure 1i The processed second scene terrain is shown in Figure (2). The processed first scene terrain and the processed second scene terrain can be subtracted to obtain the following: Figure 1j The scene and terrain shown, and then as Figure 1j Mapping the shown scene terrain onto the first scene terrain will yield the following result: Figure 1k The target scene terrain is shown.

[0145] For example, Figure 11 The linear characteristics of the scene terrain data before and after processing were compared, such as... Figure 11 As shown, by blurring the first scene terrain, a smoother line shape can be obtained to simplify the features of the scene terrain and reduce noise. Then, by adjusting the height field of the second scene terrain through the processed height field, the target scene terrain can have more detailed features under low noise conditions, thereby increasing the realism of the target scene terrain.

[0146] The virtual terrain generation scheme provided in this application embodiment can be applied to various virtual terrain generation scenarios. For example, taking the generation of a cliff as an example, the terrain shape of the initial virtual terrain is obtained; the collision point between the preset ray and the initial virtual terrain is determined, the preset ray passes through the target point, and the target point includes the preset point of the terrain shape; according to the preset direction, the position of the collision point is adjusted to obtain the surface position point, the preset direction is related to the height of the initial virtual terrain; and the target virtual terrain is generated according to the surface position point.

[0147] The solution provided in this application uses preset rays passing through preset points on the initial virtual terrain shape to determine collision points on the initial virtual terrain. By adjusting the collision points, the surface location points of the target virtual terrain are obtained. In this way, corresponding surface location points can be determined based on the terrain shape of the initial virtual terrain, making the generated target virtual terrain related to the terrain shape of the initial virtual terrain. By adjusting the collision points, the surface height of the virtual terrain can be adjusted differentially. Therefore, a target virtual terrain with high adaptability to the virtual scene where the initial virtual terrain is located can be automatically generated from the initial virtual terrain. This target virtual terrain can be directly mapped into the virtual scene, resulting in high generation efficiency and optimized display effects.

[0148] The method described in the above embodiments will be further described in detail below.

[0149] In this embodiment, the method of this application embodiment will be described in detail using the generation of a cliff wall as an example.

[0150] The method described in this application can be applied to various game engines, such as mainstream engines like HOUDINI software and Unreal Engine 4 (UE4), and can also be applied to self-developed engines. The following description will use the method described in this application for application to HOUDINI.

[0151] like Figure 2 As shown, the specific process of a method for generating virtual terrain is as follows:

[0152] 210. In response to a selection operation on at least one terrain region in a virtual scene, the virtual terrain corresponding to at least one terrain region is determined as the initial virtual terrain.

[0153] For example, a 3D terrain map of a virtual scene can be pre-set in HOUDINI software, such as... Figure 1c As shown in Figure (1), the black area in the figure is the selected or drawn slope area (initial virtual terrain) that is to be generated as a cliff. In practical applications, the slope area can be extracted directly from the 3D terrain map, or the slope area can be selected around the mountain.

[0154] The heightfield_blur node can be used to blur the entire terrain of a 3D map, resulting in an image like... Figure 1c The figure shown in (2) is obtained by converting the terrain height into a mesh using the convergetheightfield command and then extracting the black area using the @mask<0.5 command. Figure 1c The initial virtual terrain is shown in (3).

[0155] A terrain feature is a height field (voxel). When editing an initial virtual terrain as a polygon, the `convertheightfield` node can be used to convert the initial virtual terrain into a polygon. For example... Figure 1c The black area shown in (2) is the mask field. When it is converted into a polygon, each vertex of the polygon will have an attribute value called mask. That is, the mask value of the black area will be equal to 1, and the mask value of the non-black area will be equal to 0. Thus, it can be said that setting mask < 0.5 will delete the non-black area and leave the black area. Figure 1c The black area in (2) yields the following result: Figure 1c The initial virtual terrain is shown in (3).

[0156] 220. Extract the skeleton lines of the initial virtual terrain to obtain shape lines.

[0157] Using straight_skeleton_3d (which can automatically draw lines as close to the grid as possible) yields results like... Figure 1d The line segment shown in (1). straight_skeleton_3d is an integrated built-in function node that can convert the input model into a volume, shrink the volume until it is thin enough, and then use an algorithm to extract the volume into a polygon. Then, it continuously merges the close points until a curve is left. For example, outputting a crescent-shaped model can get an arc curve, and inputting a rabbit's head model can get a V-shaped line.

[0158] You can also use `i@id = @ptnum;` to store the vertices of all the resulting line segments in the `id` attribute. The `id` attribute is stored on each vertex, giving each vertex a unique `id` attribute, the value of which is equal to its own vertex number. The vertex number is assigned when each model is created; it's essentially the vertex's name. For example, you can store each vertex's information in the form of vertex number and vertex attributes. The vertex attributes can include the vertex's XYZ coordinates, such as 0, (1148, 40, 934), indicating that the vertex's number is 0 and its coordinates are (1148, 40, 934).

[0159] 230. Generate a patch model that conforms to the shape of the shape lines.

[0160] For example, it can be used for such Figure 1dIn Figure (1), each line segment is subjected to a FOR loop, and VOP is used to connect them. Specifically, the vertex number of each vertex of each line segment is divided by the total vertex number to obtain a value from 0 to 1 (normalization processing). Then, this value is reramped (remapped) and mapped onto a curve from 0 to 1. The curve is then adjusted to go from 0 to 1 and then back to 0, resulting in the following: Figure 1d The line shown in (2) (the processed line) includes multiple branches (segments), with the two ends of each branch being darker black and the middle being lighter white.

[0161] You can use Sweep to loft each branch of the processed line into a separate patch component. All the lofted patch components can be combined to form a structure like this. Figure 1d The patch model shown in (3) is used, and the vertex numbers of the patch model are stored in the attribute of idd using the i@idd=@ptnum; command. sweep is an integrated node that can loft a line into a plane.

[0162] 240. Determine the first vertex and the second vertex from the vertices of the facet component. The first vertex and the second vertex have different heights along a preset direction.

[0163] For example, for each facet component, the sum of the heights of vertices with odd-numbered vertices can be stored as height0 (first total height), and the sum of the heights of vertices with even-numbered vertices can be stored as height1 (second total height). The sizes of height0 and height1 are compared, and the vertex numbers of the vertices corresponding to the smaller one are stored in the heightmin group (minimum height). In this way, we can directly distinguish which side of the facet component is short based on the vertex numbers stored in the heightmin group, and we can also distinguish which side of the facet component is tall based on the vertex numbers of vertices not stored in the heightmin group.

[0164] 250. Determine the direction of the preset ray based on the first vertex and the second vertex.

[0165] For example, for each facet in each facet component, the position of the first vertex can be subtracted from the position of the connected second vertex in the 3D coordinate system to obtain a direction vector (the direction of a preset ray), which can be stored on dir.

[0166] 260. Determine the collision point between the preset ray and the initial virtual terrain.

[0167] For example, you can use `blast` to remove vertices not in the `heightmin` group (i.e., leaving only shorter vertices). Use `pointwrangle` for each loop and process the vertices extracted in step 230. Figure 1c The three-dimensional model of the initial virtual terrain shown in (3) is connected to the second interface.

[0168] A virtual ray is emitted from the vertex corresponding to heightmin (the second vertex) in the direction of dir. If the ray touches the 3D model, the vertex is moved to the position where the ray touches the 3D model.

[0169] 270. Adjust the position of the collision point according to the preset direction to obtain the ground position point.

[0170] For example, the vertex moved to the collision position can be raised 0.5 along the Y-axis (perpendicular to the horizontal plane) and used as the target point to emit a virtual ray in the direction of dir. This process can be repeated until the ray emitted from the target point no longer touches the 3D model (i.e., it reaches the highest point of the 3D model). Figure 1f As shown, the second vertex climbs upwards along the 3D model until it stops at the highest point. Figure 1f The white dot represents the second vertex that is continuously climbing upwards, and the arrows indicate the direction of the ray corresponding to any second vertex.

[0171] For example, if the new position of the vertex (the location on the ground) is significantly offset from the old position (the location of the target point) in the three-dimensional coordinate system along the X and Z axes, that is, significantly offset in the horizontal direction, the direction (direction vector) can be obtained by subtracting the old position from the new position in the three-dimensional coordinate system. The old position can then be offset by 10 units in this direction to obtain the new position. This can prevent the vertex from being displaced too much, which would cause the generated virtual terrain to have a stretched surface.

[0172] 280. Generate the target virtual terrain based on the location points on the ground.

[0173] For example, attribcopy can be used to assign the surface location points obtained in the last iteration to the patch model, thus changing the patch model from its original state. Figure 1g The patch model shown in (1) is converted to Figure 1g The patch model shown in (2) is shown in the middle.

[0174] For example, a foreach loop can be used to process the heightmin group, and... Figure 1g The patch model shown in (2) is located at the vertex on the shorter side in the Y-axis direction. It is moved to the height of the vertex on the higher side, making it a... Figure 1gThe plane shown in (3) is used as the top of the cliff. The plane is then extruded downwards to fill the gap below, resulting in a three-dimensional cliff model.

[0175] After generating a 3D cliff model, it can be adjusted based on the initial virtual terrain. For example, using `heightfield_project`, the 3D cliff model can be mapped onto an area of ​​the initial virtual terrain in a 3D terrain map, resulting in something like... Figure 1h The terrain within the black area shown in Figure (1) is blurred, resulting in the following: Figure 1h The cliff area shown in (2) is too smooth and lacks detail. Therefore, it is possible to... Figure 1i The initial virtual terrain in the three-dimensional terrain map shown in Figure (1) is blurred to obtain the following result: Figure 1i The scene and terrain shown in (2) are as follows. This will be compared with... Figure 1h The cliff area shown in (2) is similar to... Figure 1i Subtracting the height field of the terrain shown in (2) yields the following result: Figure 1j The top of the cliff shown is then mapped onto... Figure 1h In the cliff area of ​​(2), one can obtain the following: Figure 1k The final cliff effect shown.

[0176] As can be seen from the above, the embodiments of this application can adaptively generate cliffs that adapt to the terrain shape of the slope in the virtual scene, and the generated cliffs can automatically adjust their size according to changes in the slope. In this way, cliffs with high adaptability to the virtual scene where the slope is located can be automatically generated from the slope, and can be directly mapped into the virtual scene, which not only has high generation efficiency, but also optimizes the display effect.

[0177] To better implement the above methods, this application also provides a virtual terrain generation device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer; the server can be a single server or a server cluster composed of multiple servers.

[0178] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the virtual terrain generation device as specifically integrated into the server.

[0179] For example, such as Figure 3 As shown, the virtual terrain generation device may include a shape generation unit 310, a determination unit 320, an adjustment unit 330, and a terrain generation unit 340, as follows:

[0180] (a) Shape generation unit 310

[0181] The terrain shape used to obtain the initial virtual landscape.

[0182] In some implementations, the shape generation unit 310 may specifically be used for:

[0183] The initial virtual terrain is converted into shape lines to obtain the terrain shape.

[0184] In some implementations, the shape generation unit 310 may specifically be used for:

[0185] Convert the initial virtual terrain into shape lines;

[0186] Based on the shape lines, generate a patch model that conforms to the shape lines to obtain the terrain shape. The patch model includes at least one patch component.

[0187] (II) Determine Unit 320

[0188] Used to determine the collision point between a preset ray and the initial virtual terrain. The preset ray passes through a target point, which includes a preset point of terrain shape.

[0189] In some implementations, the determining unit 320 may also be used for:

[0190] The first vertex and the second vertex are determined from the vertices of the patch component, and the first vertex and the second vertex have different heights along a preset direction;

[0191] Determine the direction of the preset ray based on the first and second vertices.

[0192] In some implementations, determining the first vertex and the second vertex from the vertices of the patch assembly based on the height of the vertices of the patch assembly along a preset direction may include:

[0193] Obtain the height values ​​of all first-side vertices and all second-side vertices in the face component, respectively, to obtain the first height sum and the second height sum. The first-side vertices and the second-side vertices are located on both sides of the face component.

[0194] The vertex corresponding to the larger of the first and second total heights is designated as the first vertex, and the vertex corresponding to the smaller of the two total heights is designated as the second vertex.

[0195] In some implementations, determining the direction of the preset ray based on the first vertex and the second vertex may include:

[0196] Determine the direction of any preset ray based on any associated first vertex and any associated second vertex.

[0197] In some implementations, the determining unit 320 may specifically be used for:

[0198] Determining the collision point between the preset ray and the initial virtual terrain may include:

[0199] Determine the collision point between the preset ray and the initial virtual terrain;

[0200] Move the target point to the collision location of the initial virtual terrain to obtain the collision point.

[0201] (III) Adjustment Unit 330

[0202] It is used to adjust the position of the collision point according to the preset direction to obtain the ground position point. The preset direction is related to the height of the initial virtual terrain.

[0203] In some implementations, the adjustment unit 330 may specifically be used for:

[0204] Based on the preset direction, adjust the position of the collision point to obtain candidate position points;

[0205] Using candidate location points as target points, repeat the steps to perform collision detection on the initial virtual terrain based on preset rays and target points to determine collision points. Then, adjust the position of the collision points according to preset directions to obtain candidate location points until no collision points exist. The surface location point is the location point determined by the candidate location points.

[0206] In some embodiments, the adjustment unit 330 may also be used for:

[0207] If the distance between the target point and the ground location point is greater than the preset value, the target direction is determined based on the target point and the ground location point;

[0208] Adjust the position of the target point along the target direction to update the position of the surface location point.

[0209] (iv) Geomorphic generation unit 340

[0210] The terrain generation unit is used to generate a target virtual terrain based on the location points on the ground.

[0211] In some implementations, the terrain generation unit 340 can specifically be used for:

[0212] When the preset point includes the second vertex, adjust the height of the first vertex according to the height of the ground location point to obtain the target location point;

[0213] Generate a virtual terrain based on the location points on the ground and the target location points.

[0214] In some implementations, the terrain generation unit 340 can also be used for:

[0215] The first scene terrain and the second scene terrain are obtained by mapping the target virtual terrain and the initial virtual terrain onto the virtual scene, respectively.

[0216] Based on the height field of the second scene's terrain, adjust the height field of the second scene's terrain to obtain the target scene's terrain.

[0217] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0218] Therefore, the embodiments of this application can automatically generate target virtual terrain with high adaptability to the virtual scene where the initial virtual terrain is located, which can be directly mapped in the virtual scene. This not only has high generation efficiency, but also optimizes the display effect.

[0219] Accordingly, this application also provides a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA) and other terminal devices.

[0220] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 400 includes a processor 410 with one or more processing cores, a memory 420 with one or more computer-readable storage media, and a computer program stored in the memory 420 and executable on the processor. The processor 410 is electrically connected to the memory 420. Those skilled in the art will understand that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0221] The processor 410 is the control center of the computer device 400. It connects various parts of the computer device 400 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 420, and calling data stored in the memory 420, it performs various functions of the computer device 400 and processes data, thereby monitoring the computer device 400 as a whole.

[0222] In this embodiment, the processor 410 in the computer device 400 loads the instructions corresponding to the processes of one or more applications into the memory 420 according to the following steps, and the processor 410 runs the applications stored in the memory 420 to achieve various functions:

[0223] Obtain the terrain shape of the initial virtual terrain; determine the collision point between the preset ray and the initial virtual terrain, the preset ray passes through the target point, the target point includes the preset point of the terrain shape; adjust the position of the collision point according to the preset direction to obtain the surface position point, the preset direction is related to the height of the initial virtual terrain; generate the target virtual terrain according to the surface position point.

[0224] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0225] Optional, such as Figure 4 As shown, the computer device 400 also includes: a touch screen display 430, a radio frequency circuit 440, an audio circuit 450, an input unit 460, and a power supply 470. The processor 410 is electrically connected to the touch screen display 430, the radio frequency circuit 440, the audio circuit 450, the input unit 460, and the power supply 470. Those skilled in the art will understand that... Figure 4 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0226] The touch display screen 430 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 430 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 410. It can also receive and execute commands from the processor 410. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 410 to determine the type of touch event. Subsequently, the processor 410 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and display panel can be integrated into the touch display screen 430 to achieve input and output functions. However, in some embodiments, the touch panel and display panel can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 430 can also be used as part of the input unit 460 to achieve input functions.

[0227] In this embodiment, a game application is executed by processor 410 to generate a graphical user interface (GUI) on touch display screen 430. The virtual scene on the GUI includes at least one skill control area, and the skill control area includes at least one skill control. The touch display screen 430 is used to present the GUI and receive operation commands generated by the user interacting with the GUI.

[0228] The radio frequency circuit 440 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other computer devices, and to transmit and receive signals with network devices or other computer devices.

[0229] Audio circuitry 450 can be used to provide an audio interface between a user and a computer device via a speaker and a microphone. Audio circuitry 450 can convert received audio data into electrical signals and transmit them to the speaker, where the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 450, converted back into audio data, and then processed by processor 410 before being transmitted via radio frequency circuitry 440 to, for example, another computer device, or output to memory 420 for further processing. Audio circuitry 450 may also include an earphone jack to facilitate communication between peripheral headphones and the computer device.

[0230] The input unit 460 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.

[0231] Power supply 470 is used to supply power to various components of computer device 400. Optionally, power supply 470 can be logically connected to processor 410 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 470 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0232] although Figure 4 As not shown in the diagram, computer equipment 400 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.

[0233] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0234] As can be seen from the above, the computer device provided in this embodiment can automatically generate a target virtual terrain with high adaptability to the virtual scene where the initial virtual terrain is located, which can be directly mapped in the virtual scene. It not only has high generation efficiency, but also optimizes the display effect.

[0235] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0236] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute steps in any of the virtual terrain generation methods provided in embodiments of this application. For example, the computer program can execute the following steps:

[0237] Obtain the terrain shape of the initial virtual terrain; determine the collision point between the preset ray and the initial virtual terrain, the preset ray passes through the target point, the target point includes the preset point of the terrain shape; adjust the position of the collision point according to the preset direction to obtain the surface position point, the preset direction is related to the height of the initial virtual terrain; generate the target virtual terrain according to the surface position point.

[0238] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0239] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0240] Since the computer program stored in the storage medium can execute the steps in any of the virtual terrain generation methods provided in the embodiments of this application, the beneficial effects that any of the virtual terrain generation methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0241] The foregoing has provided a detailed description of a method, apparatus, computer device, and storage medium for generating virtual terrain according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for generating virtual terrain, characterized in that, include: Obtain the terrain shape of the initial virtual landform, which includes shape lines or patch models; Determine the collision point between the preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; According to a preset direction, the position of the collision point is adjusted to obtain the ground position point. The preset direction is related to the height of the initial virtual terrain. The preset direction includes the direction from top to bottom in the virtual scene, or the direction from bottom to top in the virtual scene. Based on the surface location points, a target virtual terrain is generated, wherein the surface location points are used to constitute the surface of the target virtual terrain; The step of determining the collision point between the preset ray and the initial virtual terrain includes: Determine the collision position between the preset ray and the initial virtual terrain; Move the target point to the collision location of the initial virtual terrain to obtain the collision point; The step of adjusting the position of the collision point according to a preset direction to obtain the ground location point includes: The position of the collision point is adjusted from bottom to top or from top to bottom along a preset direction to obtain candidate position points; Using the candidate location points as the target points, the steps are repeated to perform collision detection on the initial virtual terrain based on the preset ray and the target points to determine the collision points. Then, the positions of the collision points are adjusted according to the preset direction to obtain candidate location points until no collision points exist. The surface location point is the location point determined by the candidate location points.

2. The method for generating virtual terrain as described in claim 1, characterized in that, The process of obtaining the terrain shape of the initial virtual landform includes: Convert the initial virtual terrain into shape lines; Based on the shape lines, a patch model conforming to the shape lines is generated to obtain the terrain shape, wherein the patch model includes at least one patch component.

3. The method for generating virtual terrain as described in claim 2, characterized in that, The process of obtaining the terrain shape of the initial virtual landform and determining the collision point between the preset ray and the initial virtual landform also includes: A first vertex and a second vertex are determined from the vertices of the patch assembly, wherein the first vertex and the second vertex have different heights along the preset direction; The direction of the preset ray is determined based on the first vertex and the second vertex.

4. The method for generating virtual terrain as described in claim 3, characterized in that, Determining the first vertex and the second vertex from the vertices of the patch component based on the height of the vertices of the patch component along the preset direction includes: The height values ​​of all first side vertices and all second side vertices in the facet component are obtained respectively to obtain the first height sum and the second height sum. The first side vertices and the second side vertices are located on both sides of the facet component respectively. The vertex corresponding to the relatively larger sum of the first height and the relatively smaller sum of the second height is determined as the first vertex, and the vertex corresponding to the relatively smaller sum of the second height is determined as the second vertex.

5. The method for generating virtual terrain as described in claim 3, characterized in that, Determining the direction of the preset ray based on the first vertex and the second vertex includes: Determine the direction of any preset ray based on any of the associated first vertices and any of the associated second vertices.

6. The method for generating virtual terrain as described in claim 3, characterized in that, The step of generating a target virtual terrain based on the surface location points includes: When the preset point includes the second vertex, the height of the first vertex is adjusted according to the height of the ground location point to obtain the target location point; Based on the surface location points and the target location points, a target virtual terrain is generated; Adjusting the height of the first vertex based on the height of the surface location point includes: Move the first vertex up to the same height as the corresponding ground location point.

7. The method for generating virtual terrain as described in claim 1, characterized in that, The process of obtaining the terrain shape of the initial virtual landform includes: The initial virtual terrain is converted into shape lines to obtain the terrain shape.

8. The method for generating virtual terrain as described in claim 1, characterized in that, After adjusting the position of the collision point according to a preset direction to obtain the ground location point, the method further includes: If the distance between the target point and the surface location point is greater than a preset value, the target direction is determined based on the target point and the surface location point; The target point is moved a preset distance along the target direction to update the position of the ground location point.

9. The method for generating virtual terrain as described in claim 1, characterized in that, After generating the target virtual terrain based on the surface location points, the process further includes: Obtain the first scene terrain and the second scene terrain, which are respectively obtained by mapping the target virtual terrain and the initial virtual terrain onto the virtual scene; The target scene terrain is obtained by subtracting the height field of the first scene terrain from the height field of the second scene terrain.

10. A device for generating virtual terrain, characterized in that, include: A shape generation unit is used to obtain the terrain shape of the initial virtual landform, which includes shape lines or patch models; A determining unit is used to determine the collision point between a preset ray and the initial virtual terrain, wherein the preset ray passes through a target point, and the target point includes a preset point of the terrain shape; An adjustment unit is used to adjust the position of the collision point according to a preset direction to obtain a ground position point. The preset direction is related to the height of the initial virtual terrain. The preset direction includes a direction from top to bottom in the virtual scene or a direction from bottom to top in the virtual scene. A terrain generation unit is used to generate a target virtual terrain based on the surface location points, wherein the surface location points are used to form the surface of the target virtual terrain. The step of determining the collision point between the preset ray and the initial virtual terrain includes: determining the collision position between the preset ray and the initial virtual terrain; moving the target point to the collision position of the initial virtual terrain to obtain the collision point; The step of adjusting the position of the collision point according to a preset direction to obtain a surface location point includes: adjusting the position of the collision point from bottom to top or from top to bottom along a preset direction to obtain a candidate location point; using the candidate location point as the target point, repeatedly performing collision detection on the initial virtual terrain according to a preset ray and the target point to determine the collision point, until the step of adjusting the position of the collision point according to the preset direction to obtain a candidate location point continues until no collision point exists, and the surface location point is the location point determined by the candidate location point.

11. A computer device, characterized in that, The system includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps in the virtual terrain generation method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the virtual terrain generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Landform generation method and device, computer equipment and storage medium

    CN111784789A

  • Virtual terrain processing method and device, storage medium and electronic equipment

    CN114022629A