Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Spatial::Spline3D Class Reference

Three-dimensional spline curve for procedural 3D path generation. More...

#include <Spline.hpp>

Inheritance diagram for Infinity::Types::Spatial::Spline3D:
[legend]
Collaboration diagram for Infinity::Types::Spatial::Spline3D:
[legend]

Public Types

using Vec = Math::Vector3
 

Public Member Functions

 Spline3D ()
 Default constructor.
 
 Spline3D (SplineKind kind)
 Constructs a spline with specified interpolation type.
 
 Spline3D (const Spline3D &other)
 Copy constructor.
 
virtual ~Spline3D ()
 Destructor.
 
std::unique_ptr< Core::Baseclone () const override
 
Spline3Doperator= (const Spline3D &other)
 Copy assignment operator.
 
Vec evaluate (float t) const
 Evaluates the spline position at parameter t.
 
Vec tangent (float t) const
 Computes the tangent vector at parameter t.
 
void setCurveKind (SplineKind kind)
 Changes the spline interpolation type.
 
SplineKind type () const
 Gets the current spline interpolation type.
 
const Infinity::Types::TypeIDtypeId () const override
 Gets the TypeID for Spline3D.
 
- Public Member Functions inherited from Infinity::Types::Core::Data
 Data ()
 
 Data (const Data &other)
 
 Data (Data &&other)
 
Dataoperator= (const Data &other)
 
Dataoperator= (Data &&other)
 
virtual ~Data ()
 Virtual destructor.
 
bool hasProperty (const std::string &key) const
 
template<typename T >
void setProperty (const std::string &key, T &&value)
 Sets a typed property value.
 
template<typename T >
void setProperty (const std::string &key, const T &value)
 Sets a typed property value.
 
void setProperty (const std::string &key, PropertyValue &&value)
 Sets a typed property value.
 
const PropertyValuegetProperty (const std::string &key) const
 Gets a property value without type checking.
 
template<typename T >
const T & getProperty (const std::string &key) const
 Gets a typed property value.
 
void removeProperty (const std::string &key)
 
- Public Member Functions inherited from Infinity::Types::Core::Base
virtual ~Base ()
 Virtual destructor.
 
virtual std::istream & legibleDataRead (std::istream &in) override
 Deserializes the object from a single-line text representation.
 
virtual std::ostream & legibleDataWrite (std::ostream &out) const override
 Serializes the object to a single-line text representation.
 

Public Attributes

Containers::Array< Vecpoints
 Control points defining the spline curve.
 
- Public Attributes inherited from Infinity::Types::Core::Data
std::unordered_map< std::string, PropertyValueproperties
 Property storage for arbitrary metadata.
 

Detailed Description

Three-dimensional spline curve for procedural 3D path generation.

Spline3D provides smooth curve interpolation through 3D control points using various mathematical methods (Bezier, Catmull-Rom, B-Spline, or Linear). It is essential for procedural generation of:

  • 3D paths, roads, and railways
  • Camera movement paths
  • Procedural cable and pipe routing
  • Animation trajectories
  • Generatrix curves for sweep surfaces
  • Roller coaster and track generation
  • River paths with elevation changes
  • Procedural vine and tendril growth

The spline can be evaluated at any parametric position t ∈ [0, 1] to obtain interpolated positions and tangent vectors along the curve. Control points are stored in a public Array for direct manipulation.

Note
The parameter t is normalized: 0 = start of curve, 1 = end of curve.
Tangent vectors are not normalized - normalize manually if unit vectors are needed.
Different SplineKind values produce different curve behaviors.

Example usage:

// Create a Catmull-Rom path through key positions
Spline3D path(SplineKind::CatmullRom);
path.points.push_back(Vector3{0.0f, 0.0f, 0.0f});
path.points.push_back(Vector3{10.0f, 5.0f, 0.0f});
path.points.push_back(Vector3{20.0f, 3.0f, 5.0f});
path.points.push_back(Vector3{30.0f, 0.0f, 10.0f});
// Generate mesh along the path with varying radius
for (int i = 0; i <= 100; ++i) {
float t = i / 100.0f;
Vector3 pos = path.evaluate(t);
Vector3 tangent = path.tangent(t).normalized();
// Create perpendicular frame for mesh generation
Vector3 up = Vector3{0, 1, 0};
Vector3 right = tangent.cross(up).normalized();
Vector3 actualUp = right.cross(tangent);
// Generate circular cross-section
generateRingMesh(pos, right, actualUp, radius);
}
// Use for camera path
system->setIn("camera_path", std::move(path));
Three-dimensional spline curve for procedural 3D path generation.
Definition Spline.hpp:283
Vec tangent(float t) const
Computes the tangent vector at parameter t.
t_Vector3< float > Vector3
Alias for t_Vector3<float>, the default 3D vector type.
Definition Vector3.hpp:580
t_Vector3< T > cross(const t_Vector3< T > &other) const
Computes the cross product with another vector.
Definition Vector3.hpp:370
t_Vector3< T > normalized() const
Computes the normalized version of this vector.
Definition Vector3.hpp:344

Member Typedef Documentation

◆ Vec

Constructor & Destructor Documentation

◆ Spline3D() [1/3]

Infinity::Types::Spatial::Spline3D::Spline3D ( )

Default constructor.

Creates an empty spline with Bezier interpolation.

◆ Spline3D() [2/3]

Infinity::Types::Spatial::Spline3D::Spline3D ( SplineKind  kind)
explicit

Constructs a spline with specified interpolation type.

Parameters
kindInterpolation method to use (Bezier, CatmullRom, BSpline, or Linear).

◆ Spline3D() [3/3]

Infinity::Types::Spatial::Spline3D::Spline3D ( const Spline3D other)

Copy constructor.

Creates a deep copy of the spline, including all control points and settings.

Parameters
otherSpline to copy from.

◆ ~Spline3D()

virtual Infinity::Types::Spatial::Spline3D::~Spline3D ( )
virtual

Destructor.

Member Function Documentation

◆ clone()

std::unique_ptr< Core::Base > Infinity::Types::Spatial::Spline3D::clone ( ) const
overridevirtual

Reimplemented from Infinity::Types::Core::Data.

◆ evaluate()

Vec Infinity::Types::Spatial::Spline3D::evaluate ( float  t) const

Evaluates the spline position at parameter t.

Computes the interpolated position on the curve at the given parameter value.

Parameters
tParameter value in range [0, 1].
Returns
Interpolated position on the curve.

◆ operator=()

Spline3D & Infinity::Types::Spatial::Spline3D::operator= ( const Spline3D other)

Copy assignment operator.

Parameters
otherSpline to copy from.
Returns
Reference to this spline.

◆ setCurveKind()

void Infinity::Types::Spatial::Spline3D::setCurveKind ( SplineKind  kind)

Changes the spline interpolation type.

Parameters
kindNew interpolation method to use.

◆ tangent()

Vec Infinity::Types::Spatial::Spline3D::tangent ( float  t) const

Computes the tangent vector at parameter t.

Calculates the derivative of the curve, providing the direction at that point.

Parameters
tParameter value in range [0, 1].
Returns
Tangent vector at the specified position.
Note
The tangent vector is NOT normalized.

◆ type()

SplineKind Infinity::Types::Spatial::Spline3D::type ( ) const

Gets the current spline interpolation type.

Returns
Current SplineKind being used for interpolation.

◆ typeId()

const Infinity::Types::TypeID & Infinity::Types::Spatial::Spline3D::typeId ( ) const
overridevirtual

Gets the TypeID for Spline3D.

Returns
TypeID identifying this Spline3D type.

Reimplemented from Infinity::Types::Core::Data.

Member Data Documentation

◆ points

Containers::Array<Vec> Infinity::Types::Spatial::Spline3D::points

Control points defining the spline curve.

Public array of Vector3 control points that define the curve shape. Modify this array directly to change the spline geometry.