This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
gamedev:navigation [2011/07/21 20:17] – created dragonlord | gamedev:navigation [2014/06/21 23:36] – [Exporting] dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP youarehere> | ||
+ | [[: | ||
+ | </ | ||
+ | |||
====== Navigation System ====== | ====== Navigation System ====== | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en>{{ : |
- | The navigation system provides the game with the necessary tools to choose a path through the game world. Often this is simply called | + | The navigation system provides the game with the necessary tools to choose a path through the game world. Often this is simply called |
===== Layering ===== | ===== Layering ===== | ||
- | All of these classes share a common property, the „Layer“ | + | All of these classes share a common property, the **layer |
<WRAP clear></ | <WRAP clear></ | ||
===== Cost System ===== | ===== Cost System ===== | ||
- | One particular strength of path finding algorithms is the ability to alter the path chosen through the game world using cost functions. This allows the AI to choose a path more intelligently. In the Drag[en]gine the cost system works using a Type System. Each type is an Integer value describing a particular cost function to be used whenever the AI wants to venture along a certain part of the game world. To allow simple usage of cost functions navigation spaces provide for individual space elements a „Type Number“. You are free to choose the type numbers the way it fits your game. You can also reuse the „Type Number“ | + | One particular strength of path finding algorithms is the ability to alter the path chosen through the game world using cost functions. This allows the AI to choose a path more intelligently. In the Drag[en]gine the cost system works using a **Type System**. Each type is an Integer value describing a particular cost function to be used whenever the AI wants to venture along a certain part of the game world. To allow simple usage of cost functions navigation spaces provide for individual space elements a **type number**. You are free to choose the type numbers the way it fits your game. You can also reuse the type number |
===== Module Support ===== | ===== Module Support ===== | ||
- | The AI Module provides support to solve the navigation problems using this system. | + | The **AI Module** provides support to solve the navigation problems using this system. |
- | ===== Navigation Spaces ===== | + | ====== Navigation Spaces |
- | Navigation problems alway take place in one or more navigation spaces depending on the need of the game. There exist different kinds of navigation spaces that can be used each of them having different properties. These are navigation grids, meshes and volumes. The „Navigation Space“ class is an allrounder | + | Navigation problems alway take place in one or more navigation spaces depending on the need of the game. There exist different kinds of navigation spaces that can be used each of them having different properties. These are **navigation grids**, **navigation |
- | The „Layer“ | + | The **layer |
- | To define types just assign the matching | + | To define types just assign the matching |
- | Navigation spaces are considered to be static in respect to their content. It is allowed to change the layout of a navigation space at runtime but the performance could suffer. The position and orientation of a navigation space though is allowed to change. This allows to simulate dynamic navigation spaces like for example a connected set of moving platforms. There the layout of the platforms itself does not alter but the location of the entire group of platforms does. Due to the static nature the elements in a navigation space are defined as continuous arrays. Hence you do not add elements to the navigation space but you set first the total number of elements you want to use and then you set each element in turn. If you have to change the layout of a navigation space you have to call the „Notify Layout Changed“ to tell the AI Module that you finished changing the layout of the navigation space. | + | Navigation spaces are considered to be static in respect to their content. It is allowed to change the layout of a navigation space at runtime but the performance could suffer. The position and orientation of a navigation space though is allowed to change. This allows to simulate dynamic navigation spaces like for example a connected set of moving platforms. There the layout of the platforms itself does not alter but the location of the entire group of platforms does. Due to the static nature the elements in a navigation space are defined as continuous arrays. Hence you do not add elements to the navigation space but you set first the total number of elements you want to use and then you set each element in turn. If you have to change the layout of a navigation space you have to call the **Notify Layout Changed** to tell the AI Module that you finished changing the layout of the navigation space. |
- | ==== Navigation Grid ==== | + | ===== Navigation Grid ===== |
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en> |
- | Navigation grids are useful for navigation problems where an exact and smooth path is not required. This is usually used for coarse grained navigation typically not directly linked to a visible world or checker board type navigation. In this navigation space vertices are the nodes and edges are the connections between nodes. For a valid navigation grid vertices and edges have to be defined. All other elements are ignored. A vertex has only a position. An edge has Integer indices of the two vertices it connects as well as two type numbers. The first type number is used if the edge is crossed from the first vertex towards the second. The second type number is used if the edge is crossed in the other direction. This allows for different costs depending in what direction an edge is crossed. | + | {{ : |
+ | <WRAP centeralign> | ||
+ | </ | ||
+ | Navigation grids are useful for navigation problems where an exact and smooth path is not required. This is usually used for coarse grained navigation typically not directly linked to a visible world or checker board type navigation. In this navigation space vertices are the nodes and edges are the connections between nodes. | ||
+ | |||
+ | For a valid navigation grid **vertices** and **edges** have to be defined. All other elements are ignored. A **vertex** has only a position. An **edge** has Integer indices of the two vertices it connects as well as two type numbers. The first type number is used if the edge is crossed from the first vertex towards the second. The second type number is used if the edge is crossed in the other direction. This allows for different costs depending in what direction an edge is crossed. | ||
<WRAP clear></ | <WRAP clear></ | ||
- | ==== Navigation Mesh ==== | + | ===== Navigation Mesh ===== |
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en> |
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
Navigation meshes are useful for all kinds of navigation problems in detailed scene geometry where a smooth path around the world is desired. This is the typical space used for AI navigation of visible game actors. Most of the time you want to use this type of navigation space. In this navigation space faces are the nodes and edges the connections between them. In contrary to the navigation grid the connection is located at the edges of the face hence you do not travel along them but simply cross them. | Navigation meshes are useful for all kinds of navigation problems in detailed scene geometry where a smooth path around the world is desired. This is the typical space used for AI navigation of visible game actors. Most of the time you want to use this type of navigation space. In this navigation space faces are the nodes and edges the connections between them. In contrary to the navigation grid the connection is located at the edges of the face hence you do not travel along them but simply cross them. | ||
- | For a valid navigation mesh vertices, corners and faces have to be defined. All other elements are ignored. Vertices behave the same as in the case of navigation grids. Corners are the vertices used in the faces and are stored as a list of Integer indices together with a type number. The edges of the faces are not explicitely | + | For a valid navigation mesh **vertices**, **corners** and **faces** have to be defined. All other elements are ignored. |
<WRAP clear></ | <WRAP clear></ | ||
- | ==== Navigation | + | ===== Navigation |
Navigation volumes are useful for all navigation problems that navigation meshes can not accurately represent anymore. These are typically situations where the movement of actors is not limited to moving on the ground with jumping or hovering but where they can roam around three dimensions freely. A good example for this is Descent where the AI roams around in 0-gravity inside a large cavern complex. Here navigation volumes provide the same smooth path finding around the game world as does the navigation mesh just in three dimensions. In this navigation space rooms are the nodes and faces are the connections between them. Here too the rooms are directly connected to each other using faces similar to navigation meshes. | Navigation volumes are useful for all navigation problems that navigation meshes can not accurately represent anymore. These are typically situations where the movement of actors is not limited to moving on the ground with jumping or hovering but where they can roam around three dimensions freely. A good example for this is Descent where the AI roams around in 0-gravity inside a large cavern complex. Here navigation volumes provide the same smooth path finding around the game world as does the navigation mesh just in three dimensions. In this navigation space rooms are the nodes and faces are the connections between them. Here too the rooms are directly connected to each other using faces similar to navigation meshes. | ||
- | For a valid navigation volume vertices, corners, faces, walls and rooms have to be defined. Vertices, corners and faces work the same as with navigation meshes except that the type numbers of corners and faces have no meaning. Walls are the indices of faces used in the rooms and are stored as a list of face indices including a type number. The system works the same as with corners hence the type number is used of the room is left along the matching face. Here too different cost functions can be defined depending in which direction the face is crossed. | + | For a valid navigation volume |
- | ===== Navigators | + | ===== Parameter Summary |
- | < | + | < |
- | While the navigation spaces define the space in which navigation takes pace it is the navigators that determine which path to choose across such a space. Navigators are also also allrounders and can thus be used on all kinds of navigation spaces. To use a navigator you have to first set the „Layer“ and the „Space Type“. The navigator is going to determine a path only using navigation | + | < |
+ | < | ||
+ | ^Name^Description^Value^ | ||
+ | |Layer|Layer this navigation space affects|Integer| | ||
+ | |Type|Space | ||
+ | </ | ||
- | ==== Cost Functions ==== | + | <WRAP boxheader> |
- | Cost functions allow you to influence the path the AI module calculates for you. As mentioned at the beginning navigation spaces define a „Type Number“ | + | <WRAP boxcontent> |
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Position|Position of the vertex relative to the parent navigation space|3-Component Vector|Grid, | ||
+ | </ | ||
+ | |||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Vertex 1|Index of the first vertex of this edge|Unsigned Short|Grid| | ||
+ | |Vertex 2|Index of the second vertex of this edge|Unsigned Short|Grid| | ||
+ | |Type Number 1|Type to use to cross the edge from the first to the second vertex|Unsigned Short|Grid| | ||
+ | |Type Number 2|Type to use to cross the edge from the second to the first vertex|Unsigned Short|Grid| | ||
+ | </ | ||
+ | |||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Vertex|Index of the vertex for this corner|Unsigned Short|Mesh, Volume| | ||
+ | |Type Number|Type to use crossing this edge|Unsigned Short|Mesh| | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Corner Count|Number of corners in this face|Unsigned Short|Mesh, Volume| | ||
+ | |Type Number|Type to use moving through this face|Unsigned Short|Mesh| | ||
+ | </ | ||
+ | |||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Face|Index of the face for this wall|Unsigned Short|Volume| | ||
+ | |Type Number|Type to use crossing this face|Unsigned Short|Volume| | ||
+ | </ | ||
+ | |||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^Space Type^ | ||
+ | |Front Wall Count|Number of front facing walls in this room|Unsigned Short|Volume| | ||
+ | |Back Wall Count|Number of back facing walls in this room|Unsigned Short|Volume| | ||
+ | |Type Number|Type to use moving through this room|Unsigned Short|Volume| | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | |||
+ | ====== Navigators ====== | ||
+ | <WRAP box 250px right :en> | ||
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
+ | While the navigation spaces define the space in which navigation takes pace it is the navigators that determine which path to choose across such a space. Navigators are also also all-round class and can thus be used on all kinds of navigation spaces. To use a navigator you have to first set the **layer number** and the **space type**. The navigator is going to determine a path only using navigation spaces having the same layer and space type. If navigation does not work properly check first if these two parameters are set correctly. Once this is done you can set a **start position** and a **goal position**. Call then **update path**“ and the AI module calculates a path for you. The path is stored as a list of points (DVector) in world space. If no path is found the list of points is 0. Otherwise the list of points defines the path starting with the first path point to head towards. The list does not start with the **start position** but with the first path point. The last point in the list is the **goal position**. The list stays intact until the next time **update path** is called. | ||
+ | |||
+ | ===== Cost Functions | ||
+ | Cost functions allow you to influence the path the AI module calculates for you. As mentioned at the beginning navigation spaces define a **type number** | ||
For navigation grids the calculation is: | For navigation grids the calculation is: | ||
- | cost = edge.fixCost + edge.costPerMeter * distance | + | < |
For navigation meshes the calculation is: | For navigation meshes the calculation is: | ||
- | cost = corner.fixCost + face.fixCost + face.costPerMeter * distance | + | < |
And for navigation volumes the calculation is: | And for navigation volumes the calculation is: | ||
- | cost = wall.fixCost + room.fixCost + room.costPerMeter * distance | + | < |
- | By default | + | By default |
<WRAP clear></ | <WRAP clear></ | ||
- | === Example | + | <WRAP boxheader> |
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP boxcontent> |
+ | <WRAP box 250px right :en> | ||
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
An example for the use of cost functions is given in the images on the right. The first image shows a sample path through the world. In this case the path leads through the office of a coworker. This is indeed the shortest possible path if we assume doors are automatically opening not hampering your progress. Yet in reality this path is not a realistic one as strolling through an office like that is not considered to be polite. We need thus a way to penalize this route without preventing the path to end up in the office should this be our destination. For this costs functions can be used. In the example the "Type Numbers" | An example for the use of cost functions is given in the images on the right. The first image shows a sample path through the world. In this case the path leads through the office of a coworker. This is indeed the shortest possible path if we assume doors are automatically opening not hampering your progress. Yet in reality this path is not a realistic one as strolling through an office like that is not considered to be polite. We need thus a way to penalize this route without preventing the path to end up in the office should this be our destination. For this costs functions can be used. In the example the "Type Numbers" | ||
- | |||
<WRAP clear></ | <WRAP clear></ | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | |
+ | <WRAP box 250px right :en> | ||
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
The first solution using doors requires us to create a " | The first solution using doors requires us to create a " | ||
Line 69: | Line 148: | ||
Which method is the better depends on the situation. The solution with the added fix cost is usually better though as it does not increase the costs too much while still delivering the desired result. | Which method is the better depends on the situation. The solution with the added fix cost is usually better though as it does not increase the costs too much while still delivering the desired result. | ||
+ | <WRAP clear></ | ||
+ | </ | ||
+ | |||
+ | ===== Parameter Summary ===== | ||
+ | <WRAP column 45%> | ||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^ | ||
+ | |Layer|Layer this navigator uses to find a path|Integer| | ||
+ | |Space Type|Navigator uses only navigation spaces of this type to find a path|Grid, Mesh or Volume| | ||
+ | |Default Fix Cost|Fix cost to use if no matching type is found|Float| | ||
+ | |Default Cost Per Meter|Cost Per Meter to use if no matching type is found|Float| | ||
+ | |Blocking Cost|Path with costs larger than this value are considered unwalkable|Float| | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | <WRAP boxheader> | ||
+ | <WRAP boxcontent> | ||
+ | ^Name^Description^Value^ | ||
+ | |Type Number|Type number matching this cost function|Unsigned Short| | ||
+ | |Fix Cost|Fix cost to use|Float| | ||
+ | |Cost Per Meter|Cost Per Meter to use|Float| | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | |||
+ | ====== Exporting ====== | ||
+ | <WRAP box 250px right :en>{{ : | ||
+ | The Blender export scripts provide support to export Mesh objects as Drag[en]gine Navigation Spaces. To mark an object as a navigation space for exporting use the Nav-Space Type property in the Object panel. Only objects with a value other than None are exported in the appropriate format. | ||
+ | <WRAP clear></ | ||
+ | |||
+ | <WRAP box 250px right :en>{{ : | ||
+ | For Mesh and Volume type navigation spaces the Cost type can be defined using the Material each face belongs to. For this use the Navigation Type property in the Material panel. The control provides a soft range from 0 to 10 for quick editing but you can enter any positive integer value including 0. | ||
+ | <WRAP clear></ | ||
+ | |||
+ | For Edges and points as used for Grid navigation spaces it is a bit more complicated due to the nature of how Blender handles custom properties. You have to use Vertex Groups for this to work. Create for each navigation type a single vertex group in the object. | ||
+ | <WRAP center round important 80%> | ||
+ | <WRAP box 250px right :en>{{ : | ||
+ | Once created you can now set the navigation type to use for edges and vertices belonging to a certain vertex group. For this use the Drag[en]gine Vertex Group sub panel in the Mesh Data panel. This shows the navigation data for the active vertex group. If no data has been set yet a button is shown to create the data. Once set the sub panel switches allowing you to set the navigation type the the same way as with materials. Once set you can assign edges and vertices to vertex groups. For a an edge the first vertex group is picked both end point vertices belong to. Hence make sure only one such vertex group fulfills this requirement or the result is undefined. | ||
<WRAP clear></ | <WRAP clear></ | ||
- | ===== Steering and Collision Avoidance ===== | ||
- | The navigation system provides you only with the path to take along the world. After this task navigation typically consists also of the process of „Steering“ and „Collision Avoidance“. These tasks though depend heavily on the game in question and are thus not provided by the AI Module. This is though not a problem since the Physics Module provides you already with collision detection to implementyour steering and collision avoidance of choice. | ||
- | ====== | + | ====== |
- | * [[gamedev: | + | The navigation system provides you only with the path to take along the world. After this task navigation typically consists also of the process of **steering** and **collision avoidance**. These tasks though depend heavily on the game in question and are thus not provided by the AI Module. This is though not a problem since the Physics Module provides you already with collision detection to implement your steering and collision avoidance of choice. |
- | | + |