UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

PathRoute Class

This class calculates the shortest 2D or 3D path around the obstacles within connected navigation areas and sets the size and velocity of the object moving along this route.

  • In case of 2D route, an object is a cylinder of the specified radius and height. Too narrow or too low navigation areas will be discarded from path finding. If the height difference between the connected areas exceeds the maximum height, the navigation area is also discarded from calculations.
  • In case of 3D route (available only for navigation sectors), an object is a sphere of a specified radius. The object cannot rise up higher then the maximum height.

The path route allows to ignore the specified navigation areas and obstacles. The maximum time acceptable to get to the destination point and the maximum danger factor can be limited as well.

To choose between navigation areas, A* algorithm is used. Inside navigation sectors dynamical pathfinding is implemented; inside navigation meshes implementation includes both A* algorithm and dynamical pathfinding.

PathRoute Class

Members


PathRoute (float radius = 0.0f)

Constructor. Creates a new 2D or 3D path.

Arguments

  • float radius = 0.0f - Radius of the object moving along the path.

void addExcludeNavigation (Node navigation)

Sets a navigation sector or a navigation mesh to be ignored when finding a path. Excluded sectors/meshes are added into the list.

Arguments

  • Node navigation - A navigation area to be ignored.

void addExcludeObstacle (Node obstacle)

Sets an obstacle to be ignored when finding a path. Excluded obstacles are added into the list.

Arguments

  • Node obstacle - An obstacle to be ignored.

void create2D (vec3 p0, vec3 p1, int delay = 0)

Creates a 2D path.

Arguments

  • vec3 p0 - The starting point.
  • vec3 p1 - The destination point.
  • int delay = 0 - The number of frames which is possible to delay pathfinding calculations. 0 means the pathfinding should be calculated immediately.

void create3D (vec3 p0, vec3 p1, int delay = 0)

Creates a 3D path.

Arguments

  • vec3 p0 - The starting point.
  • vec3 p1 - The destination point.
  • int delay = 0 - The number of frames which is possible to delay pathfinding calculations. 0 means the pathfinding should be calculated immediately.

float getDangerous ()

Returns the highest danger factor of the navigation areas met along the path.

Return value

Highest danger factor

float getDistance ()

Returns the length of the path.

Return value

Distance in units.

void getExcludeNavigations (int exclude_navigations)

Returns the list of navigation sectors and navigation meshes excluded from finding the path.

Arguments

  • int exclude_navigations - Array to store the excluded navigation areas.

void getExcludeObstacles (int obstacles)

Returns the list of obstacles ignored when finding the path.

Arguments

  • int obstacles - Array to store the ignored obstacles.

float getHeight ()

Returns the current height of the object moving along the 2D path.

Return value

Height of the moving object.

Obstacle getIntersection (int ret_index)

Performs intersection along the path to find if any new obstacle has appeared.

Arguments

  • int ret_index - Return array for intersection points.

Return value

New obstacle along the path.

float getMaxAngle ()

Returns cosine of the maximum possible angle between navigation mesh polygons. For example, this option allows to exclude walls when finding a valid route.

Return value

Maximum angle cosine.

float getMaxDangerous ()

Returns the maximum danger factor acceptable for moving along this path. If the navigation areas have a higher danger factor, the object will not move along it.

Return value

Maximum danger factor.

float getMaxHeight ()

Returns the current maximum height difference between the connected navigation areas acceptable when finding the 2D path. In case of 3D path, it is the maximum height the object can move up to.

Return value

Maximum height.

float getMaxTime ()

Returns the current maximum time for reaching the destination point. If the path takes longer, the object will not move along it.

Return value

Maximum movement time.

int getNavigationMask ()

Returns the current navigation mask. Only that navigation sectors and navigation meshes are taken into account, which have a matching mask. The default is 1.

Return value

Integer, each bit of which is a mask.

Navigation getNavigation (int num)

Returns the navigation sector or mesh within which the specified path point is located.

Arguments

  • int num - Point number.

Return value

Navigation sector or navigation mesh.

int getNumPoints ()

Returns the number of turning points along the path.

Return value

The number of points.

int getObstacleMask ()

Returns the current obstacle mask. Only that obstacles are taken into account, which have a matching mask.

Return value

Integer, each bit of which is a mask.

Obstacle getObstacle (int num)

Returns the obstacle around which the path is turning.

Arguments

  • int num - Point number.

Return value

Obstacle.

vec3 getPoint (int num)

Returns the coordinates of the turning point in the path.

Arguments

  • int num - Point number.

Return value

Point coordinates.

float getRadius ()

Returns the current radius of the object moving along the path.

Return value

Radius of the moving object.

float getTime ()

Returns the time the object requires to move along the path.

Return value

Time in seconds.

float getVelocity ()

Returns the current velocity of the object moving along the path.

Return value

Velocity of the moving object.

int isQueued ()

Returns a value indicating that a path is queued to be calculated.

Return value

1 if the path is queued; otherwise, 0.

int isReached ()

Returns a value indicating that a destination point of the path is reached.

Return value

1 if the destination point is reached; otherwise, 0.

int isReady ()

Returns a value indicating that a path is calculated.

Return value

1 if the path is calculated; otherwise, 0.

void removeExcludeNavigation (Node navigation)

Removes a navigation sector or a navigation mesh from the list of ignored ones when finding a path.

Arguments

  • Node navigation - A navigation area.

void removeExcludeObstacle (Node obstacle)

Removes an obstacle from the list of ignored ones when finding a path.

Arguments

  • Node obstacle - An obstacle.

void renderVisualizer (vec4 color)

Renderes the path in a given color.

Arguments

  • vec4 color - Path color.

void setExcludeNavigations (int navigations)

Sets the list of navigation sectors and navigation meshes to be ignored when finding a path.

Arguments

  • int navigations - Array of the ignored navigation areas.

void setExcludeObstacles (int obstacles)

Sets the list of obstacles to be ignored when finding a path.

Arguments

  • int obstacles - Array of the ignored obstacles.

void setHeight (float height)

Sets the height of the object moving along the 2D path. The default is 0.

Arguments

  • float height - Height of the moving object. If a negative value is provided, 0 will be used instead.

void setMaxAngle (float angle)

Sets cosine of the maximum possible angle between navigation mesh polygons. For example, this option allows to exclude walls when finding a valid route. The default is 0 (90 degrees).

Arguments

  • float angle - Maximum angle cosine.

void setMaxDangerous (float dangerous)

Sets the maximum danger factor acceptable for moving along this path. If the navigation areas have a higher danger factor, the object will not move along it. The default is infinity.

Arguments

  • float dangerous - Maximum danger factor.

void setMaxHeight (float height)

Sets the maximum height difference between the connected navigation areas acceptable when finding the 2D path. In case of 3D path, it is the maximum height the object can move up to. The default is infinity.

Arguments

  • float height - Maximum height.

void setMaxTime (float time)

Sets the maximum time for reaching the destination point. If the path takes longer, the object will not move along it. The default is infinity.

Arguments

  • float time - Maximum movement time.

void setNavigationMask (int mask)

Sets the navigation mask. Only that navigation sectors and navigation meshes are taken into account, which have a matching mask.

Arguments

  • int mask - Integer, each bit of which is a mask.

void setObstacleMask (int mask)

Sets the obstacle mask. Only that obstacles are taken into account, which have a matching mask. The default is 1.

Arguments

  • int mask - Integer, each bit of which is a mask.

void setRadius (float radius)

Sets the radius of the object moving along the path.

Arguments

  • float radius - Radius of the moving object. If a negative value is provided, 0 will be used instead.

void setVelocity (float velocity)

Sets the velocity of the object moving along the path. The default is 1.

Arguments

  • float velocity - Velocity of the moving object.
Last update: 2017-07-03