Exemplo n.º 1
0
        public void Build(Mesh mesh, Vector3 offset)
        {
            var graph     = mesh.BuildSimpleGraph();
            var positions = mesh.vertices.Select(v => v + offset).ToArray();

            potentialField.SetGraph(graph, positions);
        }
Exemplo n.º 2
0
    void BuildGraph()
    {
        var gb        = new SimpleGraphBuilder();
        var positions = new List <Vector3>();

        for (int i = 0; i < gridSpace.NumCells; i++)
        {
            positions.Add(gridSpace.GetBounds(i).center);
            gb.NewNode();

            var neighbours = new List <int>();

            foreach (var dir in CompassDirection.PrincipalDirections)
            {
                int neighbour;
                if (gridSpace.TryGetNeighbour(i, dir, out neighbour))
                {
                    neighbours.Add(neighbour);
                }
            }

            gb.AddArcs(neighbours.ToArray());
        }

        var graph = gb.Build();

        potentialFieldSys.SetGraph(graph, positions.ToArray());
    }