コード例 #1
0
ファイル: NavMeshViewer.cs プロジェクト: uzbekdev1/Nav
 protected virtual void CreateNavigation()
 {
     m_Navmesh          = new Navmesh();
     m_Navigator        = new NavigationEngine(m_Navmesh);
     m_Explorer         = new ExploreEngine.Nearest(m_Navmesh, m_Navigator);
     m_Explorer.Enabled = false;
 }
コード例 #2
0
        public TestBot(Navmesh navmesh, NavigationEngine navigator, ExplorationEngine explorer, Vec3 pos, float speed, float angular_speed, bool enableExplorer = true)
        {
            m_Navmesh         = navmesh;
            m_Navmesh.Verbose = true;
            //m_Navigator = new NavigationEngine(navmesh);
            m_Navigator = navigator;
            m_Navigator.EnableThreatAvoidance = true;
            m_Navigator.AddObserver(this);
            m_Navigator.CurrentPos = pos;
            //m_Navigator.EnableThreatAvoidance = true;
            //m_Navigator.DefaultPrecision = 20;
            //m_Navigator.Precision = 20;
            //m_Navigator.PathNodesShiftDist = 20;
            //m_Navigator.EnableAntiStuck = false;
            //m_Navigator.DestinationGridsId = dest_grid_id != -1 ? new List<int>(new int[] { dest_grid_id }) : null;
            //if (waypoints != null)
            //    m_Navigator.Waypoints = waypoints;

            //m_Explorer = new Nav.ExploreEngine.Nearest(m_Navmesh, m_Navigator);
            m_Explorer = explorer;
            if (enableExplorer)
            {
                m_Explorer.Enabled = true;
            }

            m_Speed        = speed;
            m_AngularSpeed = angular_speed;

            SimulateStuck = false;
            Paused        = false;
            m_GotoPosUpdateTimer.Start();
        }
コード例 #3
0
ファイル: NavMeshViewer.cs プロジェクト: kennychou0529/Nav.D3
 protected virtual void CreateNavigation()
 {
     m_Navmesh   = new Nav.Navmesh(false);
     m_Navigator = new Nav.NavigationEngine(m_Navmesh);
     m_Navmesh.RegionsMoveCostMode = Nav.Navmesh.RegionsMode.Mult;
     m_Explorer         = new Nav.ExploreEngine.Nearest(m_Navmesh, m_Navigator);
     m_Explorer.Enabled = false;
 }
コード例 #4
0
ファイル: NavMeshViewer.cs プロジェクト: uzbekdev1/Nav
        public NavMeshViewer(string[] args, Navmesh navmesh = null, NavigationEngine navigator = null, ExplorationEngine explorer = null)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            BackColor = Color.LightGray;

            m_Params = new Params(args);

            m_Navmesh   = navmesh;
            m_Navigator = navigator;
            m_Explorer  = explorer;

            CreateNavigation();
            LoadDebugConfig();

            if (m_Params.HasParam("load"))
            {
                m_Params.GetParam("load", out string file);
                LoadData(file);
            }

            if (m_Params.HasParam("start"))
            {
                m_Params.GetParam("start", out string str);
                m_Navigator.CurrentPos = new Vec3(str);
            }

            if (m_Params.HasParam("end"))
            {
                m_Params.GetParam("end", out string str);
                m_Navigator.Destination = new destination(new Vec3(str));
            }

            if (m_Params.HasParam("load_waypoints"))
            {
                m_Params.GetParam("load_waypoints", out string file);
                LoadWaypoints(file);
            }

            if (m_Params.HasParam("deserialize"))
            {
                m_Params.GetParam("deserialize", out string file);
                m_Navmesh.Deserialize(file);
                m_Navigator.Deserialize(file);
                m_Explorer.Deserialize(file);

                Vec3 initial_pos = m_Navigator.CurrentPos;
                if (initial_pos.IsZero())
                {
                    initial_pos = m_Navmesh.GetCenter();
                }
                m_RenderCenter.X = initial_pos.X;
                m_RenderCenter.Y = initial_pos.Y;
            }

            InitializeComponents();
        }
コード例 #5
0
        protected override void CreateNavigation()
        {
            m_MemoryContext = CreateMemoryContext();

            m_Navmesh   = Nav.D3.Navmesh.Create(m_MemoryContext, true);
            m_Navigator = new Nav.NavigationEngine(m_Navmesh);
            m_Navmesh.RegionsMoveCostMode = Nav.Navmesh.RegionsMode.Mult;
            m_Explorer         = new Nav.ExploreEngine.Nearest(m_Navmesh, m_Navigator);
            m_Explorer.Enabled = false;

            m_AutoClearOnLocationChange = true;
        }
コード例 #6
0
        public ExplorationEngine(Navmesh navmesh, NavigationEngine navigator, int explore_cell_size = 90)
        {
            ExploreCellSize = explore_cell_size;

            m_Navmesh = navmesh;
            m_Navmesh.AddObserver(this);

            m_Navigator = navigator;
            m_Navigator.AddObserver(this);
            m_Navigator.m_RoughtPathEstimator = m_Navigator.m_RoughtPathEstimator ?? this;

            // generate exploration data from already existing grid cells
            Reset();

            UpdatesThread      = new Thread(Updates);
            UpdatesThread.Name = "Explorator-UpdatesThread";
            UpdatesThread.Start();
        }
コード例 #7
0
ファイル: ExplorationEngine.cs プロジェクト: HiPoEGH/Nav
        public ExplorationEngine(Navmesh navmesh, NavigationEngine navigator, int explore_cell_size = 90)
        {
            ExploreCellSize           = explore_cell_size;
            MAX_AREA_TO_MARK_AS_SMALL = 2000;
            ExploreDestPrecision      = 20;

            m_Navmesh = navmesh;
            m_Navmesh.AddObserver(this);

            m_Navigator = navigator;
            m_Navigator.AddObserver(this);

            // generate exploration data from already existing grid cells
            Reset();

            UpdatesThread      = new Thread(Updates);
            UpdatesThread.Name = "Explorator-UpdatesThread";
            UpdatesThread.Start();
        }
コード例 #8
0
ファイル: Navmesh.cs プロジェクト: rol2728/Dev.D3
        public Navmesh(ExplorationEngine explorator = null, bool verbose = false)
        {
            Log("[Nav] Creating navmesh...");

            RegionsMoveCostMode = RegionsMode.Mult;
            RegionsEnabled      = true;

            UpdatesThread      = new Thread(Updates);
            UpdatesThread.Name = "Navmesh-UpdatesThread";
            UpdatesThread.Start();

            Navigator = new NavigationEngine(this);

            if (explorator != null)
            {
                explorator.AttachToNavmesh(this);
                Explorator = explorator;
            }

            Verbose = verbose;

            Log("[Nav] Navmesh created");
        }