![]() |
Skylicht Engine
|
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. | |
| SControlPoint & | addControlPoint (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< SInterpolatorEntry > | m_graph |
| std::vector< SControlPoint > | m_controls [4] |
| EInterpolatorType | m_type |
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.
| SControlPoint & Skylicht::CInterpolator::addControlPoint | ( | int | layer = 0 | ) |
Add a control point to a value layer.
| layer | Channel index [0, 3]. |
|
inline |
Add a raw graph entry.
| entry | Entry to insert. |
|
inline |
Add a 2D vector graph entry.
| x | Key position. |
| v | Vector value. |
|
inline |
Add a 3D vector graph entry.
| x | Key position. |
| v | Vector value. |
|
inline |
Add a color graph entry.
| x | Key position. |
| c | Color value. |
|
inline |
Add a scalar graph entry.
| x | Key position. |
| y | Scalar value. |
|
inline |
Add a single channel value to a graph entry.
| layer | Channel index [0, 3]. |
| x | Key position. |
| y | Channel value. |
| 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.
| p1 | First control point. |
| p2 | Second control point. |
| points | Receives sampled points. |
| bezierStep | Number of subdivisions. |
| void Skylicht::CInterpolator::computeLine | ( | int | layer, |
| std::vector< ArrayPoint2df > & | lines, | ||
| int | bezierStep ) |
Compute Bezier polyline segments for one layer.
| layer | Channel index [0, 3]. |
| lines | Receives generated line segments. |
| bezierStep | Number of subdivisions per Bezier segment. |
|
inline |
Check whether the interpolator has no graph entries.
| void Skylicht::CInterpolator::generateGraph | ( | int | layer, |
| int | bezierStep ) |
Generate graph entries for a layer from its Bezier control points.
| layer | Channel index [0, 3]. |
| bezierStep | Number of subdivisions per Bezier segment. |
|
inline |
Get mutable Bezier control points for a value layer.
| layer | Channel index [0, 3]. |
|
inline |
Get read-only Bezier control points for a value layer.
| layer | Channel index [0, 3]. |
|
inline |
Get mutable access to graph entries.
|
inline |
Get read-only access to graph entries.
| void Skylicht::CInterpolator::getMinMaxXY | ( | core::vector2df & | min, |
| core::vector2df & | max ) |
Compute the min and max X/Y bounds of the stored graph entries.
| min | Receives minimum X and Y. |
| max | Receives maximum X and Y. |
|
inline |
Get the current value layout.
| float Skylicht::CInterpolator::interpolate | ( | float | x | ) |
Sample the graph as a scalar value.
| x | Key position. |
| SColorf Skylicht::CInterpolator::interpolateColorf | ( | float | x | ) |
Sample the graph as a floating-point color.
| x | Key position. |
| core::vector2df Skylicht::CInterpolator::interpolateVec2 | ( | float | x | ) |
Sample the graph as a 2D vector.
| x | Key position. |
| core::vector3df Skylicht::CInterpolator::interpolateVec3 | ( | float | x | ) |
Sample the graph as a 3D vector.
| x | Key position. |
|
inline |
Copy another interpolator.
| other | Source interpolator. |
|
inline |
Set the value layout.
| type | Interpolator type. |