CN115131513A - Three-dimensional terrain clipping method, device and equipment and readable storage medium - Google Patents

Three-dimensional terrain clipping method, device and equipment and readable storage medium Download PDF

Info

Publication number
CN115131513A
CN115131513A CN202210785918.6A CN202210785918A CN115131513A CN 115131513 A CN115131513 A CN 115131513A CN 202210785918 A CN202210785918 A CN 202210785918A CN 115131513 A CN115131513 A CN 115131513A
Authority
CN
China
Prior art keywords
polygon
texture
fragment
projection
dimensional terrain
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
Application number
CN202210785918.6A
Other languages
Chinese (zh)
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.)
Beijing Mapabc Technology Co Ltd
Original Assignee
Beijing Mapabc 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 Beijing Mapabc Technology Co Ltd filed Critical Beijing Mapabc Technology Co Ltd
Publication of CN115131513A publication Critical patent/CN115131513A/en
Pending legal-status Critical Current

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
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/30Clipping

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • Remote Sensing (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a three-dimensional terrain clipping method, which projects a clipping polygon onto a plane and draws the clipping polygon on a texture map, converts the position of a fragment into a texture coordinate in a fragment shader, acquires a corresponding texture value through texture mapping, and judges whether the fragment is positioned in the clipping polygon to realize terrain clipping according to whether the texture value is a filling value set for the projected polygon. The texture values can be distinguished by neglecting the cutting shape, so that the method can be widely applied to cutting polygons with different shapes; in the identification and judgment of the texture value, judgment is not required to be carried out one by one according to each edge of the cut polygon, and the calculation efficiency is not influenced basically when the number of the edges is large, so that the stable and smooth operation of the system can be guaranteed. The invention also discloses a three-dimensional terrain cutting device, equipment and a readable storage medium, and the device and the equipment have corresponding technical effects.

Description

Three-dimensional terrain cutting method, device and equipment and readable storage medium
Technical Field
The invention relates to the technical field of three-dimensional information processing, in particular to a three-dimensional terrain clipping method, a three-dimensional terrain clipping device, three-dimensional terrain clipping equipment and a readable storage medium.
Background
The three-dimensional geographic information system uses the topographic data to superpose a remote sensing image or a grid map to truly represent the topographic features with high and low fluctuation in the real world, thereby forming three-dimensional geographic information basic data. In project development, three-dimensional models such as roads, buildings and trees are superposed on the basis of the terrain to construct a complete virtual reality three-dimensional scene. In addition to three-dimensional models above the surface of the earth, there are also some models below the surface of the earth that need to be represented, such as underground parking lots, underground mines, underpass highway bridges, etc., and these objects below the surface of the earth cannot be viewed because they are obstructed by the terrain. Therefore, there is a need for a method for cutting out terrain in a three-dimensional scene based on specified area range coordinates, by which the terrain can be cut out to facilitate a user's clear view of scene objects below the surface of the earth.
The currently common three-dimensional terrain clipping method is to write a custom fragment shader in a programmable rendering pipeline based on a GPU (Graphics Processing Unit), generate a plurality of vertical clipping surfaces from each side of a clipping area, calculate a spatial relationship between a fragment and the clipping surfaces, determine removal or retention of the fragment according to a result, and achieve a terrain clipping effect in a final rendering result, such as a planar clipping method based on a ceium (an open source js library for displaying a three-dimensional earth and a map). However, the method only supports the cutting of the convex polygon to the terrain, and when the method is used for cutting the concave polygon, the convex polygon is required to be split into a plurality of convex polygons and then the terrain is cut, so that the method does not support the direct cutting of the concave polygon, and cannot meet the flexible use requirement. And when the shape of the cut polygon is complex or the number of edges is large, the number of generated cutting surfaces is correspondingly increased, and the calculated amount is greatly increased, so that the problems of efficiency reduction, operation blockage and the like are caused, and the use experience is influenced.
In summary, how to realize flexible and fast three-dimensional terrain clipping is a technical problem that needs to be solved by those skilled in the art at present.
Disclosure of Invention
The invention aims to provide a three-dimensional terrain clipping method, a three-dimensional terrain clipping device, three-dimensional terrain clipping equipment and a readable storage medium, so as to realize flexible and quick three-dimensional terrain clipping.
In order to solve the technical problems, the invention provides the following technical scheme:
a method of three-dimensional terrain cropping, comprising:
determining a polygon to be cut and a corresponding projection plane in the three-dimensional terrain model;
projecting the polygon to be cut to the projection plane to obtain a projection polygon, and determining an enclosing rectangle of the projection polygon;
drawing the projection polygon in the texture object, and filling according to a set filling color;
a fragment shader is called to project the coordinates of each fragment in the three-dimensional terrain model to the projection plane, and the texture coordinates of each fragment are determined according to the bounding rectangle;
acquiring a texture value corresponding to the texture coordinate from the texture object, and judging whether the texture value is the filling color;
if yes, the fragment is eliminated from the fragment shader.
Optionally, before the determining the texture coordinates of each fragment according to the bounding rectangle, the method further includes:
judging whether the projection position of each fragment is in the bounding rectangle or not;
and if the fragment is in the bounding rectangle, executing the step of determining the texture coordinate of each fragment according to the bounding rectangle.
Optionally, the determining a bounding rectangle of the projected polygon comprises:
determining the coordinate axis of the projection plane by taking the mass center of the polygon to be cut as an origin;
and acquiring a surrounding rectangle of the projection polygon in the projection plane, wherein the surrounding rectangle is parallel to the coordinate axis.
Optionally, the determining a bounding rectangle of the projection polygon in the projection plane parallel to the coordinate system comprises: determining a smallest bounding rectangle of the projected polygon in the projection plane parallel to the coordinate system.
Optionally, the projecting the polygon to be clipped to the projection plane includes:
and projecting each vertex of the polygon to be cut to the projection plane, and taking the polygon generated after the projected vertices are connected in sequence as the projection polygon.
Optionally, before the rendering the projected polygon in the texture object, further comprising: obtaining the default size creates a square texture object.
Optionally, before the rendering the projected polygon in the texture object, further comprising:
and correspondingly creating a texture object with matched size according to the width-height ratio of the surrounding rectangle.
A computer device, comprising:
a memory for storing a computer program;
and the processor is used for realizing the steps of the three-dimensional terrain clipping method when the computer program is executed.
A readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned three-dimensional terrain cropping method.
The method provided by the embodiment of the invention comprises the steps of projecting a clipping polygon to a plane and then drawing the clipping polygon on a texture map, converting the position of a fragment into texture coordinates in a fragment shader, obtaining a corresponding texture value through texture mapping, and judging whether the fragment is positioned in the clipping polygon to realize topographic clipping according to whether the texture value is a filling value set for the projection polygon. The method realizes the distinction between the inside and the outside of the cutting polygon through the texture value, the distinction of the texture value can ignore the cutting shape, and the concave, convex or any complex polygon can be projected to a plane and drawn on a texture map, so the method can be widely applied to the cutting polygons with different shapes; and in the identification and judgment of the texture value, judgment is not required to be carried out one by one according to each edge of the cut polygon, namely, the calculation efficiency is not basically influenced when the number of the edges of the cut polygon is large, so that the system can be ensured to operate stably and smoothly, and the actual application requirements can be well met.
Correspondingly, the embodiment of the invention also provides a three-dimensional terrain cutting device, equipment and a readable storage medium corresponding to the three-dimensional terrain cutting method, and the three-dimensional terrain cutting device, the equipment and the readable storage medium have the technical effects, and are not described again.
Drawings
In order to more clearly illustrate the embodiments of the present invention or technical solutions in related arts, the drawings used in the description of the embodiments or related arts will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a method for cutting three-dimensional terrain according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a three-dimensional terrain cropping device according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The core of the invention is to provide a three-dimensional terrain clipping method which can realize flexible and rapid three-dimensional terrain clipping.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The traditional three-dimensional terrain clipping method for writing a custom fragment shader in a programmable rendering pipeline based on a GPU has low computational efficiency, and a Cesum-based plane clipping method is taken as an example. The principle of the method is that the position and normal vector of a clipping plane are converted into a view space coordinate system from a world coordinate system, then the position of the current fragment of the model is converted into the view space coordinate system from a window coordinate system, the vector between the position of the plane and the position of the fragment is calculated, and the vector is point-multiplied with the normal vector of the plane to obtain the projection length of the vector in the normal direction of the plane; and if the length is equal to 0, the fragment is positioned on the cutting surface, if the length is greater than or less than 0, the fragment is positioned on the front side or the back side of the cutting surface, so that the fragment is removed or reserved, and finally the cutting of the whole model is realized.
At present, the terrain is cut along a designated polygon area in the Cesum, based on the plane cutting algorithm, a cutting surface perpendicular to the ground and rightward in the normal direction is formed through each edge of the polygon, all the cutting surfaces are traversed, if one fragment is located on the removed side of all the cutting surfaces, the fragment is removed, and otherwise, the fragment is reserved.
The algorithm realizes the function of cutting the terrain based on the polygon, but has certain limitation, because the algorithm judges whether the cutting surface belongs to the cutting polygon or not by judging the directions of all sides of the cutting surface in the polygon, only the convex polygon is supported, and when the algorithm is applied to the concave polygon, the obtained result is chaotic and wrong, which is caused by the limitation of the algorithm. In addition, since it is necessary to determine the orientation of each side of each cutting polygon when determining each cutting surface, when the polygon shape is complicated or the number of sides is large, the amount of calculation is greatly increased, which causes problems of efficiency reduction and running jam.
The invention provides a three-dimensional terrain cutting method, which can support the cutting of three-dimensional terrains of polygons with various shapes such as convex polygons, does not obviously reduce the system operation efficiency even if the shapes of the polygons are complex and the number of sides is large, has higher practical value and can meet the requirements on terrain cutting in practical project application.
Referring to fig. 1, fig. 1 is a flowchart illustrating a three-dimensional terrain clipping method according to an embodiment of the present invention, the method including the following steps:
s101, determining polygons to be cut in a three-dimensional terrain model and corresponding projection planes;
the three-dimensional terrain model is an object to be cut in the method, wherein the terrain model refers to a map model which is produced according to unified specifications and used for representing basic physical elements such as residential areas, roads, water systems, boundaries, soil texture, vegetation and the like on the earth surface in detail and representing the ground fluctuation by using contour lines.
The polygon to be cut is a polygon which is customized in a three-dimensional terrain model by a user and needs terrain cutting, concave, convex or any complex polygon is supported by the method for cutting the terrain, so that the shape of the polygon to be cut is not limited, and corresponding drawing or editing setting can be carried out according to actual use requirements.
The projection plane is used for providing a common coordinate system for clipping polygons and fragments of a three-dimensional terrain model in the fragment shader, so that data processing between the clipping polygons and the fragments is realized. For the determination method of the projection plane, the present embodiment is not limited, and the determination method of the reference plane in the related art may be referred to, for example, all vertices of the clipping polygon may be converted into a world coordinate system, and then the coordinates of the centroid of the clipping polygon may be calculated as a point on the projection plane; then, a vector formed by a connecting line between the origin and the centroid of the world coordinate system is normalized and used as a normal vector of a plane; and determining a plane as a projection plane according to a point on the projection plane and the normal vector. For convenience of further calculation, the projection plane determined by the method can be rotated to a horizontal plane to be used as a final determined projection plane. In this embodiment, only the two generation manners of the projection plane are described as an example, and other implementation manners can refer to the description of this embodiment and are not described herein again.
S102, projecting a polygon to be cut to a projection plane to obtain a projection polygon, and determining an enclosing rectangle of the projection polygon;
and projecting the polygon to be cut to a projection plane, and taking the polygon obtained after projection as a projection polygon. The specific implementation manner of the projection may refer to related technologies, and in order to improve the projection efficiency, the vertices of the polygon to be clipped may be projected onto a projection plane, and the vertices are projected and then directly connected in sequence to form a polygon as a projection polygon.
After the projected polygon is obtained, the bounding rectangle (the edge line and the rectangle containing all the projected polygons inside) of the projected polygon is determined, so as to facilitate the determination of the subsequent texture coordinate. The calculation method of the bounding rectangle is not limited, and reference may be made to the description in the related art, which is not described herein again.
S103, drawing a projection polygon in the texture object, and filling according to a set filling color;
creating a texture object (a storage type which can be read and written by a shader), drawing and filling the projected clipping polygon in the texture object, and writing the clipping polygon into a texture buffer area. The set filling color can be set by a user, which is not limited herein.
S104, calling a fragment shader to project the coordinates of each fragment in the three-dimensional terrain model to a projection plane, and determining the texture coordinates of each fragment according to a bounding rectangle;
in a fragment shader of a terrain model rendering pipeline, the position of a current fragment of a terrain is converted into a world coordinate system and then projected to a projection plane, so that the purpose of fragment coordinate projection is achieved.
The phase of finally controlling the display color on the screen by programming in the conventional rendering process is called a fragment shading phase, and the phase processes the independent fragments generated after OpenGL rasterization by calculating the final color and the depth value of the fragment through a fragment shader. Rasterization is a process of converting a primitive into a two-dimensional image, each point on the two-dimensional image contains color, depth and texture data, and the point and related information are called a fragment (fragment). In the method, a fragment shader is called to project the coordinates of the fragments to a projection plane, and the projected coordinates are unified with a clipping polygon coordinate system, so that clipping is facilitated.
S105, acquiring a texture value corresponding to the texture coordinate from the texture object, and judging whether the texture value is a filling color; if yes, go to step S106;
and further converting the projected fragment position into a texture coordinate, sampling on the texture object through texture mapping to obtain a texture value, if the texture value is a fill color, indicating that the current fragment is located in the clipping polygon, executing step S106 to eliminate the fragment in the fragment shader, otherwise, keeping the fragment, and in this case, this embodiment is not limited, and further performing other rendering processing, which is not described herein again.
After the above processing is carried out piece by piece, all terrain model pieces in the cutting polygon are removed, thereby realizing the cutting operation of any concave-convex polygon on the three-dimensional terrain model.
S106, removing the fragment from the fragment shader.
Based on the above description, in the technical solution provided by the embodiment of the present invention, the clipping polygon is projected onto a plane and then drawn on a texture map, after the position of the fragment is converted into a texture coordinate in the fragment shader, a corresponding texture value is obtained through texture mapping, and whether the fragment is located in the clipping polygon is determined according to whether the texture value is a fill value set for the projected polygon, so as to implement the topographic clipping. The method realizes the distinction between the inside and the outside of the cutting polygon through the texture value, the distinction of the texture value can ignore the cutting shape, and the concave, convex or any complex polygon can be projected to a plane and drawn on a texture map, so the method can be widely applied to the cutting polygons with different shapes; and in the identification and judgment of the texture value, judgment is not required to be carried out one by one according to each edge of the cut polygon, namely, the calculation efficiency is not basically influenced when the number of the edges of the cut polygon is large, so that the stable and smooth operation of a system can be ensured, and the requirement of practical application can be well met.
It should be noted that, based on the above embodiments, the embodiments of the present invention also provide corresponding improvements. In the preferred/improved embodiment, the same steps as those in the above embodiment or corresponding steps may be referred to each other, and corresponding advantageous effects may also be referred to each other, which are not described in detail in the preferred/improved embodiment herein.
To further improve the three-dimensional terrain clipping efficiency, before the step S104 determines the texture coordinates of each fragment, the following steps may be further performed:
s107, judging whether the projection position of each fragment is in a bounding rectangle; if the bounding rectangle is included, the triggering step S104 executes a step of determining texture coordinates of each fragment according to the bounding rectangle.
In the embodiment, before calculating the texture coordinates of each fragment, a step of judging whether the projection position is in a bounding rectangle is added, and if the position of the fragment after projection is not in the bounding rectangle of the clipping polygon, the position is reserved; if the clipping polygon is in the enclosing rectangle, the clipping polygon is further converted into texture coordinates, and texture values are obtained by sampling on texture objects through texture mapping.
According to the method, the positions of the fragments are firstly pre-judged before the texture values are judged one by one, which is equivalent to the fact that a step of pre-screening the fragments is added, the fragments in a surrounding rectangle corresponding to a cutting polygon are pre-screened, the judgment and calculation efficiency of the positions of the rectangles is high, and a large number of fragments far away from the polygon can be quickly eliminated, so that the texture values can be calculated and the filling colors can be judged only aiming at the fragments in the surrounding rectangle, the accurate distinguishing of the positions of the fragments is realized, the calculation resources can be effectively saved, and the calculation efficiency is improved.
In the above embodiment, the calculation determination method for the bounding rectangle is not limited, and optionally, in order to simplify the calculation amount and improve the calculation efficiency, a calculation method for projecting the polygon bounding rectangle is as follows:
(1) determining the coordinate axis of the projection plane by taking the mass center of the polygon to be cut as an origin;
the coordinate axis of the projection plane can be set according to the actual calculation requirement, and the determination mode is not limited, for example, a vector between the world coordinate origin and the centroid point and a positive direction vector of the z axis can be cross-multiplied, and the obtained vector is used as the positive direction of the y axis of the projection plane and is rotated by 90 degrees in the clockwise direction to obtain the positive direction of the x axis of the projection plane. When the projection plane is horizontal, the xy-axis direction of the world coordinate system can be directly used as the xy-axis direction of the projection plane. In this embodiment, only the determination manner of the two coordinate axes is taken as an example for description, and other determination manners can refer to the description of this embodiment and are not described herein again.
(2) A bounding rectangle of the projected polygon in the projection plane parallel to the coordinate axes is obtained.
The rectangle is parallel to the coordinate axis means that the adjacent sides of the rectangle are respectively parallel to the x axis and the y axis in the coordinate axis, for example, the long side of the rectangle is parallel to the x axis, and the short side is parallel to the y axis; alternatively, the long side is parallel to the y-axis and the short side is parallel to the x-axis.
The enclosing rectangle parallel to the coordinate axis of the projection plane is obtained in the mode, so that the calculation amount caused by the deviation of the enclosing rectangle can be ignored when whether the projection position of the calculation fragment is in the enclosing rectangle, and the simplification of calculation and the improvement of efficiency are realized.
In order to further reduce the amount of computation and maximize one-time exclusion of fragments not close to the projection polygon, the step (2) determines a bounding rectangle of the projection polygon in the projection plane parallel to the coordinate system, which may specifically be: a minimum bounding rectangle of the projected polygon in the projection plane parallel to the coordinate system is determined.
The elimination of the projection position of the fragment is carried out by determining the minimum bounding rectangle of the projection polygon, and only the fragments in the minimum bounding rectangle are reserved for further refinement and comparison, so that the calculation amount can be obviously reduced.
In the present embodiment, only the calculation method of the above-mentioned bounding rectangle is described as an example, and all other calculation methods can be referred to the description of the present embodiment, and can be calculated as the protection scope of the present invention.
On the basis of the above embodiment, the texture object is a raster image, and the larger the size and the higher the resolution are, the higher the precision of the final cropping result is, and the smoother the boundary of the cropping area is. However, too much resolution may affect the efficiency of texture mapping, thereby reducing the system operating efficiency. In a general practical application scenario, too high clipping precision is generally not required, and therefore, in order to further improve the system operation efficiency, further technical limitation is performed on the texture object in this embodiment.
Optionally, before the step S103 of rendering the projected polygon in the texture object, the following steps may be further performed:
and step S108, acquiring a default size to create a square texture object.
Obtaining a default size creates a square texture object, where the default size is, for example, 512 x 512 resolution. The specific value of the default size is not limited in this embodiment.
The realization mode of fixing the polygon size is simple, the corresponding texture object can be directly created without calculation, and therefore the realization efficiency of cutting is improved; meanwhile, the method can simplify the background deployment step and improve the online efficiency of the method.
Alternatively, before the step S103 of rendering the projected polygon in the texture object, the following steps may be further performed:
and step S109, correspondingly creating a texture object with matched size according to the width-height ratio of the bounding rectangle.
The method provides that a rectangular texture object is defined by adopting the aspect ratio consistent with the bounding rectangle of the clipping polygon, wherein the size proportion of the created texture object to the bounding rectangle is the same, the high definition and high resolution of the drawn projection polygon can be ensured, the condition that the resolution is limited due to size compression is avoided, and the purpose of realizing higher clipping precision under the same resolution can be achieved.
It should be noted that, in this embodiment, two creating manners of texture objects are provided, and one or more of the two creating manners may be configured according to actual use needs, which is not limited herein.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a three-dimensional terrain clipping device, and the three-dimensional terrain clipping device described below and the three-dimensional terrain clipping method described above may be referred to in correspondence with each other.
Referring to fig. 2, the apparatus includes the following modules:
the polygon determining unit 110 is mainly configured to determine a polygon to be clipped and a corresponding projection plane in the three-dimensional terrain model;
the projection processing unit 120 is mainly configured to project a polygon to be cut to a projection plane to obtain a projection polygon, and determine an enclosing rectangle of the projection polygon;
the texture drawing unit 130 is mainly configured to draw a projection polygon in a texture object and perform filling according to a set filling color;
the texture coordinate determination unit 140 is mainly configured to invoke a fragment shader to project coordinates of each fragment in the three-dimensional terrain model to a projection plane, and determine texture coordinates of each fragment according to a bounding rectangle;
the filling judgment unit 150 is mainly configured to obtain a texture value corresponding to the texture coordinate from the texture object, and judge whether the texture value is a filling color; if yes, triggering a fragment eliminating unit 160;
the fragment culling unit 160 is mainly used for culling fragments in the fragment shader.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a computer device, and a computer device described below and a three-dimensional terrain cropping method described above may be referred to in correspondence with each other.
The computer device includes:
a memory for storing a computer program;
and the processor is used for realizing the steps of the three-dimensional terrain cutting method of the embodiment of the method when executing the computer program.
Specifically, referring to fig. 3, a specific structural diagram of a computer device provided in this embodiment is a schematic diagram of a computer device, which may generate relatively large differences due to different configurations or performances, and may include one or more processors (CPUs) 322 (e.g., one or more processors) and a memory 332, where the memory 332 stores one or more computer applications 342 or data 344. Memory 332 may be, among other things, transient or persistent storage. The program stored in memory 332 may include one or more modules (not shown), each of which may include a sequence of instructions operating on a data processing device. Still further, the central processor 322 may be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the computer device 301.
The computer device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input-output interfaces 358, and/or one or more operating systems 341.
The steps in the three-dimensional terrain cropping method described above may be implemented by the structure of a computer device.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a readable storage medium, and a readable storage medium described below and a three-dimensional terrain cropping method described above may be referred to in correspondence with each other.
A readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the three-dimensional terrain cropping method of the above method embodiment.
The readable storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various other readable storage media capable of storing program codes.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

Claims (10)

1. A method of three-dimensional terrain cropping, comprising:
determining a polygon to be cut and a corresponding projection plane in the three-dimensional terrain model;
projecting the polygon to be cut to the projection plane to obtain a projection polygon, and determining an enclosing rectangle of the projection polygon;
drawing the projection polygon in the texture object, and filling according to a set filling color;
a fragment shader is called to project the coordinates of each fragment in the three-dimensional terrain model to the projection plane, and the texture coordinates of each fragment are determined according to the bounding rectangle;
acquiring a texture value corresponding to the texture coordinate from the texture object, and judging whether the texture value is the filling color;
if yes, the fragment is eliminated from the fragment shader.
2. A method of three-dimensional terrain cropping according to claim 1, further comprising, prior to said determining texture coordinates for each of said slices from said bounding rectangle:
judging whether the projection position of each fragment is in the bounding rectangle or not;
and if the fragment is in the bounding rectangle, executing the step of determining the texture coordinate of each fragment according to the bounding rectangle.
3. The method of three-dimensional terrain cropping according to claim 2, wherein said determining a bounding rectangle for the projected polygon comprises:
determining the coordinate axis of the projection plane by taking the mass center of the polygon to be cut as an origin;
and acquiring a surrounding rectangle of the projection polygon in the projection plane, wherein the surrounding rectangle is parallel to the coordinate axis.
4. A method of three-dimensional terrain clipping according to claim 3, wherein the determining a bounding rectangle of the projected polygon in the projection plane parallel to the coordinate system comprises: determining a smallest bounding rectangle of the projected polygon in the projection plane parallel to the coordinate system.
5. The three-dimensional terrain cropping method according to claim 1, wherein said projecting the polygon to be cropped to the projection plane comprises:
and projecting each vertex of the polygon to be cut to the projection plane, and taking the polygon generated after the projected vertices are connected in sequence as the projection polygon.
6. The method of three-dimensional terrain clipping according to claim 1, further comprising, prior to said rendering the projected polygon in a texture object: acquiring the default size creates a square texture object.
7. The method of three-dimensional terrain clipping according to claim 1, further comprising, prior to said rendering the projected polygon in a texture object:
and correspondingly creating a size-matched texture object according to the width-height ratio of the surrounding rectangle.
8. A three-dimensional terrain clipping device, comprising:
the polygon determining unit is used for determining a polygon to be cut and a corresponding projection plane in the three-dimensional terrain model;
the projection processing unit is used for projecting the polygon to be cut to the projection plane to obtain a projection polygon and determining a surrounding rectangle of the projection polygon;
the texture drawing unit is used for drawing the projection polygon in the texture object and filling the projection polygon according to the set filling color;
the texture coordinate determination unit is used for calling a fragment shader to project the coordinates of each fragment in the three-dimensional terrain model to the projection plane and determining the texture coordinates of each fragment according to the bounding rectangle;
the filling judgment unit is used for acquiring a texture value corresponding to the texture coordinate from the texture object and judging whether the texture value is the filling color; if yes, triggering a fragment removing unit;
the fragment eliminating unit is used for eliminating the fragments in the fragment shader.
9. A computer device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the three-dimensional terrain cropping method of any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the method for three-dimensional terrain cropping according to any one of claims 1 to 7.
CN202210785918.6A 2022-04-20 2022-07-04 Three-dimensional terrain clipping method, device and equipment and readable storage medium Pending CN115131513A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2022104196345 2022-04-20
CN202210419634 2022-04-20

Publications (1)

Publication Number Publication Date
CN115131513A true CN115131513A (en) 2022-09-30

Family

ID=83382483

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210785918.6A Pending CN115131513A (en) 2022-04-20 2022-07-04 Three-dimensional terrain clipping method, device and equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115131513A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116228949A (en) * 2023-02-28 2023-06-06 如你所视(北京)科技有限公司 Three-dimensional model processing method, device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116228949A (en) * 2023-02-28 2023-06-06 如你所视(北京)科技有限公司 Three-dimensional model processing method, device and storage medium
CN116228949B (en) * 2023-02-28 2024-03-08 如你所视(北京)科技有限公司 Three-dimensional model processing method, device and storage medium

Similar Documents

Publication Publication Date Title
CN108648269B (en) Method and system for singulating three-dimensional building models
JP3358169B2 (en) Mirror surface rendering method and apparatus
EP2972723B1 (en) Smooth draping layer for rendering vector data on complex three dimensional objects
US20130300740A1 (en) System and Method for Displaying Data Having Spatial Coordinates
US7170527B2 (en) Interactive horizon mapping
US7098915B2 (en) System and method for determining line-of-sight volume for a specified point
CN111784833A (en) WebGL-based flood evolution situation three-dimensional dynamic visualization display method
US7158133B2 (en) System and method for shadow rendering
JP2014186570A (en) Three dimensional map display system
US9401044B1 (en) Method for conformal visualization
CN115131513A (en) Three-dimensional terrain clipping method, device and equipment and readable storage medium
CN117011492B (en) Image rendering method and device, electronic equipment and storage medium
Frommholz et al. Inlining 3d reconstruction, multi-source texture mapping and semantic analysis using oblique aerial imagery
KR101118597B1 (en) Method and System for Rendering Mobile Computer Graphic
CN111431953B (en) Data processing method, terminal, server and storage medium
JPH0636013A (en) Method and device for generating topographic data
CN109427084B (en) Map display method, device, terminal and storage medium
CN113674419B (en) Three-dimensional display method and device for meteorological cloud data, electronic equipment and storage medium
KR100517590B1 (en) System and method for processing three dimension data and recording medium having program for three dimension data processing function
Glander et al. Automated cell based generalization of virtual 3D city models with dynamic landmark highlighting
CN111325783A (en) WebGIS-based visual domain analysis method and device
CN117368869B (en) Visualization method, device, equipment and medium for radar three-dimensional power range
EP3241186B1 (en) System and method of shadow effect generation for concave objects with dynamic lighting in three-dimensional graphics
CN111340941B (en) Oblique photography dynamic singleization method based on vector graphics under spherical coordinate system
CN116474363A (en) Scene model rendering method and device 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