• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            翻譯: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查詢器)打交道的次數比Navmes本身多的多。網格包含數據,但是查詢器提供了幾乎全部的尋路特性。



            Core Class: NavmeshQuery
            核心類:NavmeshQuery


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


            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.)
            尋路使用標準的A*和Dijkstra算法,用于找出兩點之間最好的路徑(可能不止一條)。Path(路徑)是由一組Polygon的引用(1)組成數據,從開始點到結束點。路徑矯正是將一個Path數據轉為一組路點數據(即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.
            局部搜索功能提供多種方式進行多邊形和多邊形上的點的定位,以及查詢局部的一些環境信息。比如射線查詢、計算離最近的墻的距離之類的。


            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.
            許多查詢方法要求一個NavmeshQueryFilter(查詢過濾器)。過濾器定義了Polygon和off-mesh connections的穿越代價,代價值可以參與啟發式的計算,用來決定是否在最終路徑里包含/排除某個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.
            理解查詢器的最好辦法就是用一用?!維ample 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)
            本節是例子
            查詢一個在Navmesh上的點
            如果你沒有一個Navmesh上的起始點的話,你能做的不多。所以第一部就是找一個點。
            GetNearestPoint(Vector3, Vector3, NavmeshQueryFilter, NavmeshPoint)函數提供此功能。


            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'是一個 NavmeshQuery對象,'filter'是一個NavmeshQueryFilter對象。
            // 'position' 是一個Vector3對象,值為角色的世界坐標。


            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.
                    // 錯誤處理。找不到結果。
                    // 可以檢查狀態看看是什么問題。如果沒有問題,說明指定范圍里不包含多邊形。
            }


            // Use the result point, which includes a vector point and the reference of 
            // the polygon that contains the point.
            //使用結果點。包括一個Vector3的點和包含這個點的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.
            基礎的尋徑
            即使你打算使用pathcorridor或crowdmanager,你也會需要NavmeshQuery的功能來完成一些長距離路徑規劃。第一,獲取一條路徑,然后選擇性的弄直它(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'是一個 NavmeshQuery對象,'filter'是一個NavmeshQueryFilter對象;
            // 'start' 和 'end' 是已知的在Navmesh上的點;


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


            if (start.polyRef == end.polyRef)
            {
                    // No need to do any planning.
                    // 開始點和結束點在同一個多邊形內,不需要進行路徑規劃;
                    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.)
                        // 處理只有一部分路徑的情況;
                        // 可能是結束點不可達;
                        // 或者路徑的buffer長度太小,裝不下整條路徑;
                        // 如果是buffer太小,可以檢查state;
                    }


            }


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


            const int MaxStraightPath = 4;  // Just getting the first 4 waypoints. // 只處理前4個路點;
            int wpCount;


            // The waypoints.
            // 路點列表;
            Vector3[] wpPoints = new Vecotr3[MaxStraightPath];


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


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


            status = query.GetStraightPath(start.point
                    , goal.point
                    , path
                    , 0                // The index of the start of the path. // 路徑的開始點;
                    , pathCount        // The length of the path.             // 路徑的長度;
                    , 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,
                    // 處理失敗。應該總是存在一個點(目標點)用于路徑合并.
            }


            // Use the path and waypoints.
            // 使用路徑和路點;


            (1)可以理解為句柄,或索引。
            (2)Path上每個多邊形中心之間的連線一般不會是直線,路徑如果有拐角也會造成一些美觀上的問題,這個時候需要使用特定的方法將路徑變得盡量筆直,就好像將一根繩子拉直。
            日韩欧美亚洲综合久久| 99久久国产综合精品五月天喷水| 欧美粉嫩小泬久久久久久久 | 狠狠色综合网站久久久久久久| 久久青草国产精品一区| 国产999精品久久久久久| 亚洲精品国产第一综合99久久| 久久人人爽爽爽人久久久| 狠狠色丁香婷婷综合久久来| 久久亚洲欧洲国产综合| 亚洲午夜久久久影院伊人| 久久久中文字幕| 色狠狠久久AV五月综合| 久久久久国产精品麻豆AR影院| 人妻无码αv中文字幕久久 | 久久久久亚洲AV无码麻豆| 久久综合狠狠综合久久激情 | 影音先锋女人AV鲁色资源网久久| 久久精品无码一区二区三区日韩| 奇米影视7777久久精品| 亚洲欧洲精品成人久久奇米网| 久久精品国产亚洲综合色| 久久久久久久女国产乱让韩| 久久成人18免费网站| 久久线看观看精品香蕉国产| 亚洲人成伊人成综合网久久久| 久久综合九色综合欧美就去吻| 日本一区精品久久久久影院| 72种姿势欧美久久久久大黄蕉| 国产成人无码精品久久久性色| 久久午夜无码鲁丝片秋霞 | 人妻丰满?V无码久久不卡| 日本一区精品久久久久影院| 久久精品国产99国产精品澳门| 久久久久人妻一区二区三区vr | 免费精品国产日韩热久久| 一本伊大人香蕉久久网手机| 久久精品国产只有精品2020| 蜜桃麻豆www久久| 久久九九免费高清视频| 久久久久国色AV免费观看|