Exemplo n.º 1
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="copy">The group to copy.</param>
 /// <param name="cloneFilter">
 /// If true, the filter will be cloned. Otherwise it will be referenced.
 /// </param>
 public NavGroup(NavGroup copy, bool cloneFilter)
 {
     this.mesh    = copy.mesh;
     this.query   = copy.query;
     this.crowd   = copy.crowd;
     this.filter  = (cloneFilter ? copy.filter.Clone() : copy.filter);
     this.extents = copy.extents;
 }
Exemplo n.º 2
0
 void OnDestroy()
 {
     if (m_DefaultFilter != null)
     {
         m_DefaultFilter.RequestDisposal();
         m_DefaultFilter = null;
     }
     Clear();
     m_Map = null;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="mesh">The navigation mesh used by the query.</param>
 /// <param name="query">A navigation mesh query.</param>
 /// <param name="crowd">A crowd.</param>
 /// <param name="filter">The filter to use with the query.</param>
 /// <param name="extents">The extents to use with the query.</param>
 /// <param name="cloneFilter">
 /// If true, the filter will be cloned rather than referenced.
 /// </param>
 public NavGroup(Navmesh mesh, NavmeshQuery query, CrowdManager crowd
                 , NavmeshQueryFilter filter, Vector3 extents
                 , bool cloneFilter)
 {
     this.mesh    = mesh;
     this.query   = query;
     this.crowd   = crowd;
     this.filter  = (cloneFilter ? filter.Clone() : filter);
     this.extents = extents;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="mesh">The navigation mesh used by the query.</param>
 /// <param name="query">A navigation mesh query.</param>
 /// <param name="crowd">A crowd.</param>
 /// <param name="filter">The filter to use with the query.</param>
 /// <param name="extents">The extents to use with the query.</param>
 /// <param name="cloneFilter">
 /// If true, the filter will be cloned rather than referenced.
 /// </param>
 public NavGroup(Navmesh mesh, NavmeshQuery query, CrowdManager crowd
     , NavmeshQueryFilter filter, Vector3 extents
     , bool cloneFilter)
 {
     this.mesh = mesh;
     this.query = query;
     this.crowd = crowd;
     this.filter = (cloneFilter ? filter.Clone() : filter);
     this.extents = extents;
 }
Exemplo n.º 5
0
        public Pathfinder(Navmesh navMesh)
        {
            _navMesh = navMesh;
            _filter  = new NavmeshQueryFilter();

            if (NavUtil.Failed(NavmeshQuery.Create(_navMesh, 1000, out _query)))
            {
                throw new Exception("NavQuery failed");
            }

            _pathCorridor = new PathCorridor(1000, 1000, _query, _filter);
        }
Exemplo n.º 6
0
        public PathBuffer _FindPath(Vector3 start, Vector3 end, Vector3 extends, NavmeshQueryFilter filter = null)
        {
            var query = this.Query;

            if (query == null)
            {
                return(null);
            }
            if (filter == null)
            {
                filter = this.DefaultQueryFilter;
            }
            NavmeshPoint startPoint;
            var          status = query.GetNearestPoint(start, extends, filter, out startPoint);

            if (NavUtil.Failed(status))
            {
                return(null);
            }
            NavmeshPoint endPoint;

            status = query.GetNearestPoint(end, extends, filter, out endPoint);
            if (NavUtil.Failed(status))
            {
                return(null);
            }

            PathBuffer pathBuf = GetPathBuffer();

            if (pathBuf == null || pathBuf.Buffer == null)
            {
                return(null);
            }
            try
            {
                int dataCount;
                status = query.FindPath(ref startPoint, ref endPoint, extends, filter, pathBuf.Buffer, out dataCount);
                if (NavUtil.Failed(status))
                {
                    return(null);
                }

                pathBuf.SetDataCount(dataCount);

                return(pathBuf);
            } catch
            {
                StorePathBuffer(pathBuf);
            }
            return(null);
        }
Exemplo n.º 7
0
        //从池子里面获取通道,如果没有就需要建立一个(目前都是在NavAgent里面处理的)
        public PathCorridor GetCorridor(NavmeshPoint position, NavmeshQuery query, NavmeshQueryFilter filter)
        {
            if (mCorridors.Count > 0)
            {
                PathCorridor corr = mCorridors.Pop();

                if (PathCorridor.LoadLocals(corr, position, query, filter))
                {
                    return(corr);
                }

                return(null);
            }
            return(new PathCorridor(mMaxPathSize, mMaxStraightPathSize, query, filter));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="copy">The group to copy.</param>
 /// <param name="cloneFilter">
 /// If true, the filter will be cloned. Otherwise it will be referenced.
 /// </param>
 public NavGroup(NavGroup copy, bool cloneFilter)
 {
     this.mesh = copy.mesh;
     this.query = copy.query;
     this.crowd = copy.crowd;
     this.filter = (cloneFilter ? copy.filter.Clone() : copy.filter);
     this.extents = copy.extents;
 }
        public void createScene()
        {
            // set background and some fog
            AdvancedMogreFramework.Singleton.m_pViewport.BackgroundColour = new ColourValue(1.0f, 1.0f, 0.8f);
            m_pSceneMgr.SetFog(FogMode.FOG_LINEAR, new ColourValue(1.0f, 1.0f, 0.8f), 0, 15, 100);

            // set shadow properties
            m_pSceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE;
            m_pSceneMgr.ShadowColour    = new ColourValue(0.5f, 0.5f, 0.5f);
            m_pSceneMgr.SetShadowTextureSize(1024);
            m_pSceneMgr.ShadowTextureCount = 1;

            // disable default camera control so the character can do its own
            m_pCameraMan.setStyle(CameraStyle.CS_MANUAL);
            // use a small amount of ambient lighting
            m_pSceneMgr.AmbientLight = new ColourValue(0.3f, 0.3f, 0.3f);

            // add a bright light above the scene
            Light light = m_pSceneMgr.CreateLight();

            light.Type           = (Light.LightTypes.LT_POINT);
            light.Position       = new Mogre.Vector3(-10, 40, 20);
            light.SpecularColour = ColourValue.White;

            // create a floor mesh resource
            MeshManager.Singleton.CreatePlane("floor", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                                              new Plane(Mogre.Vector3.UNIT_Y, 0), 100, 100, 10, 10, true, 1, 10, 10, Mogre.Vector3.UNIT_Z);

            // create a floor entity, give it a material, and place it at the origin
            SceneProp floorSceneProp = new SceneProp(
                this,
                m_pSceneMgr,
                m_pSceneMgr.RootSceneNode,
                physicsScene,
                "Floor",
                "floor"
                );

            floorSceneProp.SetMaterialName("Examples/Rockwall");

            //Navmesh
            Navmesh      floorNavMesh = MeshToNavmesh.LoadNavmesh(floorSceneProp.Entity);
            NavmeshQuery query;
            NavmeshPoint retStartPoint;
            NavmeshPoint retEndPoint;

            org.critterai.Vector3 pointStart = new org.critterai.Vector3(0, 0, 0);
            org.critterai.Vector3 pointEnd   = new org.critterai.Vector3(0, 0, 0);
            org.critterai.Vector3 extents    = new org.critterai.Vector3(2, 2, 2);

            NavStatus status = NavmeshQuery.Create(floorNavMesh, 100, out query);

            Console.WriteLine("Status returned when NavmeshQuery was built: " + status);

            NavmeshQueryFilter filter = new NavmeshQueryFilter();

            filter.IncludeFlags = 1;

            status = query.GetNearestPoint(pointStart, extents, filter, out retStartPoint);
            Console.WriteLine("\nStatus of startPoint GetNearestPoint: " + status);
            status = query.GetNearestPoint(pointEnd, extents, filter, out retEndPoint);
            Console.WriteLine("\nStatus of endPoint GetNearestPoint: " + status);

            uint[] path = new uint[100];
            int    pathCount;

            status = query.FindPath(retStartPoint, retEndPoint, filter, path, out pathCount);
            Console.WriteLine("\nStatus of Find path: " + status);

            // create our character controller
            m_pChara = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(0, 5, 0), 0);
            SinbadCharacterController bot1 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(-10, 5, 0), 1, false);
            SinbadCharacterController bot2 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(0, 5, -10), 2, false);
            SinbadCharacterController bot3 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(10, 5, 0), 3, false);

            agents.Add(m_pChara);
            agents.Add(bot1);
            agents.Add(bot2);
            agents.Add(bot3);

            AdvancedMogreFramework.Singleton.m_pTrayMgr.toggleAdvancedFrameStats();

            StringVector items = new StringVector();

            items.Insert(items.Count, "Help");
            ParamsPanel help = AdvancedMogreFramework.Singleton.m_pTrayMgr.createParamsPanel(TrayLocation.TL_TOPLEFT, "HelpMessage", 100, items);

            help.setParamValue("Help", "H / F1");
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets a standard corridor from the pool. (Or creates one if none is available.)
        /// </summary>
        /// <remarks>
        /// <para>
        /// The corridor maximum path will equal <see cref="MaxPathSize"/>, and maximum corners 
        /// will equal <see cref="MaxStraightPathSize"/> .
        /// </para>
        /// </remarks>
        /// <param name="query">The query to assign to the corridor.</param>
        /// <param name="filter">The filter to assign to the corridor.</param>
        /// <returns>A standard corridor, or null on error.</returns>
        public PathCorridor GetCorridor(NavmeshPoint position, NavmeshQuery query, NavmeshQueryFilter filter)
        {
            if (mCorridors.Count > 0)
            {
                PathCorridor corr = mCorridors.Pop();

                if (PathCorridor.LoadLocals(corr, position, query, filter))
                    return corr;

                return null;
            }
            return new PathCorridor(mMaxPathSize, mMaxStraightPathSize, query, filter);
        }
Exemplo n.º 11
0
 public static PathBuffer FindPath(Vector3 start, Vector3 end, Vector3 extends, NavmeshQueryFilter filter = null)
 {
     if (m_Map == null)
     {
         return(null);
     }
     return(m_Map._FindPath(start, end, extends, filter));
 }
Exemplo n.º 12
0
        protected bool _GetGroudPt(Vector3 source, Vector3 extends, out Vector3 result, NavmeshQueryFilter filter = null)
        {
            result = source;
            var query = this.Query;

            if (query == null)
            {
                return(false);
            }
            NavmeshPoint navPoint;

            if (filter == null)
            {
                filter = this.DefaultQueryFilter;
            }
            var status = query.GetNearestPoint(source, extends, filter, out navPoint);

            if (NavUtil.Failed(status))
            {
                return(false);
            }
            result = navPoint.point;
            return(true);
        }
Exemplo n.º 13
0
        public static bool GetNavmeshPoint(Vector3 source, Vector3 extends, out NavmeshPoint point, NavmeshQueryFilter filter = null)
        {
            point = new NavmeshPoint();
            if (m_Map == null)
            {
                return(false);
            }
            var query = m_Map.Query;

            if (query == null)
            {
                return(false);
            }
            if (filter == null)
            {
                filter = m_Map.DefaultQueryFilter;
            }
            var status = query.GetNearestPoint(source, extends, filter, out point);

            if (NavUtil.Failed(status))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
 public static bool GetGroudPt(Vector3 source, Vector3 extends, out Vector3 result, NavmeshQueryFilter filter = null)
 {
     result = source;
     if (m_Map == null)
     {
         return(false);
     }
     return(m_Map._GetGroudPt(source, extends, out result, filter));
 }
Exemplo n.º 15
0
        public static PathCorridor CreateAgent(int maxPathSize = 10, int maxCorners = 10, NavmeshQueryFilter filter = null)
        {
            if (m_Map == null)
            {
                return(null);
            }
            if (filter == null)
            {
                filter = m_Map.DefaultQueryFilter;
            }
            PathCorridor ret = new PathCorridor(maxPathSize, maxCorners, m_Map.Query, filter);

            return(ret);
        }