kzc_spline.hpp File Reference

Spline curves. More...

Namespaces

 kanzi
 

Functions

KANZI_API kzsError kzcSplineCreateEmpty (const struct KzcMemoryManager *memoryManager, struct KzcSpline **out_spline)
 Creates an empty spline with no data. More...
 
KANZI_API kzsError kzcSplineCreate (const struct KzcMemoryManager *memoryManager, kzUint dimension, kzUint degree, kzUint pointCount, kzFloat *controlPoints, kzBool loop, struct KzcSpline **out_spline)
 Creates an arbitrary spline with given control points. More...
 
KANZI_API kzsError kzcSplineCreateHermite (const struct KzcMemoryManager *memoryManager, kzUint dimension, kzUint pointCount, const kzFloat *const *points, const kzFloat *const *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector2 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector2 *points, const struct KzcVector2 *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 2-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector2Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector2 *const *points, const struct KzcVector2 *const *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 2-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector3 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector3 *points, const struct KzcVector3 *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 3-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector3Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector3 *const *points, const struct KzcVector3 *const *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 3-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector4 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector4 *points, const struct KzcVector4 *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 4-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateHermiteVector4Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector4 *const *points, const struct KzcVector4 *const *tangents, kzBool loop, struct KzcSpline **out_spline)
 Creates a Hermite spline with given control points of 4-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRom (const struct KzcMemoryManager *memoryManager, kzUint dimension, kzUint pointCount, const kzFloat *const *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector2 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector2 *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 2-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector2Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector2 *const *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 2-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector3 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector3 *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 3-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector3Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector3 *const *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 3-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector4 (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector4 *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 4-dimensional vectors. More...
 
KANZI_API kzsError kzcSplineCreateCatmullRomVector4Pointers (const struct KzcMemoryManager *memoryManager, kzUint pointCount, const struct KzcVector4 *const *points, kzBool loop, struct KzcSpline **out_spline)
 Creates a Catmull-Rom spline with given control points of 4-dimensional vector pointers. More...
 
KANZI_API kzsError kzcSplineDelete (struct KzcSpline *spline)
 Frees the memory allocated for spline. More...
 
kzsError kzcSplineLoadFromKZB (struct KzcSpline *spline, struct KzcInputStream *inputStream)
 Loads spline from KZB. More...
 
kzsError splineLoadFromKZB (struct KzcSpline &spline, kanzi::KzbMemoryParser &parser)
 Loads spline from KZB. More...
 
KANZI_API kzUint kzcSplineGetLength (const struct KzcSpline *spline)
 Returns the length of the spline. More...
 
KANZI_API kzUint kzcSplineGetDimension (const struct KzcSpline *spline)
 
KANZI_API kzUint kzcSplineGetDegree (const struct KzcSpline *spline)
 
KANZI_API bool kzcSplineIsLooping (const struct KzcSpline *spline)
 
KANZI_API void kzcSplineGetControlPoints (const struct KzcSpline *spline, kzFloat **out_points)
 
KANZI_API void kzcSplineGetPoint (const struct KzcSpline *spline, kzFloat t, kzFloat *out_point)
 Evaluates the value of the spline in the given location t. More...
 
KANZI_API kzsError kzcSplineTrackerCreate (const struct KzcMemoryManager *memoryManager, const struct KzcSpline *spline, struct KzcSplineTracker **out_splineTracker)
 Creates a new spline tracker with the given spline curve. More...
 
KANZI_API kzsError kzcSplineTrackerDelete (struct KzcSplineTracker *splineTracker)
 Frees the memory allocated for spline tracker. More...
 
KANZI_API kzFloat kzcSplineTrackerGetT (const struct KzcSplineTracker *splineTracker)
 Returns the t location of the given spline tracker. More...
 
KANZI_API void kzcSplineTrackerMove (struct KzcSplineTracker *splineTracker, kzFloat deltaT)
 Moves given amount (forward or backwards) in the given spline tracker. More...
 
KANZI_API void kzcSplineTrackerGetPoint (const struct KzcSplineTracker *splineTracker, kzFloat *out_point)
 Evaluates the value of the spline tracker in the current location. More...
 

Detailed Description

Spline curves.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

KANZI_API kzsError kzcSplineCreateEmpty ( const struct KzcMemoryManager memoryManager,
struct KzcSpline **  out_spline 
)

Creates an empty spline with no data.

KANZI_API kzsError kzcSplineCreate ( const struct KzcMemoryManager memoryManager,
kzUint  dimension,
kzUint  degree,
kzUint  pointCount,
kzFloat controlPoints,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates an arbitrary spline with given control points.

Parameters
degreeDegree of the polynomial.
dimensionDimension of the point vectors, i.e. the number of components in the point array.
pointCountNumber of control points.
controlPointsControl points as polynomial coefficients, where the highest order coefficient is the first element. This is an array of polynomials, where each polynomial is an array of coefficients, where each coefficient is a vector. This 3-dimensional array is given as flattened to 1-dimensional: controlPoints[numPoints][degree][dimension] -> controlPoints[numPoints * degree * dimension].
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermite ( const struct KzcMemoryManager memoryManager,
kzUint  dimension,
kzUint  pointCount,
const kzFloat *const *  points,
const kzFloat *const *  tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points.

Hermite spline is a cubic spline where each control point is defined with position and tangent vector.

Parameters
dimensionDimension of the point vectors, i.e. the number of components in the point array.
pointCountNumber of control points.
pointsLocation vectors of control points as an array of arrays, where each inner array represents a vector.
tangentsTangent vectors of control points as an array of arrays, where each inner array represents a vector.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector2 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector2 points,
const struct KzcVector2 tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 2-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
tangentsTangent vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector2Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector2 *const *  points,
const struct KzcVector2 *const *  tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 2-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
tangentsTangent vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector3 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector3 points,
const struct KzcVector3 tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 3-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
tangentsTangent vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector3Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector3 *const *  points,
const struct KzcVector3 *const *  tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 3-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
tangentsTangent vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector4 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector4 points,
const struct KzcVector4 tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 4-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
tangentsTangent vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateHermiteVector4Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector4 *const *  points,
const struct KzcVector4 *const *  tangents,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Hermite spline with given control points of 4-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
tangentsTangent vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRom ( const struct KzcMemoryManager memoryManager,
kzUint  dimension,
kzUint  pointCount,
const kzFloat *const *  points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points.

Catmull-Rom spline is a Hermite spline where tangents are calculated automatically as t_n = (p_n+1 - p_n-1) / 2. If looping is disabled, first and last tangents are calculated simply t_0 = p_1 - p_0 and t_N = p_N - p_N-1.

Parameters
dimensionDimension of the point vectors, i.e. the number of components in the point array.
pointCountNumber of control points.
pointsLocation vectors of control points as an array of arrays, where each inner array represents a vector.
loopControls whether the spline is looping as an array of arrays, where each inner array represents a vector.
KANZI_API kzsError kzcSplineCreateCatmullRomVector2 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector2 points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 2-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRomVector2Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector2 *const *  points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 2-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRomVector3 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector3 points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 3-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRomVector3Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector3 *const *  points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 3-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRomVector4 ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector4 points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 4-dimensional vectors.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vectors.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineCreateCatmullRomVector4Pointers ( const struct KzcMemoryManager memoryManager,
kzUint  pointCount,
const struct KzcVector4 *const *  points,
kzBool  loop,
struct KzcSpline **  out_spline 
)

Creates a Catmull-Rom spline with given control points of 4-dimensional vector pointers.

Parameters
pointCountNumber of control points.
pointsLocation vectors of control points as array of vector pointers.
loopControls whether the spline is looping.
KANZI_API kzsError kzcSplineDelete ( struct KzcSpline spline)

Frees the memory allocated for spline.

kzsError kzcSplineLoadFromKZB ( struct KzcSpline spline,
struct KzcInputStream inputStream 
)

Loads spline from KZB.

Old format loader.

kzsError splineLoadFromKZB ( struct KzcSpline spline,
kanzi::KzbMemoryParser parser 
)

Loads spline from KZB.

New format loader.

KANZI_API kzUint kzcSplineGetLength ( const struct KzcSpline spline)

Returns the length of the spline.

This is the number of control points or possibly one less if looping is disabled. Each spline segment (part between two consecutive control points) has a length of one.

KANZI_API kzUint kzcSplineGetDimension ( const struct KzcSpline spline)
KANZI_API kzUint kzcSplineGetDegree ( const struct KzcSpline spline)
KANZI_API bool kzcSplineIsLooping ( const struct KzcSpline spline)
KANZI_API void kzcSplineGetControlPoints ( const struct KzcSpline spline,
kzFloat **  out_points 
)
KANZI_API void kzcSplineGetPoint ( const struct KzcSpline spline,
kzFloat  t,
kzFloat out_point 
)

Evaluates the value of the spline in the given location t.

Integer part of t defines the segment index and decimal part of t defines the location in that segment.

KANZI_API kzsError kzcSplineTrackerCreate ( const struct KzcMemoryManager memoryManager,
const struct KzcSpline spline,
struct KzcSplineTracker **  out_splineTracker 
)

Creates a new spline tracker with the given spline curve.

KANZI_API kzsError kzcSplineTrackerDelete ( struct KzcSplineTracker splineTracker)

Frees the memory allocated for spline tracker.

KANZI_API kzFloat kzcSplineTrackerGetT ( const struct KzcSplineTracker splineTracker)

Returns the t location of the given spline tracker.

KANZI_API void kzcSplineTrackerMove ( struct KzcSplineTracker splineTracker,
kzFloat  deltaT 
)

Moves given amount (forward or backwards) in the given spline tracker.

KANZI_API void kzcSplineTrackerGetPoint ( const struct KzcSplineTracker splineTracker,
kzFloat out_point 
)

Evaluates the value of the spline tracker in the current location.