52 for (
int i = 0; i < 4; i++)
62 for (
int i = 0; i < 4; i++)
73 for (
int i = 0; i < 4; i++)
83 return entry0.
X < entry1.
X;
91 return entry0.
X == entry1.
X;
164 std::set<SInterpolatorEntry> m_graph;
166 std::vector<SControlPoint> m_controls[4];
168 EInterpolatorType m_type;
205 m_type = other.m_type;
206 m_graph = other.m_graph;
207 for (
int i = 0; i < 4; i++)
208 m_controls[i] = other.m_controls[i];
217 return m_graph.empty();
268 inline const std::set<SInterpolatorEntry>&
getGraph()
const
280 return m_controls[layer];
290 return m_controls[layer];
307 return m_graph.insert(entry).second;
335 entry.
Value[layer] = y;
345 inline bool addEntry(
float x,
const core::vector2df& v)
349 entry.
Value[0] = v.X;
350 entry.
Value[1] = v.Y;
360 inline bool addEntry(
float x,
const core::vector3df& v)
364 entry.
Value[0] = v.X;
365 entry.
Value[1] = v.Y;
366 entry.
Value[2] = v.Z;
376 inline bool addEntry(
float x,
const video::SColorf& c)
380 entry.
Value[0] = c.r;
381 entry.
Value[1] = c.g;
382 entry.
Value[2] = c.b;
383 entry.
Value[3] = c.a;
394 for (
int i = 0; i < 4; i++)
395 m_controls[i].clear();
411 void computeLine(
int layer, std::vector<ArrayPoint2df>& lines,
int bezierStep);
void getMinMaxXY(core::vector2df &min, core::vector2df &max)
Compute the min and max X/Y bounds of the stored graph entries.
bool addEntry(float x, float y)
Add a scalar graph entry.
Definition CInterpolator.h:316
virtual ~CInterpolator()
Destroy the interpolator.
std::vector< SControlPoint > & getControlPoints(int layer)
Get mutable Bezier control points for a value layer.
Definition CInterpolator.h:278
bool addEntry(int layer, float x, float y)
Add a single channel value to a graph entry.
Definition CInterpolator.h:331
const std::vector< SControlPoint > & getControlPoints(int layer) const
Get read-only Bezier control points for a value layer.
Definition CInterpolator.h:288
bool addEntry(float x, const core::vector2df &v)
Add a 2D vector graph entry.
Definition CInterpolator.h:345
SColorf interpolateColorf(float x)
Sample the graph as a floating-point color.
bool addEntry(float x, const core::vector3df &v)
Add a 3D vector graph entry.
Definition CInterpolator.h:360
EInterpolatorType
Value layout used by the interpolator.
Definition CInterpolator.h:152
@ Color
Four float color channels.
Definition CInterpolator.h:160
@ Vector2
Two float channels.
Definition CInterpolator.h:156
@ Vector3
Three float channels.
Definition CInterpolator.h:158
@ Float
One float channel.
Definition CInterpolator.h:154
SControlPoint & addControlPoint(int layer=0)
Add a control point to a value layer.
void generateGraph(int layer, int bezierStep)
Generate graph entries for a layer from its Bezier control points.
const std::set< SInterpolatorEntry > & getGraph() const
Get read-only access to graph entries.
Definition CInterpolator.h:268
void computeLine(int layer, std::vector< ArrayPoint2df > &lines, int bezierStep)
Compute Bezier polyline segments for one layer.
EInterpolatorType getType()
Get the current value layout.
Definition CInterpolator.h:185
void operator=(const CInterpolator &other)
Copy another interpolator.
Definition CInterpolator.h:203
void setType(EInterpolatorType type)
Set the value layout.
Definition CInterpolator.h:194
CInterpolator()
Construct an empty float interpolator.
std::set< SInterpolatorEntry > & getGraph()
Get mutable access to graph entries.
Definition CInterpolator.h:259
bool empty()
Check whether the interpolator has no graph entries.
Definition CInterpolator.h:215
core::vector3df interpolateVec3(float x)
Sample the graph as a 3D vector.
bool addEntry(float x, const video::SColorf &c)
Add a color graph entry.
Definition CInterpolator.h:376
core::vector2df interpolateVec2(float x)
Sample the graph as a 2D vector.
bool addEntry(const SInterpolatorEntry &entry)
Add a raw graph entry.
Definition CInterpolator.h:305
void clearGraph()
Remove all graph entries and control points.
Definition CInterpolator.h:390
float interpolate(float x)
Sample the graph as a scalar value.
void computeBezier(const SControlPoint &p1, const SControlPoint &p2, ArrayPoint2df &points, int bezierStep)
Compute sampled points for the Bezier segment between two control points.
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
core::array< core::vector2df > ArrayPoint2df
Dynamic array of 2D points used for generated curve segments.
Definition CInterpolator.h:136
bool operator<(const SInterpolatorEntry &entry0, const SInterpolatorEntry &entry1)
Sort interpolation entries by their X key.
Definition CInterpolator.h:81
bool operator==(const SInterpolatorEntry &entry0, const SInterpolatorEntry &entry1)
Compare interpolation entries by their X key.
Definition CInterpolator.h:89
Bezier control point used to generate interpolation graph entries.
Definition CInterpolator.h:99
core::vector2df Left
Left tangent offset.
Definition CInterpolator.h:118
EControlType Type
Control point tangent type.
Definition CInterpolator.h:122
core::vector2df Position
Point position.
Definition CInterpolator.h:116
EControlType
Tangent behavior for a control point.
Definition CInterpolator.h:104
@ Linear
Segment is treated as linear.
Definition CInterpolator.h:112
@ Smooth
Tangents remain smooth through the point.
Definition CInterpolator.h:108
@ Auto
Tangents are generated automatically.
Definition CInterpolator.h:106
@ Broken
Left and right tangents may move independently.
Definition CInterpolator.h:110
core::vector2df Right
Right tangent offset.
Definition CInterpolator.h:120
SControlPoint()
Construct an automatic control point.
Definition CInterpolator.h:127
One keyed interpolation value.
Definition CInterpolator.h:39
SInterpolatorEntry(float x)
Construct an entry at a key position with zeroed values.
Definition CInterpolator.h:49
float X
Key position on the X axis.
Definition CInterpolator.h:41
SInterpolatorEntry()
Construct a zero entry.
Definition CInterpolator.h:59
void operator=(const SInterpolatorEntry &entry)
Copy another entry.
Definition CInterpolator.h:70
float Value[4]
Interpolated channel values.
Definition CInterpolator.h:43