导航网格
The Navigation Mesh is a navigation area which is arranged above the surface of an arbitrary mesh. In fact, the Navigation Mesh is an area of the specified height above the mesh polygons, which is available for pathfinding.Navigation Mesh是一个导航区域,它位于任意网格的表面上方。实际上,Navigation Mesh是网格多边形上方指定高度的区域,可用于寻路。
In contrast to navigation sectors, the Navigation Mesh enables the following:与之相反导航部门,Navigation Mesh启用以下功能:
- Only 2D routes can be calculated within the Navigation Mesh.在Navigation Mesh内只能计算2D路线。
Pathfinding can be performed within 1 Navigation Mesh only. Pathfinding within the following areas is not supported:寻路只能在1 Navigation Mesh内执行。不支持以下区域内的寻路:
- Within several intersecting Navigation Meshes在几个相交的Navigation Meshes内
- Within the intersecting Navigation Mesh and sector在相交的Navigation Mesh和扇区内
See also也可以看看#
- The NavigationMesh class to manage navigation meshes via APINavigationMesh类,用于通过API管理导航网格物体
- The article on Creating Routes to learn how to create routes inside the navigation mesh的文章创建路线了解如何在导航网格内创建路线
- A set of samples located in the <UnigineSDK>/data/samples/paths folder:
- mesh_00
- route_03
- mesh_00
- route_03
- Navigation sample in C# Component Samples suite一组 C# Component Samples 例子中的一个 Navigation 例子
Creating Navigation Mesh创建导航网格#
Before adding a Navigation Mesh, you should prepare a mesh, on which this Navigation Mesh will be based. Such mesh is created separately and should meet the following requirements:在添加Navigation Mesh之前,您应该准备一个网格,该Navigation Mesh将基于该网格。此类网格是单独创建的,并且应满足以下要求:
- Any polygon of the mesh must not share its edge with more than 2 other polygons; otherwise, an error will occur.网格的任何多边形不得与2个以上的其他多边形共享其边;否则,将发生错误。
- Mesh polygons should be as wide as possible (ideally, they should be equilateral). Too narrow and high polygons may reduce accuracy of path calculation.网格多边形应尽可能宽(理想情况下,它们应是等边的)。多边形太窄和太高都会降低路径计算的准确性。
- The mesh should be optimized: it should not contain a large number of polygons.网格应该被优化:它不应该包含大量的多边形。
When a mesh is prepared, you can add the Navigation Mesh to the scene via UnigineEditor:准备好网格物体后,可以通过UnigineEditor将Navigation Mesh添加到场景中:
- Run UnigineEditor.跑步UnigineEditor。
On the Menu bar, click Create -> Navigation -> Navigation Mesh.在菜单栏上,单击Create -> Navigation -> Navigation Mesh。
In the file dialog window that opens, choose the required mesh to be used as a base for the new navigation area and click OK.在打开的文件对话框窗口中,选择所需的网格用作新导航区域的基础,然后单击OK。
- Click somewhere in the world to place the Navigation Mesh. A new Navigation Mesh is added to UnigineEditor and you can edit it via the Parameters window.单击世界上的某个地方以放置Navigation Mesh。新的Navigation Mesh已添加到UnigineEditor,您可以通过Parameters窗口进行编辑。
Example例子#
If you have a scene with different objects and need to calculate a 2D route among them, add the Navigation Mesh to this scene as follows:如果您的场景包含不同的对象,并且需要在它们之间计算2D路线,请按如下所示将Navigation Mesh添加到该场景:
Create a flat mesh with holes in places where the objects are positioned.在放置对象的位置创建带有孔的平面网格。
The scene现场The mesh created for the Navigation Mesh为Navigation Mesh创建的网格Specify this mesh as a base for a Navigation Mesh within which the route is calculated, and add the Navigation Mesh to the world. It will be highlighted in green:将这个网格指定为Navigation Mesh的基础(在其中计算路线),然后将Navigation Mesh添加到世界中。它将以绿色突出显示:
A Navigation Mesh based on the flat mesh基于平面网格的Navigation MeshPlace the Navigation Mesh above the scene.将Navigation Mesh放置在场景上方。
The Navigation Mesh positioned above the sceneNavigation Mesh位于场景上方
Editing Navigation Mesh编辑导航网格#
In the Node tab of the Parameters window, you can adjust the following parameters of the Navigation Mesh:在Parameters窗口的Node选项卡中,可以调整Navigation Mesh的以下参数:
Loading a New Mesh加载新的网格#
To load a new mesh on which the navigation area is based:要加载导航区域所基于的新网格,请执行以下操作:
- On the Navigation tab, press .在Navigation选项卡上,按。
- In the file dialog window that opens, choose the required mesh and press OK.在打开的文件对话框窗口中,选择所需的网格,然后按OK。
Saving the Current Mesh保存当前网格#
To save the current mesh on which the navigation area is based:要保存导航区域所基于的当前网格,请执行以下操作:
- On the Navigation tab, press .在Navigation选项卡上,按。
- In the file dialog window that opens, specify a name for the mesh and press OK.在打开的文件对话框窗口中,为网格指定名称,然后按OK。