<分区>
我正在尝试创建从 txt 文件获取高度值的地形。
在我的搜索过程中,我意识到地形通常是从 bmp 文件或另一种从像素中获取值的图片创建的。我将文件中的高度值读取到二维数组中。
void File(){
FILE* file = fopen("data.txt", "r"); // data.txt opened with read only mode to get heights
int i,j;
for (i = 0; i < 17; i++){
for (j = 0; j < 21; j++){
fscanf(file, "%d", &data[i][j]);
}
}
fclose(file);
}
然后将这些值加载到顶点以创建三角形。
但是当我更改 x y z
值时到处都是三角形。
预期的项目是创建地形。
是否有一种特殊的方法或代码可以仅使用 txt 文件中的高度值来创建地形?