Method, apparatus, storage medium and electronic device for generating terrain mesh
By constructing a virtual terrain model on the first terrain grid and generating height data maps, combined with baked mesh matching, the problems of poor terrain model height representation and insufficient design flexibility are solved, achieving a more natural terrain height representation and greater design flexibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-05-12
- Publication Date
- 2026-06-19
Smart Images

Figure CN116570915B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, storage medium, and electronic device for generating terrain grids. Background Technology
[0002] In recent years, a large number of simulation strategy games (SLGs) based on hexagonal grids have emerged, with the terrain of these SLGs being created using hexagonal grids as units. The existing terrain creation methods involve pre-creating hexagonal grids and corresponding terrain models on them, then assembling them together; or using terrain brushes based on hexagonal grids for terrain editing and generation. However, when the terrain models corresponding to the hexagonal grids in the game scene have arbitrary altitudes, the above methods struggle to achieve smooth height transitions between these models (such as cliffs and slopes). Therefore, how to generate effective model heights corresponding to the terrain grids has become a significant problem in this field. Currently, no effective solution has been proposed to address this issue.
[0003] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0004] At least some embodiments of this application provide a method, apparatus, storage medium, and electronic device for generating terrain meshes, in order to at least solve the technical problems in the related art where the lack of a suitable terrain mesh production method leads to poor height representation of terrain models and poor flexibility in terrain design.
[0005] According to one embodiment of this application, a method for generating a terrain mesh is provided, comprising: constructing a virtual terrain model on a first terrain mesh and generating a first height map corresponding to the virtual terrain model, wherein the first terrain mesh is an initial terrain mesh for constructing the virtual terrain model, and the first height map is a base height map; matching the first terrain mesh with a second terrain mesh to generate a height data map, wherein the second terrain mesh is a baked mesh corresponding to the virtual terrain model, the height data map is used to generate the second height map, and the second height map is the height map to be used by the virtual terrain model in the game; obtaining the second height map using the first height map and the height data map; and generating a target terrain mesh based on the second height map, wherein the target terrain mesh is the terrain mesh to be used in the game.
[0006] According to one embodiment of this application, an apparatus for generating a terrain mesh is also provided, comprising: a first generation module, configured to construct a virtual terrain model on a first terrain mesh and generate a first height map corresponding to the virtual terrain model, wherein the first terrain mesh is an initial terrain mesh for constructing the virtual terrain model, and the first height map is a base height map; a second generation module, configured to match the first terrain mesh and a second terrain mesh to generate a height data map, wherein the second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate a second height map, the second height map being a height map to be used by the virtual terrain model in the game; an acquisition module, configured to acquire the second height map using the first height map and the height data map; and a third generation module, configured to generate a target terrain mesh based on the second height map, wherein the target terrain mesh is a terrain mesh to be used in the game.
[0007] According to one embodiment of this application, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to execute the method for generating terrain mesh as described above when running.
[0008] According to one embodiment of this application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method of generating terrain mesh as described above.
[0009] In at least some embodiments of this application, a virtual terrain model is constructed on a first terrain mesh, and a first height map corresponding to the virtual terrain model is generated. The first terrain mesh is the initial terrain mesh used to construct the virtual terrain model, and the first height map is the base height map. Further, the first terrain mesh and a second terrain mesh are matched to generate a height data map. The second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate the second height map, which is the height map to be used by the virtual terrain model in the game. The second height is obtained using the first height map and the height data map. A target terrain mesh is generated based on the second height map, which is the terrain mesh to be used in the game. Therefore, the method provided by this application achieves the goal of generating a usable terrain mesh by combining the height data map obtained from matching the initial terrain mesh and the baked mesh with the base height map corresponding to the terrain model. This achieves the technical effect of enriching the height representation of the terrain model and improving the design flexibility of the terrain model corresponding to the terrain mesh. It also solves the technical problem in related technologies where the lack of a suitable terrain mesh production method leads to poor height representation of the terrain model and poor terrain design flexibility. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0011] Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of generating terrain mesh according to one embodiment of this application;
[0012] Figure 2 This is a flowchart of a method for generating a terrain mesh according to one embodiment of this application;
[0013] Figure 3 This is a schematic diagram of an optional virtual terrain model according to one embodiment of this application;
[0014] Figure 4 This is an optional first height view according to one embodiment of this application;
[0015] Figure 5 This is a schematic diagram of a second terrain grid according to one embodiment of this application;
[0016] Figure 6 This is a schematic diagram showing the positional relationship between an optional first terrain grid and a second terrain grid according to one embodiment of this application;
[0017] Figure 7 This is a schematic diagram of height data corresponding to an optional first terrain grid according to one embodiment of this application;
[0018] Figure 8 This is a schematic diagram showing the positional relationship between another optional first terrain grid and second terrain grid according to one embodiment of this application;
[0019] Figure 9 This is a schematic diagram of the three-dimensional coordinates of an optional second terrain grid according to one embodiment of this application;
[0020] Figure 10 This is a schematic diagram of an optional rotation transformation of a second cell according to one embodiment of this application;
[0021] Figure 11 This is a schematic diagram of an optional height matching method according to one embodiment of this application;
[0022] Figure 12 This is an optional second height view according to one embodiment of this application;
[0023] Figure 13 This is a schematic diagram of an optional target terrain grid according to one embodiment of this application;
[0024] Figure 14 This is a structural block diagram of an apparatus for generating terrain mesh according to one embodiment of this application;
[0025] Figure 15 This is a schematic diagram of an electronic device according to one embodiment of the present application. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] It should be noted that, in the specification 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 this application. In the following description, details are set forth for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid unnecessarily obscuring the description of this application. Therefore, this application 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.
[0029] In recent years, a large number of simulation strategy games (SLGs) based on hexagonal grids have emerged, and the terrain of these SLG games is created using hexagonal grids as units. Currently, there are two main technical solutions for this.
[0030] The first method involves generating terrain using software with terrain editing capabilities, exporting terrain height maps and texture distribution maps, and then importing these maps into the game engine to recreate the scene terrain within the engine's terrain system. The drawbacks of this method are: the terrain models generated by this software have a high polygon count, resulting in a very large amount of terrain mesh data when the terrain is complex; furthermore, the generated terrain models are fixed and cannot support random adjustments by the game engine or secondary editing by technical personnel, thus lacking flexibility.
[0031] The second method involves creating a hexagonal grid-based terrain model according to the scene requirements. Then, different hexagonal grids and their corresponding terrain models are stitched together manually or programmatically to generate the scene terrain. The drawback of this method is that the resulting terrain is fixed, and the resulting terrain stitching has limited visual effects, making it difficult to achieve smooth transitions between different elevations in a game scene.
[0032] Therefore, how to generate the model height effect corresponding to the terrain mesh has become one of the important problems in the relevant technical field. Currently, no effective solution has been proposed to address this problem.
[0033] In one possible implementation of this application, the inventors, after practice and careful research, found that the two existing technical solutions commonly used in the context of the height representation effect of virtual terrain models in the fields of computer technology and video games still have technical problems such as poor height representation effect of terrain models and poor flexibility in terrain model design. Based on this, the application scenarios of the embodiments of this application can be application scenarios involving the height representation effect of virtual terrain models in the fields of computer graphics, virtual reality / augmented reality and video games. In particular, taking the field of video games as an example, the target game types can be action, adventure, simulation, role-playing and casual games, etc.
[0034] This application proposes a method for generating terrain meshes. A terrain model is established based on a hexagonal terrain mesh, and an initial height map corresponding to the terrain model is generated. Then, the hexagonal terrain mesh is matched with a baked triangular mesh to generate a height data texture map corresponding to the terrain model. Further, using the initial height map and the height data texture map, a height map to be used corresponding to the terrain model is generated, thereby generating a terrain mesh to be used. Therefore, the above-mentioned method of this application embodiment achieves the technical effects of enriching the height representation of the terrain model and improving the design flexibility of the terrain model corresponding to the terrain mesh, thus solving the technical problems in related technologies where the lack of suitable terrain mesh production methods leads to poor height representation of terrain models and poor terrain design flexibility.
[0035] The methods described in this application can be executed in a terminal device (e.g., a mobile terminal, a computer terminal, or a similar computing device). Taking a mobile terminal as an example, the mobile terminal can be a smartphone, tablet computer, PDA, mobile internet device, game console, or other terminal device.
[0036] Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of generating terrain mesh according to one embodiment of this application. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 (Only one is shown) Processor 102, memory 104, transmission device 106, input / output device 108, and display device 110. Taking the method of generating terrain meshes applied to a video game scene via this mobile terminal as an example, processor 102 calls and runs the computer program stored in memory 104 to execute the method of generating terrain meshes. The generated terrain meshes to be used in the game are transmitted to input / output device 108 and / or display device 110 via transmission device 106, thereby providing the terrain meshes to the player.
[0037] Still as Figure 1As shown, the processor 102 may include, but is not limited to, processing devices such as: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Digital Signal Processing (DSP) chip, Microcontroller Unit (MCU), Field Programmable Gate Array (FPGA), Neural-Network Processing Unit (NPU), Tensor Processing Unit (TPU), Artificial Intelligence (AI) type processor, etc.
[0038] Those skilled in the art will understand that Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0039] In some optional embodiments primarily focused on gaming scenarios, the aforementioned terminal device may also provide a human-computer interaction interface with a touch-sensitive surface. This interface can sense finger contact and / or gestures to interact with a graphical user interface (GUI). The human-computer interaction functions may include the following: creating web pages, drawing, word processing, creating electronic documents, playing games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. Executable instructions for performing the aforementioned human-computer interaction functions are configured / stored in one or more processor-executable computer program products or readable storage media.
[0040] The methods described in this application can also be executed on a server. 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, content delivery networks (CDNs), and big data and artificial intelligence platforms. Taking the method of generating terrain meshes applied to a video game scene via a video game server as an example, the video game server can generate terrain meshes to be used in the game based on this method and provide the terrain meshes to the player (e.g., by rendering and displaying them on the player's terminal screen, or by providing them to the player through holographic projection, etc.).
[0041] According to one embodiment of this application, an embodiment of a method for generating a terrain mesh is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0042] This embodiment provides a method for generating terrain meshes that runs on the aforementioned mobile terminal. Figure 2 This is a flowchart of a method for generating a terrain mesh according to one embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0043] Step S21: Construct a virtual terrain model on the first terrain grid and generate a first elevation map corresponding to the virtual terrain model. The first terrain grid is the initial terrain grid for constructing the virtual terrain model, and the first elevation map is the base elevation map.
[0044] Step S22: Match the first terrain mesh and the second terrain mesh to generate a height data map. The second terrain mesh is the baked mesh corresponding to the virtual terrain model. The height data map is used to generate a second height map, which is the height map of the virtual terrain model to be used in the game.
[0045] Step S23: Obtain the second height map using the first height map and the height data texture;
[0046] Step S24: Generate a target terrain mesh based on the second elevation map, wherein the target terrain mesh is the terrain mesh to be used in the game.
[0047] In one optional implementation, the first terrain mesh is a hexagonal grid-based terrain mesh (such as the scene terrain mesh in an SLG game). The virtual terrain model can be a virtual 3D terrain model in a video game scene, such as mountains, grasslands, rocks, waterfalls, cliffs, hills, etc. The first height map is a texture that records the model height data of the virtual terrain model. In this implementation, the first terrain mesh is used as the initial terrain mesh, and the first height map is used as the base height map. Based on this, using preset modeling software or image processing software, the virtual terrain model is constructed on the first terrain mesh, and the first height map corresponding to the virtual terrain model is generated.
[0048] The game types corresponding to the above-mentioned video game scenarios can be: action games (e.g., first-person or third-person shooter games, 2D or 3D fighting games, war action games, and sports action games), adventure games (e.g., exploration games, collection games, puzzle games), simulation games (e.g., simulation sandbox games, simulation management games, strategy simulation games, city building simulation games, business simulation games), role-playing games, and casual games (e.g., board games, casual competitive games, music rhythm games, dress-up and simulation games), etc.
[0049] In one optional implementation, the second terrain mesh is a baked mesh corresponding to the virtual terrain model. The grid cells of this baked mesh can be triangular lattice cells; that is, the second terrain mesh is a terrain mesh based on triangular lattice cells. Based on the grid cells, height data matching is performed on the second terrain mesh within the first terrain mesh to obtain the height data map. The height data map is a map that records the height matching data of the virtual terrain model. This height data map is used to generate a height map of the virtual terrain model to be used in the game scene.
[0050] The aforementioned second height map is the height map to be used in the game scene. The second height map is obtained using the first height map and height data textures. In other words, the second height map is a height map to be used, determined by combining the base height map of the virtual terrain model, the first terrain mesh, and the second terrain mesh. It contains richer height information corresponding to the virtual terrain model. The target terrain mesh generated based on the second height map has a more natural terrain height representation effect. Using this target terrain mesh in the game scene can improve the richness of the visuals and the realism of the scene, thus enhancing the player's gaming experience.
[0051] In at least some embodiments of this application, a virtual terrain model is constructed on a first terrain mesh, and a first height map corresponding to the virtual terrain model is generated. The first terrain mesh is the initial terrain mesh used to construct the virtual terrain model, and the first height map is the base height map. Further, the first terrain mesh and a second terrain mesh are matched to generate a height data map. The second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate the second height map, which is the height map to be used by the virtual terrain model in the game. The second height is obtained using the first height map and the height data map. A target terrain mesh is generated based on the second height map, which is the terrain mesh to be used in the game. Therefore, the method provided by this application achieves the goal of generating a usable terrain mesh by combining the height data map obtained from matching the initial terrain mesh and the baked mesh with the base height map corresponding to the terrain model. This achieves the technical effect of enriching the height representation of the terrain model and improving the design flexibility of the terrain model corresponding to the terrain mesh. It also solves the technical problem in related technologies where the lack of a suitable terrain mesh production method leads to poor height representation of the terrain model and poor terrain design flexibility.
[0052] The methods provided in this application embodiment can be applied, but are not limited to, to the application scenario of generating scene terrain meshes in SLG games. The following uses this application scenario as an example to further describe the above methods in this application embodiment.
[0053] Optionally, the first terrain grid includes: a plurality of first cells, the shape of which adopts a first planar geometry. In step S21, constructing a virtual terrain model on the first terrain grid may include the following execution steps:
[0054] Step S211: Determine the construction area on the first terrain grid;
[0055] Step S212: Obtain the altitude of at least a portion of the first cells within the constructed area;
[0056] Step S213: Calculate the elevation difference between every two adjacent cells in at least part of the first cell using the elevation, wherein the elevation difference is used to determine the representation of multiple types of landforms;
[0057] Step S214: Construct a virtual terrain model based on the elevation difference.
[0058] When generating a scene terrain mesh in an SLG game, the first terrain mesh may include multiple first cells, and each of the multiple first cells adopts a first planar geometry. Figure 3 This is a schematic diagram of an optional virtual terrain model according to one embodiment of this application, such as... Figure 3As shown, a virtual terrain model is constructed on a first terrain grid, where each of the multiple first cells in the first terrain grid is a regular hexagon. Furthermore, based on the scene requirements of an SLG game, in... Figure 3 The construction area of the virtual terrain model is determined on the hexagonal terrain grid (i.e., the first terrain grid), and the elevation of each first cell in at least a portion of the first cells within this construction area is obtained, such as... Figure 3 The numerical labels on the virtual terrain model represent the elevation of the corresponding first cell (i.e., the hexagonal grid). The elevation difference between any two adjacent cells in at least a portion of the first cells is calculated using these elevation differences. These elevation differences are used to determine multiple types of terrain features, such as flat land, slopes, and cliffs, which correspond to multiple numerical ranges of elevation difference values. A virtual terrain model is constructed based on these elevation differences, containing at least one type of terrain feature.
[0059] Figure 4 This is an optional first height map according to one embodiment of this application. In such... Figure 3 After constructing a virtual terrain model on the first terrain grid shown, the following is derived based on the virtual terrain model: Figure 4 The height map shown.
[0060] Optionally, in step S214, constructing a virtual terrain model based on the elevation difference may include the following steps:
[0061] Step S2141: In response to the elevation difference being greater than or equal to the first value, determine that the terrain appearance between two adjacent cells is the first type of terrain appearance.
[0062] Step S2142: In response to the elevation difference value being equal to the second value, determine that the terrain appearance between two adjacent cells is the second type of terrain appearance;
[0063] Step S2143: In response to the elevation difference value being equal to the third value, determine that the terrain appearance between two adjacent cells is the third type of terrain appearance;
[0064] Step S2144: Construct a virtual terrain model based on the first type of landform representation, the second type of landform representation, and the third type of landform representation;
[0065] Among them, the first value is greater than the second value, and the second value is greater than the third value.
[0066] In one alternative implementation, the aforementioned multiple types of landform representations include: a first type of landform representation, a second type of landform representation, and a third type of landform representation.
[0067] Still as Figure 3 As shown, when constructing a virtual terrain model based on elevation differences, the first value is set to 2, the second value to 1, and the third value to 0. The first type of terrain is represented as a cliff, the second type as a slope, and the third type as flat land. For any two adjacent first cells, if the corresponding elevation difference is equal to or greater than 2, the terrain between the two first cells is determined to be a cliff; if the corresponding elevation difference is 1, the terrain between the two first cells is determined to be a slope; and if the corresponding elevation difference is 0, the terrain between the two first cells is determined to be flat land. A virtual terrain model is constructed based on the terrain representation between any two adjacent first cells in multiple first cells of the first terrain grid. This virtual terrain model can represent the transition effects between terrain models on multiple first cells, exhibiting a strong sense of physical realism.
[0068] Optionally, the second terrain grid includes: a plurality of second cells, the shape of which adopts a second planar geometry. In step S22, matching the first terrain grid and the second terrain grid to generate a height data map may include the following execution steps:
[0069] Step S221: In the first terrain grid, a plurality of third cells are determined based on the center positions of a plurality of first cells, wherein the shape of the plurality of third cells adopts a second planar geometry.
[0070] Step S222: Based on altitude, perform height matching on multiple second cells and multiple third cells to generate an altitude data texture.
[0071] When generating scene terrain meshes in SLG games, the second terrain mesh can include multiple second cells, each of which uses a second planar geometry. The aforementioned second terrain mesh is a baked mesh.
[0072] Figure 5 This is a schematic diagram of a second terrain grid according to one embodiment of this application, such as... Figure 5 As shown, each of the multiple second cells in the second terrain grid is a triangle. These second cells are referred to as baked triangle grids. Each baked triangle grid corresponds to a three-dimensional coordinate (X, Y, Z), and the three-dimensional coordinates of each baked triangle grid satisfy the following constraints: the sum of the three-dimensional coordinates of a baked triangle grid with its apex pointing upwards (i.e., "△") is 2; the sum of the three-dimensional coordinates of a baked triangle grid with its apex pointing downwards (i.e., "▽") is 1.
[0073] Specifically, such as Figure 5The numerical pattern of the three-dimensional coordinates of the baked triangle grid in the second terrain grid shown is as follows: the X-direction is the direction in which the X coordinate value increases, the Y-direction is the direction in which the Y coordinate value increases, and the Z-direction is the direction in which the Z coordinate value increases.
[0074] Figure 6 This is a schematic diagram illustrating the positional relationship between an optional first terrain grid and a second terrain grid according to one embodiment of this application, as shown below. Figure 6 As shown, the first terrain grid uses hexagonal grids as its cells, while the second terrain grid uses baked triangle grids. The center of each hexagonal grid is an endpoint of a baked triangle grid. Specifically, the center of each hexagonal grid is the common vertex of its six corresponding baked triangle grids.
[0075] Figure 7 This is a schematic diagram of height data corresponding to an optional first terrain grid according to one embodiment of this application, such as... Figure 7 As shown, the hexagonal grids displaying numbers indicate the altitude of the corresponding hexagonal grid. A larger number indicates a higher altitude of the virtual terrain model on that hexagonal grid. For example, two hexagonal grids with a value of 3 correspond to... Figure 4 The area displayed in the middle is white (without grayscale).
[0076] Figure 8 This is a schematic diagram showing the positional relationship between another optional first terrain grid and second terrain grid according to one embodiment of this application. Figure 7 The location distribution of the second terrain grid (i.e., multiple baked triangle grids) corresponding to the first terrain grid (i.e., multiple hexagonal grids) shown is as follows: Figure 8 As shown. Figure 9 This is a schematic diagram of the three-dimensional coordinates of an optional second terrain grid according to one embodiment of this application. Figure 8 In the second terrain grid shown in the image, the three-dimensional coordinates of each baked triangle grid are as follows: Figure 9 As shown, the numerical patterns of three-dimensional coordinates can be referenced. Figure 5 The corresponding explanations will not be elaborated upon.
[0077] When generating scene terrain meshes in an SLG game, multiple third cells are determined within the first terrain mesh based on the center positions of multiple hexagonal grids. Each of these third cells is a triangular grid. Since these multiple third cells are determined by the center positions of multiple hexagonal grids in the game scene, they are referred to as game triangular grids. Furthermore, based on the elevation corresponding to each hexagonal grid, multiple baked triangular grids and multiple game triangular grids are height-matched to generate the aforementioned height data texture.
[0078] It is readily understood that, according to the method provided in the embodiments of this application, the terrain height information to be used in the game scene is determined by mapping the height information of the second terrain grid to the first terrain grid of the game scene.
[0079] Since each hexagonal grid is composed of a portion of six corresponding triangular grids, and each triangular grid is composed of a portion of three corresponding hexagonal grids, the combination of hexagonal and triangular grids in determining the terrain grid to be used has a richer expressiveness compared to terrain grids that only use hexagonal grids in related technologies.
[0080] Optionally, in step S222, the height matching of multiple second cells and multiple third cells based on altitude to generate a height data map may include the following steps:
[0081] Step S2221: Rotate and transform multiple second cells to obtain the transformed cells;
[0082] Step S2222: Based on the altitude, perform height matching between the transformed cell and multiple third cells to generate an altitude data texture.
[0083] In one alternative implementation, when generating a scene terrain mesh in an SLG game, multiple baked triangle grids (i.e. multiple second cells) in the second terrain mesh are rotated and transformed to obtain the transformed cells. Figure 10 This is a schematic diagram of an optional rotation transformation of a second cell according to one embodiment of this application, as shown below. Figure 10 As shown, rotating multiple baking triangle grids includes the following 12 cases (hereinafter, rotation refers to clockwise rotation):
[0084] Transformation 1: Rotate 0 degrees (i.e., no transformation);
[0085] Transformation 2: Rotate 120 degrees;
[0086] Transformation 3: Rotate 240 degrees;
[0087] Transformation 4: Rotate 60 degrees;
[0088] Transformation 5: Rotate 180 degrees;
[0089] Transformation 6: Rotate 300 degrees;
[0090] Transformation 7: Rotate 0 degrees, mirror image in the X direction;
[0091] Transformation 8: Rotate 120 degrees, mirror image in the X direction;
[0092] Transformation 9: Rotate 240 degrees, mirror image in the X direction;
[0093] Transformation 10: Rotate 60 degrees, mirror image in the X direction;
[0094] Transformation 11: Rotate 180 degrees, mirror image in the X direction;
[0095] Transformation 12: Rotate 300 degrees, mirror flip in the X direction.
[0096] Each of the baked triangle grids (i.e., multiple second cells) in the second terrain grid undergoes at least one of the above rotation transformations to obtain multiple rotated baked triangle grids. Based on the elevation corresponding to each hexagonal grid in the multiple hexagonal grids, the heights of the rotated baked triangle grids and the multiple game triangle grids are matched to generate the above-mentioned height data texture.
[0097] It's easy to understand that since the altitude of the virtual terrain model corresponding to the multiple hexagonal grids in the first terrain grid of the game scene is arbitrary, the terrain representation of the corresponding type in the game scene is mapped to the baked grid. That is, the game triangle grids in the game scene that represent flat land are mapped to the baked triangle grids in the baked grids that represent flat land; the game triangle grids in the game scene that represent slopes are mapped to the baked triangle grids that represent slopes; and the game triangle grids in the game scene that represent cliffs are mapped to the baked triangle grids that represent cliffs.
[0098] Figure 11 This is a schematic diagram of an optional height matching method according to one embodiment of this application, such as... Figure 11 As shown, solid-lined triangles represent game triangles, and dashed-lined triangles represent transformed baking triangles. The number corresponding to each corner of each triangle represents the altitude of the hexagonal grid corresponding to that corner. Within each triangle, if the altitude difference between two corners is greater than or equal to 2, the terrain type corresponding to the edge between those two corners is a cliff; if the altitude difference is equal to 1, the terrain type corresponding to the edge between those two corners is a slope; and if the altitude difference is equal to 0, the terrain type corresponding to the edge between those two corners is flat. Altitude matching based on multiple transformed baking triangles and multiple game triangles includes, but is not limited to, the following: Figure 11 The four matching methods shown are easy to understand. They map the terrain type corresponding to each edge of multiple game triangle grids to the terrain type of the corresponding edge in the transformed baked triangle grid.
[0099] When generating scene terrain meshes in an SLG game, the height map corresponding to the virtual terrain model is read. Based on this height map, multiple hexagonal grids of the first terrain mesh in the game scene are assigned altitudes. Then, based on the center positions of the multiple hexagonal grids, multiple game triangle grids are generated, each carrying corresponding altitude information. Further, the multiple game triangle grids are traversed, and each game triangle grid is matched with multiple baked triangle grids according to its altitude. After matching, each game triangle grid is matched with a corresponding baked triangle grid. The height data of the matched game triangle grids is exported to generate a height data texture map to be used in the game scene.
[0100] Optionally, in the above method for generating terrain meshes, the height data map includes: a first data map, wherein the first data map includes: a first map channel, a second map channel, a third map channel, and a fourth map channel. The first part of the storage space of the first map channel and the second map channel is used to store the vertex elevation of multiple third cells. The second part of the storage space of the second map channel is used to store the cell state of multiple cells, and the cell state is used to determine whether the vertex elevation of the same cell is the same. The first part of the storage space of the third map channel and the fourth map channel is used to store the vertex elevation of multiple second cells. The second part of the storage space of the fourth map channel is used to store the rotation transformation index of multiple second cells, and the rotation transformation index is used to determine the rotation transformation matrix corresponding to multiple second cells.
[0101] When generating scene terrain meshes in SLG games, the generated height data texture includes a first data texture. Each pixel in the first data texture corresponds to the height data and height matching information of a game triangle grid. The first texture channel (R channel in this example) and the first part of the storage space of the second texture channel (the first 4 bits of the G channel in this example) of the first data texture are used to store the vertex elevation of multiple game triangle grids (i.e., multiple third cells); the second part of the storage space of the second texture channel of the first data texture (the remaining storage space of the G channel excluding the first 4 bits in this example) is used to store the cell state of multiple game triangle grids. The cell state is used to determine whether the vertex elevation of the same cell is the same (in this example, the cell state is "whether it is flat ground"); the third texture channel (B channel in this example) and the first part of the storage space of the fourth texture channel of the first data texture (the first 4 bits of the A channel in this example) are used to store the vertex elevation of multiple transformed baked triangle grids (i.e., multiple second cells); the second part of the storage space of the fourth texture channel of the first data texture (the remaining storage space of the A channel excluding the first 4 bits in this example) is used to store the rotation transformation index of multiple transformed baked triangle grids. The rotation transformation index is used to determine the rotation transformation matrix (i.e., ...) corresponding to multiple transformed baked triangle grids. Figure 10 (The corresponding transformation type in the text).
[0102] Optionally, in the above method for generating terrain mesh, the height data map further includes: a second data map, wherein the second data map includes: a fifth map channel and a sixth map channel, the fifth map channel is used to store the planar coordinates of multiple second cells, and part of the storage space of the sixth map channel is used to store the mesh state of the second terrain mesh, the mesh state being used to determine the top orientation of the second terrain mesh.
[0103] When generating scene terrain meshes in an SLG game, the generated height data map includes a second data map. Each pixel of the second data map corresponds to the height data and height matching information of a game triangle grid. The fifth map channel of the second data map (R channel in this example) is used to store the planar coordinates (X, Y coordinates) of multiple transformed baked triangle grids (i.e., multiple second cells). Part of the storage space of the sixth map channel of the second data map (the first storage space of the G channel in this example) is used to store the grid state of the baked mesh (i.e., the second terrain mesh). The grid state is used to determine the orientation of the top of multiple transformed baked triangle grids in the baked mesh (in this example, the grid state is "whether the triangle tip is pointing upwards").
[0104] Optionally, in step S23, obtaining a second height map using the first height map and the height data texture may include the following steps:
[0105] Step S231: Divide the virtual terrain model to obtain multiple virtual plots;
[0106] Step S232: Use the first height map and height data texture to obtain the second height map corresponding to each virtual plot in the multiple virtual plots.
[0107] When generating scene terrain meshes in an SLG game, the virtual terrain model is divided into multiple virtual chunks. Based on the base height map corresponding to the virtual terrain model and the aforementioned height data texture (which may include the aforementioned first data texture and the aforementioned second data texture), a corresponding second height map is generated for each virtual chunk.
[0108] For example, for a virtual terrain model with a size of 300×300, if the preset size of each virtual plot is 20×20, then the virtual terrain model needs to be divided into 15×15 virtual plots. Furthermore, to ensure correct edge sampling of the height data texture, the virtual plots used to generate the second height map will be slightly larger; for example, if the preset size of each virtual plot is 20×20, but the size of the virtual plots used to generate the second height map is 22×22.
[0109] Optionally, in step S232, obtaining a second height map corresponding to each virtual plot among multiple virtual plots using the first height map and height data texture may include the following execution steps:
[0110] Step S2321: Determine the data map index corresponding to each virtual plot from the second data map;
[0111] Step S2322: Use the data texture index to obtain the first parameter, second parameter, third parameter and fourth parameter corresponding to each virtual plot from the first data texture. The first parameter is used to determine the minimum vertex elevation of the third cell corresponding to each virtual plot, the second parameter is used to determine the minimum vertex elevation of the second cell corresponding to each virtual plot, the third parameter is used to determine the centroid interpolation result of the third cell corresponding to each virtual plot, and the fourth parameter is used to determine the centroid interpolation result of the second cell corresponding to each virtual plot.
[0112] Step S2323: Perform height sampling on the first height map to obtain the sampling results;
[0113] Step S2324: Based on the first parameter, the second parameter, the third parameter, the fourth parameter, the sampling result, the first unit height, and the second unit height, generate a second height map corresponding to each virtual plot, wherein the first unit height is the preset unit height of the first height map, and the second unit height is the preset unit height of the second height map.
[0114] When generating scene terrain meshes in an SLG game, the two-dimensional coordinates (X, Y) of the triangular grids in the second data texture of the height data map are determined as the data texture index for each virtual plot. The first, second, third, and fourth parameters for each virtual plot are obtained from the first data texture using the data texture index. The first parameter is used to determine the minimum vertex elevation of the third cell for each virtual plot, denoted as `minElevation`; the second parameter is used to determine the minimum vertex elevation of the second cell for each virtual plot, denoted as `minBakingElevation`; the third parameter is used to determine the centroid interpolation result of the third cell for each virtual plot, denoted as `elevationHeight`; and the fourth parameter is used to determine the centroid interpolation result of the second cell for each virtual plot, denoted as `elevationBakingHeight`. Further, height sampling is performed based on the base height map corresponding to the virtual terrain model to obtain the sampled result, denoted as `sampleHeight`. Determine the preset unit height for the base heightmap, denoted as heightUnit (1 in this example); determine the preset unit height for the heightmaps to be used for multiple virtual tiles in the game, denoted as SampleHeightUnit (0.25 in this example). Based on the first parameter minElevation, the second parameter minBakingElevation, the third parameter elevationHeight, the fourth parameter elevationBakingHeight, the sample result sampleHeight, the first unit height heightUnit, and the second unit height SampleHeightUnit, generate the second heightmap for each virtual tile.
[0115] It should be noted that the above centroid interpolation result refers to the centroid interpolation performed during the rasterization step of the shading process when using shaders (such as vertex shaders and pixel shaders) to generate height maps in application scenarios. Specifically, based on the elevation of the three vertices of a triangular lattice, the position coordinates of the three vertices, and the position coordinates of the centroid of the triangle, the elevation of the centroid of the triangular lattice is calculated through interpolation.
[0116] Optionally, in step S2324, generating a second height map corresponding to each virtual plot based on the first parameter, the second parameter, the third parameter, the fourth parameter, the sampling result, the first unit height, and the second unit height may include the following execution steps:
[0117] Step S23241: Calculate using the first parameter and the third parameter to obtain the first calculation result;
[0118] Step S23242: Calculate using the second and fourth parameters to obtain the second calculation result;
[0119] Step S23243: Calculate using the sampling results, the first unit height, and the second parameter to obtain the third calculation result;
[0120] Step S23244: Calculate using the first calculation result, the second calculation result, the third calculation result, and the second unit height to obtain the target calculation result;
[0121] Step S23245: Generate a second elevation map corresponding to each virtual plot based on the target calculation results.
[0122] In one alternative implementation, when generating scene terrain meshes in an SLG game, the calculation method for generating a height map for each virtual tile is as follows:
[0123] floatoutputHeight=(minElevation+(elevationHeight-minElevation)*(1 / (elevationBakingHeight-minBakingElevation))*(sampleHeight / sampleHeightUnit–minBakingElevation))*heightUnit.
[0124] The above floatoutputHeight represents the second elevation map corresponding to the virtual plot. It is easy to understand that the first calculation result is obtained based on the first parameter minElevation and the third parameter elevationHeight, which is (minElevation + (elevationHeight - minElevation).
[0125] Figure 12 This is an optional second height view according to one embodiment of this application. For example... Figure 12 As shown, the second elevation map calculated for each virtual plot based on the above method steps carries richer elevation information. Using this second elevation map in the game scene can produce a virtual terrain mesh with better elevation representation.
[0126] Optionally, in step S24, generating the target terrain grid based on the second elevation map may include the following steps:
[0127] Step S241: Using each third cell as a unit, perform an initial division of each virtual plot in the multiple virtual plots to construct the third terrain grid corresponding to each virtual plot;
[0128] Step S242: In the third terrain grid, the cells corresponding to the second type of landform and the third type of landform are further subdivided to obtain the fourth terrain grid;
[0129] Step S243: Sample the second elevation map based on the fourth terrain grid to generate the target terrain grid.
[0130] It is readily understood that, in this embodiment, the use of a baked mesh based on triangle grids enables the subdivision of the terrain mesh based on hexagonal grids in the game. During the generation of the target terrain mesh, to reduce the number of faces, a terrain mesh is constructed vertex-by-vertex for each virtual terrain element, using triangle grids as cells. Specifically, each game triangle grid (i.e., multiple third cells) is used as a unit to initially divide each virtual plot, constructing a third terrain mesh corresponding to each virtual plot.
[0131] Each of the aforementioned game triangle grids carries height transition information between the virtual terrain models corresponding to the hexagonal grids. In the third terrain grid, if the virtual terrain models transition from a slope to a cliff, the corresponding cells in the third terrain grid need to be subdivided again during the generation of the target terrain grid to obtain the fourth terrain grid. If the virtual terrain models of the hexagonal grids transition from flat ground, no further subdivision is needed. A constraint can also be introduced here: in the third terrain grid, if adjacent cells of a triangle grid are subdivided, the triangle grid must maintain the same subdivision level as its adjacent cells.
[0132] Figure 13 This is a schematic diagram of an optional target terrain grid according to one embodiment of this application, such as... Figure 13 As shown, based on the re-divided fourth terrain grid, the second elevation maps corresponding to the above-mentioned multiple virtual plots are sampled to obtain the following results: Figure 13 The target terrain grid is shown. In this example, to ensure the continuity of the triangular grid edges, bilinear sampling is used to sample the second elevation map.
[0133] It is easy to understand that, since the above-mentioned terrain mesh to be used (target terrain mesh) is generated based on the base height map corresponding to the virtual terrain model and the second height map obtained by matching the height of the baked mesh, the terrain mesh to be used carries richer terrain model height information, and the terrain mesh to be used can represent terrain models of any altitude and the corresponding height transition effects.
[0134] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a magnetic disk or optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0135] This embodiment also provides an apparatus for generating terrain meshes, which is used to implement the above embodiments and preferred embodiments, and will not be repeated as already described. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0136] Figure 14 This is a structural block diagram of an apparatus for generating terrain meshes according to one embodiment of this application, such as... Figure 14 As shown, the device includes: a first generation module 1401, used to construct a virtual terrain model on a first terrain grid and generate a first height map corresponding to the virtual terrain model, wherein the first terrain grid is the initial terrain grid for constructing the virtual terrain model, and the first height map is the base height map; a second generation module 1402, used to match the first terrain grid and the second terrain grid to generate a height data map, wherein the second terrain grid is a baked grid corresponding to the virtual terrain model, and the height data map is used to generate the second height map, which is the height map to be used by the virtual terrain model in the game; an acquisition module 1403, used to acquire the second height map using the first height map and the height data map; and a third generation module 1404, used to generate a target terrain grid based on the second height map, wherein the target terrain grid is the terrain grid to be used in the game.
[0137] Optionally, the first terrain grid includes: a plurality of first cells, the shape of which adopts a first planar geometry. The first generation module 1401 is further configured to: determine a construction area on the first terrain grid; obtain the elevation corresponding to at least some of the first cells in the construction area; calculate the elevation difference between each two adjacent cells in at least some of the first cells using the elevation, wherein the elevation difference is used to determine the representation of various types of landforms; and construct a virtual terrain model based on the elevation difference.
[0138] Optionally, the first generation module 1401 is further configured to: determine the terrain appearance between two adjacent cells as a first type of terrain appearance in response to an elevation difference greater than or equal to a first value; determine the terrain appearance between two adjacent cells as a second type of terrain appearance in response to an elevation difference equal to a second value; determine the terrain appearance between two adjacent cells as a third type of terrain appearance in response to an elevation difference equal to a third value; and construct a virtual terrain model based on the first type of terrain appearance, the second type of terrain appearance, and the third type of terrain appearance; wherein the first value is greater than the second value, and the second value is greater than the third value.
[0139] Optionally, the second terrain grid includes: a plurality of second cells, the shape of which adopts a second planar geometry. The second generation module 1402 is further configured to: determine a plurality of third cells in the first terrain grid based on the center position of the plurality of first cells, wherein the shape of the plurality of third cells adopts a second planar geometry; and perform height matching between the plurality of second cells and the plurality of third cells based on the altitude to generate a height data map.
[0140] Optionally, the second generation module 1402 described above is further configured to: rotate and transform multiple second cells to obtain transformed cells; and perform height matching between the transformed cells and multiple third cells based on altitude to generate a height data texture.
[0141] Optionally, in the above-described apparatus for generating terrain meshes, the height data map includes: a first data map, wherein the first data map includes: a first map channel, a second map channel, a third map channel, and a fourth map channel. The first part of the storage space of the first map channel and the second map channel is used to store the vertex elevation of multiple third cells. The second part of the storage space of the second map channel is used to store the cell state of multiple cells, and the cell state is used to determine whether the vertex elevation of the same cell is the same. The first part of the storage space of the third map channel and the fourth map channel is used to store the vertex elevation of multiple second cells. The second part of the storage space of the fourth map channel is used to store the rotation transformation index of multiple second cells, and the rotation transformation index is used to determine the rotation transformation matrix corresponding to the multiple second cells.
[0142] Optionally, in the above-described apparatus for generating terrain mesh, the height data map further includes a second data map, wherein the second data map includes a fifth map channel and a sixth map channel, the fifth map channel is used to store the planar coordinates of multiple second cells, and a portion of the storage space of the sixth map channel is used to store the mesh state of the second terrain mesh, the mesh state being used to determine the top orientation of the second terrain mesh.
[0143] Optionally, the acquisition module 1403 is further configured to: divide the virtual terrain model to obtain multiple virtual plots; and use the first elevation map and elevation data texture to obtain the second elevation map corresponding to each virtual plot among the multiple virtual plots.
[0144] Optionally, the acquisition module 1403 is further configured to: determine the data map index corresponding to each virtual plot from the second data map; acquire the first parameter, second parameter, third parameter, and fourth parameter corresponding to each virtual plot from the first data map using the data map index, wherein the first parameter is used to determine the minimum vertex elevation of the third cell corresponding to each virtual plot, the second parameter is used to determine the minimum vertex elevation of the second cell corresponding to each virtual plot, the third parameter is used to determine the centroid interpolation result of the third cell corresponding to each virtual plot, and the fourth parameter is used to determine the centroid interpolation result of the second cell corresponding to each virtual plot; perform height sampling on the first height map to obtain the sampling result; and generate the second height map corresponding to each virtual plot based on the first parameter, second parameter, third parameter, fourth parameter, sampling result, first unit height, and second unit height, wherein the first unit height is a preset unit height of the first height map, and the second unit height is a preset unit height of the second height map.
[0145] Optionally, the acquisition module 1403 is further configured to: perform calculations using the first parameter and the third parameter to obtain a first calculation result; perform calculations using the second parameter and the fourth parameter to obtain a second calculation result; perform calculations using the sampling result, the first unit height, and the second parameter to obtain a third calculation result; perform calculations using the first calculation result, the second calculation result, the third calculation result, and the second unit height to obtain a target calculation result; and generate a second height map corresponding to each virtual plot based on the target calculation result.
[0146] Optionally, the third generation module 1404 is further configured to: initially divide each virtual plot among multiple virtual plots using each third cell as a unit, and construct a third terrain grid corresponding to each virtual plot; further divide the cells corresponding to the second type of landform representation and the third type of landform representation in the third terrain grid to obtain a fourth terrain grid; and sample the second elevation map based on the fourth terrain grid to generate a target terrain grid.
[0147] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0148] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0149] Optionally, in this embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0150] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0151] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0152] S1, Construct a virtual terrain model on the first terrain grid and generate a first elevation map corresponding to the virtual terrain model, wherein the first terrain grid is the initial terrain grid for constructing the virtual terrain model, and the first elevation map is the base elevation map;
[0153] S2, Match the first terrain mesh and the second terrain mesh to generate a height data map, wherein the second terrain mesh is the baked mesh corresponding to the virtual terrain model, and the height data map is used to generate a second height map, which is the height map of the virtual terrain model to be used in the game;
[0154] S3, use the first height map and height data texture to obtain the second height map;
[0155] S4 generates a target terrain mesh based on the second elevation map, where the target terrain mesh is the terrain mesh to be used in the game.
[0156] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining a construction region on a first terrain grid; obtaining the elevation corresponding to at least a portion of the first cells within the construction region; calculating the elevation difference between every two adjacent cells in at least a portion of the first cells using the elevation, wherein the elevation difference is used to determine multiple types of landform representation; and constructing a virtual terrain model based on the elevation difference.
[0157] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining that the terrain representation between two adjacent cells is a first type of terrain representation in response to an elevation difference value being greater than or equal to a first value; determining that the terrain representation between two adjacent cells is a second type of terrain representation in response to an elevation difference value being equal to a second value; determining that the terrain representation between two adjacent cells is a third type of terrain representation in response to an elevation difference value being equal to a third value; and constructing a virtual terrain model based on the first type of terrain representation, the second type of terrain representation, and the third type of terrain representation; wherein the first value is greater than the second value, and the second value is greater than the third value.
[0158] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: in a first terrain grid, determining a plurality of third cells based on the center positions of a plurality of first cells, wherein the shapes of the plurality of third cells adopt a second planar geometry; and performing height matching between the plurality of second cells and the plurality of third cells based on altitude to generate a height data map.
[0159] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: rotating and transforming multiple second cells to obtain transformed cells; and performing height matching between the transformed cells and multiple third cells based on altitude to generate a height data map.
[0160] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: the height data map includes: a first data map, wherein the first data map includes: a first map channel, a second map channel, a third map channel, and a fourth map channel; a first portion of the storage space of the first map channel and the second map channel is used to store the vertex elevation heights of multiple third cells; a second portion of the storage space of the second map channel is used to store the cell states of multiple cells, the cell states being used to determine whether the vertex elevation heights of the same cell are the same; a first portion of the storage space of the third map channel and the fourth map channel is used to store the vertex elevation heights of multiple second cells; a second portion of the storage space of the fourth map channel is used to store the rotation transformation indexes of multiple second cells, the rotation transformation indexes being used to determine the rotation transformation matrices corresponding to the multiple second cells.
[0161] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: the height data map further includes: a second data map, wherein the second data map includes: a fifth map channel and a sixth map channel, the fifth map channel being used to store the planar coordinates of a plurality of second cells, and a portion of the storage space of the sixth map channel being used to store the grid state of the second terrain grid, the grid state being used to determine the top orientation of the second terrain grid.
[0162] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: dividing the virtual terrain model to obtain multiple virtual plots; and obtaining a second height map corresponding to each virtual plot in the multiple virtual plots using a first height map and a height data texture.
[0163] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining the data map index corresponding to each virtual plot from the second data map; obtaining a first parameter, a second parameter, a third parameter, and a fourth parameter corresponding to each virtual plot from the first data map using the data map index, wherein the first parameter is used to determine the minimum vertex elevation of the third cell corresponding to each virtual plot, the second parameter is used to determine the minimum vertex elevation of the second cell corresponding to each virtual plot, the third parameter is used to determine the centroid interpolation result of the third cell corresponding to each virtual plot, and the fourth parameter is used to determine the centroid interpolation result of the second cell corresponding to each virtual plot; performing height sampling on the first height map to obtain the sampling result; generating a second height map corresponding to each virtual plot based on the first parameter, the second parameter, the third parameter, the fourth parameter, the sampling result, the first unit height, and the second unit height, wherein the first unit height is a preset unit height of the first height map, and the second unit height is a preset unit height of the second height map.
[0164] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: performing calculations using a first parameter and a third parameter to obtain a first calculation result; performing calculations using a second parameter and a fourth parameter to obtain a second calculation result; performing calculations using a sampling result, a first unit height, and a second parameter to obtain a third calculation result; performing calculations using the first calculation result, the second calculation result, the third calculation result, and the second unit height to obtain a target calculation result; and generating a second height map corresponding to each virtual plot based on the target calculation result.
[0165] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: initially dividing each virtual plot among multiple virtual plots into units of each third cell, constructing a third terrain grid corresponding to each virtual plot; further dividing the cells corresponding to the second type of landform representation and the third type of landform representation in the third terrain grid to obtain a fourth terrain grid; sampling the second elevation map based on the fourth terrain grid to generate a target terrain grid.
[0166] In the computer-readable storage medium of the above embodiments, a technical solution is provided for implementing a method for generating terrain meshes. A virtual terrain model is constructed on a first terrain mesh, and a first height map corresponding to the virtual terrain model is generated. The first terrain mesh is the initial terrain mesh for constructing the virtual terrain model, and the first height map is the base height map. Further, the first terrain mesh and a second terrain mesh are matched to generate a height data map. The second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate the second height map, which is the height map to be used by the virtual terrain model in the game. The second height is obtained using the first height map and the height data map. A target terrain mesh is generated based on the second height map, which is the terrain mesh to be used in the game. Therefore, the method provided by this application achieves the purpose of generating a usable terrain mesh by combining the height data map obtained by matching the initial terrain mesh and the baked mesh with the base height map corresponding to the terrain model. This achieves the technical effect of enriching the height representation of the terrain model and improving the design flexibility of the terrain model corresponding to the terrain mesh, thereby solving the technical problem in related technologies where the lack of a suitable terrain mesh production method leads to poor height representation of the terrain model and poor terrain design flexibility.
[0167] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.
[0168] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of this application may also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this embodiment according to various exemplary embodiments of this application.
[0169] The program product for implementing the above-described method according to embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the embodiments of this application is not limited thereto. In the embodiments of this application, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0170] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0171] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0172] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0173] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0174] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0175] S1, Construct a virtual terrain model on the first terrain grid and generate a first elevation map corresponding to the virtual terrain model, wherein the first terrain grid is the initial terrain grid for constructing the virtual terrain model, and the first elevation map is the base elevation map;
[0176] S2, Match the first terrain mesh and the second terrain mesh to generate a height data map, wherein the second terrain mesh is the baked mesh corresponding to the virtual terrain model, and the height data map is used to generate a second height map, which is the height map of the virtual terrain model to be used in the game;
[0177] S3, use the first height map and height data texture to obtain the second height map;
[0178] S4 generates a target terrain mesh based on the second elevation map, where the target terrain mesh is the terrain mesh to be used in the game.
[0179] Optionally, the processor may also be configured to perform the following steps via a computer program: determining a construction area on a first terrain grid; obtaining the elevation of at least a portion of the first cells within the construction area; calculating the elevation difference between every two adjacent cells in at least a portion of the first cells using the elevation, wherein the elevation difference is used to determine the representation of multiple types of landforms; and constructing a virtual terrain model based on the elevation difference.
[0180] Optionally, the processor may also be configured to perform the following steps via a computer program: in response to an elevation difference greater than or equal to a first value, determine that the terrain representation between two adjacent cells is a first type of terrain representation; in response to an elevation difference equal to a second value, determine that the terrain representation between two adjacent cells is a second type of terrain representation; in response to an elevation difference equal to a third value, determine that the terrain representation between two adjacent cells is a third type of terrain representation; and construct a virtual terrain model based on the first type of terrain representation, the second type of terrain representation, and the third type of terrain representation; wherein the first value is greater than the second value, and the second value is greater than the third value.
[0181] Optionally, the processor may also be configured to perform the following steps via a computer program: in a first terrain grid, determine a plurality of third cells based on the center positions of a plurality of first cells, wherein the shape of the plurality of third cells adopts a second planar geometry; perform height matching between the plurality of second cells and the plurality of third cells based on the altitude to generate a height data map.
[0182] Optionally, the processor described above can also be configured to perform the following steps via a computer program: rotate and transform multiple second cells to obtain transformed cells; perform height matching between the transformed cells and multiple third cells based on altitude to generate a height data map.
[0183] Optionally, the processor described above can also be configured to perform the following steps via a computer program: the height data map includes: a first data map, wherein the first data map includes: a first map channel, a second map channel, a third map channel, and a fourth map channel; the first part of the storage space of the first map channel and the second map channel is used to store the vertex elevation heights of multiple third cells; the second part of the storage space of the second map channel is used to store the cell states of multiple cells, the cell states being used to determine whether the vertex elevation heights of the same cell are the same; the first part of the storage space of the third map channel and the fourth map channel is used to store the vertex elevation heights of multiple second cells; the second part of the storage space of the fourth map channel is used to store the rotation transformation indexes of multiple second cells, the rotation transformation indexes being used to determine the rotation transformation matrices corresponding to the multiple second cells.
[0184] Optionally, the processor described above may also be configured to perform the following steps via a computer program: the height data map further includes: a second data map, wherein the second data map includes: a fifth map channel and a sixth map channel, the fifth map channel is used to store the planar coordinates of a plurality of second cells, and a portion of the storage space of the sixth map channel is used to store the grid state of the second terrain grid, the grid state being used to determine the top orientation of the second terrain grid.
[0185] Optionally, the processor may also be configured to perform the following steps via a computer program: dividing the virtual terrain model to obtain multiple virtual plots; and using a first height map and a height data map to obtain a second height map corresponding to each virtual plot.
[0186] Optionally, the processor may also be configured to perform the following steps via a computer program: determining the data map index corresponding to each virtual plot from the second data map; obtaining the first parameter, second parameter, third parameter, and fourth parameter corresponding to each virtual plot from the first data map using the data map index, wherein the first parameter is used to determine the minimum vertex elevation of the third cell corresponding to each virtual plot, the second parameter is used to determine the minimum vertex elevation of the second cell corresponding to each virtual plot, the third parameter is used to determine the centroid interpolation result of the third cell corresponding to each virtual plot, and the fourth parameter is used to determine the centroid interpolation result of the second cell corresponding to each virtual plot; performing height sampling on the first height map to obtain the sampling result; and generating the second height map corresponding to each virtual plot based on the first parameter, second parameter, third parameter, fourth parameter, sampling result, first unit height, and second unit height, wherein the first unit height is a preset unit height of the first height map, and the second unit height is a preset unit height of the second height map.
[0187] Optionally, the processor may also be configured to perform the following steps via a computer program: calculate using a first parameter and a third parameter to obtain a first calculation result; calculate using a second parameter and a fourth parameter to obtain a second calculation result; calculate using the sampling result, a first unit height, and a second parameter to obtain a third calculation result; calculate using the first calculation result, the second calculation result, the third calculation result, and the second unit height to obtain a target calculation result; and generate a second height map corresponding to each virtual plot based on the target calculation result.
[0188] Optionally, the processor may also be configured to perform the following steps via a computer program: initially dividing each virtual plot in a plurality of virtual plots into units of each third cell, and constructing a third terrain grid corresponding to each virtual plot; further dividing the cells corresponding to the second type of landform representation and the third type of landform representation in the third terrain grid to obtain a fourth terrain grid; sampling the second elevation map based on the fourth terrain grid to generate a target terrain grid.
[0189] In the electronic device described in the above embodiments, a technical solution is provided for implementing a method for generating terrain meshes. A virtual terrain model is constructed on a first terrain mesh, and a first height map corresponding to the virtual terrain model is generated. The first terrain mesh is the initial terrain mesh used to construct the virtual terrain model, and the first height map is the base height map. Further, the first terrain mesh and a second terrain mesh are matched to generate a height data map. The second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate the second height map, which is the height map to be used by the virtual terrain model in the game. The second height is obtained using the first height map and the height data map. A target terrain mesh is generated based on the second height map, which is the terrain mesh to be used in the game. Therefore, the method provided by this application achieves the purpose of generating a usable terrain mesh by combining the height data map obtained from matching the initial terrain mesh and the baked mesh with the base height map corresponding to the terrain model. This achieves the technical effect of enriching the height representation of the terrain model and improving the design flexibility of the terrain model corresponding to the terrain mesh. It also solves the technical problem in related technologies where the lack of a suitable terrain mesh production method leads to poor height representation of the terrain model and poor terrain design flexibility.
[0190] Figure 15 This is a schematic diagram of an electronic device according to one embodiment of this application. Figure 15 As shown, the electronic device 1500 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0191] like Figure 15As shown, the electronic device 1500 is presented in the form of a general-purpose computing device. The components of the electronic device 1500 may include, but are not limited to: at least one processor 1510, at least one memory 1520, a bus 1530 connecting different system components (including memory 1520 and processor 1510), and a display 1540.
[0192] The memory 1520 stores program code that can be executed by the processor 1510, causing the processor 1510 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of this application.
[0193] The memory 1520 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 15201 and / or cache memory 15202, and may further include read-only memory (ROM) 15203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0194] In some instances, memory 1520 may also include programs / utilities 15204 having a set (at least one) of program modules 15205, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 1520 may further include memory remotely located relative to processor 1510, which can be connected to electronic device 1500 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0195] Bus 1530 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 1510, or a local bus using any of the various bus structures.
[0196] The display 1540 may be, for example, a touch-screen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 1500.
[0197] Optionally, the electronic device 1500 can also communicate with one or more external devices 1600 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 1500, and / or any device that enables the electronic device 1500 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 1550. Furthermore, the electronic device 1500 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via the network adapter 1560. Figure 15 As shown, network adapter 1560 communicates with other modules of electronic device 1500 via bus 1530. It should be understood that, although... Figure 15 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 1500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems.
[0198] The aforementioned electronic device 1500 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply, and / or a camera.
[0199] Those skilled in the art will understand that Figure 15 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 1500 may also include components that are more... Figure 15 The more or fewer components shown, or having the same Figure 15 Different configurations are shown. The memory 1520 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the method for generating terrain meshes in this embodiment. The processor 1510 executes various functional applications and data processing by running the computer program stored in the memory 1520, thereby implementing the aforementioned method for generating terrain meshes.
[0200] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0201] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0202] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0203] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0204] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0205] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0206] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating terrain meshes, characterized in that, include: A virtual terrain model is constructed on a first terrain grid, and a first elevation map corresponding to the virtual terrain model is generated. The first terrain grid is the initial terrain grid for constructing the virtual terrain model, and the first elevation map is the base elevation map. The first terrain grid includes multiple first cells, each with a first planar geometric shape. Constructing the virtual terrain model on the first terrain grid includes: determining a construction area on the first terrain grid; obtaining the elevation of at least a portion of the first cells within the construction area; calculating the elevation difference between every two adjacent cells in the at least a portion of the first cells using the elevations, wherein the elevation difference is used to determine various landform representations; and constructing the virtual terrain model based on the elevation difference. The first terrain mesh and the second terrain mesh are matched to generate a height data map, wherein the second terrain mesh is a baked mesh corresponding to the virtual terrain model, and the height data map is used to generate a second height map, which is the height map to be used by the virtual terrain model in the game; The virtual terrain model is divided into multiple virtual plots; The second height map corresponding to each of the plurality of virtual plots is obtained using the first height map and the height data texture; A target terrain mesh is generated based on the second elevation map, wherein the target terrain mesh is the terrain mesh to be used in the game.
2. The method according to claim 1, characterized in that, Constructing the virtual terrain model based on the elevation difference includes: In response to the elevation difference being greater than or equal to a first value, the terrain appearance between two adjacent cells is determined to be a first type of terrain appearance. In response to the elevation difference value being equal to the second value, the terrain appearance between two adjacent cells is determined to be the second type of terrain appearance; In response to the elevation difference value being equal to the third value, the terrain appearance between two adjacent cells is determined to be the third type of terrain appearance; The virtual terrain model is constructed based on the first type of landform representation, the second type of landform representation, and the third type of landform representation. Wherein, the first value is greater than the second value, and the second value is greater than the third value.
3. The method according to claim 1, characterized in that, The second terrain grid includes: a plurality of second cells, the shape of which adopts a second planar geometry; matching the first terrain grid with the second terrain grid to generate the height data map includes: In the first terrain grid, a plurality of third cells are determined based on the center positions of the plurality of first cells, wherein the shape of the plurality of third cells adopts the second planar geometry; Based on the altitude, the multiple second cells and the multiple third cells are height-matched to generate the altitude data texture.
4. The method according to claim 3, characterized in that, Based on the altitude, the height of the plurality of second cells and the plurality of third cells is matched to generate the altitude data texture, including: Rotate and transform the plurality of second cells to obtain the transformed cells; Based on the altitude, the transformed cell is height-matched with the plurality of third cells to generate the altitude data texture.
5. The method according to claim 4, characterized in that, The height data texture includes: a first data texture, wherein the first data texture includes: a first texture channel, a second texture channel, a third texture channel, and a fourth texture channel. A first portion of the storage space of the first texture channel and the second texture channel is used to store the vertex elevation of the plurality of third cells. A second portion of the storage space of the second texture channel is used to store the cell states of the plurality of cells, the cell states being used to determine whether the vertex elevation of the same cell is the same. A first portion of the storage space of the third texture channel and the fourth texture channel is used to store the vertex elevation of the plurality of second cells. A second portion of the storage space of the fourth texture channel is used to store the rotation transformation index of the plurality of second cells, the rotation transformation index being used to determine the rotation transformation matrix corresponding to the plurality of second cells.
6. The method according to claim 5, characterized in that, The height data map further includes a second data map, wherein the second data map includes a fifth map channel and a sixth map channel. The fifth map channel is used to store the planar coordinates of the plurality of second cells, and a portion of the storage space of the sixth map channel is used to store the grid state of the second terrain grid, the grid state being used to determine the top orientation of the second terrain grid.
7. The method according to claim 6, characterized in that, Obtaining the second height map corresponding to each of the plurality of virtual plots using the first height map and the height data texture includes: Determine the data map index corresponding to each virtual plot from the second data map; The first parameter, second parameter, third parameter, and fourth parameter corresponding to each virtual plot are obtained from the first data texture using the data texture index. The first parameter is used to determine the minimum vertex elevation of the third cell corresponding to each virtual plot. The second parameter is used to determine the minimum vertex elevation of the second cell corresponding to each virtual plot. The third parameter is used to determine the centroid interpolation result of the third cell corresponding to each virtual plot. The fourth parameter is used to determine the centroid interpolation result of the second cell corresponding to each virtual plot. The first height map is sampled to obtain the sampling results; Based on the first parameter, the second parameter, the third parameter, the fourth parameter, the sampling result, the first unit height, and the second unit height, a second height map corresponding to each virtual plot is generated, wherein the first unit height is a preset unit height of the first height map, and the second unit height is a preset unit height of the second height map.
8. The method according to claim 7, characterized in that, Based on the first parameter, the second parameter, the third parameter, the fourth parameter, the sampling result, the first unit height, and the second unit height, generating the second height map corresponding to each virtual plot includes: The first calculation result is obtained by using the first parameter and the third parameter; The second calculation result is obtained by using the second parameter and the fourth parameter; The third calculation result is obtained by using the sampling result, the first unit height, and the second parameter; The target calculation result is obtained by using the first calculation result, the second calculation result, the third calculation result, and the second unit height. Based on the target calculation results, a second height map corresponding to each virtual plot is generated.
9. The method according to claim 6, characterized in that, Generating the target terrain mesh based on the second elevation map includes: Using each third cell as a unit, each virtual plot in the plurality of virtual plots is initially divided to construct a third terrain grid corresponding to each virtual plot; In the third terrain grid, the cells corresponding to the second type of landform and the third type of landform are further subdivided to obtain the fourth terrain grid; The target terrain grid is generated by sampling the second elevation map based on the fourth terrain grid.
10. An apparatus for generating a terrain grid, characterized in that, include: A first generation module is used to construct a virtual terrain model on a first terrain grid and generate a first elevation map corresponding to the virtual terrain model. The first terrain grid is an initial terrain grid for constructing the virtual terrain model, and the first elevation map is a base elevation map. The first terrain grid includes multiple first cells, the shapes of which adopt a first planar geometric shape. Constructing the virtual terrain model on the first terrain grid includes: determining a construction area on the first terrain grid; obtaining the elevation of at least a portion of the first cells within the construction area; calculating the elevation difference between every two adjacent cells in the at least a portion of the first cells using the elevations, wherein the elevation difference is used to determine various types of landform representation; and constructing the virtual terrain model based on the elevation difference. The second generation module is used to match the first terrain grid and the second terrain grid to generate a height data map, wherein the second terrain grid is a baked grid corresponding to the virtual terrain model, and the height data map is used to generate a second height map, which is the height map to be used by the virtual terrain model in the game; The acquisition module is used to divide the virtual terrain model into multiple virtual plots; and to acquire the second height map corresponding to each virtual plot in the multiple virtual plots using the first height map and the height data texture. The third generation module is used to generate a target terrain grid based on the second height map, wherein the target terrain grid is the terrain grid to be used in the game.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to be executed by a processor to perform the method for generating a terrain grid as described in any one of claims 1 to 9.
12. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method for generating a terrain grid as described in any one of claims 1 to 9.