我想制作一个简单的二维地形,只有一些颠簸和高度变化:
我想过只使用随机数来描述某个顶点的高度,但我不知道如何从中制作一个网格。我正在寻找一种方法来查找地形的顶点和索引缓冲区。
我该怎么做?
最佳答案
您可以将 GL_POLYGON 与所有顶点的列表一起使用,其中第一个和最后一个顶点位于 View 下方。
如果你想使用三角形网格,你必须在每个高度点正下方( View 之外)创建一个点,那么图案(顺时针顺序)将是:
for (number of height points-1)
//vertices
vertice below height;
height vertice;
next_height vertice;
next height vertice;
vertice below next height;
vertice below height;
然后计算索引取决于您存储顶点的方式,但数组中会有类似的模式。
关于opengl - 如何用opengl制作2D地形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10422947/