• <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上每個多邊形中心之間的連線一般不會是直線,路徑如果有拐角也會造成一些美觀上的問題,這個時候需要使用特定的方法將路徑變得盡量筆直,就好像將一根繩子拉直。
            2021国内久久精品| 久久精品国产第一区二区三区| 91精品国产高清久久久久久io| 99国产欧美精品久久久蜜芽| 久久亚洲欧美日本精品| 国产精品伊人久久伊人电影 | 亚洲国产精久久久久久久| 久久亚洲高清观看| 国产精品99久久久久久宅男小说| 亚洲va久久久噜噜噜久久男同| 国产精品毛片久久久久久久| 久久嫩草影院免费看夜色| 亚洲国产精品无码久久一区二区| 久久久精品免费国产四虎| 亚洲欧美久久久久9999| 久久精品国产一区| 久久精品国产99国产精品导航| 久久国产成人精品麻豆| 热99RE久久精品这里都是精品免费 | 国产精品VIDEOSSEX久久发布| 亚洲天堂久久久| 99久久精品免费看国产| 亚洲女久久久噜噜噜熟女| 久久国产精品免费一区| A狠狠久久蜜臀婷色中文网| 色妞色综合久久夜夜| 久久亚洲2019中文字幕| 亚洲精品国产成人99久久| 日韩AV无码久久一区二区 | 中文字幕无码久久人妻| 99久久国产亚洲高清观看2024 | 99久久中文字幕| 久久久亚洲裙底偷窥综合| 久久久久综合国产欧美一区二区| 久久99精品国产麻豆宅宅| 性做久久久久久久| 伊人久久精品无码av一区| 成人午夜精品无码区久久| 久久只有这精品99| 久久伊人亚洲AV无码网站| 欧美一级久久久久久久大片|