DirectX Z 顺序
我必须使用 Managed DirectX 绘制地图。地图以 MapInfo 格式(线、折线、区域/多边形)到达。多边形已经被三角化(使用 GLUtesselator 完成)。
想法:
- GPS坐标转换为x,y点(墨卡托投影)
- 我使用PositionColored VertexFormat
- 视图的中心是[x,y](可以通过鼠标移动修改)
- 相机始终定位到[x,y,z],其中z 为缩放比例(默认为-100,可通过鼠标滚轮修改)
- 相机目标为:[x,y,0],相机向上:[0,1,0]
- 地图图层以 Z(+1.0 ,0.99,0.98,0.97...等)
我已经可以做到:
- 绘制线条和折线
- 绘制一层多边形
我的问题是:当我想绘制所有层时,我只看到其中一层。我认为 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:
- 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的地图是纯 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.