我有道路左侧和右侧的顶点坐标(显示为绿色和黑色点)。我的地形是一个数组,正方形的角代表不同的高度值。我只是通过为每个顶点提供插值高度来绘制我的道路,但这并没有给出正确的结果(道路不与地形重叠)
问题:在opengl中有什么方法可以正确绘制这条路吗?或者我必须手动计算所有交叉点(蓝点)并镶嵌我的道路?
**编辑:**如果我只给每个顶点一个插值高度,这就是结果。正如所见,由于高度图,某些部分仍处于地形之下。
最佳答案
这是我为实现结果所做的算法:
对于每条路:
1) Generate Initial vertexes from road Lines
2) Find Intersections Vertically and add in order to the buffer
3) Find Intersections Horizontally and add in order to the buffer
4) Find Intersections Diagonally and add in order to the buffer
5) Find texture coordinates for each vertex in buffer
在我们按顺序排列顶点后,我将它传递给 Tesselator 以绘制最终的凹多边形。瞧!
关于algorithm - 在地形图上绘制道路,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29055755/