DirectX Z 顺序

发布于 2024-10-14 04:16:44 字数 620 浏览 10 评论 0原文

我必须使用 Managed DirectX 绘制地图。地图以 MapInfo 格式(线、折线、区域/多边形)到达。多边形已经被三角化(使用 GLUtesselator 完成)。

想法:

  1. GPS坐标转换为x,y点(墨卡托投影)
  2. 我使用PositionColored VertexFormat
  3. 视图的中心是[x,y](可以通过鼠标移动修改)
  4. 相机始终定位到[x,y,z],其中z 为缩放比例(默认为-100,可通过鼠标滚轮修改)
  5. 相机目标为:[x,y,0],相机向上:[0,1,0]
  6. 地图图层以 Z(+1.0 ,0.99,0.98,0.97...等)

我已经可以做到:

  1. 绘制线条和折线
  2. 绘制一层多边形

我的问题是:当我想绘制所有层时,我只看到其中一层。我认为 z 排序存在一些问题。我应该怎么做才能解决这个问题?修改渲染状态?最好的是我可以像 GDI 一样绘制(首先在后面,最后在前面)。

其他问题:如何获取鼠标光标下像素的坐标? (在地图的 GDI 版本中我可以做到这一点,因为我使用自己的视口进行渲染,但现在 directx 可以完成所有操作)

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白昼 2024-10-21 04:16:44

如果您的地图是纯 2D,请确保 Z 缓冲已关闭。一旦完成,事物就会按照您绘制的顺序显示。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文