CN113570717A - Map rendering method for unity, electronic device and readable storage medium - Google Patents

Map rendering method for unity, electronic device and readable storage medium Download PDF

Info

Publication number
CN113570717A
CN113570717A CN202110863036.2A CN202110863036A CN113570717A CN 113570717 A CN113570717 A CN 113570717A CN 202110863036 A CN202110863036 A CN 202110863036A CN 113570717 A CN113570717 A CN 113570717A
Authority
CN
China
Prior art keywords
map
unity
mesh
rendering method
vertices
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.)
Granted
Application number
CN202110863036.2A
Other languages
Chinese (zh)
Other versions
CN113570717B (en
Inventor
白启扉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dilu Technology Co Ltd
Original Assignee
Dilu Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Dilu Technology Co Ltd filed Critical Dilu Technology Co Ltd
Priority to CN202110863036.2A priority Critical patent/CN113570717B/en
Publication of CN113570717A publication Critical patent/CN113570717A/en
Application granted granted Critical
Publication of CN113570717B publication Critical patent/CN113570717B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/05Geographic models
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation

Abstract

The invention discloses a map rendering method for unity, an electronic device and a readable storage medium, wherein the method comprises the steps of defining the maximum length and width of a map grid according to the maximum zoom level of a map, and creating a mesh by utilizing unity API, wherein the grid in the mesh corresponds to the map grid; acquiring a map tile picture address according to the current zoom grade and the longitude and latitude information; obtaining a map tile picture, and pasting the map tile picture as a uv texture to the mesh; and when the map is zoomed, dynamically adjusting the mesh according to the current zoom level, and realizing the rapid rendering of the map. The invention can control the details of map rendering, cover unity content on the map layer and can be developed conveniently on an editor.

Description

Map rendering method for unity, electronic device and readable storage medium
Technical Field
The invention belongs to the field of unity development, and particularly relates to a unity map rendering technology.
Background
At present, maps are increasingly widely applied to interactive apps such as take-out, navigation and scene display, and the Unity integrates the maps mainly by calling an SDK (security description key) for packaging android and ios provided by Baidu and the like.
The existing method has more limitations:
1. SDK provided by Baidu Gade realizes view interfaces under different platforms, and unity cannot interact with and cover more contents on the SDK;
2. baidu God only provides a mobile SDK, and the unit pc editor cannot be debugged and is inconvenient to develop;
3. the SDK of the Baidu God map rendering does not open source codes, and rendering efficiency cannot be optimized.
Disclosure of Invention
In order to solve the technical problems mentioned in the background art, the present invention provides a method, an electronic device, and a readable storage medium for rendering a map for unity, which can control details of map rendering, cover unity content on a map layer, and can be conveniently developed on an editor.
In order to achieve the technical purpose, the technical scheme of the invention is as follows:
a map rendering method for unity, comprising the steps of:
(1) defining the maximum length and width of a map grid according to the maximum zoom level of the map, and creating a mesh by using a unity API (application programming interface), wherein the grid in the mesh corresponds to the map grid;
(2) acquiring a map tile picture address according to the current zoom grade and the longitude and latitude information;
(3) obtaining a map tile picture, and pasting the map tile picture as a uv texture to the mesh;
(4) and when the map is zoomed, dynamically adjusting the mesh according to the current zoom level, and realizing the rapid rendering of the map.
Further, in step (2), a tile map service based on OSM map data is built through mapnik2, apache2, and mod _ tile.
Further, in step (3), the map tile picture is obtained through the API of unity, resources.
Further, in step (4), when the zoom level is switched from high to low, merging the grids in the mesh; when the zoom level is switched from low to high, the grid in the mesh is split.
Further, when the zoom level is switched from a to b, a > b, determining vertexes A needing to be deleted, recording all vertexes connected with the vertexes A, deleting connecting lines between the recorded vertexes and the vertexes A, and finally connecting two vertexes which are farthest away from the vertexes A in the recorded vertexes;
when the zoom level is switched from b to a, the operation process is the reverse of the above process.
An electronic device comprises a processor and a memory, wherein the memory stores execution instructions of the processor, and the processor is configured to execute the execution instructions to realize the map rendering method for unity.
A computer-readable storage medium for storing a program, which is executed to implement the above-described map rendering method for unity.
Adopt the beneficial effect that above-mentioned technical scheme brought:
1. according to the invention, the tile map is directly rendered by using the C # without depending on other SDKs, so that the tile map of each level can be rapidly rendered;
2. the source code of the bottom rendering part of the invention is controllable and can be directly debugged in an editor;
3. the invention can make any customization to the map and cover the unity content.
Drawings
FIG. 1 is a flow chart of a method of the present invention;
FIG. 2 is a schematic diagram of mesh generation in the present invention;
fig. 3 is a schematic diagram of zoom level switching mesh change in the present invention.
Detailed Description
The technical scheme of the invention is explained in detail in the following with the accompanying drawings.
The invention designs a map rendering method for unity, which comprises the following steps as shown in figure 1:
step 1: and defining the maximum length and width of the map grid according to the maximum zoom level of the map, and creating a mesh by using a unity API (application programming interface), wherein the grid in the mesh corresponds to the map grid. As shown in fig. 2, for example, if a region zoom is 4, 4 × 4 tiles are to be displayed, the generated mesh needs 4 × 4=16 grids, and a total of 32 triangular surfaces.
Step 2: and obtaining the map tile picture address according to the current zoom grade and the latitude and longitude information. In the present embodiment, the tile map service based on OSM map data is built by mapnik2, apache2, and mod _ tile.
And step 3: and acquiring a map tile picture, and pasting the map tile picture as a uv texture to the mesh. In this embodiment, the map tile picture is obtained through the API of unity, resources.
And 4, step 4: and when the map is zoomed, dynamically adjusting the mesh according to the current zoom level, and realizing the rapid rendering of the map. For example, when the map zoom level is switched from 4 to 3, the original graph is as the left graph (a) in fig. 3, and it is necessary to find out the vertex (1, 1) to be deleted, and record all the vertices connected by (1, 1): (0, 1), (1, 0), (1, 2), (2, 1), (0, 2), (2, 0), all connecting lines are deleted to obtain a middle graph (b), and finally two points (0, 2), (2, 0) farthest from the point (1, 1) are connected to obtain a right graph (c).
Expressed algorithmically, the following are:
For i in 0:n:
For j in 0:n:
X = i + 1;
Y = j + 1;
i+=2;
j+=2;
clear (X, Y);/Clear (X, Y) all the connecting lines at the point
MakeSquareIn (X, Y);/create a new square of two triangles at point (X, Y).
If the map level is switched from 3 to 4, the reverse operation of the above steps is performed. In the step, all grid points of the maximum zoom level are cached, and the mesh grid is dynamically adjusted according to different zoom levels operated by the current user, so that the effect of quick rendering is achieved.
The invention also designs an electronic device, which comprises a processor and a memory, wherein the memory stores execution instructions of the processor, and the processor is configured to execute the execution instructions to realize the map rendering method for unity.
The present invention also contemplates a computer-readable storage medium storing a program, which is executed to implement the above-described map rendering method for unity.
The embodiments are only for illustrating the technical idea of the present invention, and the technical idea of the present invention is not limited thereto, and any modifications made on the basis of the technical scheme according to the technical idea of the present invention fall within the scope of the present invention.

Claims (7)

1. A map rendering method for unity, comprising the steps of:
(1) defining the maximum length and width of a map grid according to the maximum zoom level of the map, and creating a mesh by using a unity API (application programming interface), wherein the grid in the mesh corresponds to the map grid;
(2) acquiring a map tile picture address according to the current zoom grade and the longitude and latitude information;
(3) obtaining a map tile picture, and pasting the map tile picture as a uv texture to the mesh;
(4) and when the map is zoomed, dynamically adjusting the mesh according to the current zoom level, and realizing the rapid rendering of the map.
2. The map rendering method for unity according to claim 1, wherein in step (2), the tile map service based on the OSM map data is built by mapnik2, apache2 and mod _ tile.
3. The map rendering method for unity according to claim 1, wherein in step (3), the map tile picture is obtained through API of unity, resources.
4. The map rendering method for unity according to claim 1, wherein in step (4), when the zoom level is switched from high to low, the meshes in the mesh are merged; when the zoom level is switched from low to high, the grid in the mesh is split.
5. The unit map rendering method of claim 4, wherein when the zoom level is switched from a to b, a > b, determining vertices a to be deleted, recording all vertices connected to the vertices a, deleting the connection lines between the recorded vertices and the vertices a, and finally connecting two vertices of the recorded vertices which are farthest from the vertices a;
when the zoom level is switched from b to a, the operation process is the reverse of the above process.
6. An electronic device, comprising a processor and a memory, wherein the memory stores execution instructions of the processor, and the processor is configured to execute the execution instructions to implement the map rendering method for unity according to any one of claims 1-5.
7. A computer-readable storage medium storing a program, wherein the program is executed to implement the map rendering method for unity according to any one of claims 1 to 5.
CN202110863036.2A 2021-07-29 2021-07-29 Map rendering method for units, electronic equipment and readable storage medium Active CN113570717B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110863036.2A CN113570717B (en) 2021-07-29 2021-07-29 Map rendering method for units, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110863036.2A CN113570717B (en) 2021-07-29 2021-07-29 Map rendering method for units, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN113570717A true CN113570717A (en) 2021-10-29
CN113570717B CN113570717B (en) 2024-04-09

Family

ID=78168869

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110863036.2A Active CN113570717B (en) 2021-07-29 2021-07-29 Map rendering method for units, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN113570717B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106384371A (en) * 2016-09-20 2017-02-08 国家基础地理信息中心 Map drawing method based on vector tile
CN107423445A (en) * 2017-08-10 2017-12-01 腾讯科技(深圳)有限公司 A kind of map data processing method, device and storage medium
CN110570506A (en) * 2019-09-11 2019-12-13 珠海金山网络游戏科技有限公司 Map resource management method and device, computing equipment and storage medium
CN112800164A (en) * 2021-03-17 2021-05-14 统信软件技术有限公司 Map loading method and device, computing equipment and readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106384371A (en) * 2016-09-20 2017-02-08 国家基础地理信息中心 Map drawing method based on vector tile
CN107423445A (en) * 2017-08-10 2017-12-01 腾讯科技(深圳)有限公司 A kind of map data processing method, device and storage medium
CN110570506A (en) * 2019-09-11 2019-12-13 珠海金山网络游戏科技有限公司 Map resource management method and device, computing equipment and storage medium
CN112800164A (en) * 2021-03-17 2021-05-14 统信软件技术有限公司 Map loading method and device, computing equipment and readable storage medium

Also Published As

Publication number Publication date
CN113570717B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
CN111402390B (en) Model rendering method, device, equipment and storage medium
CN102667864B (en) Image file generation device, image processing device, image file generation method, image processing method
CN104216691A (en) Application creating method and device
KR101546705B1 (en) Method for visualizing building-inside bim data by bim data process terminal
CN104657934A (en) Image data processing method and device
CN112559667A (en) Map editor, map engine, map editing system, map editing method, and storage medium
CN114756937B (en) Visualization system and method based on UE4 engine and Cesium framework
CN104657206A (en) Image data processing method and device
CN110599891A (en) Map rendering method for power grid equipment
CN107741964A (en) A kind of interest point indication method, device, equipment and medium
CN112017285B (en) Method for accurately fitting terrain to strip-shaped model in three-dimensional GIS (geographic information System) in real time
CN110457512A (en) A kind of map-indication method, device, server, terminal and storage medium
CN112685616A (en) Precise power component management method based on space grid and building information model
CN113110731B (en) Method and device for generating media content
CN116681835A (en) Virtual engine-based three-dimensional model manufacturing method and system
CN104091608A (en) Video editing method and device based on IOS equipment
CN109272567A (en) Model optimization method and apparatus
CN113570717A (en) Map rendering method for unity, electronic device and readable storage medium
CN109925715A (en) A kind of virtual waters generation method, device and terminal
KR20200065797A (en) 3D spatial information visualization system and method
CN116737852A (en) Vector tile data-based vector drawing method and device and electronic equipment
CN110827400B (en) Method and device for generating model of object in three-dimensional scene and terminal
CN114625990A (en) Method, device, equipment and medium for rendering webpage end grid data
CN113888673A (en) Map editing method, system, device, computing equipment and storage medium
CN102402531A (en) Method and system for processing geographic information symbol

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
GR01 Patent grant
GR01 Patent grant