Class Spline
Spline shape actor that defines spatial curve with utility functions for general purpose usage.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Level/Actors/Spline.h
Syntax
public class Spline : public Actor
Fields
Curve
The spline bezier curve points represented as series of transformations in 3D space (with tangents). Points are stored in local-space of the actor.
Ensure to call UpdateSpline() after editing curve to reflect the changes.
Declaration
public BezierCurve<Transform> Curve
Field Value
BezierCurve<Transform>
|
SplineUpdated
Called when spline gets updated (eg. after curve modification).
Declaration
public Action SplineUpdated
Field Value
Action
|
Methods
AddSplineLocalPoint(const Transform& point, bool updateSpline=true)
Adds the point to the spline curve (at the end).
Declaration
public void AddSplineLocalPoint(const Transform& point, bool updateSpline=true)
Parameters
Transform
point
The transformation of the point to add to the curve (local-space). |
bool
updateSpline
True if update spline after adding the point, otherwise false. |
AddSplineLocalPoint(const Vector3& point, bool updateSpline=true)
Adds the point to the spline curve (at the end).
Declaration
public void AddSplineLocalPoint(const Vector3& point, bool updateSpline=true)
Parameters
Vector3
point
The location of the point to add to the curve (local-space). |
bool
updateSpline
True if update spline after adding the point, otherwise false. |
AddSplinePoint(const Transform& point, bool updateSpline=true)
Adds the point to the spline curve (at the end).
Declaration
public void AddSplinePoint(const Transform& point, bool updateSpline=true)
Parameters
Transform
point
The transformation of the point to add to the curve (world-space). |
bool
updateSpline
True if update spline after adding the point, otherwise false. |
AddSplinePoint(const Vector3& point, bool updateSpline=true)
Adds the point to the spline curve (at the end).
Declaration
public void AddSplinePoint(const Vector3& point, bool updateSpline=true)
Parameters
Vector3
point
The location of the point to add to the curve (world-space). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
ClearSpline()
Clears the spline to be empty.
Declaration
public void ClearSpline()
Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
Deserializes object from the input stream.
Declaration
public virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
Parameters
Deserialize The input stream. |
ISerialize The deserialization modifier object. Always valid. |
Overrides
GetIsLoop()
Whether to use spline as closed loop. In that case, ensure to place start and end at the same location.
Declaration
public bool GetIsLoop() const
Returns
bool
|
GetSplineColor()
GetSplineDirection(float time)
Evaluates the spline curve direction (forward vector, aka position 1st derivative) at the given time in 3D (world-space).
Declaration
public Vector3 GetSplineDirection(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve direction (world-space). |
GetSplineDuration()
Gets the total duration of the spline curve (time of the last point).
Declaration
public float GetSplineDuration() const
Returns
float
|
GetSplineLength()
Gets the total length of the spline curve (distance between all the points).
Declaration
public float GetSplineLength() const
Returns
float
|
GetSplineLocalDirection(float time)
Evaluates the spline curve direction (forward vector, aka position 1st derivative) at the given time in 3D (local-space).
Declaration
public Vector3 GetSplineLocalDirection(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve direction (local-space). |
GetSplineLocalOrientation(float time)
Evaluates the spline curve at the given time and calculates the point rotation in 3D (local-space).
Declaration
public Quaternion GetSplineLocalOrientation(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Quaternion
The calculated curve point rotation (local-space). |
GetSplineLocalPoint(float time)
Evaluates the spline curve at the given time and calculates the point location in 3D (local-space).
Declaration
public Vector3 GetSplineLocalPoint(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve point location (local-space). |
GetSplineLocalPoint(int32 index)
Evaluates the spline curve at the given index (local-space).
Declaration
public Vector3 GetSplineLocalPoint(int32 index) const
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
Vector3
The curve point location (local-space). |
GetSplineLocalPoints(Array<Transform>& points)
Gets the spline curve points list (local-space).
Declaration
public void GetSplineLocalPoints(Array<Transform>& points) const
Parameters
Array<Transform>
points
The result points collection. |
GetSplineLocalPoints(Array<Vector3>& points)
Gets the spline curve points list (local-space).
Declaration
public void GetSplineLocalPoints(Array<Vector3>& points) const
Parameters
Array<Vector3>
points
The result points collection. |
GetSplineLocalScale(float time)
Evaluates the spline curve at the given time and calculates the point scale in 3D (local-space).
Declaration
public Vector3 GetSplineLocalScale(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve point scale (local-space). |
GetSplineLocalTangent(int32 index, bool isIn)
Gets the spline curve point tangent at the given index (local-space).
Tangents are stored relative to the curve point but this methods converts them to be in local-space of the actor.
Declaration
public Transform GetSplineLocalTangent(int32 index, bool isIn)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
bool
isIn
True if get arrive tangent, otherwise gets leave tangent (in or out). |
Returns
Transform
The transformation of the tangent to set (world-space). |
GetSplineLocalTransform(float time)
Evaluates the spline curve at the given time and calculates the transformation in 3D (local-space).
Declaration
public Transform GetSplineLocalTransform(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Transform
The calculated curve point transformation (local-space). |
GetSplineLocalTransform(int32 index)
Evaluates the spline curve at the given index (local-space).
Declaration
public Transform GetSplineLocalTransform(int32 index) const
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
Transform
The curve point transformation (local-space). |
GetSplineOrientation(float time)
Evaluates the spline curve at the given time and calculates the point rotation in 3D (world-space).
Declaration
public Quaternion GetSplineOrientation(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Quaternion
The calculated curve point rotation (world-space). |
GetSplinePoint(float time)
Evaluates the spline curve at the given time and calculates the point location in 3D (world-space).
Declaration
public Vector3 GetSplinePoint(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve point location (world-space). |
GetSplinePoint(int32 index)
Evaluates the spline curve at the given index (world-space).
Declaration
public Vector3 GetSplinePoint(int32 index) const
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
Vector3
The curve point location (world-space). |
GetSplinePointClosestToPoint(const Vector3& point)
Calculates the closest point to the given location.
Declaration
public Vector3 GetSplinePointClosestToPoint(const Vector3& point) const
Parameters
Vector3
point
The point in world-space to find the spline point that is closest to it. |
Returns
Vector3
The spline position. |
GetSplinePoints(Array<Transform>& points)
Gets the spline curve points list (world-space).
Declaration
public void GetSplinePoints(Array<Transform>& points) const
Parameters
Array<Transform>
points
The result points collection. |
GetSplinePoints(Array<Vector3>& points)
Gets the spline curve points list (world-space).
Declaration
public void GetSplinePoints(Array<Vector3>& points) const
Parameters
Array<Vector3>
points
The result points collection. |
GetSplinePointsCount()
Gets the amount of points in the spline.
Declaration
public int32 GetSplinePointsCount() const
Returns
int32
|
GetSplineScale(float time)
Evaluates the spline curve at the given time and calculates the point scale in 3D (world-space).
Declaration
public Vector3 GetSplineScale(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Vector3
The calculated curve point scale (world-space). |
GetSplineSegmentLength(int32 index)
Gets the length of the spline segment (distance between pair of two points).
Declaration
public float GetSplineSegmentLength(int32 index) const
Parameters
int32
index
The index of the segment end index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
float
The spline segment length. |
GetSplineTangent(int32 index, bool isIn)
Gets the spline curve point tangent at the given index (world-space).
Tangents are stored relative to the curve point but this methods converts them to be in world-space.
Declaration
public Transform GetSplineTangent(int32 index, bool isIn)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
bool
isIn
True if get arrive tangent, otherwise gets leave tangent (in or out). |
Returns
Transform
The transformation of the tangent to set (world-space). |
GetSplineTime(int32 index)
Gets the time of the spline keyframe.
Declaration
public float GetSplineTime(int32 index) const
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
float
The spline time. |
GetSplineTimeClosestToPoint(const Vector3& point)
Calculates the closest point to the given location and returns the spline time at that point.
Declaration
public float GetSplineTimeClosestToPoint(const Vector3& point) const
Parameters
Vector3
point
The point in world-space to find the spline point that is closest to it. |
Returns
float
The spline time. |
GetSplineTransform(float time)
Evaluates the spline curve at the given time and calculates the transformation in 3D (world-space).
Declaration
public Transform GetSplineTransform(float time) const
Parameters
float
time
The time value. Can be negative or larger than curve length (curve will loop or clamp). |
Returns
Transform
The calculated curve point transformation (world-space). |
GetSplineTransform(int32 index)
Evaluates the spline curve at the given index (world-space).
Declaration
public Transform GetSplineTransform(int32 index) const
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Returns
Transform
The curve point transformation (world-space). |
Initialize()
Called after object loading or spawning to initialize the object (eg. call OnAwake for scripts) but before BeginPlay. Initialization should be performed only within a single SceneObject (use BeginPlay to initialize with a scene).
Declaration
public virtual void Initialize() override
Overrides
InsertSplineLocalPoint(int32 index, float time, const Transform& point, bool updateSpline=true)
Inserts the spline curve point at the given index (local-space).
Declaration
public void InsertSplineLocalPoint(int32 index, float time, const Transform& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
float
time
The time value. |
Transform
point
The location of the point to add to the curve (local-space). |
bool
updateSpline
True if update spline after removing the point, otherwise false. |
InsertSplinePoint(int32 index, float time, const Transform& point, bool updateSpline=true)
Inserts the spline curve point at the given index (world-space).
Declaration
public void InsertSplinePoint(int32 index, float time, const Transform& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
float
time
The time value. |
Transform
point
The location of the point to add to the curve (world-space). |
bool
updateSpline
True if update spline after removing the point, otherwise false. |
OnDebugDraw()
Draws debug shapes for the actor and all child scripts.
Declaration
public virtual void OnDebugDraw() override
Overrides
OnDebugDrawSelected()
Draws debug shapes for the selected actor and all child scripts.
Declaration
public virtual void OnDebugDrawSelected() override
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
public virtual void OnTransformChanged() override
Overrides
RemoveSplinePoint(int32 index, bool updateSpline=true)
Removes the spline curve point at the given index.
Declaration
public void RemoveSplinePoint(int32 index, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
bool
updateSpline
True if update spline after removing the point, otherwise false. |
Serialize(SerializeStream& stream, const void* otherObj)
Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
Declaration
public virtual void Serialize(SerializeStream& stream, const void* otherObj) override
Parameters
Serialize The output stream. |
void
otherObj
The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties. |
Overrides
SetIsLoop(bool value)
Whether to use spline as closed loop. In that case, ensure to place start and end at the same location.
Declaration
public void SetIsLoop(bool value)
Parameters
bool
value
|
SetSplineLocalPoint(int32 index, const Vector3& point, bool updateSpline=true)
Sets the spline curve at the given index (local-space).
Declaration
public void SetSplineLocalPoint(int32 index, const Vector3& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Vector3
point
The location of the point to set (local-space). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplineLocalTangent(int32 index, const Transform& point, bool isIn, bool updateSpline=true)
Sets the spline curve point tangent at the given index (local-space).
Tangents are stored relative to the curve point but this methods converts them to be in local-space of the actor.
Declaration
public void SetSplineLocalTangent(int32 index, const Transform& point, bool isIn, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Transform
point
The transformation of the tangent to set (local-space). |
bool
isIn
True if set arrive tangent, otherwise sets leave tangent (in or out). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline=true)
Sets the spline curve at the given index (local-space).
Declaration
public void SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Transform
point
The transformation of the point to set (local-space). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplinePoint(int32 index, const Vector3& point, bool updateSpline=true)
Sets the spline curve at the given index (world-space).
Declaration
public void SetSplinePoint(int32 index, const Vector3& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Vector3
point
The location of the point to set (world-space). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplinePointTime(int32 index, float time, bool updateSpline=true)
Sets the spline curve point time at the given index (world-space).
Declaration
public void SetSplinePointTime(int32 index, float time, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
float
time
The time to set. |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplineTangent(int32 index, const Transform& point, bool isIn, bool updateSpline=true)
Sets the spline curve point tangent at the given index (world-space).
Tangents are stored relative to the curve point but this methods converts them to be in world-space.
Declaration
public void SetSplineTangent(int32 index, const Transform& point, bool isIn, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Transform
point
The transformation of the tangent to set (world-space). |
bool
isIn
True if set arrive tangent, otherwise sets leave tangent (in or out). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetSplineTransform(int32 index, const Transform& point, bool updateSpline=true)
Sets the spline curve at the given index (world-space).
Declaration
public void SetSplineTransform(int32 index, const Transform& point, bool updateSpline=true)
Parameters
int32
index
The curve keyframe index. Zero-based, smaller than GetSplinePointsCount(). |
Transform
point
The transformation of the point to set (world-space). |
bool
updateSpline
True if update spline after editing the point, otherwise false. |
SetTangentsLinear()
Updates the curve tangent points to make curve linear.
Declaration
public void SetTangentsLinear()
SetTangentsSmooth()
Updates the curve tangent points to make curve smooth.
Declaration
public void SetTangentsSmooth()
UpdateSpline()
Updates the spline after it was modified. Recreates the collision and/or any cached state that depends on the spline type.
Declaration
public virtual void UpdateSpline()