I have to draw a map with Managed DirectX. The map arrived in MapInfo format (lines, polylines, regions/polygons). Polygons are already triangulated (done with GLUtesselator).
The idea:
- GPS Coordinates are converted to x,y points (Mercator Projection)
- I use PositionColored VertexFormat
- Center of the view is [x,y] (can modify by mouse move)
- Camera is always positioned to [x,y,z] where z is the zoom (-100 by default, can modify by mouse wheel)
- Camera target is: [x,y,0], camera up: [0,1,0]
- The layers of the map are positioned by Z (+1.0, 0.99, 开发者_运维百科0.98, 0.97...etc)
I can already do:
- Draw lines and polylines
- Draw one layer of polygons
My problem is: when I want to draw all layers I see only one of them. I think there is some problem with z ordering. What should I do to solve this? Modify the RenderState? The best would be if I could draw as in GDI (first in the back, last in the front).
Other question: how can I get the coordinate of a pixel under the mouse cursor? (in the GDI version of the map I could do it because I used my own viewport for rendering, but now directx do everything)
Thanks!
If your map is purely 2D, make sure that Z buffering is turned off. Once it is, things will display in the order you draw them in.
精彩评论