开发者

DirectX Z order

开发者 https://www.devze.com 2023-02-06 23:28 出处:网络
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).

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:

  1. GPS Coordinates are converted to x,y points (Mercator Projection)
  2. I use PositionColored VertexFormat
  3. Center of the view is [x,y] (can modify by mouse move)
  4. Camera is always positioned to [x,y,z] where z is the zoom (-100 by default, can modify by mouse wheel)
  5. Camera target is: [x,y,0], camera up: [0,1,0]
  6. The layers of the map are positioned by Z (+1.0, 0.99, 开发者_运维百科0.98, 0.97...etc)

I can already do:

  1. Draw lines and polylines
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消