Infohazard.HyperNav 1.1.5
3D Navigation for Flying Characters
|
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< SplinePoint > | ControlPoints [get] |
List of all the control points of the spline. More... | |
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.
Infohazard.HyperNav.SplinePath.SplinePath | ( | NavPath | path, |
float | tangentScale, | ||
int | sampleCount, | ||
bool | raycastTangents | ||
) |
Create a new SplinePath with the given path.
path | The input navigation path. |
tangentScale | Scale to apply to spline tangents (lower values make the spline less curvy). |
sampleCount | How many samples to take per segment of the spline when mapping the distance. |
raycastTangents | Whether to shorten tangents by raycasting against NavVolume blocking triangles. |
void Infohazard.HyperNav.SplinePath.Dispose | ( | ) |
Dispose arrays allocated for this spline path.
Vector3 Infohazard.HyperNav.SplinePath.GetControlPosition | ( | int | index | ) |
Get the position of a given control point.
index | Control point index. |
Vector3 Infohazard.HyperNav.SplinePath.GetControlTangent | ( | int | index | ) |
Get the tangent of a given control point.
index | Control point index. |
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.
parameter | The parameter value in range [0, 1]. |
offset | Offset distance to sample derivative of tangent function. |
float Infohazard.HyperNav.SplinePath.GetDistance | ( | float | parameter | ) |
Get the distance along the spline for a given parameter value.
parameter | The parameter value in range [0, 1]. |
float Infohazard.HyperNav.SplinePath.GetParameter | ( | float | distance | ) |
Get the parameter value for a given distance along the spline.
distance | The distance value in range [0, Length]. |
Vector3 Infohazard.HyperNav.SplinePath.GetPosition | ( | float | parameter | ) |
Get the position at a given parameter value.
parameter | The parameter value in range [0, 1]. |
Vector3 Infohazard.HyperNav.SplinePath.GetTangent | ( | float | parameter | ) |
Get the tangent at a given parameter value.
parameter | The parameter value in range [0, 1]. |
NavVolume Infohazard.HyperNav.SplinePath.GetVolume | ( | float | parameter | ) |
void Infohazard.HyperNav.SplinePath.Initialize | ( | NavPath | path, |
float | tangentScale, | ||
int | sampleCount, | ||
bool | raycastTangents | ||
) |
Re-initialize an existing SplinePath with the given path.
path | The input navigation path. |
tangentScale | Scale to apply to spline tangents (lower values make the spline less curvy). |
sampleCount | How many samples to take per segment of the spline when mapping the distance. |
raycastTangents | Whether to shorten tangents by raycasting against NavVolume blocking triangles. |
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.
position | Position to project. |
iterations | Number of Newton's method iterations. |
debug | Whether to draw debug lines showing Newton's method iterations. |
|
get |
List of all the control points of the spline.
|
getprivate set |
Whether an actual spline has been constructed.
|
getprivate set |
Length of the spline in world units.
|
getprivate set |
Number of control points on the spline.