Terrain grid, virtual terrain generation method and device, medium and equipment
By dividing the polygon mesh into ring-shaped sub-grids and generating transition meshes, the problem of low hexagonal mesh generation efficiency is solved, fast and efficient mesh generation and flexible virtual terrain adjustment are achieved, and game development is improved. efficiency and rendering effects.
Patent Information
- Application Number
- CN202310233059.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2024-09-03
AI Technical Summary
The generation efficiency of hexagonal grids in the existing technology is low, and editing hexagonal grids through general tools takes a long time, which affects the efficiency of game development.
By dividing polygonal grid units into ring-shaped sub-grids and connecting grid units based on transition grids, automatic generation of target terrain grids is achieved, reducing manual participation and improving generation efficiency.
It realizes the rapid and efficient generation of hexagonal meshes, improves the generation efficiency, and flexibly adjusts the terrain height, color and lighting through the transition mesh, improving the terrain rendering effect and flexibility.
Smart Images

Figure CN118587384A
Abstract
Description
Background Art
[0002] For games such as SLG (Simulation Game, strategy game), virtual terrain based on hexagonal grids can often provide richer and more variable gameplay, so hexagonal grid terrain is indispensable for games such as SLG.
[0003] Currently, virtual terrains in the gaming industry are created through editors, and then manually through the LandScape tool provided by Unreal, the Terrain tool provided by Unity, and other tools to create various terrains.
[0004] However, editing hexagonal meshes using general tools is very time-consuming, resulting in low efficiency in current hexagonal mesh generation. Summary of the invention
[0005] The present disclosure provides a terrain grid generation, virtual terrain generation method, device, computer-readable storage medium and electronic device, thereby improving the generation efficiency of the terrain grid.
[0006] In a first aspect, an embodiment of the present disclosure provides a terrain mesh generation method, comprising:
[0007] Determine the center point position of each polygonal grid unit center point arranged in a matrix, and the first vertex position of each vertex;
[0008] For each of the grid units, the grid unit is divided into at least two annular sub-grids; wherein the center points of the sub-grids in one of the grid units are the same;
[0009] Constructing a transition grid between each of the grid units according to each two adjacent first sub-grids; wherein the first sub-grid refers to a sub-grid closest to the center point of the grid unit among the sub-grids in the grid unit;
[0010] The target terrain grid is generated by connecting the grid units based on the transition grid.
[0011] In an optional embodiment of the present disclosure, the mesh units have the same shape and are symmetrical polygons, and determining the center point position of the center points of the polygonal mesh units arranged in a matrix and the first vertex position of each vertex includes:
[0012] Determine the center point position of each of the grid unit center points;
[0013] The first vertex position of each vertex of the grid unit is determined according to the center point position and the path length of the grid unit.
[0014] In an optional embodiment of the present disclosure, constructing a transition grid between each of the grid units according to each two adjacent first sub-grids includes:
[0015] Constructing a connected grid using the vertices of two adjacent first sub-grids;
[0016] The transitional grid is constructed based on the connection grid and the second sub-grid; wherein the second sub-grid refers to the sub-grid farthest from the center point of the grid unit among the sub-grids in the grid unit.
[0017] In an optional embodiment of the present disclosure, the terrain grid generation method further includes:
[0018] Constructing a filling grid between adjacent connected grids according to each vertex of the adjacent connected grids;
[0019] Correspondingly, constructing the transitional grid based on the connected grid and the second sub-grid includes:
[0020] The transition grid is constructed based on the connection grid, the filling grid and the second sub-grid.
[0021] In an optional embodiment of the present disclosure, the step of connecting the grid units based on the transition grid to generate a target terrain grid includes:
[0022] Connecting each of the grid cells based on the transition grid to form an initial terrain grid;
[0023] The height of the transition grid is adjusted based on a preset height to obtain the target terrain grid.
[0024] In an optional embodiment of the present disclosure, the grid unit is a regular hexagon.
[0025] In a second aspect, an embodiment of the present disclosure provides a method for generating a virtual terrain, comprising:
[0026] Generate a target terrain grid according to any of the terrain grid generation methods described above;
[0027] The target terrain grid is rendered according to pre-configured terrain information to obtain a target virtual terrain; wherein the terrain information includes at least one of illumination information and color information.
[0028] In an optional embodiment of the present disclosure, the virtual terrain generation method further includes:
[0029] Determine the second vertex position of each vertex in each filled grid;
[0030] For each of the filling meshes, determining a normal of the filling mesh according to each of the second vertex positions;
[0031] Correspondingly, rendering the target terrain grid according to the pre-configured terrain information to obtain the target virtual terrain includes:
[0032] According to the normal of the filling grid, the target terrain grid is rendered according to the pre-configured landform information to obtain the target virtual terrain.
[0033] In a third aspect, an embodiment of the present disclosure provides a terrain grid generation device, the device comprising:
[0034] A determination module, used to determine the center point position of each polygonal mesh unit center point arranged in a matrix, and the first vertex position of each vertex;
[0035] A splitting module, used for dividing each of the grid units into at least two annular sub-grids; wherein the center points of the sub-grids in one grid unit are the same;
[0036] A construction module, configured to construct a transition grid between each of the grid units according to each two adjacent first sub-grids; wherein the first sub-grid refers to a sub-grid closest to a center point of the grid unit among the sub-grids in the grid unit;
[0037] The first generating module is used to connect the grid units to generate a target terrain grid based on the transition grid.
[0038] In a fourth aspect, an embodiment of the present disclosure provides a virtual terrain generating device, comprising:
[0039] A second generating module, used for generating a target terrain grid according to any of the terrain grid generating methods described above;
[0040] A rendering module is used to render the target terrain grid according to pre-configured terrain information to obtain a target virtual terrain; wherein the terrain information includes at least one of illumination information and color information.
[0041] In a fifth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the above method when executed by a processor.
[0042] In a sixth aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above method by executing the executable instructions.
[0043] The technical solution disclosed in this disclosure has the following beneficial effects:
[0044] The terrain grid generation method described above first determines the center point position of each polygonal grid unit arranged in a matrix, and the first vertex position of each vertex, and for each of the grid units, divides the grid unit into at least two annular sub-grids, and constructs a transition grid between each of the grid units based on each two adjacent first sub-grids, and finally connects each of the grid units based on the transition grid to generate a target terrain grid. The full name does not require human participation, and the target terrain grid can be generated quickly and efficiently, thereby solving the current technical problem of low efficiency in hexagonal grid generation and achieving the technical effect of improving the efficiency of hexagonal grid generation. On the second aspect, the target terrain grid of the embodiment of the present disclosure includes a grid body consisting of three parts: the first sub-grid, other sub-grids in the grid unit except the first sub-grid, and the transition grid. In the subsequent process, the height, color, lighting, etc. of the virtual terrain can be flexibly transitioned through the transition grid, which has higher flexibility and better terrain grid rendering effect.
[0045] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 A flow chart showing a method for generating a terrain grid in this exemplary embodiment is shown;
[0048] Figure 2 A schematic diagram of a hexagonal terrain grid in a terrain grid generation method in this exemplary embodiment is shown;
[0049] Figure 3 A schematic diagram of a hexagonal grid unit in a terrain grid generation method in this exemplary embodiment is shown;
[0050] Figure 4 A flow chart showing a method for generating a terrain grid in this exemplary embodiment is shown;
[0051] Figure 5 A schematic diagram showing a grid unit in a terrain grid generation method in this exemplary embodiment;
[0052] Figure 6 A flow chart showing a method for generating a terrain grid in this exemplary embodiment is shown;
[0053] Figure 7 A schematic diagram showing a transitional grid in a terrain grid generation method in this exemplary embodiment;
[0054] Figure 8 A schematic diagram showing a grid filling method in a terrain grid generation method according to the exemplary embodiment is shown;
[0055] Fig. 9 A flow chart showing a method for generating a terrain grid in this exemplary embodiment is shown;
[0056] Fig.10 A schematic diagram of a target terrain grid in a terrain grid generation method in this exemplary embodiment is shown;
[0057] Fig.11 A flowchart showing a method for generating a virtual terrain in this exemplary embodiment is shown;
[0058] Fig.12 A flowchart showing a method for generating a virtual terrain in this exemplary embodiment is shown;
[0059] Fig.13 A schematic diagram of the structure of a terrain grid generating device in this exemplary embodiment is shown;
[0060] Fig.14 A schematic diagram of the structure of a virtual map generating device in this exemplary embodiment is shown;
[0061] Fig.15 A schematic structural diagram of an electronic device in this exemplary embodiment is shown. DETAILED DESCRIPTION
[0062] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the exemplary embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0063] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0064] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the steps. For example, some steps may be decomposed, while some steps may be combined or partially combined, so the actual execution order may change according to the actual situation.
[0065] In the related art, for games such as SLG (Simulation Game, strategy game), virtual terrain based on hexagonal grids can often provide richer and more variable gameplay, so hexagonal grid terrain is indispensable for games such as SLG. At present, virtual terrains in the gaming industry are all made through editors and then manually through the LandScape tool provided by Unreal, the Terrain tool provided by Unity, etc. to make various terrains. However, it is very time-consuming to edit hexagonal grids through general tools, resulting in low efficiency in the current generation of hexagonal grids.
[0066] In view of the above problems, the present disclosure provides a terrain grid generation method to improve the generation efficiency of hexagonal grids. The following briefly introduces the application environment of the terrain grid generation method provided by the present disclosure embodiment:
[0067] The terrain grid generation method provided in the embodiment of the present disclosure is applied to a terminal device, which may be a server, a computer, a laptop, a tablet computer or other wearable device. The embodiment of the present disclosure does not make any limitation and may be specifically selected according to actual conditions.
[0068] The following uses the above terminal device as the execution subject and applies the terrain mesh generation method to the above terminal device to generate a terrain mesh as an example. Figure 1 The terrain grid generation method provided by the embodiment of the present disclosure includes the following steps 101 to 104:
[0069] Step 101: Determine the center point position of each polygonal mesh unit center point arranged in a matrix, and the first vertex position of each vertex.
[0070] The grid unit can be any symmetrical polygon such as a quadrilateral, a hexagon, an octagon, etc., and multiple grid units are arranged in a matrix. For example, see Figure 2 As shown in the figure, multiple hexagonal grid cells form a terrain grid with a width of width and a length of height. The center point refers to the center point of each grid cell, for example Figure 2 The center point 211 of any grid unit 210 in the grid unit 210 is deduced by analogy. The vertex refers to each vertex of the grid unit, such as Figure 2 The terminal device can determine the first vertex position of each vertex of the hexagonal grid unit 210 in the following ways: the first way is that the terminal device can obtain the first vertex position of each vertex by calculating the matrix arrangement and the size of each grid unit; the second way is that the terminal device obtains the first vertex position of each vertex by calculating the center point position of each grid unit; the third way is to directly read the first vertex position of each grid unit vertex by real-time position acquisition.
[0071] Step 102: For each of the grid units, divide the grid unit into at least two annular sub-grids.
[0072] The center points of the subgrids in a grid unit are the same, each subgrid is a closed grid, and the number of subgrids can be two or more, which is not specifically limited in the embodiment of the present disclosure and can be specifically limited according to actual conditions. For example, see Figure 3 , Figure 3 A hexagonal grid unit is divided into two sub-grids, a first sub-grid 301 located in the inner circle, and a second sub-grid 302 located in the outer circle.
[0073] Step 103: construct a transition grid between each of the grid units according to every two adjacent first sub-grids.
[0074] The first subgrid refers to the subgrid closest to the center point of the grid unit among the subgrids in the grid unit, for example Figure 3 The first sub-grid 301 in the figure. The transition grid refers to a connecting grid body used to connect two adjacent unit grids, and the first sub-grid is not included in the transition grid, that is, the first sub-grid does not participate in the terrain transition, such as height transition, color transition, lighting transition, etc. Only other sub-grids and transition grids except the first sub-grid participate in the terrain transition. The width of the first sub-grid can be specifically set according to actual conditions and is not limited here. The transition grid can include other sub-grids in the grid unit except the first sub-grid, such as the above Figure 3The second sub-grid 302 in the figure, that is, each grid unit is connected by the second sub-grid and the newly constructed grid body; the transition grid may also only include the newly constructed grid body outside the grid unit, that is, each grid unit is connected by the newly constructed grid body.
[0075] Step 104: Connect the grid units based on the transition grid to generate a target terrain grid.
[0076] That is, each grid unit is connected through a transition grid. If the transition grid contains some grid units, each first sub-grid is connected through the transition grid to form a target terrain grid; if the transition grid does not contain a grid unit, each grid unit is connected through the transition grid to form a target terrain grid. The target terrain grid includes at least three parts: the first sub-grid, other sub-grids in the grid unit except the first sub-grid, and the transition grid. In this way, the terrain can be flexibly transitioned in height, color, lighting, etc. in the future.
[0077] The terrain grid generation method provided by the embodiment of the present disclosure first determines the center point position of the center point of each polygonal grid unit arranged in a matrix, and the first vertex position of each vertex, and for each of the grid units, divides the grid unit into at least two annular sub-grids, and constructs a transition grid between each of the grid units based on each two adjacent first sub-grids. Finally, based on the transition grid, each of the grid units is connected to generate a target terrain grid. No human intervention is required, and the target terrain grid can be generated quickly and efficiently, thereby solving the current technical problem of low efficiency in hexagonal grid generation and achieving the technical effect of improving the efficiency of hexagonal grid generation. On the second aspect, the target terrain grid of the embodiment of the present disclosure includes a grid body consisting of three parts: the first sub-grid, other sub-grids in the grid unit except the first sub-grid, and the transition grid. In the subsequent process, the height, color, lighting, etc. of the virtual terrain can be flexibly transitioned through the transition grid, which has higher flexibility and better terrain grid rendering effect.
[0078] See also Figure 4 In an optional embodiment of the present disclosure, the mesh units described above have the same shape and are all symmetrical polygons. The step 101, determining the center point position of the center points of the polygonal mesh units arranged in a matrix, and the first vertex position of each vertex, includes the following steps 401-402:
[0079] Step 401: Determine the center point position of each grid unit center point.
[0080] The terminal device may determine the center point position of the grid unit center point in the same manner as in step 101 above, and may also calculate the center point position by the following formula (1):
[0081] CellPos = ((i * 2 + j % 2) * innerRadius, j * (1.5 * outerRadius)) (1)
[0082] In formula (1), CellPos represents the center point position of the grid cell center point, i represents the index position of the grid cell on the horizontal axis coordinate, j represents the index position of the grid cell on the vertical axis coordinate, and innerRadius represents the shortest distance from the center point of the grid cell to the grid edge, such as Figure 5 In the first line 501, outerRadius represents the longest distance from the center point of the grid unit to the grid edge, such as Figure 5 The second line 502 in .
[0083] Step 402: Determine the first vertex position of each vertex of the grid unit according to the center point position and the path length of the grid unit.
[0084] The path length refers to the inner diameter length of the grid unit, which can be a diameter or a radius. If the grid unit can contain one or more path lengths, such as the shortest inner diameter and the longest inner diameter, the embodiment of the present disclosure does not specifically limit it. For example, if the grid unit is a hexagonal grid, after the terminal device obtains the center point position, the terminal device can calculate the first vertex position of each vertex through the following formulas (2)-(7):
[0085] True north direction: P1 = CellPos + (0, OuterRadius) (2)
[0086] Northeast direction: P2 = CellPos + (innerRadius, 0.5*outerRadius) (3)
[0087] Southeast direction: P3 = CellPos + (innerRadius, -0.5*outerRadius) (4)
[0088] South direction: P4 = CellPos + (0, - OuterRadius) (5)
[0089] Southwest direction: P5 = CellPos + (-innerRadius, -0.5*outerRadius) (6)
[0090] Northwest direction: P6 = CellPos + (-innerRadius, 0.5*outerRadius) (7)
[0091] P iRepresents the ith vertex of the grid cell, CellPos represents the center point position of the grid cell center point, innerRadius represents the shortest distance between the center point in the grid cell and the grid edge, and outerRadius represents the longest distance between the center point in the grid cell and the grid edge. After determining the center point position of each grid cell and the first vertex position of each vertex, six triangles can be formed and then added to the grid.
[0092] In the embodiment of the present disclosure, when the grid units have the same shape and are all symmetrical polygons, the center point position of the center point of each grid unit is first determined, and then the first vertex position of each vertex of the grid unit is determined according to the center point position and the diameter length of the grid unit. The first vertex position of each vertex of the grid unit is quickly calculated through the center point position of the grid unit and the diameter length of the grid unit. The calculation method is simple, fast and more efficient, which can further improve the terrain grid generation efficiency of the embodiment of the present disclosure.
[0093] See also Figure 6 In an optional embodiment of the present disclosure, the above step 103, constructing a transition grid between each of the grid units according to each two adjacent first sub-grids, includes the following steps 601-602:
[0094] Step 601: construct a connected mesh using the vertices of two adjacent first sub-meshes.
[0095] See for example Figure 7 The two adjacent first sub-grids, that is, the part of the grid body of the grid unit that does not need to participate in the transition, connect the vertices of the two first sub-grids, and the formed quadrilateral grid body is the connected grid 701. Of course, the shape of the connected grid can be determined according to the actual situation, including but not limited to Figure 7 Examples in .
[0096] Step 602: construct the transition grid based on the connection grid and the second sub-grid.
[0097] The second sub-grid refers to the sub-grid farthest from the center point of the grid unit among the sub-grids in the grid unit, for example Figure 3 The second sub-grid 302 in the figure can be connected to the connection grid 701 and the second sub-grid 302 to form the transition grid. Through the transition grid, the height, color, lighting, etc. of the virtual terrain can be flexibly transitioned, which has higher flexibility and better terrain grid rendering effect.
[0098] The embodiment of the present disclosure constructs a connection grid with the vertices of two adjacent first sub-grids, and then constructs the transition grid based on the connection grid and the second sub-grid, which can maximize the fineness of the transition grid and the fineness of the terrain grid, thereby improving the rendering effect of the virtual terrain obtained after rendering the target terrain grid generated based on the embodiment of the present disclosure.
[0099] In an optional embodiment of the present disclosure, the terrain grid generation method further includes the following steps:
[0100] A filling grid between adjacent connected grids is constructed according to each vertex of the adjacent connected grids.
[0101] For example, Figure 3 The second subgrid 302 in Figure 7 After the connection is completed, the connection grid 701 in Figure 8 The triangular gap in the connection mesh, that is, the filling mesh can be constructed by connecting the vertices of the connection mesh and the second sub-mesh, and the shape of the filling mesh is the same as the shape of the gap between the connection mesh and the second sub-mesh.
[0102] Correspondingly, the step 602, constructing the transitional grid based on the connected grid and the second sub-grid, comprises the following steps:
[0103] The transition grid is constructed based on the connection grid, the filling grid and the second sub-grid.
[0104] The terminal device can connect the connection grid, the filling grid and the second sub-grid in the same manner as in the above embodiment to obtain the transition grid. The transition grid can realize flexible transition of the height, color, lighting, etc. of the virtual terrain, with higher flexibility and better terrain grid rendering effect.
[0105] The embodiment of the present disclosure constructs the transition grid based on the connection grid, the filling grid and the second sub-grid, which can maximize the fineness of the transition grid and the fineness of the terrain grid, thereby improving the rendering effect of the virtual terrain obtained after rendering the target terrain grid generated based on the embodiment of the present disclosure.
[0106] See also Fig. 9 In an optional embodiment of the present disclosure, the above step 104, connecting the grid units based on the transition grid to generate the target terrain grid, includes the following steps 901-902:
[0107] Step 901: Connect the grid units based on the transition grid to form an initial terrain grid.
[0108] The initial terrain grid formed is a terrain grid whose height parameters are all initial values or equal heights.
[0109] Step 902: Adjust the height of the transition grid based on a preset height to obtain the target terrain grid.
[0110] The terrain height in the virtual terrain is one of the important parameters for characterizing the terrain. The preset height in the embodiment of the present disclosure can be specifically set according to the actual situation. For example, the heights of transition grids at different positions are different to form a virtual terrain. Fig.10 In this way, the height of the virtual terrain is flexibly transitioned, and the target terrain mesh formed has higher accuracy and better effect.
[0111] In an optional embodiment of the present disclosure, the above-mentioned grid unit is a regular hexagon. The corresponding above-mentioned transition grid is a quadrilateral, and the filling grid is a triangle. In this way, a hexagonal terrain grid can be generated quickly and efficiently, with higher efficiency and better generated terrain grid.
[0112] See also Fig.11 An embodiment of the present disclosure provides a method for generating a virtual terrain, comprising the following steps 1101 to 1102:
[0113] Step 1101: Generate a target terrain grid according to any of the terrain grid generation methods described above.
[0114] The specific determination process of the target terrain grid and the corresponding beneficial effects have been described in detail in the above embodiments and will not be repeated here.
[0115] Step 1102: Render the target terrain grid according to the pre-configured terrain information to obtain the target virtual terrain.
[0116] The topographic information includes at least one of illumination information and color information, and may also include other topographic information such as texture, which are not exhaustively listed here.
[0117] The target terrain grid in the virtual terrain generation method provided by the embodiment of the present disclosure is generated based on the above-mentioned terrain grid generation method. The generation efficiency of the target terrain grid is higher and the effect is better. The target virtual terrain rendered based on the target terrain grid is also more efficient and the display effect of the virtual terrain is also better.
[0118] See also Fig.12In an optional embodiment of the present disclosure, the target terrain grid is formed by constructing the transition grid based on the connection grid, the filling grid and the second sub-grid in the terrain grid generation method of the above embodiment, and the virtual terrain generation method further includes the following steps 1201-1202:
[0119] Step 1201: Determine the second vertex position of each vertex in each filled mesh.
[0120] For example, the above Figure 8 The filling mesh of the triangular gap in includes three vertices with coordinates v1, v2, and v3 respectively.
[0121] Step 1202: for each of the filling meshes, determine the normal of the filling mesh according to the positions of the second vertices;
[0122] The terminal device can calculate the normal of the filled grid based on the following formula (8):
[0123] normal = cross(v2 – v1, v3 -v1) (8)
[0124] In formula (8), normal represents the normal of the filled mesh, and v1, v2, and v3 represent the second vertex positions of the three vertices of the filled mesh, respectively.
[0125] Correspondingly, step 1102, rendering the target terrain grid according to the pre-configured terrain information to obtain the target virtual terrain, includes the following steps:
[0126] According to the normal of the filling grid, the target terrain grid is rendered according to the pre-configured landform information to obtain the target virtual terrain.
[0127] The disclosed embodiment renders the target terrain mesh based on the normal of the filling mesh according to the pre-configured terrain information. The obtained target virtual terrain can ensure that the normal of the newly constructed filling mesh is the same as the normal of each vertex, so that the terrain morphology of the rendered target virtual terrain is more accurate and the display effect is better.
[0128] See also Fig.13 In order to implement the above-mentioned terrain grid generation method, a terrain grid generation device 1300 is provided in one embodiment of the present disclosure. Fig.13 The schematic architecture diagram of the terrain grid generation device 1300 is shown, comprising: a determination module 1310, a splitting module 1320, a construction module 1330 and a first generation module 1340, wherein:
[0129] The determination module 1310 is used to determine the center point position of each polygonal mesh unit arranged in a matrix, and the first vertex position of each vertex;
[0130] The splitting module 1320 is used to divide each of the grid units into at least two annular sub-grids; wherein the center points of the sub-grids in one grid unit are the same;
[0131] The construction module 1330 is used to construct a transition grid between each of the grid units according to each two adjacent first sub-grids; wherein the first sub-grid refers to a sub-grid that is closest to the center point of the grid unit among the sub-grids in the grid unit;
[0132] The first generating module 1340 is used to connect the grid units based on the transition grid to generate a target terrain grid.
[0133] In an optional embodiment of the present disclosure, each of the grid units has the same shape and is a symmetrical polygon. The determination module 1310 is specifically used to determine the center point position of each of the grid unit center points; and determine the first vertex position of each vertex of the grid unit based on the center point position and the diameter length of the grid unit.
[0134] In an optional embodiment of the present disclosure, the construction module 1330 is specifically used to construct a connected grid with the vertices of two adjacent first sub-grids; and construct the transition grid based on the connected grid and the second sub-grid; wherein the second sub-grid refers to the sub-grid in each of the sub-grids in the grid unit that is farthest from the center point of the grid unit.
[0135] In an optional embodiment of the present disclosure, the construction module 1330 is further used to construct a filling mesh between adjacent connected meshes according to vertices of the adjacent connected meshes; and construct the transition mesh based on the connected meshes, the filling meshes and the second sub-mesh.
[0136] In an optional embodiment of the present disclosure, the first generation module 1340 is specifically used to connect the grid units based on the transition grid to form an initial terrain grid; and adjust the height of the transition grid based on a preset height to obtain the target terrain grid.
[0137] In an optional embodiment of the present disclosure, the grid unit described above is a regular hexagon.
[0138] See also Fig.14 In order to implement the above-mentioned virtual terrain generation method, a virtual terrain generation device 1400 is provided in one embodiment of the present disclosure. Fig.14The schematic architecture diagram of the virtual terrain generating device 1400 is shown, including: a second generating module 1410 and a rendering module 1420, wherein:
[0139] The second generating module 1410 is used to generate a target terrain grid according to any of the terrain grid generating methods described above;
[0140] The rendering module 1420 is used to render the target terrain grid according to pre-configured terrain information to obtain a target virtual terrain; wherein the terrain information includes at least one of illumination information and color information.
[0141] In an optional embodiment of the present disclosure, the rendering module 1420 is also used to determine the second vertex position of each vertex in each filling mesh; for each of the filling meshes, determine the normal of the filling mesh according to each second vertex position; based on the normal of the filling mesh, render the target terrain mesh according to pre-configured terrain information to obtain the target virtual terrain.
[0142] The exemplary embodiments of the present disclosure also provide a computer-readable storage medium, which can be implemented in the form of a program product, which includes a program code, and when the program product is run on an electronic device, the program code is used to cause the electronic device to perform the steps described in the above "Exemplary Method" section of this specification according to various exemplary embodiments of the present disclosure. In one embodiment, the program product can be implemented as a portable compact disk read-only memory (CD-ROM) and includes program code, and can be run on an electronic device, such as a personal computer. However, the program product of the present disclosure is not limited to this, and in this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or device.
[0143] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0144] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0145] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0146] The program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet). In the embodiments of the present disclosure, the program code stored in the computer-readable storage medium may implement any step in the above terrain mesh generation method and virtual terrain generation method when executed.
[0147] See also Fig.15 The exemplary embodiment of the present disclosure further provides an electronic device 1500, which may be a background server of an information platform. Fig.15 The electronic device 1500 is described. It should be understood that Fig.15 The electronic device 1500 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0148] like Fig.15 As shown, the electronic device 1500 is in the form of a general computing device. The components of the electronic device 1500 may include, but are not limited to: at least one processing unit 1510, at least one storage unit 1520, and a bus 1530 connecting different system components (including the storage unit 1520 and the processing unit 1510).
[0149] The storage unit stores program codes, which can be executed by the processing unit 1510, so that the processing unit 1510 performs the steps of various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 1510 can perform the following steps: Figure 2 The method steps shown, etc.
[0150] The storage unit 1520 may include a volatile storage unit, such as a random access storage unit (RAM) 1521 and / or a cache storage unit 1522 , and may further include a read-only storage unit (ROM) 1523 .
[0151] The storage unit 1520 may also include a program / utility 1524 having a set (at least one) of program modules 1525, such program modules 1525 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0152] The bus 1530 may include a data bus, an address bus, and a control bus.
[0153] The electronic device 1500 may also communicate with one or more external devices 2000 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), and such communication may be performed via an input / output (I / O) interface 1540. The electronic device 1500 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1550. As shown, the network adapter 1550 communicates with other modules of the electronic device 1500 via a bus 1530. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0154] In the embodiment of the present disclosure, when the program code stored in the electronic device is executed, any step in the terrain mesh generation method and the virtual terrain generation method as described above can be implemented.
[0155] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0156] It will be appreciated by those skilled in the art that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or implementations combining hardware and software aspects, which may be collectively referred to herein as "circuit", "module" or "system". Those skilled in the art will readily think of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptive changes of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and implementation are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0157] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A terrain grid generation method, characterized in that: include: Determine the center point position of each polygonal grid unit center point arranged in a matrix, and the first vertex position of each vertex; For each of the grid units, the grid unit is divided into at least two annular sub-grids; wherein the center points of the sub-grids in one of the grid units are the same; Constructing a transition grid between each of the grid units according to each two adjacent first sub-grids; wherein the first sub-grid refers to a sub-grid closest to the center point of the grid unit among the sub-grids in the grid unit; The target terrain grid is generated by connecting the grid units based on the transition grid.
2. The terrain grid generation method according to claim 1, characterized in that: The mesh units have the same shape and are symmetrical polygons. The determining of the center point position of the center points of the polygonal mesh units arranged in a matrix and the first vertex position of each vertex includes: Determine the center point position of each of the grid unit center points; The first vertex position of each vertex of the grid unit is determined according to the center point position and the path length of the grid unit.
3. The terrain grid generation method according to claim 1, characterized in that: The step of constructing a transition grid between each of the grid units according to each two adjacent first sub-grids includes: Constructing a connected grid using the vertices of two adjacent first sub-grids; The transitional grid is constructed based on the connection grid and the second sub-grid; wherein the second sub-grid refers to the sub-grid farthest from the center point of the grid unit among the sub-grids in the grid unit.
4. The terrain grid generation method according to claim 3, characterized in that: The method further comprises: Constructing a filling grid between adjacent connected grids according to each vertex of the adjacent connected grids; Correspondingly, constructing the transitional grid based on the connected grid and the second sub-grid includes: The transition grid is constructed based on the connection grid, the filling grid and the second sub-grid.
5. The terrain grid generation method according to claim 1, characterized in that: The step of connecting the grid units based on the transition grid to generate a target terrain grid comprises: Connecting each of the grid cells based on the transition grid to form an initial terrain grid; The height of the transition grid is adjusted based on a preset height to obtain the target terrain grid.
6. The terrain grid generation method according to any one of claims 1 to 5, characterized in that: The grid unit is a regular hexagon.
7. A method for generating a virtual terrain, characterized in that: include: Generate a target terrain grid according to the terrain grid generation method according to any one of claims 1 to 6; The target terrain grid is rendered according to pre-configured terrain information to obtain a target virtual terrain; wherein the terrain information includes at least one of illumination information and color information.
8. The method for generating virtual terrain according to claim 7, characterized in that: The target terrain grid is determined by the terrain grid generation method according to claim 4, wherein the method further comprises: Determine the second vertex position of each vertex in each filled grid; For each of the filling meshes, determining a normal of the filling mesh according to each of the second vertex positions; Correspondingly, rendering the target terrain grid according to the pre-configured terrain information to obtain the target virtual terrain includes: According to the normal of the filling grid, the target terrain grid is rendered according to the pre-configured landform information to obtain the target virtual terrain.
9. A terrain grid generation device, characterized in that: The device comprises: A determination module, used to determine the center point position of each polygonal mesh unit center point arranged in a matrix, and the first vertex position of each vertex; A splitting module, used for dividing each of the grid units into at least two annular sub-grids; wherein the center points of the sub-grids in one grid unit are the same; A construction module, configured to construct a transition grid between each of the grid units according to each two adjacent first sub-grids; wherein the first sub-grid refers to a sub-grid closest to a center point of the grid unit among the sub-grids in the grid unit; The first generating module is used to connect the grid units based on the transition grid to generate a target terrain grid.
10. A virtual terrain generating device, characterized in that: include: A second generation module, configured to generate a target terrain grid according to the terrain grid generation method according to any one of claims 1 to 6; A rendering module is used to render the target terrain grid according to pre-configured terrain information to obtain a target virtual terrain; wherein the terrain information includes at least one of illumination information and color information.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 8 by executing the executable instructions.
