CN113838164A - Grid drawing method and device and storage medium - Google Patents
Grid drawing method and device and storage medium Download PDFInfo
- Publication number
- CN113838164A CN113838164A CN202110951298.4A CN202110951298A CN113838164A CN 113838164 A CN113838164 A CN 113838164A CN 202110951298 A CN202110951298 A CN 202110951298A CN 113838164 A CN113838164 A CN 113838164A
- Authority
- CN
- China
- Prior art keywords
- grid
- determining
- maximum
- precision
- plane
- 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
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000009877 rendering Methods 0.000 claims abstract description 21
- 238000012937 correction Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 5
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 101100234408 Danio rerio kif7 gene Proteins 0.000 description 1
- 101100221620 Drosophila melanogaster cos gene Proteins 0.000 description 1
- 101100398237 Xenopus tropicalis kif11 gene Proteins 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/20—Drawing from basic elements, e.g. lines or circles
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Processing Or Creating Images (AREA)
Abstract
The application discloses a grid drawing method, a device and a storage medium, which are used for improving the drawing efficiency of a grid and improving the drawing experience of a user. The method comprises the following steps: acquiring the appointed operation of a user, and determining a maximum drawing area according to the appointed operation; determining a placement plane within the maximum rendering area for placing a model; determining the drawing range of the grid in the placing plane according to the ray; and determining the grid precision, and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a grid drawing method and apparatus, and a storage medium.
Background
In recent years, as consumer device performance has gradually increased and XR technology has become popular, more and more applications are required to be compatible with both the oversized model and the micro-sized model. The use of a mesh can give the user the most intuitive feel for the model size.
However, the existing fixed grid display mode only supports a specified small range, and if the range is simply increased, the performance consumption is very high. Therefore, the fixed grid mode cannot meet the requirements of high precision range and high performance at the same time, the drawing efficiency is low, and the user experience is not good.
Disclosure of Invention
In order to solve the technical problem, the application provides a grid drawing method, a device and a storage medium, which are used for improving the drawing efficiency of a grid and improving the drawing experience of a user.
A first aspect of the present application provides a mesh drawing method, including:
acquiring the appointed operation of a user, and determining a maximum drawing area according to the appointed operation;
determining a placement plane within the maximum rendering area for placing a model;
determining the drawing range of the grid in the placing plane according to the ray;
and determining the grid precision, and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
Optionally, determining a rendering range of the grid in the placement plane according to the ray includes:
acquiring intersection points of rays and the placing plane from the current camera position along four corner emission lines of the rectangular window;
and determining the drawing range of the grid according to the intersection point of the ray and the placing plane.
Optionally, when the intersection point is outside the maximum rendering area, after determining the rendering range of the grid according to the intersection point of the ray and the placement plane, the method further includes:
and correcting the drawing range according to the maximum value of the maximum drawing area.
Optionally, the determining the grid accuracy includes:
and determining the grid precision according to the distance between the current camera and the placing plane.
Optionally, the determining the grid accuracy includes:
and determining the grid precision according to the precision parameters input by the user.
A second aspect of the present application provides a mesh-drawing apparatus, the apparatus comprising:
the device comprises an acquisition unit, a display unit and a display unit, wherein the acquisition unit is used for acquiring the designated operation of a user and determining a maximum drawing area according to the designated operation;
a first determining unit, configured to determine a placement plane within the maximum rendering area, for placing a model;
a second determining unit, configured to determine a drawing range of the grid in the placement plane according to the ray;
and the third determining unit is used for determining the grid precision and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
Optionally, the second determining unit is specifically configured to:
acquiring intersection points of rays and the placing plane from the current camera position along four corner emission lines of the rectangular window;
and determining the drawing range of the grid according to the intersection point of the ray and the placing plane.
Optionally, the apparatus further comprises: a correction unit for:
and correcting the drawing range according to the maximum value of the maximum drawing area.
A third aspect of the present application provides a mesh drawing apparatus, including:
the device comprises a processor, a memory, an input and output unit and a bus;
the processor is connected with the memory, the input and output unit and the bus;
the memory holds a program that the processor calls to perform the method of any of the first aspect and the first aspect.
A fourth aspect of the present application provides a computer readable storage medium having a program stored thereon, which when executed on a computer performs the method of any one of the first aspect and the first aspect.
According to the technical scheme, the method has the following advantages:
according to the grid drawing method, the drawing range of the grid can be determined by using rays in the placing plane of the model, the grid precision is further determined, the grid precision is used for drawing the grid, the grid precision is only adjusted in the drawing range during drawing, the drawing with the specified precision can be completed by using smaller performance cost, the efficiency is greatly improved, the open graphics library OpenGL is used for drawing during drawing, smaller resources can be occupied for completing the drawing, the application high performance is guaranteed, and the effect is good.
Drawings
In order to more clearly illustrate the technical solutions in the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram illustrating one embodiment of a grid rendering method provided herein;
FIG. 2 is a schematic flow chart diagram illustrating another embodiment of a grid rendering method provided herein;
FIG. 3 is a schematic structural diagram of an embodiment of a grid rendering apparatus provided in the present application;
fig. 4 is a schematic structural diagram of another embodiment of the grid drawing device provided in the present application.
Detailed Description
In recent years, as consumer device performance has gradually increased and XR technology has become popular, more and more applications are required to be compatible with both the oversized model and the micro-sized model. The use of a mesh can give the user the most intuitive feel for the model size.
However, the existing fixed grid display mode only supports a specified small range, and if the range is simply increased, the performance consumption is very high. Therefore, the fixed grid pattern cannot satisfy both the requirements of high precision range and high performance.
Based on the above, the application provides a grid drawing method, which is used for improving the drawing efficiency of the grid and improving the drawing experience of a user.
It should be noted that the grid drawing method provided by the present application may be applied to a terminal, a system, or a server, for example, the terminal may be a fixed terminal such as a smart phone or a computer, a tablet computer, a smart television, a smart watch, a portable computer terminal, or a desktop computer. For convenience of explanation, the terminal is taken as an execution subject for illustration in the present application.
Referring to fig. 1, fig. 1 is a schematic flow chart of an embodiment of a grid drawing method provided in the present application, where the grid drawing method includes:
101. acquiring the appointed operation of a user, and determining a maximum drawing area according to the appointed operation;
the user may first specify a maximum drawing area in the drawing region by a specifying operation, that is, subsequent drawings may be limited to the maximum drawing area, for example, the user specifies the maximum drawing area as 100m × 100m by means of an output parameter.
102. Determining a placing plane in the maximum drawing area for placing the model;
the terminal determines a placement plane within the maximum rendering area, which is used to place the model, e.g., the X-Y plane is determined as the placement plane.
103. Determining the drawing range of the grid in the placing plane according to the ray;
determining a drawing range of the grid in the placement plane through ray detection, within which the subsequent adjustment of the accuracy of the grid can be limited, wherein one possible implementation manner of the ray detection is as follows:
acquiring intersection points of rays and a placing plane from the current camera position along four corner emission lines of the rectangular window; the drawing range of the grid is determined according to the intersection point of the ray and the placing plane, and a plane coordinate-to-ray method can be used.
104. And determining the grid precision, and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
After the specific grid precision is determined, the grid is drawn in the drawing range according to the grid precision, specifically, the grid can be drawn by using OpenGL (Open Graphics Library) packaged by Unity, and after the drawing range is determined, a starting point of the drawing can be set.
In practical applications, the grid accuracy may be determined in various ways, for example, the grid accuracy may be automatically determined by the distance between the current camera and the placing plane, or the grid accuracy may be determined by an accuracy parameter input by a user, that is, the user may specify the grid accuracy on the terminal.
The method provided by the application can be used for drawing a grid, and can also be used for drawing circles, numbers and the like by using OpenGL, wherein the specified type is LINES when drawing grid LINES, the specified type is QUADS when drawing circles or numbers, and the mode of drawing numbers, circles or letters is specifically as follows: first, a picture set composed of numbers and letters is prepared. The required font set is generated by the BMFont, which is a font editor under Windows, and the generated fnt file can be used for CCLabel of cos2 d-x. The BMFont download and install font editor requires, for example, numbers (0-9), letters (c m d), symbols (-), to import the font set picture. And acquiring the UV value of each number and letter in the picture, acquiring the UV value corresponding to the corresponding number and letter during drawing, and then drawing by using OpenGL.
The invention can meet the requirements of users on oversized models and micro-sized models, and dynamically draw grids and scales; because OpenGL is used for drawing all contents, the drawing can be finished by occupying small resources, and the high performance of the application is ensured. The effect is good after the test and use of the actual product.
According to the grid drawing method, the drawing range of the grid can be determined by using rays in the placing plane of the model, the grid precision is further determined, the grid precision is used for drawing the grid, the grid precision is only adjusted in the drawing range during drawing, the drawing with the specified precision can be completed by using smaller performance cost, the efficiency is greatly improved, the open graphics library OpenGL is used for drawing during drawing, smaller resources can be occupied for completing the drawing, the application high performance is guaranteed, and the effect is good.
In practical applications, the intersection point may not fall exactly at the grid start point or may exceed the maximum rendering area by ray detection, and therefore, a correction is required. The following examples will be specifically explained in detail.
201. Acquiring the appointed operation of a user, and determining a maximum drawing area according to the appointed operation;
202. determining a placing plane in the maximum drawing area for placing the model;
203. determining the drawing range of the grid in the placing plane according to the ray;
204. Correcting the drawing range according to the maximum value of the maximum drawing area;
when the intersection point is outside the maximum drawing area, the maximum value of the maximum drawing area is taken as the actual drawing range, and the drawing range is ensured to be limited within the maximum drawing area and not to be exceeded.
205. And determining the grid precision, and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
Step 205 is similar to step 104 in the previous embodiment, and will not be described herein again.
The grid drawing method provided in the present application is explained in detail in the above embodiments, and the grid drawing apparatus and the storage medium provided in the present application will be explained below with reference to the accompanying drawings.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an embodiment of a grid drawing device provided in the present application, the grid drawing device including:
an obtaining unit 301, configured to obtain a specified operation of a user, and determine a maximum drawing area according to the specified operation;
a first determining unit 302, configured to determine a placement plane within the maximum rendering area, for placing the model;
a second determining unit 303, configured to determine a drawing range of the grid in the placement plane according to the ray;
a third determining unit 304, configured to determine the grid precision, and according to the grid precision, draw the grid within the drawing range using OpenGL.
Optionally, the second determining unit 303 is specifically configured to:
acquiring intersection points of rays and a placing plane from the current camera position along four corner emission lines of the rectangular window;
and determining the drawing range of the grid according to the intersection point of the ray and the placing plane.
Optionally, the apparatus further comprises: a correcting unit 305, wherein the correcting unit 305 is specifically configured to:
and correcting the drawing range according to the maximum value of the maximum drawing area.
Optionally, the third determining unit 304 is specifically configured to:
and determining the grid precision according to the distance between the current camera and the placing plane.
Optionally, the third determining unit 304 is specifically configured to:
and determining the grid precision according to the precision parameters input by the user.
The present application further provides a device is drawn to grid, including:
a processor 401, a memory 402, an input-output unit 403, a bus 404;
the processor 401 is connected to the memory 402, the input/output unit 403, and the bus 404;
the memory 402 holds a program that the processor 401 calls to perform any of the grid drawing methods described above.
The present application also relates to a computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, causes the computer to perform any of the grid rendering methods described above.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and the like.
Claims (10)
1. A grid drawing method, characterized in that the method comprises:
acquiring the appointed operation of a user, and determining a maximum drawing area according to the appointed operation;
determining a placement plane within the maximum rendering area for placing a model;
determining the drawing range of the grid in the placing plane according to the ray;
and determining the grid precision, and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
2. The grid rendering method of claim 1, wherein determining the rendering range of the grid in the placement plane based on the ray comprises:
acquiring intersection points of rays and the placing plane from the current camera position along four corner emission lines of the rectangular window;
and determining the drawing range of the grid according to the intersection point of the ray and the placing plane.
3. The grid drawing method according to claim 2, wherein when the intersection point is outside the maximum drawing area, after said determining the drawing range of the grid from the intersection point of the ray and the lying plane, the method further comprises:
and correcting the drawing range according to the maximum value of the maximum drawing area.
4. The mesh rendering method of claim 1, wherein said determining mesh accuracy comprises:
and determining the grid precision according to the distance between the current camera and the placing plane.
5. The grid rendering method of any of claims 1 to 4, wherein the determining the grid accuracy comprises:
and determining the grid precision according to the precision parameters input by the user.
6. A mesh drawing apparatus, characterized in that the apparatus comprises:
the device comprises an acquisition unit, a display unit and a display unit, wherein the acquisition unit is used for acquiring the designated operation of a user and determining a maximum drawing area according to the designated operation;
a first determining unit, configured to determine a placement plane within the maximum rendering area, for placing a model;
a second determining unit, configured to determine a drawing range of the grid in the placement plane according to the ray;
and the third determining unit is used for determining the grid precision and drawing the grid in the drawing range by using an open graphics library OpenGL according to the grid precision.
7. The mesh rendering apparatus of claim 6, wherein the second determining unit is specifically configured to:
acquiring intersection points of rays and the placing plane from the current camera position along four corner emission lines of the rectangular window;
and determining the drawing range of the grid according to the intersection point of the ray and the placing plane.
8. The mesh rendering apparatus of claim 7, wherein said apparatus further comprises: a correction unit for:
and correcting the drawing range according to the maximum value of the maximum drawing area.
9. A mesh drawing apparatus, characterized in that the apparatus comprises:
the device comprises a processor, a memory, an input and output unit and a bus;
the processor is connected with the memory, the input and output unit and the bus;
the memory holds a program that the processor calls to perform the method of any of claims 1 to 5.
10. A computer-readable storage medium having a program stored thereon, the program, when executed on a computer, performing the method of any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110951298.4A CN113838164A (en) | 2021-08-18 | 2021-08-18 | Grid drawing method and device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110951298.4A CN113838164A (en) | 2021-08-18 | 2021-08-18 | Grid drawing method and device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113838164A true CN113838164A (en) | 2021-12-24 |
Family
ID=78960868
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110951298.4A Pending CN113838164A (en) | 2021-08-18 | 2021-08-18 | Grid drawing method and device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113838164A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH02146687A (en) * | 1988-11-29 | 1990-06-05 | Fujitsu Ltd | Reference point detecting system |
CN102074050A (en) * | 2011-03-01 | 2011-05-25 | 哈尔滨工程大学 | Fractal multi-resolution simplified method used for large-scale terrain rendering |
CN102105850A (en) * | 2008-07-23 | 2011-06-22 | 微软公司 | Presenting dynamic grids |
CN109903384A (en) * | 2019-04-16 | 2019-06-18 | 珠海金山网络游戏科技有限公司 | A kind of method and device, calculating equipment and the storage medium of model setting |
CN110096736A (en) * | 2019-03-21 | 2019-08-06 | 上海得见计算机科技有限公司 | A kind of two dimension house type drawing drawing method |
CN110246202A (en) * | 2018-03-07 | 2019-09-17 | 苏州猫耳网络科技有限公司 | A kind of grid drawing method based on map area boundary GPS coordinate |
CN110533780A (en) * | 2019-08-28 | 2019-12-03 | 深圳市商汤科技有限公司 | A kind of image processing method and its device, equipment and storage medium |
CN111167120A (en) * | 2019-12-31 | 2020-05-19 | 网易(杭州)网络有限公司 | Method and device for processing virtual model in game |
CN111612921A (en) * | 2020-05-20 | 2020-09-01 | 腾讯科技(深圳)有限公司 | Collision range determining method and related device |
-
2021
- 2021-08-18 CN CN202110951298.4A patent/CN113838164A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH02146687A (en) * | 1988-11-29 | 1990-06-05 | Fujitsu Ltd | Reference point detecting system |
CN102105850A (en) * | 2008-07-23 | 2011-06-22 | 微软公司 | Presenting dynamic grids |
CN102074050A (en) * | 2011-03-01 | 2011-05-25 | 哈尔滨工程大学 | Fractal multi-resolution simplified method used for large-scale terrain rendering |
CN110246202A (en) * | 2018-03-07 | 2019-09-17 | 苏州猫耳网络科技有限公司 | A kind of grid drawing method based on map area boundary GPS coordinate |
CN110096736A (en) * | 2019-03-21 | 2019-08-06 | 上海得见计算机科技有限公司 | A kind of two dimension house type drawing drawing method |
CN109903384A (en) * | 2019-04-16 | 2019-06-18 | 珠海金山网络游戏科技有限公司 | A kind of method and device, calculating equipment and the storage medium of model setting |
CN110533780A (en) * | 2019-08-28 | 2019-12-03 | 深圳市商汤科技有限公司 | A kind of image processing method and its device, equipment and storage medium |
CN111167120A (en) * | 2019-12-31 | 2020-05-19 | 网易(杭州)网络有限公司 | Method and device for processing virtual model in game |
CN111612921A (en) * | 2020-05-20 | 2020-09-01 | 腾讯科技(深圳)有限公司 | Collision range determining method and related device |
Non-Patent Citations (1)
Title |
---|
农业小气候: "Unity场景网格化方法(复习)", pages 2 - 7, Retrieved from the Internet <URL:https://www.bilibili.com/read/cv6226433> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106791212B (en) | A kind of control method, device and the mobile terminal of mobile terminal refresh rate | |
CN112102437B (en) | Canvas-based radar map generation method and device, storage medium and terminal | |
CN113808231B (en) | Information processing method and device, image rendering method and device, and electronic device | |
CN109045694B (en) | Virtual scene display method, device, terminal and storage medium | |
CN110750664A (en) | Picture display method and device | |
CN112181568A (en) | Locally adapting screen method and apparatus | |
CN112287257A (en) | Page display method and device, electronic equipment and storage medium | |
CN112233009A (en) | Picture rendering method, device, equipment and storage medium | |
CN107122104B (en) | Data display method and device | |
CN114758034A (en) | Map generation method and device, computer-readable storage medium and electronic device | |
CN111603767A (en) | Method, terminal and storage medium for adjusting resolution | |
CN106535002B (en) | Desktop starter template layout updating method and device | |
CN113407254A (en) | Form generation method and device, electronic equipment and storage medium | |
CN112487067A (en) | Method, device and storage medium for page display based on data configuration | |
CN115272523B (en) | Method and device for drawing air quality distribution map, electronic equipment and storage medium | |
CN113838164A (en) | Grid drawing method and device and storage medium | |
CN105005550A (en) | Table generation method and apparatus | |
CN108986034B (en) | Raster data coordinate conversion method, system, terminal equipment and storage medium | |
CN114741144B (en) | Web-side complex form display method, device and system | |
CN109144624B (en) | Method, storage medium, device and system for displaying unequal height lists in IOS | |
CN115328429A (en) | Display method, display device, electronic apparatus, and storage medium | |
CN115861510A (en) | Object rendering method, device, electronic equipment, storage medium and program product | |
CN115797267A (en) | Image quality evaluation method, system, electronic device, and storage medium | |
CN113987791A (en) | Method and device for acquiring part attribute information, terminal equipment and storage medium | |
CN114693894A (en) | Method, system and device for converting pictures into building blocks in virtual world |
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 |