本文整理汇总了C#中MapData.GetNeighbourOffset方法的典型用法代码示例。如果您正苦于以下问题:C# MapData.GetNeighbourOffset方法的具体用法?C# MapData.GetNeighbourOffset怎么用?C# MapData.GetNeighbourOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapData
的用法示例。
在下文中一共展示了MapData.GetNeighbourOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSubMesh
Mesh CreateSubMesh(MapData data, int xOffset, int zOffset, int patchXCount, int patchZCount, float size, Vector3 offset)
{
Mesh mesh = new Mesh();
int vCount = patchXCount * patchZCount * 4;
Vector3[] pts = new Vector3[vCount];
Color[] colors = new Color[vCount];
int[] indices = new int[vCount * 2];
size *= 0.5f;
Vector3[] squareBias = new Vector3[4]{ new Vector3(-size, 0, -size)
,new Vector3(-size, 0, size)
,new Vector3(size, 0, size)
,new Vector3(size, 0, -size) };
//Vector3 offset = GetOffset() + bia;
int i = 0;
for (int z = zOffset; z < zOffset + patchZCount; z++)
{
for (int x = xOffset; x < xOffset + patchXCount; x++)
{
MapData.MapNode node = data.GetNode(x, z);
Vector3[] neighbours = data.GetNeighbourOffset(x, z);
Vector3 center = node.Position;
Color vertexColor = node.IsWayPoint ? wayPointColor : node.IsReachable ? reachableColor : notReachableColor;
pts[i * 4] = center + squareBias[0] + offset + neighbours[0];
pts[i * 4 + 1] = center + squareBias[1] + offset + neighbours[1];
pts[i * 4 + 2] = center + squareBias[2] + offset + neighbours[2];
pts[i * 4 + 3] = center + squareBias[3] + offset + neighbours[3];
int start = i * 4;
for (int j = 0; j < 4; j++)
{
colors[start + j] = vertexColor;
}
indices[i * 8] = start; indices[i * 8 + 1] = start + 1;
indices[i * 8 + 2] = start + 1; indices[i * 8 + 3] = start + 2;
indices[i * 8 + 4] = start + 2; indices[i * 8 + 5] = start + 3;
indices[i * 8 + 6] = start + 3; indices[i * 8 + 7] = start;
i++;
}
}
mesh.vertices = pts;
mesh.colors = colors;
//mesh.SetIndices(indices, MeshTopology.Lines, 0);
mesh.SetIndices(indices, MeshTopology.Quads, 0);
return mesh;
}