• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 311, comments - 0, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            翻譯:kun 2014.12.4

            The navigation mesh query is the most important class to understand since most navigation clients will interact with the query rather than the navigation mesh itself. The mesh contains the data, but the query provides almost all of the features necessary for pathfinding.
            用戶和navigation mesh query(Navmesh查詢器)打交道的次數(shù)比Navmes本身多的多。網(wǎng)格包含數(shù)據(jù),但是查詢器提供了幾乎全部的尋路特性。



            Core Class: NavmeshQuery
            核心類:NavmeshQuery


            Query features fall into two general categories: Pathfinding and local search.
            查詢器的特性包括兩個(gè)大的方面:尋路和局部搜索。


            Pathfinding involves standard A* and Dijkstra searches that find the best path(s) between two points. Paths are made up of a list polygon references that represent a polygon corridor from the start to the end position. Path straightening is used to convert the path into a list of waypoints. (I.e. String pulling.)
            尋路使用標(biāo)準(zhǔn)的A*和Dijkstra算法,用于找出兩點(diǎn)之間最好的路徑(可能不止一條)。Path(路徑)是由一組Polygon的引用(1)組成數(shù)據(jù),從開始點(diǎn)到結(jié)束點(diǎn)。路徑矯正是將一個(gè)Path數(shù)據(jù)轉(zhuǎn)為一組路點(diǎn)數(shù)據(jù)(即String pulling(繩子拉直))(2)。


            The local search features offer various methods for locating polygons and points on polygons, and for querying the local environment. I.e. Raycasting, finding the distance to the nearest wall, etc.
            局部搜索功能提供多種方式進(jìn)行多邊形和多邊形上的點(diǎn)的定位,以及查詢局部的一些環(huán)境信息。比如射線查詢、計(jì)算離最近的墻的距離之類的。


            Many of the query methods require a NavmeshQueryFilter. Filters define area traversal costs as well as flags used for including/excluding polygons and off-mesh connections from results.
            許多查詢方法要求一個(gè)NavmeshQueryFilter(查詢過濾器)。過濾器定義了Polygon和off-mesh connections的穿越代價(jià),代價(jià)值可以參與啟發(fā)式的計(jì)算,用來決定是否在最終路徑里包含/排除某個(gè)Polygon或off-mesh connections。


            The best way to understand the query class is to play around with it. The Sample Pack includes the Query Explorer demo that permits experimentation with all of the main query features.
            理解查詢器的最好辦法就是用一用。【Sample Pack(示例包)】里的【Query Explorer(查詢演示)】demo展示了查詢器一些主要的特性。


            Common Operations
            通用操作


            This section contains some simple examples of common query operations.
            Finding a Point in the Navigation Mesh
            You can't do much without first getting a valid point on the navigation mesh. So the first step is to find one.
            GetNearestPoint(Vector3, Vector3, NavmeshQueryFilter, NavmeshPoint)
            本節(jié)是例子
            查詢一個(gè)在Navmesh上的點(diǎn)
            如果你沒有一個(gè)Navmesh上的起始點(diǎn)的話,你能做的不多。所以第一部就是找一個(gè)點(diǎn)。
            GetNearestPoint(Vector3, Vector3, NavmeshQueryFilter, NavmeshPoint)函數(shù)提供此功能。


            CopyC#
            // Where 'query' is a NavmeshQuery object and 'filter' is a NavmeshQueryFilter object.
            // 'position' is a Vector3 indicating the world position of the client.
            // 'query'是一個(gè) NavmeshQuery對(duì)象,'filter'是一個(gè)NavmeshQueryFilter對(duì)象。
            // 'position' 是一個(gè)Vector3對(duì)象,值為角色的世界坐標(biāo)。


            NavmeshPoint result;
            Vector3 extents = new Vector3(1, 1, 1);  // Keep this to the minimum extents practical. // 范圍越小越好。


            NavStatus status = query.GetNearestPoly(position, extents, filter
                    , out result);


            if (result.polyRef == Navmesh.NullPoly)
            {
                    // Handle error.  Could not find a result.
                    // The status can be checked to see if there was an error.  If not, then
                    // the cause is that the search extents did not overlap any polygons.
                    // 錯(cuò)誤處理。找不到結(jié)果。
                    // 可以檢查狀態(tài)看看是什么問題。如果沒有問題,說明指定范圍里不包含多邊形。
            }


            // Use the result point, which includes a vector point and the reference of 
            // the polygon that contains the point.
            //使用結(jié)果點(diǎn)。包括一個(gè)Vector3的點(diǎn)和包含這個(gè)點(diǎn)的Polygon的引用。


            Basic Pathfinding
            Even if you are planning to use PathCorridor or CrowdManager, you'll always need to do long distance planning using the basic NavmeshQuery features. First, get a path, then optionally straighten it.
            基礎(chǔ)的尋徑
            即使你打算使用pathcorridor或crowdmanager,你也會(huì)需要NavmeshQuery的功能來完成一些長(zhǎng)距離路徑規(guī)劃。第一,獲取一條路徑,然后選擇性的弄直它(3)。


            CopyC#
            // Where 'query' is a NavmeshQuery object and 'filter' is a NavmeshQueryFilter object.
            // 'start' and 'end' are NavmeshPoints known to be on the navigation mesh.
            // 'query'是一個(gè) NavmeshQuery對(duì)象,'filter'是一個(gè)NavmeshQueryFilter對(duì)象;
            // 'start' 和 'end' 是已知的在Navmesh上的點(diǎn);


            int pathCount;
            // The path will be a list of polygon references.
            // path是一組polygon的引用;
            uint[] path = new uint[100];  // Size for maximum allowed path length. // 路徑的最大長(zhǎng)度;
            NavStatus status;


            if (start.polyRef == end.polyRef)
            {
                    // No need to do any planning.
                    // 開始點(diǎn)和結(jié)束點(diǎn)在同一個(gè)多邊形內(nèi),不需要進(jìn)行路徑規(guī)劃;
                    pathCount = 1;
                    path[0] = start.polyRef;
            }
            else
            {
                    status = query.FindPath(start, end, filter, path
                            , out pathCount);


                    if (NavUtil.Failed(status) || path.pathCount == 0)
                    {
                            // Handle pathfinding failure.
                            // 處理尋路失敗;
                    }
                    else if (end.polyRef != path[pathCount - 1])
                    {
                        // Handle a partial path.
                        // The query either could not reach the end point,
                        // or the path buffer was too small to hold the
                        // entire path.  (A check of 'status' will reveal if
                        // the buffer was too small.)
                        // 處理只有一部分路徑的情況;
                        // 可能是結(jié)束點(diǎn)不可達(dá);
                        // 或者路徑的buffer長(zhǎng)度太小,裝不下整條路徑;
                        // 如果是buffer太小,可以檢查state;
                    }


            }


            // If you need to straighten the path...
            // 如果你需要拉直路徑;


            const int MaxStraightPath = 4;  // Just getting the first 4 waypoints. // 只處理前4個(gè)路點(diǎn);
            int wpCount;


            // The waypoints.
            // 路點(diǎn)列表;
            Vector3[] wpPoints = new Vecotr3[MaxStraightPath];


            // A list of polygon references.  (The polygon being entered at each waypoint.)
            // 一個(gè)多邊形引用列表;(路點(diǎn)是多邊形的入口點(diǎn))
            uint[] wpPath = new uint[MaxStraightPath];


            // The type of each waypoint. (Start, end, off-mesh connection.)
            // 每一個(gè)路點(diǎn)的類型信息.(開始點(diǎn),結(jié)束點(diǎn), 連接);
            WaypointFlag[] wpFlags = new WaypointFlag[MaxStraightPath];


            status = query.GetStraightPath(start.point
                    , goal.point
                    , path
                    , 0                // The index of the start of the path. // 路徑的開始點(diǎn);
                    , pathCount        // The length of the path.             // 路徑的長(zhǎng)度;
                    , wpPoints
                    , wpFlags
                    , wpPath
                    , out wpCount);


            if (NavUtil.Failed(status) || wpCount == 0)
            {
                    // Handle the failure.  There should always be at least one waypoint 
                    // (the goal) for a valid point/path combination,
                    // 處理失敗。應(yīng)該總是存在一個(gè)點(diǎn)(目標(biāo)點(diǎn))用于路徑合并.
            }


            // Use the path and waypoints.
            // 使用路徑和路點(diǎn);


            (1)可以理解為句柄,或索引。
            (2)Path上每個(gè)多邊形中心之間的連線一般不會(huì)是直線,路徑如果有拐角也會(huì)造成一些美觀上的問題,這個(gè)時(shí)候需要使用特定的方法將路徑變得盡量筆直,就好像將一根繩子拉直。
            久久人爽人人爽人人片AV | 欧美午夜精品久久久久久浪潮| 久久人爽人人爽人人片AV| 国内精品伊人久久久久av一坑| 国产亚洲欧美精品久久久| 麻豆精品久久精品色综合| 欧美久久一区二区三区| 日产精品久久久一区二区| 青青青国产精品国产精品久久久久| 无码任你躁久久久久久久| 伊人久久综合成人网| 狠狠色伊人久久精品综合网| 2021国内久久精品| AAA级久久久精品无码区| 国产aⅴ激情无码久久| 伊人色综合久久天天| 无码人妻久久久一区二区三区| 色综合久久中文色婷婷| 久久无码人妻一区二区三区| 久久精品亚洲乱码伦伦中文| .精品久久久麻豆国产精品| 欧美国产成人久久精品| 久久国产成人亚洲精品影院| 国产精品毛片久久久久久久| 国产69精品久久久久9999APGF | 久久久久久久久无码精品亚洲日韩| 久久成人18免费网站| 狠狠色丁香婷婷综合久久来| 日韩精品久久久肉伦网站| 久久久久久精品无码人妻| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久成人国产精品| 精品久久久一二三区| 天堂无码久久综合东京热| 久久久久久青草大香综合精品| 久久精品这里热有精品| 97久久天天综合色天天综合色hd| 99久久99久久精品国产片果冻| 国产69精品久久久久9999APGF| 97久久婷婷五月综合色d啪蜜芽| 亚洲国产成人久久一区久久|