A kind of method for visualizing of mobile terminal oblique model data
Technical field
The present invention relates to a kind of method for visualizing, in particular to a kind of method for visualizing of mobile terminal oblique model data.
Background technique
Oblique photograph technology is the new and high technology to grow up the International Photography fields of measurement nearly more than ten years, and the technology is logical
It crosses from five different visual angle synchronous acquisition images such as vertical, four inclinations, gets building top surface and side abundant
The high-resolution texture in face.It can not only really reflect atural object situation, accurately obtain atural object texture information, can also lead to
The technologies such as advanced positioning, fusion, modeling are crossed, true D Urban model is generated, user is introduced and meets human eye vision
The true intuitive world.
Oblique photograph measuring technique complete perception complex scene in a manner of extensive, high-precision, high-resolution, by efficient
Data acquisition equipment and the outcome data that generates of flow chart of data processing of profession intuitively reflect appearance, position, the height of atural object
Equal attributes provide guarantee for true effect and mapping class precision.However, just because of these advantages of oblique photograph, so that it is given birth to
The data volume of production is very huge, to loading and visualizing to these data, proposes higher requirement to hardware device.
At this stage since computer end hardware performance is powerful, the software of oblique photograph data visualization can be selected very
More, function is also very rich, but mobile terminal can software to oblique photograph data visualization it is just very rare, and mostly
All be applied with lightweight based on.The visualization of small range single game scape is only supported in the application of lightweight, to large-scale inclination three
It ties up scene and supports deficiency, and when mobile terminal loads canted shot model, need to carry out texture compression to oblique photograph model, with
Meets the needs of different type movement end equipment, in addition, being limited by mobile end equipment performance itself, a wide range of tilt data exhibition
Very more hardware resources will be occupied by showing, directly will be extremely difficult to entire a wide range of single game scape load and displaying.Therefore, such as
, to a wide range of oblique model in the displaying of mobile terminal, smoothly load, meeting practical application request is asking for current urgent need to resolve for what
Topic.
Summary of the invention
The technical problem to be solved by the invention for the present situation of prior art is to provide one kind can dynamically calculate visually
The method for visualizing of range, the mobile terminal oblique model data of reduction data volume load in region.
The technical scheme of the invention to solve the technical problem is: a kind of mobile terminal oblique model data is visual
Change method, for by showing oblique model data on mobile terminal, wherein oblique model data are spliced mutually by multiple data blocks
Composition, and each data block is made of the different multi-layer data of granularity, it is characterised in that: a kind of mobile terminal oblique model data
Method for visualizing the following steps are included:
Step 1 obtains the coordinate of current camera in three dimensions;
Step 2, obtain mobile terminal current screen four apex coordinates, by each apex coordinate be respectively perpendicular screen to
Ray is inside generated in three dimensions, obtains four rays, wherein four rays are denoted as d1, d2, d3 and d4 respectively;
The ground of three-dimensional scenic is made of multiple triangle griddings in step 3, oblique model data, traverses all triangulation networks
Lattice calculate separately the focus that each ray d1, d2, d3 and d4 in step 2 intersects with all triangle griddings, successively obtain phase
Four focuses handed over, wherein four focuses are denoted as p1, p2, p3 and p4 respectively;
Whether step 4, all data block of traversal judge to have in each data block arbitrary coordinate point to fall in step 3 four
Within the quadrangle of a focus p1, p2, p3 and p4 composition, if so, then the data block is visible number in the current screen of mobile terminal
According to block, and it is transferred to step 6;If not, the data block is sightless data block in the current screen of mobile terminal, and it is transferred to step 5;
Step 5 judges whether the data block had loaded in memory, if so, then releasing the data block from memory
It puts, if not, the data block does not operate;
Step 6, the center point coordinate for obtaining visible data block in the current screen of mobile terminal, by the coordinate of video camera with
Data block center point coordinate calculates the linear distance between each data block and video camera;
Step 7, by the linear distance between data block each in step 6 and video camera, it is corresponding to find each data block
The hierarchical relationship of granularity, and indexed according to the level of each data block endoparticle degree, it selects to correspond to level in each data block
Data, read and load corresponding tilt data in the level of each data block selection;
Step 8 traverses and renders visible inclination three-dimensional data in current screen.
Specifically, the coordinate that ray intersects with triangle gridding is calculated using Ray-Triangle algorithm in the step 3,
In, specific calculating step that a ray intersects with triangle gridding are as follows:
Step 3-1, the coordinate of any point on triangle gridding are as follows:
P (u, v)=(1-u-v) * V0+u*V1+v*V2
Wherein, P is the coordinate of any point on the triangle gridding of vertex V0, V1, V2 composition, and V0, V1, V2 are respectively triangle
The coordinate on the vertex of grid, u, v are preset value, wherein u+v≤1, and u >=0, v >=0;
Step 3-2, on ray any point coordinate expressions are as follows: P (t)=O+t*D;
Wherein, O is the starting point coordinate of ray, and D is the direction of ray, and t is preset value;
Step 3-3, the focus of triangle gridding and ray intersection, calculation formula are calculated are as follows:
O+t*D=(1-u-v) * V0+u*V1+v*V;
The coordinate of P point is obtained in the expression formula of ray in corresponding t value substitution step 3-2 when above-mentioned equation is set up, or
U, v value are substituted into any point expression formula of step 3-1 intermediate cam grid, obtain the coordinate of P point, i.e., the P point is focus.
Assume that the data point in any data block is P (x, y, z) in the step 4, judges arbitrary number strong point P (x, y, z)
Whether focus p1, p2, p3, the calculation formula quadrangle of p4 composition in are fallen in are as follows:
A=(p2.x-p1.x) * (y-p1.y)-(p2.y-p1.y) * (x-p1.x)
B=(p3.x-p2.x) * (y-p2.y)-(p3.y-p2.y) * (x-p2.x)
C=(p4.x-p3.x) * (y-p3.y)-(p4.y-p3.y) * (x-p3.x)
D=(p1.x-p4.x) * (y-p4.y)-(p1.y-p4.y) * (x-p4.x)
Wherein, p1.x is the x-axis coordinate of focus p1, and p1.y is the y-axis coordinate of focus p1, and the x-axis that p2.x is focus p2 is sat
Mark, p2.y are the y-axis coordinate of focus p2, and p3.x is the x-axis coordinate of focus p3, and p3.y is the y-axis coordinate of focus p3, and p4.x is coke
The x-axis coordinate of point p4, p4.y are the y-axis coordinate of focus p4;
When a, b, c, d symbol are identical, i.e., when a, b, c, d are all positive or are all negative, then the data point P in data block
(x, y, z) is fallen on the quadrangle of four focuses composition, conversely, then data point P (x, y, z) is not fallen on quadrangle.
Preferably, the tilt module data are the OSGB data of Smart3D production.
Compared with the prior art, the advantages of the present invention are as follows: by calculating current window visible area in three-dimensional scenic
Coordinate range, find the data block in visible area;And by calculating between the data block in camera and visible area
Distance, judge the granularity that each data block needs to show, and corresponding find needs data block level to be loaded, from regardless of
How scene changes, and for the data volume loaded never more than the range of a window, each window moves all only need to be to need
The data to be shown carry out dynamic calculating, load the data in visible area, and rejecting has loaded and the data outside visible area,
The visual purpose of broad range of data can be reached under the limitation of limited mobile terminal hardware resource.
Detailed description of the invention
Fig. 1 is the flow chart of the method for visualizing of mobile terminal oblique model data in the embodiment of the present invention.
Specific embodiment
The present invention will be described in further detail below with reference to the embodiments of the drawings.
As shown in Figure 1, a kind of method for visualizing of mobile terminal oblique model data, for by showing inclination on mobile terminal
Model data, wherein the tilt module data are the OSGB data of Smart3D production, and an inclination scene is by multiple mutual spellings
The data chunk connect is at each data block is identical by range, the different multi-layer data composition of granularity.It is mobile in the present embodiment
End is mobile phone, and tilt module data are shown on mobile phone.
A kind of method for visualizing of mobile terminal oblique model data, comprising the following steps:
Step 1 obtains the coordinate of current camera in three dimensions;
Step 2, obtain mobile terminal current screen four apex coordinates, by each apex coordinate be respectively perpendicular screen to
Ray is inside generated in three dimensions, obtains four rays, wherein four rays are denoted as d1, d2, d3 and d4 respectively;
The ground of three-dimensional scenic is made of multiple triangle griddings in step 3, oblique model data, traverses all triangulation networks
Lattice calculate separately the focus that each ray d1, d2, d3 and d4 in step 2 intersects with all triangle griddings, successively obtain phase
Four focuses handed over, wherein four focuses are denoted as p1, p2, p3 and p4 respectively;
In the present embodiment, the coordinate that ray intersects with triangle gridding is calculated using Ray-Triangle algorithm, wherein one
The specific calculating step that ray intersects with triangle gridding are as follows:
Wherein, the specific calculating step that a ray intersects with triangle gridding are as follows:
Step 3-1, the coordinate of any point on triangle gridding are as follows:
P (u, v)=(1-u-v) * V0+u*V1+v*V2
Wherein, P is the coordinate of any point on the triangle gridding of vertex V0, V1, V2 composition, and V0, V1, V2 are respectively triangle
The coordinate on the vertex of grid, u, v are preset value, wherein u+v≤1, and u >=0, v >=0;
Step 3-2, on ray any point coordinate expressions are as follows: P (t)=O+t*D;
Wherein, O is the starting point coordinate of ray, and D is the direction of ray, and t is preset value;
Step 3-3, the focus of triangle gridding and ray intersection, calculation formula are calculated are as follows:
O+t*D=(1-u-v) * V0+u*V1+v*V;
The coordinate of P point is obtained in the expression formula of ray in corresponding t value substitution step 3-2 when above-mentioned equation is set up, or
U, v value are substituted into any point expression formula of step 3-1 intermediate cam grid, obtain the coordinate of P point, i.e., the P point is focus;
Whether step 4, all data block of traversal judge to have in each data block arbitrary coordinate point to fall in step 3 four
Within the quadrangle of a focus p1, p2, p3 and p4 composition, if so, then the data block is visible number in the current screen of mobile terminal
According to block, and it is transferred to step 6;If not, the data block is sightless data block in the current screen of mobile terminal, and it is transferred to step
5;;
In the present solution, inclination scene be tile in the plane as data block made of, therefore only consideration plane on knot
Fruit does not consider z coordinate, it is assumed that the data point in any data block is P (x, y, z), whether judges arbitrary number strong point P (x, y, z)
Fall in focus p1, p2, p3, the calculation formula in the quadrangle of p4 composition are as follows:
A=(p2.x-p1.x) * (y-p1.y)-(p2.y-p1.y) * (x-p1.x)
B=(p3.x-p2.x) * (y-p2.y)-(p3.y-p2.y) * (x-p2.x)
C=(p4.x-p3.x) * (y-p3.y)-(p4.y-p3.y) * (x-p3.x)
D=(p1.x-p4.x) * (y-p4.y)-(p1.y-p4.y) * (x-p4.x)
Wherein, p1.x is the x-axis coordinate of focus p1, and p1.y is the y-axis coordinate of focus p1, and the x-axis that p2.x is focus p2 is sat
Mark, p2.y are the y-axis coordinate of focus p2, and p3.x is the x-axis coordinate of focus p3, and p3.y is the y-axis coordinate of focus p3, and p4.x is coke
The x-axis coordinate of point p4, p4.y are the y-axis coordinate of focus p4;
When a, b, c, d symbol are identical, i.e., when a, b, c, d are all positive or are all negative, then the data point P in data block
(x, y, z) is fallen on the quadrangle of four focuses composition, conversely, then the data point is not fallen on quadrangle;
Step 5 judges whether the data block had loaded in memory, if so, then releasing the data block from memory
It puts, if not, the data block does not operate;
Step 6, the center point coordinate for obtaining visible data block in the current screen of mobile terminal, by the coordinate of video camera with
Data block center point coordinate calculates the linear distance between each data block and video camera;
Wherein, the distance of the linear distance between each data block and video camera represents data block and will render in screen
Granularity size, the linear distance between data block and video camera is remoter, then the granularity for representing the data block is thicker, on the contrary
Linear distance between data block and video camera is closer, then the granularity of the data block is thinner;
Step 7, by the linear distance between data block each in step 6 and video camera, it is corresponding to find each data block
The hierarchical relationship of granularity, and indexed according to the level of each data block endoparticle degree, it selects to correspond to level in each data block
Data, read and load corresponding tilt data in the level of each data block selection;
In load, due to multi-layer data different containing granularity in the data of each data block, from camera shooting
The closer data block of linear distance between machine, then the granularity of the data block is thinner, needs data volume to be loaded bigger, content
It is more, thus the level for needing to select granularity thinner in the data block, correspondingly, being got over from the linear distance between video camera
Remote data block, then the granularity of the data block is thicker, needs data volume to be loaded smaller, content is fewer, then selects the data
The data of the thicker level of granularity can make data block loading velocity become faster by this kind of loading method in block, and loaded
Data volume does not exceed the range of a screen window.
Step 8 traverses and renders visible inclination three-dimensional data in current screen.
It is according to each in data load process in the method for visualizing of existing mobile terminal oblique model data
The most thin level of the granularity of data block is rendered, although can also be loaded into entire scene in this way, which adds
The data volume of load is big, and rendering speed is slow, and when load will appear the feeling of card, and the method for visualizing in the present invention passes through dynamic first
State calculates the range of current screen, finds out the visible data block of mobile terminal current screen, discharges sightless data block, and according to
The distance between data block and video camera judge need data block level to be loaded, and by loading suitable data block level,
Therefore make data block loading velocity faster, and no matter how scene changes, the data volume loaded is never shielded more than one
The range of curtain window, therefore the hardware resource utilization of mobile device is made to reach maximization, also breach three-dimensional tilt data
Maximum magnitude.