[This is preliminary documentation and is subject to change.]

Returns the staight path from the start to the end point within the polygon corridor.

Namespace: org.critterai.nav
Assembly: cai-nav (in cai-nav.dll) Version: 0.4.0.0 (0.4.0.0)

Syntax

         
 C#  Visual Basic  Visual C++ 
public NavStatus GetStraightPath(
	Vector3 start,
	Vector3 end,
	uint[] path,
	int pathStart,
	int pathCount,
	Vector3[] resultPoints,
	WaypointFlag[] resultFlags,
	uint[] resultRefs,
	out int resultCount
)
Public Function GetStraightPath ( _
	start As Vector3, _
	end As Vector3, _
	path As UInteger(), _
	pathStart As Integer, _
	pathCount As Integer, _
	resultPoints As Vector3(), _
	resultFlags As WaypointFlag(), _
	resultRefs As UInteger(), _
	<OutAttribute> ByRef resultCount As Integer _
) As NavStatus
public:
NavStatus GetStraightPath(
	Vector3 start, 
	Vector3 end, 
	array<unsigned int>^ path, 
	int pathStart, 
	int pathCount, 
	array<Vector3>^ resultPoints, 
	array<WaypointFlag>^ resultFlags, 
	array<unsigned int>^ resultRefs, 
	[OutAttribute] int% resultCount
)

Parameters

start
Vector3
The start point.
end
Vector3
The end point.
path
array<UInt32>[]()[][]
The list of polygon references that represent the path corridor.
pathStart
Int32
The index within the path buffer of the polygon that contains the start point.
pathCount
Int32
The length of the path within the path buffer. (endPolyIndex - startPolyIndex)
resultPoints
array<Vector3>[]()[][]
Points describing the straight path. [(point) * straightPathCount].
resultFlags
array<WaypointFlag>[]()[][]
Flags describing each point. [(flags) * striaghtPathCount] (Optional)
resultRefs
array<UInt32>[]()[][]
The reference of the polygon that is being entered at the point position. [(polyRef) * straightPathCount] (Optional)
resultCount
Int32%
The number of points in the straight path.

Return Value

The NavStatus flags for the query.

Remarks

This method peforms what is often called 'string pulling'.

If the provided result buffers are too small for the entire result, they will be filled as far as possible from the start point toward the end point.

The start point is clamped to the first polygon in the path, and the end point is clamped to the last. So the start and end points should be within or very near the first and last polygons respectively. The pathStart and pathCount parameters can be adjusted to restrict the usable portion of the the path to meet this requirement. (See the example below.)

The returned polygon references represent the polygon that is entered at the associated path point. The reference associated with the end point will always be zero.

Example use case for adjusting the straight path during locomotion:

Senario: The path consists of polygons A, B, C, D, with the start point in A and the end point in D.

The first call to the method will return straight waypoints for the entire path:

CopyC#
query.GetStraightPath(startPoint, endPoint
    , path
    , 0, 4   // pathStart, pathCount
    , straigthPath, null, null
    , out straightCount);

If the agent moves into polygon B and needs to recaclulate its straight path for some reason, it can call the method as follows using the original path buffer:

CopyC#
query.GetStraightPath(startPoint, endPoint
    , path
    , 1, 3   // pathStart, pathCount  <- Note the changes here.
    , straigthPath, null, null
    , out straightCount);

See Also