Пример #1
0
 private HashSet <HeightMapNode> GetNonDiagonalNeighbours(HeightMapNode node)
 {
     return(new HashSet <HeightMapNode> (new[]
     {
         GetNode(node.GetX() + 1, node.GetY()),
         GetNode(node.GetX() - 1, node.GetY()),
         GetNode(node.GetX(), node.GetY() + 1),
         GetNode(node.GetX(), node.GetY() - 1),
     }.Where(pos => InBounds(pos.GetX(), pos.GetY()))
                                         ));
 }
Пример #2
0
        private Vector3 HeightmapNodeToWorldSpace(HeightMapNode node)
        {
            var terrainData         = _terrain.terrainData;
            var terrainSize         = terrainData.size;
            var heightmapResolution = terrainData.heightmapResolution;

            return(new Vector3(
                       node.GetX() * terrainSize.x / heightmapResolution,
                       node.height * terrainSize.y,
                       node.GetY() * terrainSize.z / heightmapResolution
                       ));
        }
Пример #3
0
 private bool IsNeighbour(HeightMapNode a, HeightMapNode b)
 {
     return(Mathf.Abs(a.GetX() - b.GetX()) <= 1 && Mathf.Abs(a.GetY() - b.GetY()) <= 1);  //X and Y are always positive
 }