• <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í)候需要使用特定的方法將路徑變得盡量筆直,就好像將一根繩子拉直。
            亚洲婷婷国产精品电影人久久| 一本色综合网久久| 久久久久久A亚洲欧洲AV冫| 国产精品成人99久久久久 | 亚洲国产成人精品女人久久久 | 久久99国产综合精品| 欧美黑人又粗又大久久久| 欧美日韩精品久久久免费观看| 亚洲中文字幕伊人久久无码 | 超级97碰碰碰碰久久久久最新| 国产精品嫩草影院久久| 久久国产综合精品五月天| 久久水蜜桃亚洲av无码精品麻豆 | 国产精品99久久久久久宅男小说| 久久婷婷国产剧情内射白浆| 成人久久久观看免费毛片| 精品久久久久久中文字幕大豆网| 久久精品国产久精国产| 国产精品对白刺激久久久| 国产精品久久久久久久久久影院| 久久久久无码专区亚洲av| 久久99精品久久久久久久不卡 | 久久久精品午夜免费不卡| 久久亚洲私人国产精品| 国产婷婷成人久久Av免费高清| 国产精品久久久久久久app| 久久久久免费精品国产| 色综合久久久久综合体桃花网 | 国产精品99精品久久免费| 无码专区久久综合久中文字幕 | 婷婷久久久亚洲欧洲日产国码AV| 香蕉久久夜色精品国产2020 | 久久丫精品国产亚洲av不卡| 91精品国产9l久久久久| yy6080久久| 久久99国产精品二区不卡| 久久综合色区| 国产精品久久国产精麻豆99网站| 国产精品一区二区久久精品无码 | 午夜精品久久久久久中宇| 国产69精品久久久久99|