在生成网格获取噪声图之后,就需要在网格之中计算每一个格子对应的贴图索引数字
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32private void SetVertexType(Vector2Int vertexIndex,MapVertexType mapVertexType)
{
MapVertex vertex = GetVertex(vertexIndex);
if ((vertex.VertexType!=mapVertexType))
{
vertex.VertexType = mapVertexType;
//计算附近的贴图权重
if(vertex.VertexType == MapVertexType.Swamp)
{
MapCell tempCell = GetLeftBottomMapCell(vertexIndex);
if (tempCell != null)
{
tempCell.TextureIndex += 1;
}
tempCell = GetRightBottomMapCell(vertexIndex);
if (tempCell != null)
{
tempCell.TextureIndex += 2;
}
tempCell = GetLeftTopMapCell(vertexIndex);
if (tempCell != null)
{
tempCell.TextureIndex += 4;
}
tempCell = GetRightTopMapCell(vertexIndex);
if (tempCell != null)
{
tempCell.TextureIndex += 8;
}
}
}
}
1 | public int[,] CalculateCellTextureIndex(float[,] noiseMap,float limit) |