Exemple #1
0
    public Improbable.Collections.List <Improbable.Vector3f> generatePointToPointPlan(Improbable.Vector3f p1, Improbable.Vector3f p2)
    {
        if (isPointInNoFlyZone(p2))
        {
            Debug.LogError("next target is in a NFZ");
            return(null); // A plan can not be found
        }

        int[] coord1 = bitmap.findGridCoordinatesOfPoint(p1);
        if (coord1 == null)
        {
            Debug.LogError("coord1 fail");
            return(null);
        }

        int[] coord2 = bitmap.findGridCoordinatesOfPoint(p2);
        if (coord1 == null)
        {
            Debug.LogError("coord2 fail");
            return(null);
        }

        GridLocation l1 = new GridLocation(coord1[0], coord1[1]);
        GridLocation l2 = new GridLocation(coord2[0], coord2[1]);

        ASearch = new ThetaStarSearch(true); // Use AStarSearch or ThetaStarSearch here.

        float droneHeight        = UnityEngine.Random.Range(SimulationSettings.MinimumDroneHeight, SimulationSettings.MaximumDroneHeight);
        List <GridLocation> locs = ASearch.run(bitmap, l1, l2);

        if (locs == null)
        {                 // The case that a path could not be found.
            Debug.LogError("search fail");
            return(null); // Just return empty list.
        }

        //Debug.LogWarning("NUM VERTICES IN PATH: " + locs.Count);

        Improbable.Collections.List <Improbable.Vector3f> result = new Improbable.Collections.List <Improbable.Vector3f>();

        result.Add(p1);
        foreach (GridLocation l in locs)
        {
            Improbable.Vector3f convertedLocation = convertLocation(l);
            Improbable.Vector3f location          = new Improbable.Vector3f(convertedLocation.x, droneHeight, convertedLocation.z);

            result.Add(location);
        }
        result.Add(p2);

        return(result);
    }
    private void _searchCommand_Click(object sender, EventArgs e)
    {
        IGridSearch child = (this.ActiveMdiChild as IGridSearch);

        if (child != null)
        {
            child.PerformSearch("whatever to search for");
        }
        else
        {
            MessageBox.Show("Can't search in the active form");
        }
    }