Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Spline Class Referenceabstract

#include <Spline.h>

Inherited by AZ::BezierSpline, AZ::CatmullRomSpline, and AZ::LinearSpline.

Public Member Functions

 Spline (const Spline &spline)
 
virtual RaySplineQueryResult GetNearestAddressRay (const Vector3 &localRaySrc, const Vector3 &localRayDir) const =0
 
virtual PositionSplineQueryResult GetNearestAddressPosition (const Vector3 &localPos) const =0
 
virtual SplineAddress GetAddressByDistance (float distance) const =0
 
virtual SplineAddress GetAddressByFraction (float fraction) const =0
 
virtual Vector3 GetPosition (const SplineAddress &splineAddress) const =0
 
virtual Vector3 GetNormal (const SplineAddress &splineAddress) const =0
 
virtual Vector3 GetTangent (const SplineAddress &splineAddress) const =0
 
virtual float GetLength (const SplineAddress &splineAddress) const =0
 
virtual float GetSplineLength () const =0
 
virtual float GetSegmentLength (size_t index) const =0
 
virtual size_t GetSegmentCount () const =0
 
virtual u16 GetSegmentGranularity () const =0
 
virtual void GetAabb (Aabb &aabb, const Transform &transform=Transform::CreateIdentity()) const =0
 
void SetClosed (bool closed)
 
bool IsClosed () const
 
size_t GetVertexCount () const
 
const AZStd::vector< Vector3 > & GetVertices () const
 
const Vector3GetVertex (size_t index) const
 
void SetCallbacks (const VoidFunction &onChangeElement, const VoidFunction &onChangeContainer, const BoolFunction &onOpenClose)
 
void SetCallbacks (const IndexFunction &onAddVertex, const IndexFunction &onRemoveVertex, const IndexFunction &onUpdateVertex, const VoidFunction &onSetVertices, const VoidFunction &onClearVertices, const BoolFunction &onOpenClose)
 
virtual void OnSplineChanged ()
 

Static Public Member Functions

static void Reflect (SerializeContext &context)
 

Public Attributes

VertexContainer< Vector3m_vertexContainer
 Vertices representing the spline.
 

Protected Member Functions

virtual void OnVertexAdded (size_t index)
 Internal function to be overridden by derived spline spline to handle custom logic when a vertex is added.
 
virtual void OnVerticesSet ()
 Internal function to be overridden by derived spline spline to handle custom logic when all vertices are set.
 
virtual void OnVertexRemoved (size_t index)
 Internal function to be overridden by derived spline to handle custom logic when a vertex is removed.
 
virtual void OnVerticesCleared ()
 Internal function to be overridden by derived spline to handle custom logic when spline is reset (vertices are cleared).
 

Protected Attributes

bool m_closed = false
 Is the spline closed - default is not.
 

Static Protected Attributes

static const float s_splineEpsilon
 Epsilon value for splines to use to check approximate results.
 

Detailed Description

Generic base spline class.

Member Function Documentation

◆ GetAabb()

virtual void AZ::Spline::GetAabb ( Aabb aabb,
const Transform transform = Transform::CreateIdentity() 
) const
pure virtual

Gets the Aabb of the vertices in the spline.

Parameters
aabbout param of filled aabb.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetAddressByDistance()

virtual SplineAddress AZ::Spline::GetAddressByDistance ( float  distance) const
pure virtual

Return address at distance value - range [0, splineLength].

Parameters
distanceDistance along the spline.
Returns
SplineAddress corresponding to distance.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetAddressByFraction()

virtual SplineAddress AZ::Spline::GetAddressByFraction ( float  fraction) const
pure virtual

Return address at fractional value - range [0, 1].

Parameters
fractionfraction/proportion/percentage along the spline.
Returns
SplineAddress corresponding to fraction.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetLength()

virtual float AZ::Spline::GetLength ( const SplineAddress splineAddress) const
pure virtual

Returns spline length from the beginning to the specific point.

Parameters
splineAddressAddress of the point to get the distance to.
Returns
Distance to the address specified along the spline

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetNearestAddressPosition()

virtual PositionSplineQueryResult AZ::Spline::GetNearestAddressPosition ( const Vector3 localPos) const
pure virtual

Return nearest address on spline from position (local space).

Parameters
localPosPosition in local space of spline (must be transformed prior to being passed).
Returns
SplineAddress closest to given position on spline.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetNearestAddressRay()

virtual RaySplineQueryResult AZ::Spline::GetNearestAddressRay ( const Vector3 localRaySrc,
const Vector3 localRayDir 
) const
pure virtual

Return nearest address on spline from ray (local space).

Parameters
localRaySrcPosition of ray in local space of spline (must be transformed prior to being passed).
localRayDirDirection of ray in local space of spline (must be transformed prior to being passed).
Returns
SplineAddress closest to given ray on spline.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetNormal()

virtual Vector3 AZ::Spline::GetNormal ( const SplineAddress splineAddress) const
pure virtual

Return normal at SplineAddress (local space).

Parameters
splineAddressAddress representing a point on the spline.
Returns
Normal of given SplineAddress in local space.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetPosition()

virtual Vector3 AZ::Spline::GetPosition ( const SplineAddress splineAddress) const
pure virtual

Return position at SplineAddress (local space).

Parameters
splineAddressAddress representing a point on the spline.
Returns
Position of given SplineAddress in local space.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetSegmentCount()

virtual size_t AZ::Spline::GetSegmentCount ( ) const
pure virtual

Return number of Segments along spline. Explicitly returns the number of valid/real segments in the spline Some splines technically have invalid segments (example: that lie in the range [0 - 1] and [vertexCount - 2, vertexCount -1] - these will be ignored in the segment count calculation).

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetSegmentGranularity()

virtual u16 AZ::Spline::GetSegmentGranularity ( ) const
pure virtual

Return the number of parts (lines) that make up a segment (higher granularity - smoother curve).

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetSegmentLength()

virtual float AZ::Spline::GetSegmentLength ( size_t  index) const
pure virtual

Returns length the segment between vertices - [index, index + 1].

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetSplineLength()

virtual float AZ::Spline::GetSplineLength ( ) const
pure virtual

Returns total length of spline.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetTangent()

virtual Vector3 AZ::Spline::GetTangent ( const SplineAddress splineAddress) const
pure virtual

Return tangent at SplineAddress (local space).

Parameters
splineAddressAddress representing a point on the spline.
Returns
Tangent of given SplineAddress in local space.

Implemented in AZ::LinearSpline, AZ::BezierSpline, and AZ::CatmullRomSpline.

◆ GetVertex()

const Vector3 & AZ::Spline::GetVertex ( size_t  index) const
inline

Return immutable position of vertex at index (local space).

◆ GetVertexCount()

size_t AZ::Spline::GetVertexCount ( ) const
inline

Return number of vertices composing the spline.

◆ GetVertices()

const AZStd::vector< Vector3 > & AZ::Spline::GetVertices ( ) const
inline

Return immutable stored vertices (local space).

◆ IsClosed()

bool AZ::Spline::IsClosed ( ) const
inline

Return if the spline is closed (looping) or not

◆ OnSplineChanged()

virtual void AZ::Spline::OnSplineChanged ( )
virtual

Notification that spline has changed

Reimplemented in AZ::BezierSpline.

◆ OnVertexAdded()

virtual void AZ::Spline::OnVertexAdded ( size_t  index)
protectedvirtual

Internal function to be overridden by derived spline spline to handle custom logic when a vertex is added.

Reimplemented in AZ::BezierSpline.

◆ OnVertexRemoved()

virtual void AZ::Spline::OnVertexRemoved ( size_t  index)
protectedvirtual

Internal function to be overridden by derived spline to handle custom logic when a vertex is removed.

Reimplemented in AZ::BezierSpline.

◆ OnVerticesCleared()

virtual void AZ::Spline::OnVerticesCleared ( )
protectedvirtual

Internal function to be overridden by derived spline to handle custom logic when spline is reset (vertices are cleared).

Reimplemented in AZ::BezierSpline.

◆ OnVerticesSet()

virtual void AZ::Spline::OnVerticesSet ( )
protectedvirtual

Internal function to be overridden by derived spline spline to handle custom logic when all vertices are set.

Reimplemented in AZ::BezierSpline.

◆ SetCallbacks() [1/2]

void AZ::Spline::SetCallbacks ( const IndexFunction onAddVertex,
const IndexFunction onRemoveVertex,
const IndexFunction onUpdateVertex,
const VoidFunction onSetVertices,
const VoidFunction onClearVertices,
const BoolFunction onOpenClose 
)

Override callbacks to be used when spline changes/is modified (specific). (use if you need more fine grained control over modifications to the container)

◆ SetCallbacks() [2/2]

void AZ::Spline::SetCallbacks ( const VoidFunction onChangeElement,
const VoidFunction onChangeContainer,
const BoolFunction onOpenClose 
)

Override callbacks to be used when spline changes/is modified (general).

◆ SetClosed()

void AZ::Spline::SetClosed ( bool  closed)

Set whether the spline is closed or not - should its last vertex connect to the first


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