import numpy as np import PIL.Image as image from sklearn.cluster import KMeans def loadData(filePath): f = open(filePath,'rb')#以二进制形式打开文件 data = [] img = image.open(f)#以列表形式返回图片像素值 m,n = img.size#获取图片大小 for i in range(m):#将每个像素点RGB处理到0-1 for j in ra…
准备灰度图 IGray.png及草地贴图 IGrass.jpg ,放入Assets下StreamingAssets文件夹中. 创建空材质,用作参数传入脚本. 脚本如下,挂载并传入材质球即可根据灰度图生成mesh. using System.Collections; using System.Collections.Generic; using UnityEngine; //根据灰度图创建mesh地形 public class MeshTerrainCreate : MonoBeh…