WorldWind Source Analysis Series: Latitude Grid class Latlonggrid

Source: Internet
Author: User

The Latitude Grid class Latlonggrid inherits from the Renderableobject object class, which is the encapsulation class used in WorldWind to draw the latitude and longitude grids on the surface of the planet. The class diagram is shown below.

The body function that draws the graticule grid is render (), and its interior primarily calls the following function to complete the drawing:

Computegridvalues ()// computed grid value rendertropicline ()// draw regression line

The computed grid value Computegridvalues () internally specifies the latitude division interval for the graticule grid in 1, 2, 5, and 104 through the camera's true field of view angle DrawArgs.WorldCamera.TrueViewRange.Radians Then specify the longitude split interval equal to the latitude interval. Next, determine whether the current camera's visual body contains a north-south Pole, if it is included, it will specify a longitude split interval equal to 10 degrees, so that the pole part of the Graticule partition interval is larger, rather than the very dense drawing. Next, calculate the maximum/small visible longitude value of the camera's visible scene, the maximum/small visible latitude value, the integer type. And when the longitude split interval equals 10 degrees, the minimum visible longitude is equal to 180 degrees, and the maximum visible longitude equals 180 degrees. Next, calculate the number of split points in each row along the longitude direction, dividing each column in the latitude direction by 1, which is the same as in my previous blog post, "DirectX-based, C + + and C # implementations of the hemispherical sky class". This is done in order to connect the spheres to each other. The larger value between the longitude points (line) and the Latitude Points (column) is then calculated, and then the value is used to apply the three-dimensional coordinate point space required for the planetary body Division:

if Null | | Vertexpointcount >new Customvertex.positioncolored[math.max (Latitudepointcount, Longitudepointcount)];

Next, the radius of the sphere in which the planet's graticule is set is the radius value that is carried by the planet World in which the object was constructed. Next, determine if the current camera's height is less than 0.1*worldradius, and if so, do not turn on the zbuffer depth test. If the ZBuffer depth test is otherwise turned on, and the larger of the two values are set 1.01* Worldradius and (Worldradius + 0.015f * drawArgs.WorldCamera.Altitude), The radius of the sphere where the Earth's graticule is ultimately located.

Next, set whether to turn on the zbuffer depth test, set the texture stage color action coloroperation, set the vertex format VertexFormat, and then follow the fixed graphics rendering pipeline for DirectX 3D Sets the world transformation matrix DrawArgs.device.Transform.World, sets the turn off rendering state lighting effect drawArgs.device.RenderState.Lighting. Each intersection of the graticule is obtained by converting the spherical coordinates of the lattice mesh points to Cartesian controls, and the following formula transforms the spherical coordinates of the mesh point into a spatial Cartesian coordinate to obtain an approximation of the hemispherical mesh split model.

Where B and L are the latitude and longitude of the sphere respectively, the value range is:-π/2≤b≤π/2,-π≤l≤π,r is the set sphere radius. You can use 、、、 coordinates to generate the desired spherical grid. Depending on the accuracy requirements, different values can be set for the zonal and warp split intervals.

The texture coordinates can calculate the zonal and warp meshing points respectively according to the zonal and warp split intervals, then calculate the zonal and meridional grid number of the special dot based on the current spherical coordinates, and finally calculate the texture coordinates of the cloud map according to the following formula. Where the current line number and column number are forced to take floating-point type is to ensure that the division operation by floating-point operation, the final result falls between [0.0,1.0]. For detailed code, please refer to my previous blog post, "C + + and C # implementations of the DirectX-based hemispherical Sky class."

Finally, the longitude grid network cable, longitude value label, latitude Grid network cable, latitude value label are plotted sequentially through two double loops. The type of entity specified when plotting the graticule is the line band Primitivetype.linestrip, which is drawn along the warp direction and the latitude direction, respectively. For detailed implementation code, see the LatLongGrid.cs file below the PLUGINSDK project.

WorldWind Source Analysis Series: Latitude Grid class Latlonggrid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.