CN117036626A - Rendering method and device of three-dimensional terrain model and electronic equipment - Google Patents
Rendering method and device of three-dimensional terrain model and electronic equipment Download PDFInfo
- Publication number
- CN117036626A CN117036626A CN202310536952.4A CN202310536952A CN117036626A CN 117036626 A CN117036626 A CN 117036626A CN 202310536952 A CN202310536952 A CN 202310536952A CN 117036626 A CN117036626 A CN 117036626A
- Authority
- CN
- China
- Prior art keywords
- model
- parameters
- units
- vertex
- grid
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000009877 rendering Methods 0.000 title claims abstract description 101
- 238000000034 method Methods 0.000 title claims abstract description 71
- 230000007704 transition Effects 0.000 claims abstract description 17
- 230000011218 segmentation Effects 0.000 claims description 35
- 239000000463 material Substances 0.000 claims description 12
- 210000004027 cell Anatomy 0.000 claims description 8
- 210000001316 polygonal cell Anatomy 0.000 claims description 3
- 230000000694 effects Effects 0.000 abstract description 6
- 230000000875 corresponding effect Effects 0.000 description 95
- 238000010586 diagram Methods 0.000 description 19
- 230000008569 process Effects 0.000 description 8
- 238000012876 topography Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 5
- 101150071246 Hexb gene Proteins 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000005070 sampling Methods 0.000 description 4
- 101150081099 OGA gene Proteins 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 239000003086 colorant Substances 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000002596 correlated effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
- 239000011435 rock Substances 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
- G06T17/05—Geographic models
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/50—Controlling the output signals based on the game progress
- A63F13/52—Controlling the output signals based on the game progress involving aspects of the displayed game scene
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T19/00—Manipulating 3D models or images for computer graphics
- G06T19/20—Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/60—Methods for processing data by generating or executing the game program
- A63F2300/66—Methods for processing data by generating or executing the game program for rendering three dimensional images
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02A—TECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
- Y02A90/00—Technologies having an indirect contribution to adaptation to climate change
- Y02A90/10—Information and communication technologies [ICT] supporting adaptation to climate change, e.g. for weather forecasting or climate simulation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- Multimedia (AREA)
- Geometry (AREA)
- Computer Graphics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Remote Sensing (AREA)
- Computer Hardware Design (AREA)
- General Engineering & Computer Science (AREA)
- Architecture (AREA)
- Image Generation (AREA)
Abstract
The invention provides a rendering method and device of a three-dimensional terrain model and electronic equipment, wherein grid models and terrain model parameters corresponding to the grid models are obtained; the grid model is formed by connecting a plurality of polygonal units; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model. The method reduces the number of faces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
Description
Technical Field
The invention relates to the technical field of model rendering, in particular to a rendering method and device of a three-dimensional terrain model and electronic equipment.
Background
In some games, it is desirable to set a game terrain for all players to play, with which both the player's thinking about the game strategy and the visual experience have a strong correlation. In the related art, game topography is usually manufactured by an artist through some digital content creation software, and the art cost of this method is high, and the number of grid faces adopted when converting to topography in a virtual space is usually high, so that the rendering efficiency of the game topography is low.
Disclosure of Invention
Accordingly, the present invention is directed to a method, an apparatus, and an electronic device for rendering a three-dimensional terrain model, so as to improve the rendering efficiency of the three-dimensional terrain model in a game.
In a first aspect, an embodiment of the present invention provides a rendering method of a three-dimensional terrain model, including: obtaining a terrain model parameter corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model.
In a second aspect, an embodiment of the present invention provides a rendering apparatus for a three-dimensional terrain model, including: the grid model acquisition module is used for acquiring a grid model and terrain model parameters corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model; the expansion model generation module is used for generating an expansion model based on a plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; the vertex parameter determining module is used for determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; the model rendering module is used for rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, where the memory stores machine executable instructions executable by the processor, and the processor executes the machine executable instructions to implement the method for rendering a three-dimensional terrain model described above.
In a fourth aspect, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions that, when invoked and executed by a processor, cause the processor to implement the method of rendering a three-dimensional terrain model described above.
The embodiment of the invention has the following beneficial effects:
according to the rendering method and device of the three-dimensional terrain model and the electronic equipment, the grid model and the terrain model parameters corresponding to the grid model are obtained; the grid model is formed by connecting a plurality of polygonal units; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model. The method reduces the number of faces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are some embodiments of the invention and that other drawings may be obtained from these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a rendering method of a three-dimensional terrain model according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a three-dimensional terrain model according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a mesh model according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of another mesh model according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an expansion model according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of another expansion model according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a grid splicing unit according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a hexagonal block according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a coordinate calculation method of a hexagonal block according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of an editing tool according to an embodiment of the present invention;
FIG. 11 is a schematic diagram of a grid according to an embodiment of the present invention;
FIG. 12 is a schematic diagram of another grid provided by an embodiment of the present invention;
FIG. 13 is a schematic diagram of a transition grid according to an embodiment of the present invention;
FIG. 14 is a schematic diagram of a rendered three-dimensional terrain model according to an embodiment of the present invention;
FIG. 15 is a schematic diagram of a block matching process according to an embodiment of the present invention;
FIG. 16 is a schematic structural diagram of a rendering device for a three-dimensional terrain model according to an embodiment of the present invention;
fig. 17 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In policy-like games (also known as "simulated games," abbreviated as "SLG"), it is often necessary to have a large topography for all players to play. Both the player's thinking about game strategies and the visual experience are strongly correlated with terrain. Game terrain is typically created by an artist through some terrain digital content authoring software (Digital Content Creation, simply "DCC") software, which creates high cost of art, high grid count, and difficulty for game designers to modify the terrain in the game engine.
The above-described terrain digital content creation software may be generally World Machine, houdini, or the like. After the fine arts personnel make topography through the software, the topography that will make is imported into the game engine and is processed, and the performance of topography in the game engine is optimized by the developer at last.
The above method requires high art cost and time, and the generated topography often has high number of faces, which is easy to form performance problem. In addition, the method is difficult to develop the terrain secondarily in the game engine, and the development period of the whole game is prolonged.
Based on the above, the method, the device and the electronic equipment for rendering the three-dimensional terrain model provided by the embodiment of the invention can be applied to various virtual scenes needing to be rendered by the three-dimensional terrain model.
Referring to fig. 1, first, a method for rendering a three-dimensional terrain model according to an embodiment of the present invention is described, where the method includes the following steps:
step S102, obtaining a grid model and a terrain model parameter corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface texture of the three-dimensional terrain model.
The three-dimensional terrain model can be generally regarded as formed by splicing a plurality of polygonal plots, and the heights of the polygonal plots can be different. The polygonal land block is usually the smallest terrain splicing unit in the three-dimensional terrain model; the polygon may be triangle, square or regular hexagon, etc., and may be specifically set according to the requirement, which is not limited herein.
The mesh model is a planar model formed by connecting a plurality of polygonal units. Wherein the polygonal units correspond to polygonal plots of the three-dimensional terrain model. When the three-dimensional terrain model is a model formed by splicing hexagonal plots as shown in fig. 2, the connection relationship of polygonal units in the grid model is shown in fig. 3.
The terrain model parameters may generally include height parameters corresponding to each polygon unit of the grid module, where the height parameters may be determined based on a preset height plane in a virtual scene where the three-dimensional terrain model is located, and may also correspond to an altitude in real life. The height parameters corresponding to the polygon units in the grid module can indicate the situation of the terrain height distribution of the three-dimensional terrain model.
In addition, as the model surface of the three-dimensional terrain model also needs to simulate the ground surface materials in real scenes such as grasslands, rocks, water surfaces and the like, or different colors of the land parcels are used for distinguishing the attributes of different land parcels. Thus, the terrain model parameters also need to include parameters for rendering the three-dimensional terrain model, which may be data of a certain texture map, or parameter values of a certain or a certain specific color, which may be set according to requirements, and are not limited herein.
Step S104, generating an expansion model based on a plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the plurality of expansion units are used for forming transition areas between model areas corresponding to the plurality of polygon units in the three-dimensional terrain model.
The mesh model described above may be considered to some extent as a top view of a three-dimensional terrain model. The model area in the three-dimensional terrain model corresponding to the polygonal elements may be generally considered to be parallel to a horizontal plane in the virtual scene. When the heights of the model areas are different, the model areas need to be connected through other model areas, namely the transition areas.
In the process of generating an expansion model based on polygonal units, expansion units are added between adjacent polygonal units. These expansion units need to be connected to the polygonal units to form a closed planar area. The specific expansion mode is related to the number of sides of the polygonal unit, and can be set manually. For example, when the polygonal cells are triangle cells, as shown in fig. 4. The expansion model can firstly generate rectangular units between two adjacent triangular units, and after the rectangular units are connected, the relative direction between the two triangular units is unchanged. Since the expansion model needs to be a closed planar figure, hexagonal units surrounded by rectangular units are also needed as part of the expansion model. As shown in fig. 5, the gray part is an expansion unit of the expansion model.
Step S106, determining the vertex parameters of the model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters include vertex position parameters and rendering color parameters.
As it is typically connected by multiple primitives in a three-dimensional model. The number of primitives typically affects the smoothness and color rendering of the three-dimensional model. In the related art, triangle primitives are generally adopted, and the primitives are formed by connecting adjacent model vertices. The primitive segmentation algorithm may be set for the polygon unit and the expansion unit to segment both the polygon unit and the expansion unit into triangles. The specific segmentation mode can be set according to the color expression requirement, smoothness requirement and the like of the three-dimensional terrain model, and is not limited herein.
After the polygon unit and the extension unit are divided, a plurality of primitives can be obtained. And then, the vertexes of the plurality of primitives can be used as model vertexes of the three-dimensional terrain model. The model vertexes comprise vertexes of polygonal units and primitive vertexes generated after segmentation. After determining the model vertices, further determination of the model vertices' position parameters and rendering color parameters based on the terrain model parameters is required.
The height parameters of the vertexes of the polygon unit and the vertexes of the primitives positioned in the polygon unit are the same as the height parameters corresponding to the polygon unit. The coordinate parameters of the vertices of the polygon elements in the mesh model in a planar coordinate system are generally known. The location of primitive vertices in the polygon unit, as determined based on the primitive segmentation algorithm, is also typically computable. Therefore, the vertex position parameters of the vertices of the polygon unit and the vertices of the primitives located inside the polygon unit can be easily determined.
For the primitive vertex located in the expansion unit, the vertex position parameter of the primitive vertex can be calculated based on the relative position relationship between the primitive vertex and the vertex of each expansion unit (which coincides with the vertex of the polygon unit). Specifically, vertex position parameters may be set for the vertices of the primitives according to experience, and the method is not limited herein.
The terrain parameters may include texture parameters or set color parameters of the surface texture corresponding to the polygon unit and the extension unit. Parameters corresponding to the polygon unit and the expansion unit can be different, and rendering color parameters of model vertexes positioned between the polygon unit and the expansion unit can be determined based on the texture parameters or the color parameters of the surface materials corresponding to the polygon unit and the expansion unit respectively. When the terrain parameters include texture parameters, the texture parameters are typically represented by texture maps. It is often necessary to sample the texture map and determine rendering color parameters for the model vertices based on the sampling results. The specific determination mode can be set according to requirements, and is described in detail herein.
And step S108, rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model.
After the vertex position parameters and the rendering color parameters of the model vertices are determined, the surface patch forming the three-dimensional terrain model can be rendered. The specific process is consistent with the common model rendering process, and will not be described here.
According to the rendering method of the three-dimensional terrain model, the grid model and the terrain model parameters corresponding to the grid model are obtained; the grid model is formed by connecting a plurality of polygonal units; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model. The method reduces the number of faces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
The following embodiments provide an implementation of generating an extended model based on a plurality of polygonal elements.
Taking a polygonal unit as a hexagonal unit as an example, an implementation manner of generating an expansion model is described. The hexagonal unit is formed by connecting six basic vertexes; adjacent two hexagonal cells have two basic vertices that coincide. The generated extension unit comprises a rectangular unit and a triangular unit.
Specifically, rectangular cells may be generated based on the coincident base vertices of two neighboring hexagonal cells of the plurality of hexagonal cells, as shown by the rectangular areas shown by 1,2,3 in fig. 6; adjacent two hexagonal units are connected through a rectangular unit; determining a triangular area surrounded by three adjacent rectangular units as a triangular unit, as shown by a rectangular area in fig. 6; and finally, determining a plane model formed by connecting a plurality of hexagonal units, rectangular units and triangular units as an expansion model. The length of the rectangle in the specific implementation process can be set according to the requirement, and is not limited herein.
The following embodiments provide an implementation of determining vertex parameters for model vertices of a three-dimensional terrain model based on extended model and terrain model parameters.
In specific implementation, firstly, a model vertex of a three-dimensional terrain model can be determined based on an expansion model and a preset primitive segmentation algorithm; then, determining vertex parameters of the model vertices based on the terrain model parameters and the expansion model; the terrain model parameters correspond to a plurality of polygonal elements.
Since model vertices in a three-dimensional terrain model are typically connected as patches of triangles, an extended model may be first segmented into multiple triangles and then the vertices of the triangle may be determined as model vertices. Specifically, the polygon unit may be subjected to segmentation processing based on a preset primitive segmentation algorithm, so as to obtain a first segmentation result; the first segmentation result comprises a plurality of segmentation lines; the intersection of the plurality of dividing lines is then determined as the first extended vertex. Then dividing the expansion unit based on a preset primitive dividing algorithm to obtain a second dividing result; the second segmentation result also comprises a plurality of segmentation lines; and determining the intersection points of the plurality of dividing lines and the edges of the expansion unit as second expansion vertexes, and finally determining the first expansion vertexes, the second expansion vertexes and the basic vertexes as model vertexes of the three-dimensional terrain model. The specific dividing manner may be various, and may be set according to the need, and is not limited herein.
The terrain model parameters generally include elevation parameters and surface texture parameters corresponding to the polygonal elements. The vertex position parameters of the model vertices may be determined based on the position parameters and corresponding height parameters of the polygon units, and the rendering color parameters of the model vertices may be determined based on the surface texture parameters corresponding to the polygon units.
The polygon unit is formed by connecting a plurality of basic vertexes, for example, the triangle unit is formed by connecting three basic vertexes, and the hexagonal vertexes are formed by connecting six basic vertexes. The position parameters of the polygon unit are typically plane coordinate parameters of the basic vertices in a plane coordinate system corresponding to the mesh model. When determining the height parameters of the model vertexes, firstly, determining the height parameters corresponding to the polygonal units as the height coordinate parameters of the basic vertexes of the polygonal units for each polygonal unit; generating vertex position parameters of the basic vertexes in a three-dimensional coordinate system corresponding to the three-dimensional terrain model based on the height coordinate parameters and the plane coordinate parameters of the basic vertexes; in specific implementation, coordinate conversion can be performed based on a plane coordinate system corresponding to the grid model and a plane coordinate system corresponding to a horizontal plane of the three-dimensional scene, so as to determine vertex position parameters of the basic vertices. For each extended vertex, a vertex position parameter for the extended vertex may be generated based on a vertex position parameter for the extended vertex's associated vertex; wherein, the related vertex can be a basic vertex connected with the extended vertex to form the surface sheet.
When determining the rendering color parameters of the model vertices, the rendering color parameters of the basic vertices of the polygon units can be generated for each polygon unit based on the surface texture parameters corresponding to the polygon units, and when the surface texture parameters are represented by the texture map data in specific implementation, the texture map data also need to be sampled based on the vertex position parameters of the basic vertices to obtain sampling data, and further, the corresponding rendering color data is determined based on the sampling data. For each extended vertex, generating rendering color parameters of the extended vertex based on surface texture parameters corresponding to the relevant vertex of the extended vertex, wherein the relevant vertex can be a basic vertex connected with the extended vertex to form a surface patch, or can be a preset designated model vertex.
The following embodiments provide an implementation manner for obtaining the terrain model parameters corresponding to the grid model.
The grid model may be generated by a grid stitching module. Specifically, a plurality of grid splicing modules and terrain model parameters corresponding to each grid splicing model can be obtained first; the grid splicing module is formed by connecting a plurality of splicing units and a plurality of polygonal units; the splice cells are located in the edge region of the grid splice module, typically as part of a polygonal cell. Each polygonal unit and each splicing unit has corresponding terrain model parameters. Further, based on the terrain model parameters of the splicing units, the splicing relation of a plurality of grid splicing modules can be determined, namely when the terrain model parameters of the splicing units of different grid splicing modules are the same, the two grid splicing modules can be spliced; and finally, based on the splicing relation, carrying out splicing treatment on the plurality of grid splicing modules to obtain a grid model.
The grid splicing unit comprises at least one region to be matched; in the process of determining the splicing relationship, a first module and a second module can be determined from a plurality of grid splicing modules; and matching the to-be-matched area of the first module and the to-be-matched area of the second module based on the terrain model parameters corresponding to the to-be-matched area of the first module and the terrain model parameters corresponding to the to-be-matched area of the second module to obtain a matching result. Based on the situation in fig. 7, when the area to be matched is composed of m, n, and l splicing units, the terrain model parameters of the area to be matched are the terrain model parameters of the three splicing units arranged in the connection order. The first module and the second module may include a plurality of areas to be matched, and after the areas to be matched of different modules are matched in pairs, if the terrain model parameters cannot be matched, it is determined that the first module and the second module are not matched.
If the matching result is matching, determining that the region to be matched of the first module has a splicing relationship with the region to be matched of the second module; continuously determining a first module and a second module from the grid splicing modules, and matching the first module and the second module until the splicing relationship meets the preset condition; if the matching result is not matched, determining that the region to be matched of the first module and the region to be matched of the second module do not have a splicing relationship; and continuously determining the first module and the second module from the grid splicing modules, and matching the first module and the second module until the splicing relationship meets the preset condition. Wherein, the preset conditions may be: the number of the splicing relations is equal to a preset number threshold, or all areas to be matched of the grid splicing modules are set to have splicing relations with the areas to be matched of other grid splicing modules. And may be specifically set according to the needs, and is not limited herein.
The embodiment of the invention also provides another rendering method of the three-dimensional terrain model, which is realized on the basis of the method shown in fig. 1. The method is used for solving the problems that the art cost is high, the number of faces is high, and the terrain is difficult to be secondarily generated in a game engine in the game terrain generation process.
Firstly, a designer is required to edit the generation information of the hexagonal land block through an editor or other modes, then a terrain generation program is used for carrying out programming generation on the terrain block required by the designer according to the generation information, and finally the designer is used for splicing and combining the terrain block according to project requirements to generate the terrain.
The method is realized by the following steps:
(1) The coordinates of all hexagonal lattices contained in the hexagonal block with radius R are calculated.
The hexagonal block is shown in fig. 8. The grid coordinates refer to coordinates under a hexagonal coordinate system, the radius R of the hexagonal block refers to a distance from an origin of the block to an edge vertex of the block, the hexagonal coordinate system and the radius of the hexagonal block are shown in schematic diagram 1, wherein the hexagonal grid coordinates have the following constraint relation: q+r+s=0
Specifically, the coordinates of all hexagonal lattices in the hexagonal block with radius R may be calculated according to a limited coordinate range, and a schematic diagram of the calculation is shown in fig. 9.
The pseudo code of this algorithm is described as follows:
(2) The height and elevation of the cells within the hexagonal block are set.
In order to generate the hexagonal terrain blocks, a terrain designer needs to manually set the elevation and the surface number corresponding to each hexagonal grid in the terrain blocks, an editing tool is manufactured by the flow scheme to meet the work of the designer, a schematic diagram of the editing tool is shown in fig. 10, E on the grid represents an elevation unit, G represents a surface number, and data of a left input box can be assigned to the inside of the grid by clicking the grid. The method is a data setting mode of hexagonal lattices in the terrain block, and the mode of editing the data scheme of the lattices in the terrain block is not limited.
This step finally outputs the hexagonal block radius R, coordinates, altitude and surface number information of all hexagonal lattices in the block to the terrain generation step.
(3) And (5) terrain generation.
a grid generation inside a single hexagon
The first step is mainly to generate a hexagon, specifically traverse six directions of the hexagon, and program to generate six triangles to combine to generate the hexagon, as shown by the bolded black line part in fig. 11. The height of each vertex is the elevation of the corresponding hexagonal lattice (actually the elevation multiplied by the ratio of the heights taken by the actual project).
The x, y channels of UV2 and the x channels of UV3 of the vertices store the surface numbers of the corresponding hexagonal lattices. The vertex colors of the vertices are RGB (1, 0), and the above surface numbers and vertex color arrangement can ensure that the material parts of the single hexagonal internal grids are not mixed by surrounding hexagonal grids after being used.
b grid generation between two hexagonal blocks
This step mainly creates a transition grid between two hexagonal lattices, which is a combination of rectangular strip-shaped grids, as shown in the bolded black line section in fig. 12 below.
The transition grid is specifically generated by traversing six directions, programming in each direction to generate a rectangular strip grid, as shown in fig. 13 below, the dotted line represents the internal grid generated in the previous step, and the P plus the number represents a vertex on the grid.
In the grid programming process, the attributes of the vertex P meet the following requirements.
(a) Altitude requirement
P0.Elevation=P1.Elevation=P2.Elevation=P3.Elevation=HexA.Elevation
P6.Elevation=P7.Elevation=P4.Elevation=P5.Elevation=HexB.Elevation
(b) Surface numbering requirements (stored in UV2 nd and third channels)
UV at all 8 vertices satisfies the following relationship:
P.UV2=float2(HexA.GroundId,HexB.GroundId)
P.UV3=float2(0,0)
(c) Vertex color requirement
P0.Color=P1.Color=Color(1,0,0)
P6.Color=P7.Color=Color(0,1,0)
P2.Color=P3.Color=Color(2/3,1/3,0)
P4.Color=P5.Color=Color(1/3,2/3,0)
Grid generation between c three hexagonal blocks
The generation mode is to traverse six directions of the hexagonal grids and sequentially generate corresponding triangular transition grids. Fig. 13 shows relevant fixed point information, the dashed line represents the generated internal mesh, and P plus the number represents one vertex on the mesh.
In the grid generated by programming, the vertices need to meet the following requirements:
(a) Altitude requirement
P0.Elevation=P3.Elevation=HexA.Elevation
P2.Elevation=P4.Elevation=HexB.Elevation
P1.Elevation=P5.Elevation=HexC.Elevation
(b) Vertex color requirement
P0.Color=float3(1,0,0)
P1.Color=float3(0,1,0)
P2.Color=float3(0,0,1)
P3.Color=float3(2/3,1/3,1/3)
P5.Color=float3(1/3,2/3,1/3)
P4.Color=float3(1/3,1/3,2/3)
(c) The surface numbering requirements are the same for all vertices
P.UV2=float2(HexA.GroundId,HexB.GroundId)
P.UV3=float2(HexC.GroundId,0)
(4) Basic material of land block
The block surface maps are combined together in the form of a map array, so the map array is sampled in a loader. The vertex Shader of the surface texture transfers the vertex attributes to the corresponding pixels in the Pixel Shader by way of rasterization interpolation, and the Pixel Shader (Pixel Shader) of the surface texture is shown in the following pseudo code, wherein Pixel. Vertexcolor represents the interpolated vertex color of the pixels, pixel. World pos represents world coordinates, pixel. Uv represents the interpolation UV, groundTextures of the pixels, represents the surface map array, and SampleTextureArray represents the sampling function of the map array.
float3 GroundColorA = Pixel.VertexColor.x *SampleTextureArray(GroundTextures, Pixel.WorldPos.xy,Pixel.UV2.x);
float3 GroundColorB = Pixel.VertexColor.y *SampleTextureArray(GroundTextures, Pixel.WorldPos.xy,Pixel.UV2.y);
float3 GroundColorC = Pixel.VertexColor.z *SampleTextureArray(GroundTextures, Pixel.WorldPos.xy,Pixel.UV3.x);
float3 GroundColor=GroundColorA+GroundColorB+GroundColorC;
The color of the earth's surface can be obtained by the above pseudo code, and an example plot grid generation plus base material is shown in fig. 14.
(5) Parquet matching
According to the above-described block programming generation method, if the grids at the edges of two hexagonal blocks can be matched in elevation and surface number, the blocks on both sides can be seamlessly spliced together, and the matching example is shown in fig. 15.
The method firstly utilizes programming to generate the land block, reduces the art cost and the number of faces for generating the terrain, and simultaneously can support the combination of the land blocks in a game engine to generate the terrain through the principle that the land blocks can be spliced.
For the above method embodiment, referring to fig. 16, an embodiment of the present invention provides a rendering device for a three-dimensional terrain model, where the device includes:
a grid model acquisition module 1502, configured to acquire a grid model and a terrain model parameter corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model;
an expansion model generation module 1504 for generating an expansion model based on a plurality of polygon units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model;
the vertex parameter determining module 1506 is configured to determine vertex parameters of model vertices of the three-dimensional terrain model based on the extended model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters;
The model rendering module 1508 is configured to render the three-dimensional terrain model based on the rendering color parameter and the vertex position parameter corresponding to the model vertex, and obtain a rendered three-dimensional terrain model.
The rendering device of the three-dimensional terrain model acquires the grid model and the terrain model parameters corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model. The method reduces the number of faces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
The polygonal units are hexagonal units; the hexagonal unit is formed by connecting six basic vertexes; two adjacent hexagonal units are provided with two coincident basic vertexes; the expansion unit comprises a rectangular unit and a triangular unit; the expansion model generation module is also used for; generating a rectangular unit based on the coincident basic vertexes of two adjacent hexagonal units in the plurality of hexagonal units; adjacent two hexagonal units are connected through a rectangular unit; determining a triangular area surrounded by three adjacent rectangular units as a triangular unit; a plane model formed by connecting a plurality of hexagonal units, rectangular units and triangular units is determined as an expansion model.
The vertex parameter determining module is further configured to: determining model vertexes of the three-dimensional terrain model based on the expansion model and a preset primitive segmentation algorithm; determining vertex parameters of the model vertices based on the terrain model parameters and the expansion model; the terrain model parameters correspond to a plurality of polygonal elements.
The vertex parameter determining module is further configured to: dividing the polygon unit based on a preset primitive dividing algorithm to obtain a first dividing result; the first segmentation result comprises a plurality of segmentation lines; determining an intersection point of the plurality of dividing lines as a first expansion vertex; dividing the expansion unit based on a preset primitive dividing algorithm to obtain a second dividing result; the second segmentation result comprises a plurality of segmentation lines; determining the intersection points of the plurality of dividing lines and the edges of the expansion unit as second expansion vertexes; the first extended vertex, the second extended vertex, and the base vertex are determined as model vertices of the three-dimensional terrain model.
The terrain model parameters comprise height parameters and surface texture parameters corresponding to the polygonal units; the vertex parameter determining module is further configured to: determining vertex position parameters of the model vertices based on the position parameters and the corresponding height parameters of the polygon units; and determining rendering color parameters of the model vertexes based on the surface texture parameters corresponding to the polygon units.
The polygonal unit is formed by connecting a plurality of basic vertexes; the position parameters of the polygon units comprise plane coordinate parameters of the basic vertexes in a plane coordinate system corresponding to the grid model; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; the vertex parameter determining module is further configured to: determining the height parameter corresponding to each polygonal unit as the height coordinate parameter of the basic vertex of the polygonal unit; generating vertex position parameters of the basic vertexes in a three-dimensional coordinate system corresponding to the three-dimensional terrain model based on the height coordinate parameters and the plane coordinate parameters of the basic vertexes; generating vertex position parameters of the extended vertices based on vertex position parameters of relevant vertices of the extended vertices for each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
The polygonal unit is formed by connecting a plurality of basic vertexes; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; the vertex parameter determining module is further configured to: generating rendering color parameters of basic vertexes of the polygonal units based on the surface texture parameters corresponding to the polygonal units for each polygonal unit; generating rendering color parameters of the extended vertexes based on the surface texture parameters corresponding to the relevant vertexes of the extended vertexes aiming at each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
The grid model acquisition module is further used for: acquiring terrain model parameters corresponding to a plurality of grid splicing modules and each grid splicing model; the grid splicing module is formed by connecting a plurality of splicing units and a plurality of polygonal units; the splicing unit is positioned in the edge area of the grid splicing module; the terrain model parameters correspond to the polygonal units and the splicing units; determining a splicing relationship of a plurality of grid splicing modules based on the terrain model parameters of the splicing units; and based on the splicing relation, splicing the plurality of grid splicing modules to obtain a grid model.
The grid splicing unit comprises at least one region to be matched; the area to be matched is formed by connecting a plurality of splicing units; the grid model acquisition module is further used for: determining a first module and a second module from a plurality of grid splicing modules; matching the to-be-matched area of the first module and the to-be-matched area of the second module based on the terrain model parameters corresponding to the to-be-matched area of the first module and the terrain model parameters corresponding to the to-be-matched area of the second module to obtain a matching result; the matching result is matching or unmatched; if the matching result is matching, determining that the region to be matched of the first module has a splicing relationship with the region to be matched of the second module; continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition; if the matching result is not matched, determining that the region to be matched of the first module and the region to be matched of the second module do not have a splicing relationship; and continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition.
The embodiment also provides an electronic device, including a processor and a memory, where the memory stores machine executable instructions executable by the processor, and the processor executes the machine executable instructions to implement the method for rendering a three-dimensional terrain model. The method comprises the following steps:
Obtaining a terrain model parameter corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model.
The method reduces the number of the surfaces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
Optionally, the polygonal unit is a hexagonal unit; the hexagonal unit is formed by connecting six basic vertexes; two adjacent hexagonal units are provided with two coincident basic vertexes; the expansion unit comprises a rectangular unit and a triangular unit; a step of generating an expansion model based on a plurality of polygonal units, including; generating a rectangular unit based on the coincident basic vertexes of two adjacent hexagonal units in the plurality of hexagonal units; adjacent two hexagonal units are connected through a rectangular unit; determining a triangular area surrounded by three adjacent rectangular units as a triangular unit; a plane model formed by connecting a plurality of hexagonal units, rectangular units and triangular units is determined as an expansion model.
Optionally, the step of determining the vertex parameters of the model vertices of the three-dimensional terrain model based on the extended model and the terrain model parameters includes: determining model vertexes of the three-dimensional terrain model based on the expansion model and a preset primitive segmentation algorithm; determining vertex parameters of the model vertices based on the terrain model parameters and the expansion model; the terrain model parameters correspond to a plurality of polygonal elements.
Optionally, the step of determining the model vertex of the three-dimensional terrain model based on the extended model and a preset primitive segmentation algorithm includes: dividing the polygon unit based on a preset primitive dividing algorithm to obtain a first dividing result; the first segmentation result comprises a plurality of segmentation lines; determining an intersection point of the plurality of dividing lines as a first expansion vertex; dividing the expansion unit based on a preset primitive dividing algorithm to obtain a second dividing result; the second segmentation result comprises a plurality of segmentation lines; determining the intersection points of the plurality of dividing lines and the edges of the expansion unit as second expansion vertexes; the first extended vertex, the second extended vertex, and the base vertex are determined as model vertices of the three-dimensional terrain model.
Optionally, the terrain model parameters include height parameters and surface texture parameters corresponding to the polygon units; determining vertex parameters of the model vertices based on the terrain model parameters and the extended model, comprising: determining vertex position parameters of the model vertices based on the position parameters and the corresponding height parameters of the polygon units; and determining rendering color parameters of the model vertexes based on the surface texture parameters corresponding to the polygon units.
Optionally, the polygon unit is formed by connecting a plurality of basic vertexes; the position parameters of the polygon units comprise plane coordinate parameters of the basic vertexes in a plane coordinate system corresponding to the grid model; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; determining vertex position parameters of the model vertices based on the height parameters corresponding to the polygon units and the position parameters of the polygon units, wherein the method comprises the following steps: determining the height parameter corresponding to each polygonal unit as the height coordinate parameter of the basic vertex of the polygonal unit; generating vertex position parameters of the basic vertexes in a three-dimensional coordinate system corresponding to the three-dimensional terrain model based on the height coordinate parameters and the plane coordinate parameters of the basic vertexes; generating vertex position parameters of the extended vertices based on vertex position parameters of relevant vertices of the extended vertices for each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
Optionally, the polygon unit is formed by connecting a plurality of basic vertexes; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; determining rendering color parameters of the model vertices based on the surface texture parameters corresponding to the polygon units, comprising: generating rendering color parameters of basic vertexes of the polygonal units based on the surface texture parameters corresponding to the polygonal units for each polygonal unit; generating rendering color parameters of the extended vertexes based on the surface texture parameters corresponding to the relevant vertexes of the extended vertexes aiming at each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
Optionally, the step of obtaining the grid model and the terrain model parameters corresponding to the grid model includes: acquiring terrain model parameters corresponding to a plurality of grid splicing modules and each grid splicing model; the grid splicing module is formed by connecting a plurality of splicing units and a plurality of polygonal units; the splicing unit is positioned in the edge area of the grid splicing module; the terrain model parameters correspond to the polygonal units and the splicing units; determining a splicing relationship of a plurality of grid splicing modules based on the terrain model parameters of the splicing units; and based on the splicing relation, splicing the plurality of grid splicing modules to obtain a grid model.
Optionally, the grid splicing unit includes at least one region to be matched; the area to be matched is formed by connecting a plurality of splicing units; determining a splicing relationship of the plurality of grid splicing modules based on the terrain model parameters of the splicing unit, comprising: determining a first module and a second module from a plurality of grid splicing modules; matching the to-be-matched area of the first module and the to-be-matched area of the second module based on the terrain model parameters corresponding to the to-be-matched area of the first module and the terrain model parameters corresponding to the to-be-matched area of the second module to obtain a matching result; the matching result is matching or unmatched; if the matching result is matching, determining that the region to be matched of the first module has a splicing relationship with the region to be matched of the second module; continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition; if the matching result is not matched, determining that the region to be matched of the first module and the region to be matched of the second module do not have a splicing relationship; and continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition.
Referring to fig. 17, the electronic device includes a processor 100 and a memory 101, the memory 101 storing machine executable instructions that can be executed by the processor 100, the processor 100 executing the machine executable instructions to implement the above-described rendering method of the three-dimensional terrain model.
Further, the electronic device shown in fig. 17 further includes a bus 102 and a communication interface 103, and the processor 100, the communication interface 103, and the memory 101 are connected through the bus 102.
The memory 101 may include a high-speed random access memory (RAM, random Access Memory), and may further include a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory. The communication connection between the system network element and at least one other network element is implemented via at least one communication interface 103 (which may be wired or wireless), and may use the internet, a wide area network, a local network, a metropolitan area network, etc. Bus 102 may be an ISA bus, a PCI bus, an EISA bus, or the like. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 17, but not only one bus or type of bus.
The processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 100 or by instructions in the form of software. The processor 100 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processor, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and, in combination with its hardware, performs the steps of the method of the previous embodiment.
The present embodiment also provides a machine-readable storage medium storing machine-executable instructions that, when invoked and executed by a processor, cause the processor to implement the above-described rendering method of a three-dimensional terrain model.
The embodiment of the invention provides a rendering method and device of a three-dimensional terrain model and electronic equipment, comprising a computer readable storage medium storing program codes, wherein the program codes comprise instructions for executing the method in the embodiment of the method. The method comprises the following steps:
obtaining a terrain model parameter corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model; generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygon units in the three-dimensional terrain model; determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters; and rendering the three-dimensional terrain model based on the rendering color parameters and the vertex position parameters corresponding to the model vertices to obtain the rendered three-dimensional terrain model.
The method reduces the number of the surfaces of the three-dimensional terrain model and improves the rendering efficiency of the three-dimensional terrain model while ensuring the display effect of the three-dimensional terrain model.
Optionally, the polygonal unit is a hexagonal unit; the hexagonal unit is formed by connecting six basic vertexes; two adjacent hexagonal units are provided with two coincident basic vertexes; the expansion unit comprises a rectangular unit and a triangular unit; a step of generating an expansion model based on a plurality of polygonal units, including; generating a rectangular unit based on the coincident basic vertexes of two adjacent hexagonal units in the plurality of hexagonal units; adjacent two hexagonal units are connected through a rectangular unit; determining a triangular area surrounded by three adjacent rectangular units as a triangular unit; a plane model formed by connecting a plurality of hexagonal units, rectangular units and triangular units is determined as an expansion model.
Optionally, the step of determining the vertex parameters of the model vertices of the three-dimensional terrain model based on the extended model and the terrain model parameters includes: determining model vertexes of the three-dimensional terrain model based on the expansion model and a preset primitive segmentation algorithm; determining vertex parameters of the model vertices based on the terrain model parameters and the expansion model; the terrain model parameters correspond to a plurality of polygonal elements.
Optionally, the step of determining the model vertex of the three-dimensional terrain model based on the extended model and a preset primitive segmentation algorithm includes: dividing the polygon unit based on a preset primitive dividing algorithm to obtain a first dividing result; the first segmentation result comprises a plurality of segmentation lines; determining an intersection point of the plurality of dividing lines as a first expansion vertex; dividing the expansion unit based on a preset primitive dividing algorithm to obtain a second dividing result; the second segmentation result comprises a plurality of segmentation lines; determining the intersection points of the plurality of dividing lines and the edges of the expansion unit as second expansion vertexes; the first extended vertex, the second extended vertex, and the base vertex are determined as model vertices of the three-dimensional terrain model.
Optionally, the terrain model parameters include height parameters and surface texture parameters corresponding to the polygon units; determining vertex parameters of the model vertices based on the terrain model parameters and the extended model, comprising: determining vertex position parameters of the model vertices based on the position parameters and the corresponding height parameters of the polygon units; and determining rendering color parameters of the model vertexes based on the surface texture parameters corresponding to the polygon units.
Optionally, the polygon unit is formed by connecting a plurality of basic vertexes; the position parameters of the polygon units comprise plane coordinate parameters of the basic vertexes in a plane coordinate system corresponding to the grid model; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; determining vertex position parameters of the model vertices based on the height parameters corresponding to the polygon units and the position parameters of the polygon units, wherein the method comprises the following steps: determining the height parameter corresponding to each polygonal unit as the height coordinate parameter of the basic vertex of the polygonal unit; generating vertex position parameters of the basic vertexes in a three-dimensional coordinate system corresponding to the three-dimensional terrain model based on the height coordinate parameters and the plane coordinate parameters of the basic vertexes; generating vertex position parameters of the extended vertices based on vertex position parameters of relevant vertices of the extended vertices for each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
Optionally, the polygon unit is formed by connecting a plurality of basic vertexes; the model vertexes comprise basic vertexes and extended vertexes; the extended vertex is determined based on the base vertex; determining rendering color parameters of the model vertices based on the surface texture parameters corresponding to the polygon units, comprising: generating rendering color parameters of basic vertexes of the polygonal units based on the surface texture parameters corresponding to the polygonal units for each polygonal unit; generating rendering color parameters of the extended vertexes based on the surface texture parameters corresponding to the relevant vertexes of the extended vertexes aiming at each extended vertex; the associated vertices include base vertices that are connected to the extended vertices to form a patch.
Optionally, the step of obtaining the grid model and the terrain model parameters corresponding to the grid model includes: acquiring terrain model parameters corresponding to a plurality of grid splicing modules and each grid splicing model; the grid splicing module is formed by connecting a plurality of splicing units and a plurality of polygonal units; the splicing unit is positioned in the edge area of the grid splicing module; the terrain model parameters correspond to the polygonal units and the splicing units; determining a splicing relationship of a plurality of grid splicing modules based on the terrain model parameters of the splicing units; and based on the splicing relation, splicing the plurality of grid splicing modules to obtain a grid model.
Optionally, the grid splicing unit includes at least one region to be matched; the area to be matched is formed by connecting a plurality of splicing units; determining a splicing relationship of the plurality of grid splicing modules based on the terrain model parameters of the splicing unit, comprising: determining a first module and a second module from a plurality of grid splicing modules; matching the to-be-matched area of the first module and the to-be-matched area of the second module based on the terrain model parameters corresponding to the to-be-matched area of the first module and the terrain model parameters corresponding to the to-be-matched area of the second module to obtain a matching result; the matching result is matching or unmatched; if the matching result is matching, determining that the region to be matched of the first module has a splicing relationship with the region to be matched of the second module; continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition; if the matching result is not matched, determining that the region to be matched of the first module and the region to be matched of the second module do not have a splicing relationship; and continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition.
Referring to fig. 17, the electronic device includes a processor 100 and a memory 101, the memory 101 storing machine executable instructions that can be executed by the processor 100, the processor 100 executing the machine executable instructions to implement the above-described rendering method of the three-dimensional terrain model.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
In addition, in the description of embodiments of the present invention, unless explicitly stated and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood by those skilled in the art in specific cases.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above examples are only specific embodiments of the present invention for illustrating the technical solution of the present invention, but not for limiting the scope of the present invention, and although the present invention has been described in detail with reference to the foregoing examples, it will be understood by those skilled in the art that the present invention is not limited thereto: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.
Claims (12)
1. A method of rendering a three-dimensional terrain model, comprising:
acquiring a grid model and terrain model parameters corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model;
generating an expansion model based on the plurality of polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygonal units in the three-dimensional terrain model;
determining vertex parameters of model vertices of a three-dimensional terrain model based on the extended model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters;
and rendering the three-dimensional terrain model based on the rendering color parameters corresponding to the model vertexes and the vertex position parameters to obtain a rendered three-dimensional terrain model.
2. The method of claim 1, wherein the polygonal cells are hexagonal cells; the hexagonal units are formed by connecting six basic vertexes; two adjacent hexagonal units are provided with two coincident basic vertexes; the expansion unit comprises a rectangular unit and a triangular unit;
Generating an expansion model based on the plurality of polygonal units, comprising;
generating a rectangular unit based on the overlapped basic vertexes of two adjacent hexagonal units in the plurality of hexagonal units; the two adjacent hexagonal units are connected through the rectangular unit;
determining a triangular area surrounded by three adjacent rectangular units as a triangular unit;
and determining a plane model formed by connecting a plurality of hexagonal units, rectangular units and triangular units as an expansion model.
3. The method of claim 2, wherein determining vertex parameters for model vertices of a three-dimensional terrain model based on the extended model and the terrain model parameters comprises:
determining a model vertex of the three-dimensional terrain model based on the extension model and a preset primitive segmentation algorithm;
determining vertex parameters of the model vertices based on the terrain model parameters and the extended model; the terrain model parameters correspond to the plurality of polygonal elements.
4. A method according to claim 3, wherein the step of determining model vertices of the three-dimensional terrain model based on the extended model and a preset primitive segmentation algorithm comprises:
Dividing the polygonal unit based on a preset primitive dividing algorithm to obtain a first dividing result; the first segmentation result comprises a plurality of segmentation lines;
determining the intersection point of the plurality of dividing lines as a first expansion vertex;
dividing the expansion unit based on a preset primitive dividing algorithm to obtain a second dividing result; the second segmentation result comprises a plurality of segmentation lines;
determining intersection points of the plurality of dividing lines and edges of the expansion unit as second expansion vertexes;
and determining the first extended vertex, the second extended vertex and the basic vertex as model vertices of the three-dimensional terrain model.
5. A method according to claim 3, wherein the terrain model parameters include height parameters and surface texture parameters corresponding to the polygonal elements;
determining vertex parameters of the model vertices based on the terrain model parameters and the extended model, comprising:
determining vertex position parameters of the model vertices based on the position parameters of the polygonal units and the corresponding height parameters;
and determining rendering color parameters of the model vertexes based on the surface texture parameters corresponding to the polygonal units.
6. The method of claim 5, wherein the polygonal elements are connected by a plurality of base vertices; the position parameters of the polygonal units comprise plane coordinate parameters of the basic vertexes in a plane coordinate system corresponding to the grid model; the model vertexes comprise the basic vertexes and the extended vertexes; the extended vertex is determined based on the base vertex;
determining vertex position parameters of the model vertices based on the height parameters corresponding to the polygon units and the position parameters of the polygon units, wherein the method comprises the following steps:
determining the height parameter corresponding to each polygonal unit as the height coordinate parameter of the basic vertex of the polygonal unit;
generating vertex position parameters of the basic vertex in a three-dimensional coordinate system corresponding to the three-dimensional terrain model based on the height coordinate parameters and the plane coordinate parameters of the basic vertex;
generating vertex position parameters of the extended vertices based on vertex position parameters of relevant vertices of the extended vertices for each extended vertex; the associated vertices include base vertices connected with the extended vertices to form a patch.
7. The method of claim 5, wherein the polygonal elements are connected by a plurality of base vertices; the model vertexes comprise the basic vertexes and the extended vertexes; the extended vertex is determined based on the base vertex;
determining rendering color parameters of the model vertices based on the surface texture parameters corresponding to the polygonal units, comprising:
generating rendering color parameters of basic vertexes of the polygonal units based on the surface texture parameters corresponding to the polygonal units for each polygonal unit;
generating rendering color parameters of each extended vertex based on the surface texture parameters corresponding to the relevant vertex of the extended vertex; the associated vertices include base vertices connected with the extended vertices to form a patch.
8. The method of claim 1, wherein the step of obtaining the grid model and the terrain model parameters corresponding to the grid model comprises:
acquiring terrain model parameters corresponding to a plurality of grid splicing modules and each grid splicing model; the grid splicing module is formed by connecting a plurality of splicing units and a plurality of polygonal units; the splicing unit is positioned in the edge area of the grid splicing module; the terrain model parameters correspond to the polygonal units and the splicing units;
Determining the splicing relation of the grid splicing modules based on the terrain model parameters of the splicing units;
and based on the splicing relation, splicing the plurality of grid splicing modules to obtain a grid model.
9. The method of claim 8, wherein the grid splice unit comprises at least one region to be matched; the region to be matched is formed by connecting a plurality of splicing units;
determining the splicing relationship of the grid splicing modules based on the terrain model parameters of the splicing units, wherein the step comprises the following steps:
determining a first module and a second module from the plurality of grid splice modules;
matching the to-be-matched area of the first module and the to-be-matched area of the second module based on the terrain model parameters corresponding to the to-be-matched area of the first module and the terrain model parameters corresponding to the to-be-matched area of the second module to obtain a matching result; the matching result is matching or unmatched;
if the matching result is that the matching is performed, determining that the to-be-matched area of the first module and the to-be-matched area of the second module have a splicing relationship; continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets a preset condition;
If the matching result is not matching, determining that the area to be matched of the first module and the area to be matched of the second module do not have a splicing relationship; and continuing to execute the step of determining the first module and the second module from the grid splicing modules until the splicing relationship meets the preset condition.
10. A rendering apparatus for a three-dimensional terrain model, comprising:
the grid model acquisition module is used for acquiring a grid model and terrain model parameters corresponding to the grid model; the grid model is formed by connecting a plurality of polygonal units; the terrain model parameters are used for indicating the terrain height distribution and the surface materials of the three-dimensional terrain model;
the expansion model generation module is used for generating an expansion model based on the polygonal units; the expansion model is formed by connecting a plurality of polygonal units and a plurality of expansion units; the expansion units are used for forming transition areas among model areas corresponding to the polygonal units in the three-dimensional terrain model;
the vertex parameter determining module is used for determining vertex parameters of model vertices of the three-dimensional terrain model based on the expansion model and the terrain model parameters; the vertex parameters comprise vertex position parameters and rendering color parameters;
And the model rendering module is used for rendering the three-dimensional terrain model based on the rendering color parameters corresponding to the model vertexes and the vertex position parameters to obtain a rendered three-dimensional terrain model.
11. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the method of rendering a three-dimensional terrain model as claimed in any of claims 1-9.
12. A machine-readable storage medium storing machine-executable instructions which, when invoked and executed by a processor, cause the processor to implement a method of rendering a three-dimensional terrain model as claimed in any of claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310536952.4A CN117036626A (en) | 2023-05-11 | 2023-05-11 | Rendering method and device of three-dimensional terrain model and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310536952.4A CN117036626A (en) | 2023-05-11 | 2023-05-11 | Rendering method and device of three-dimensional terrain model and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117036626A true CN117036626A (en) | 2023-11-10 |
Family
ID=88625075
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310536952.4A Pending CN117036626A (en) | 2023-05-11 | 2023-05-11 | Rendering method and device of three-dimensional terrain model and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117036626A (en) |
-
2023
- 2023-05-11 CN CN202310536952.4A patent/CN117036626A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20130063460A1 (en) | Visual shader designer | |
US20130063472A1 (en) | Customized image filters | |
CN111968216A (en) | Volume cloud shadow rendering method and device, electronic equipment and storage medium | |
CN115641415B (en) | Method, device, equipment and medium for generating three-dimensional scene based on satellite image | |
CN111583381B (en) | Game resource map rendering method and device and electronic equipment | |
US6850234B2 (en) | Method and system for determining visible parts of transparent and nontransparent surfaces of there-dimensional objects | |
CN109636889B (en) | Large-scale three-dimensional terrain model rendering method based on dynamic sewing belt | |
CN115690286B (en) | Three-dimensional terrain generation method, terminal device and computer readable storage medium | |
CN115409957A (en) | Map construction method based on illusion engine, electronic device and storage medium | |
EP2875490A1 (en) | Customized image filters | |
CN115984506A (en) | Method and related device for establishing model | |
CN111508054B (en) | Terrain construction method, device and equipment | |
CN116630555A (en) | Terrain height map generation method and device and electronic equipment | |
CN117036626A (en) | Rendering method and device of three-dimensional terrain model and electronic equipment | |
CN111681317A (en) | Data processing method and device, electronic equipment and storage medium | |
CN115409962B (en) | Method for constructing coordinate system in illusion engine, electronic device and storage medium | |
CN115409960A (en) | Model construction method based on illusion engine, electronic device and storage medium | |
CN115409958A (en) | Plane construction method based on illusion engine, electronic device and storage medium | |
CN111462343B (en) | Data processing method and device, electronic equipment and storage medium | |
CN112419137B (en) | Mask picture display method and device and mask picture display method and device | |
CN115131513A (en) | Three-dimensional terrain clipping method, device and equipment and readable storage medium | |
CN111729303B (en) | Large map baking and cutting method and restoration method | |
Hoppe et al. | Adaptive meshing and detail-reduction of 3D-point clouds from laser scans | |
CN117557710B (en) | Texture rendering method and device, terminal equipment and storage medium | |
CN115738246A (en) | Method and device for constructing insert piece combination model and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |