Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CInterpolator Class Reference

Keyframe interpolator for scalar, vector, and color values. More...

#include <Utils/CInterpolator.h>

Public Types

enum  EInterpolatorType { Float , Vector2 , Vector3 , Color }
 Value layout used by the interpolator. More...

Public Member Functions

 CInterpolator ()
 Construct an empty float interpolator.
virtual ~CInterpolator ()
 Destroy the interpolator.
EInterpolatorType getType ()
 Get the current value layout.
void setType (EInterpolatorType type)
 Set the value layout.
void operator= (const CInterpolator &other)
 Copy another interpolator.
bool empty ()
 Check whether the interpolator has no graph entries.
void getMinMaxXY (core::vector2df &min, core::vector2df &max)
 Compute the min and max X/Y bounds of the stored graph entries.
float interpolate (float x)
 Sample the graph as a scalar value.
core::vector2df interpolateVec2 (float x)
 Sample the graph as a 2D vector.
core::vector3df interpolateVec3 (float x)
 Sample the graph as a 3D vector.
SColorf interpolateColorf (float x)
 Sample the graph as a floating-point color.
std::set< SInterpolatorEntry > & getGraph ()
 Get mutable access to graph entries.
const std::set< SInterpolatorEntry > & getGraph () const
 Get read-only access to graph entries.
std::vector< SControlPoint > & getControlPoints (int layer)
 Get mutable Bezier control points for a value layer.
const std::vector< SControlPoint > & getControlPoints (int layer) const
 Get read-only Bezier control points for a value layer.
SControlPointaddControlPoint (int layer=0)
 Add a control point to a value layer.
bool addEntry (const SInterpolatorEntry &entry)
 Add a raw graph entry.
bool addEntry (float x, float y)
 Add a scalar graph entry.
bool addEntry (int layer, float x, float y)
 Add a single channel value to a graph entry.
bool addEntry (float x, const core::vector2df &v)
 Add a 2D vector graph entry.
bool addEntry (float x, const core::vector3df &v)
 Add a 3D vector graph entry.
bool addEntry (float x, const video::SColorf &c)
 Add a color graph entry.
void clearGraph ()
 Remove all graph entries and control points.
void generateGraph (int layer, int bezierStep)
 Generate graph entries for a layer from its Bezier control points.
void computeLine (int layer, std::vector< ArrayPoint2df > &lines, int bezierStep)
 Compute Bezier polyline segments for one layer.
void computeBezier (const SControlPoint &p1, const SControlPoint &p2, ArrayPoint2df &points, int bezierStep)
 Compute sampled points for the Bezier segment between two control points.

Protected Attributes

std::set< SInterpolatorEntrym_graph
std::vector< SControlPointm_controls [4]
EInterpolatorType m_type

Detailed Description

Keyframe interpolator for scalar, vector, and color values.

Values are stored as sorted entries and sampled with linear interpolation. Bezier control points can be converted into graph entries with generateGraph.

Member Enumeration Documentation

◆ EInterpolatorType

Value layout used by the interpolator.

Enumerator
Float 

One float channel.

Vector2 

Two float channels.

Vector3 

Three float channels.

Color 

Four float color channels.

Member Function Documentation

◆ addControlPoint()

SControlPoint & Skylicht::CInterpolator::addControlPoint ( int layer = 0)

Add a control point to a value layer.

Parameters
layerChannel index [0, 3].
Returns
Newly added control point.

◆ addEntry() [1/6]

bool Skylicht::CInterpolator::addEntry ( const SInterpolatorEntry & entry)
inline

Add a raw graph entry.

Parameters
entryEntry to insert.
Returns
True when inserted, false when another entry already has the same X key.

◆ addEntry() [2/6]

bool Skylicht::CInterpolator::addEntry ( float x,
const core::vector2df & v )
inline

Add a 2D vector graph entry.

Parameters
xKey position.
vVector value.
Returns
True when inserted.

◆ addEntry() [3/6]

bool Skylicht::CInterpolator::addEntry ( float x,
const core::vector3df & v )
inline

Add a 3D vector graph entry.

Parameters
xKey position.
vVector value.
Returns
True when inserted.

◆ addEntry() [4/6]

bool Skylicht::CInterpolator::addEntry ( float x,
const video::SColorf & c )
inline

Add a color graph entry.

Parameters
xKey position.
cColor value.
Returns
True when inserted.

◆ addEntry() [5/6]

bool Skylicht::CInterpolator::addEntry ( float x,
float y )
inline

Add a scalar graph entry.

Parameters
xKey position.
yScalar value.
Returns
True when inserted.

◆ addEntry() [6/6]

bool Skylicht::CInterpolator::addEntry ( int layer,
float x,
float y )
inline

Add a single channel value to a graph entry.

Parameters
layerChannel index [0, 3].
xKey position.
yChannel value.
Returns
True when inserted.

◆ computeBezier()

void Skylicht::CInterpolator::computeBezier ( const SControlPoint & p1,
const SControlPoint & p2,
ArrayPoint2df & points,
int bezierStep )

Compute sampled points for the Bezier segment between two control points.

Parameters
p1First control point.
p2Second control point.
pointsReceives sampled points.
bezierStepNumber of subdivisions.

◆ computeLine()

void Skylicht::CInterpolator::computeLine ( int layer,
std::vector< ArrayPoint2df > & lines,
int bezierStep )

Compute Bezier polyline segments for one layer.

Parameters
layerChannel index [0, 3].
linesReceives generated line segments.
bezierStepNumber of subdivisions per Bezier segment.

◆ empty()

bool Skylicht::CInterpolator::empty ( )
inline

Check whether the interpolator has no graph entries.

Returns
True if no entries are stored.

◆ generateGraph()

void Skylicht::CInterpolator::generateGraph ( int layer,
int bezierStep )

Generate graph entries for a layer from its Bezier control points.

Parameters
layerChannel index [0, 3].
bezierStepNumber of subdivisions per Bezier segment.

◆ getControlPoints() [1/2]

std::vector< SControlPoint > & Skylicht::CInterpolator::getControlPoints ( int layer)
inline

Get mutable Bezier control points for a value layer.

Parameters
layerChannel index [0, 3].
Returns
Control point list.

◆ getControlPoints() [2/2]

const std::vector< SControlPoint > & Skylicht::CInterpolator::getControlPoints ( int layer) const
inline

Get read-only Bezier control points for a value layer.

Parameters
layerChannel index [0, 3].
Returns
Control point list.

◆ getGraph() [1/2]

std::set< SInterpolatorEntry > & Skylicht::CInterpolator::getGraph ( )
inline

Get mutable access to graph entries.

Returns
Sorted graph entry set.

◆ getGraph() [2/2]

const std::set< SInterpolatorEntry > & Skylicht::CInterpolator::getGraph ( ) const
inline

Get read-only access to graph entries.

Returns
Sorted graph entry set.

◆ getMinMaxXY()

void Skylicht::CInterpolator::getMinMaxXY ( core::vector2df & min,
core::vector2df & max )

Compute the min and max X/Y bounds of the stored graph entries.

Parameters
minReceives minimum X and Y.
maxReceives maximum X and Y.

◆ getType()

EInterpolatorType Skylicht::CInterpolator::getType ( )
inline

Get the current value layout.

Returns
Interpolator type.

◆ interpolate()

float Skylicht::CInterpolator::interpolate ( float x)

Sample the graph as a scalar value.

Parameters
xKey position.
Returns
Interpolated first channel.

◆ interpolateColorf()

SColorf Skylicht::CInterpolator::interpolateColorf ( float x)

Sample the graph as a floating-point color.

Parameters
xKey position.
Returns
Interpolated four-channel color.

◆ interpolateVec2()

core::vector2df Skylicht::CInterpolator::interpolateVec2 ( float x)

Sample the graph as a 2D vector.

Parameters
xKey position.
Returns
Interpolated first two channels.

◆ interpolateVec3()

core::vector3df Skylicht::CInterpolator::interpolateVec3 ( float x)

Sample the graph as a 3D vector.

Parameters
xKey position.
Returns
Interpolated first three channels.

◆ operator=()

void Skylicht::CInterpolator::operator= ( const CInterpolator & other)
inline

Copy another interpolator.

Parameters
otherSource interpolator.

◆ setType()

void Skylicht::CInterpolator::setType ( EInterpolatorType type)
inline

Set the value layout.

Parameters
typeInterpolator type.

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