Infohazard.HyperNav 1.1.5
3D Navigation for Flying Characters
Loading...
Searching...
No Matches
Infohazard.HyperNav.SplinePath Struct Reference

A spline specialized for path following, created with a NavPath. More...

Public Member Functions

 SplinePath (NavPath path, float tangentScale, int sampleCount, bool raycastTangents)
 Create a new SplinePath with the given path. More...
 
void Initialize (NavPath path, float tangentScale, int sampleCount, bool raycastTangents)
 Re-initialize an existing SplinePath with the given path. More...
 
void Dispose ()
 Dispose arrays allocated for this spline path. More...
 
float GetDistance (float parameter)
 Get the distance along the spline for a given parameter value. More...
 
float GetParameter (float distance)
 Get the parameter value for a given distance along the spline. More...
 
Vector3 GetControlPosition (int index)
 Get the position of a given control point. More...
 
Vector3 GetControlTangent (int index)
 Get the tangent of a given control point. More...
 
NavVolume GetVolume (float parameter)
 Get the NavVolume that contains the given parameter value on the spline. More...
 
Vector3 GetPosition (float parameter)
 Get the position at a given parameter value. More...
 
Vector3 GetTangent (float parameter)
 Get the tangent at a given parameter value. More...
 
Vector3 GetCurvature (float parameter, float offset=0.01f)
 Sample the curvature at a given parameter value. More...
 
float ProjectPosition (Vector3 position, int iterations=5, bool debug=false)
 Approximate the parameter value of the position along the spline nearest to the given position. More...
 

Properties

float Length [get, private set]
 Length of the spline in world units. More...
 
int PointCount [get, private set]
 Number of control points on the spline. More...
 
bool IsCreated [get, private set]
 Whether an actual spline has been constructed. More...
 
NativeArray< SplinePointControlPoints [get]
 List of all the control points of the spline. More...
 

Detailed Description

A spline specialized for path following, created with a NavPath.

Unlike most spline tools, the tangents in this spline are calculated automatically.

This spline implementation uses two coordinate spaces: parameter and distance. Distance ranges from zero to the length of the spline, and values are distributed (approximately) evenly. Parameter ranges from zero to one and is the actual value supplied to the spline function, but values are not distributed evenly.

Constructor & Destructor Documentation

◆ SplinePath()

Infohazard.HyperNav.SplinePath.SplinePath ( NavPath  path,
float  tangentScale,
int  sampleCount,
bool  raycastTangents 
)

Create a new SplinePath with the given path.

Parameters
pathThe input navigation path.
tangentScaleScale to apply to spline tangents (lower values make the spline less curvy).
sampleCountHow many samples to take per segment of the spline when mapping the distance.
raycastTangentsWhether to shorten tangents by raycasting against NavVolume blocking triangles.

Member Function Documentation

◆ Dispose()

void Infohazard.HyperNav.SplinePath.Dispose ( )

Dispose arrays allocated for this spline path.

◆ GetControlPosition()

Vector3 Infohazard.HyperNav.SplinePath.GetControlPosition ( int  index)

Get the position of a given control point.

Parameters
indexControl point index.
Returns
Position of that control point, in world space.

◆ GetControlTangent()

Vector3 Infohazard.HyperNav.SplinePath.GetControlTangent ( int  index)

Get the tangent of a given control point.

Parameters
indexControl point index.
Returns
Tangent of that control point, in world space.

◆ GetCurvature()

Vector3 Infohazard.HyperNav.SplinePath.GetCurvature ( float  parameter,
float  offset = 0.01f 
)

Sample the curvature at a given parameter value.

Unlike GetPosition and GetTangent, this does not return an exact value.

Parameters
parameterThe parameter value in range [0, 1].
offsetOffset distance to sample derivative of tangent function.
Returns
The sampled curvature value (use magnitude to get scalar curvature).

◆ GetDistance()

float Infohazard.HyperNav.SplinePath.GetDistance ( float  parameter)

Get the distance along the spline for a given parameter value.

Parameters
parameterThe parameter value in range [0, 1].
Returns
The distance value in range [0, Length].

◆ GetParameter()

float Infohazard.HyperNav.SplinePath.GetParameter ( float  distance)

Get the parameter value for a given distance along the spline.

Parameters
distanceThe distance value in range [0, Length].
Returns
The parameter value in range [0, 1].

◆ GetPosition()

Vector3 Infohazard.HyperNav.SplinePath.GetPosition ( float  parameter)

Get the position at a given parameter value.

Parameters
parameterThe parameter value in range [0, 1].
Returns
Position along the spline, in world space.

◆ GetTangent()

Vector3 Infohazard.HyperNav.SplinePath.GetTangent ( float  parameter)

Get the tangent at a given parameter value.

Parameters
parameterThe parameter value in range [0, 1].
Returns
Tangent at that position, in world space.

◆ GetVolume()

NavVolume Infohazard.HyperNav.SplinePath.GetVolume ( float  parameter)

Get the NavVolume that contains the given parameter value on the spline.

Parameters
parameterInput parameter value.
Returns
The containing NavVolume.

◆ Initialize()

void Infohazard.HyperNav.SplinePath.Initialize ( NavPath  path,
float  tangentScale,
int  sampleCount,
bool  raycastTangents 
)

Re-initialize an existing SplinePath with the given path.

Parameters
pathThe input navigation path.
tangentScaleScale to apply to spline tangents (lower values make the spline less curvy).
sampleCountHow many samples to take per segment of the spline when mapping the distance.
raycastTangentsWhether to shorten tangents by raycasting against NavVolume blocking triangles.

◆ ProjectPosition()

float Infohazard.HyperNav.SplinePath.ProjectPosition ( Vector3  position,
int  iterations = 5,
bool  debug = false 
)

Approximate the parameter value of the position along the spline nearest to the given position.

This uses Newton's method. Increasing the iteration count increases both accuracy and cost.

Parameters
positionPosition to project.
iterationsNumber of Newton's method iterations.
debugWhether to draw debug lines showing Newton's method iterations.
Returns
The approximate parameter along the spline in range [0, 1].

Property Documentation

◆ ControlPoints

NativeArray<SplinePoint> Infohazard.HyperNav.SplinePath.ControlPoints
get

List of all the control points of the spline.

◆ IsCreated

bool Infohazard.HyperNav.SplinePath.IsCreated
getprivate set

Whether an actual spline has been constructed.

◆ Length

float Infohazard.HyperNav.SplinePath.Length
getprivate set

Length of the spline in world units.

◆ PointCount

int Infohazard.HyperNav.SplinePath.PointCount
getprivate set

Number of control points on the spline.


The documentation for this struct was generated from the following file: